osx: fix annoying focus behaviour (#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:
AntiCat 2018-10-08 07:20:21 +02:00 committed by pwpiwi
commit b742ab8cc3
4 changed files with 33 additions and 1 deletions

View file

@ -12,6 +12,7 @@
#import <Foundation/NSString.h>
#import <Foundation/NSProcessInfo.h>
#import <AppKit/NSApplication.h>
static id activity = nil;
@ -38,3 +39,17 @@ void enableAppNap() {
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