mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-14 10:37:23 -07:00
osx: fix annoying focus behaviour (@anticat)
https://github.com/Proxmark/proxmark3/pull/689 OS X has a global menu bar and a per app dock icon. Therefore, all GUI applications launched from a terminal will become focused - even if they don’t show any windows. Thereby the terminal loses focus. Since is it very annoying to re-focus the terminal after each proxmark client launch, this change makes the client unfocusable during launch and restores the regular behaviour when a window is created.
This commit is contained in:
parent
61d7f74ab9
commit
1fb121474e
4 changed files with 35 additions and 3 deletions
55
client/util_darwin.m
Normal file
55
client/util_darwin.m
Normal file
|
@ -0,0 +1,55 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// (c) 2018 AntiCat
|
||||
//
|
||||
// This code is licensed to you under the terms of the GNU GPL, version 2 or,
|
||||
// at your option, any later version. See the LICENSE.txt file for the text of
|
||||
// the license.
|
||||
//-----------------------------------------------------------------------------
|
||||
// macOS framework bindings
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#import "util_darwin.h"
|
||||
|
||||
#import <Foundation/NSString.h>
|
||||
#import <Foundation/NSProcessInfo.h>
|
||||
#import <AppKit/NSApplication.h>
|
||||
|
||||
static id activity = nil;
|
||||
|
||||
//OS X Version 10.10 is defined in OS X 10.10 and later
|
||||
#if defined(MAC_OS_X_VERSION_10_10)
|
||||
void disableAppNap(const char* reason) {
|
||||
if(activity == nil) {
|
||||
//NSLog(@"disableAppNap: %@", @(reason));
|
||||
activity = [[NSProcessInfo processInfo] beginActivityWithOptions:NSActivityBackground reason:@(reason)];
|
||||
[activity retain];
|
||||
}
|
||||
}
|
||||
|
||||
void enableAppNap() {
|
||||
if(activity != nil) {
|
||||
//NSLog(@"enableAppNap");
|
||||
[[NSProcessInfo processInfo] endActivity:activity];
|
||||
[activity release];
|
||||
activity = nil;
|
||||
}
|
||||
}
|
||||
|
||||
#else
|
||||
void disableAppNap(const char* reason) { }
|
||||
void enableAppNap() { }
|
||||
#endif
|
||||
|
||||
|
||||
//OS X Version 10.6 is defined in OS X 10.6 and later
|
||||
#if defined(MAC_OS_X_VERSION_10_6)
|
||||
void makeUnfocusable() {
|
||||
[NSApp setActivationPolicy:NSApplicationActivationPolicyProhibited];
|
||||
}
|
||||
void makeFocusable() {
|
||||
[NSApp setActivationPolicy:NSApplicationActivationPolicyRegular];
|
||||
}
|
||||
#else
|
||||
void makeUnfocusable() { }
|
||||
void makeFocusable() { }
|
||||
#endif
|
Loading…
Add table
Add a link
Reference in a new issue