mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-01-24 08:59:43 +08: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
|
@ -38,7 +38,7 @@ else
|
||||||
ifeq ($(platform),Darwin)
|
ifeq ($(platform),Darwin)
|
||||||
LUAPLATFORM = macosx
|
LUAPLATFORM = macosx
|
||||||
OBJCSRCS = util_darwin.m
|
OBJCSRCS = util_darwin.m
|
||||||
LDFLAGS += -framework Foundation
|
LDFLAGS += -framework Foundation -framework AppKit
|
||||||
else
|
else
|
||||||
LUALIB += -ldl
|
LUALIB += -ldl
|
||||||
LDLIBS += -ltermcap -lncurses
|
LDLIBS += -ltermcap -lncurses
|
||||||
|
|
|
@ -27,6 +27,10 @@
|
||||||
#include "proxgui.h"
|
#include "proxgui.h"
|
||||||
#include <QtGui>
|
#include <QtGui>
|
||||||
|
|
||||||
|
extern "C" {
|
||||||
|
#include "util_darwin.h"
|
||||||
|
}
|
||||||
|
|
||||||
bool g_useOverlays = false;
|
bool g_useOverlays = false;
|
||||||
int g_absVMax = 0;
|
int g_absVMax = 0;
|
||||||
int startMax;
|
int startMax;
|
||||||
|
@ -53,9 +57,14 @@ void ProxGuiQT::_ShowGraphWindow(void) {
|
||||||
if(!plotapp)
|
if(!plotapp)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!plotwidget)
|
if (!plotwidget) {
|
||||||
|
|
||||||
|
#if defined(__MACH__) && defined(__APPLE__)
|
||||||
|
makeFocusable();
|
||||||
|
#endif
|
||||||
|
|
||||||
plotwidget = new ProxWidget();
|
plotwidget = new ProxWidget();
|
||||||
|
}
|
||||||
plotwidget->show();
|
plotwidget->show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -100,6 +109,12 @@ void ProxGuiQT::MainLoop()
|
||||||
//start proxmark thread after starting event loop
|
//start proxmark thread after starting event loop
|
||||||
QTimer::singleShot(200, this, SLOT(_StartProxmarkThread()));
|
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();
|
plotapp->exec();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,5 +13,7 @@
|
||||||
|
|
||||||
void disableAppNap(const char* reason);
|
void disableAppNap(const char* reason);
|
||||||
void enableAppNap();
|
void enableAppNap();
|
||||||
|
void makeUnfocusable();
|
||||||
|
void makeFocusable();
|
||||||
|
|
||||||
#endif
|
#endif
|
|
@ -12,6 +12,7 @@
|
||||||
|
|
||||||
#import <Foundation/NSString.h>
|
#import <Foundation/NSString.h>
|
||||||
#import <Foundation/NSProcessInfo.h>
|
#import <Foundation/NSProcessInfo.h>
|
||||||
|
#import <AppKit/NSApplication.h>
|
||||||
|
|
||||||
static id activity = nil;
|
static id activity = nil;
|
||||||
|
|
||||||
|
@ -38,3 +39,17 @@ void enableAppNap() {
|
||||||
void disableAppNap(const char* reason) { }
|
void disableAppNap(const char* reason) { }
|
||||||
void enableAppNap() { }
|
void enableAppNap() { }
|
||||||
#endif
|
#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…
Reference in a new issue