mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-01-10 02:04:39 +08:00
ARC support for AppNap toggle
This commit is contained in:
parent
468d2ac2ba
commit
199b462d02
1 changed files with 33 additions and 1 deletions
|
@ -27,10 +27,41 @@
|
||||||
#import <AppKit/NSApplication.h>
|
#import <AppKit/NSApplication.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if !defined(USING_ARC)
|
||||||
|
# if __has_feature(objc_arc)
|
||||||
|
# define USING_ARC 1
|
||||||
|
# else
|
||||||
|
# define USING_ARC 0
|
||||||
|
# endif
|
||||||
|
#elif EMPTY_DEFINE(USING_ARC)
|
||||||
|
# undef USING_ARC
|
||||||
|
# define USING_ARC 1
|
||||||
|
#endif
|
||||||
|
|
||||||
static id activity = nil;
|
static id activity = nil;
|
||||||
|
|
||||||
//OS X Version 10.10 is defined in OS X 10.10 and later
|
//OS X Version 10.10 is defined in OS X 10.10 and later
|
||||||
#if defined(MAC_OS_X_VERSION_10_10)
|
#if defined(MAC_OS_X_VERSION_10_10)
|
||||||
|
#if USING_ARC
|
||||||
|
@implementation AppDelegate {
|
||||||
|
id <NSObject> activity;
|
||||||
|
}
|
||||||
|
void disableAppNap(const char* reason) {
|
||||||
|
if(activity == nil) {
|
||||||
|
//NSLog(@"disableAppNap: %@", @(reason));
|
||||||
|
activity = [[NSProcessInfo processInfo] beginActivityWithOptions:NSActivityBackground reason:@(reason)];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void enableAppNap() {
|
||||||
|
if(activity != nil) {
|
||||||
|
//NSLog(@"enableAppNap");
|
||||||
|
[[NSProcessInfo processInfo] endActivity:activity];
|
||||||
|
activity = nil;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@end
|
||||||
|
#else
|
||||||
void disableAppNap(const char* reason) {
|
void disableAppNap(const char* reason) {
|
||||||
if(activity == nil) {
|
if(activity == nil) {
|
||||||
//NSLog(@"disableAppNap: %@", @(reason));
|
//NSLog(@"disableAppNap: %@", @(reason));
|
||||||
|
@ -47,6 +78,7 @@ void enableAppNap() {
|
||||||
activity = nil;
|
activity = nil;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#else
|
#else
|
||||||
void disableAppNap(const char* reason) { }
|
void disableAppNap(const char* reason) { }
|
||||||
|
@ -68,4 +100,4 @@ void makeFocusable() {
|
||||||
#else
|
#else
|
||||||
void makeUnfocusable() { }
|
void makeUnfocusable() { }
|
||||||
void makeFocusable() { }
|
void makeFocusable() { }
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue