diff --git a/client/Makefile b/client/Makefile index 31c9c6a2d..4d0312e80 100644 --- a/client/Makefile +++ b/client/Makefile @@ -38,7 +38,7 @@ else ifeq ($(platform),Darwin) LUAPLATFORM = macosx OBJCSRCS = util_darwin.m - LDFLAGS += -framework Foundation + LDFLAGS += -framework Foundation -framework AppKit else LUALIB += -ldl LDLIBS += -ltermcap -lncurses diff --git a/client/proxguiqt.cpp b/client/proxguiqt.cpp index 56de71b24..296862e65 100644 --- a/client/proxguiqt.cpp +++ b/client/proxguiqt.cpp @@ -27,6 +27,10 @@ #include "proxgui.h" #include +extern "C" { +#include "util_darwin.h" +} + bool g_useOverlays = false; int g_absVMax = 0; int startMax; @@ -53,9 +57,14 @@ void ProxGuiQT::_ShowGraphWindow(void) { if(!plotapp) return; - if (!plotwidget) + if (!plotwidget) { + +#if defined(__MACH__) && defined(__APPLE__) + makeFocusable(); +#endif + plotwidget = new ProxWidget(); - + } plotwidget->show(); } @@ -100,6 +109,12 @@ void ProxGuiQT::MainLoop() //start proxmark thread after starting event loop QTimer::singleShot(200, this, SLOT(_StartProxmarkThread())); +#if defined(__MACH__) && defined(__APPLE__) + //Prevent the terminal from loosing focus during launch by making the client unfocusable + makeUnfocusable(); +#endif + + plotapp->exec(); } diff --git a/client/util_darwin.h b/client/util_darwin.h index 923a4dfc0..c69a551d3 100644 --- a/client/util_darwin.h +++ b/client/util_darwin.h @@ -13,5 +13,7 @@ void disableAppNap(const char* reason); void enableAppNap(); +void makeUnfocusable(); +void makeFocusable(); #endif \ No newline at end of file diff --git a/client/util_darwin.c b/client/util_darwin.m similarity index 75% rename from client/util_darwin.c rename to client/util_darwin.m index d07ebebc4..9d7583903 100644 --- a/client/util_darwin.c +++ b/client/util_darwin.m @@ -12,6 +12,7 @@ #import #import +#import 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 \ No newline at end of file