1 //-----------------------------------------------------------------------------
4 // This code is licensed to you under the terms of the GNU GPL, version 2 or,
5 // at your option, any later version. See the LICENSE.txt file for the text of
7 //-----------------------------------------------------------------------------
8 // macOS framework bindings
9 //-----------------------------------------------------------------------------
11 #import "util_darwin.h"
13 #import <Foundation/NSString.h>
14 #import <Foundation/NSProcessInfo.h>
15 #import <AppKit/NSApplication.h>
17 static id activity = nil;
19 //OS X Version 10.10 is defined in OS X 10.10 and later
20 #if defined(MAC_OS_X_VERSION_10_10)
21 void disableAppNap(const char* reason) {
23 //NSLog(@"disableAppNap: %@", @(reason));
24 activity = [[NSProcessInfo processInfo] beginActivityWithOptions:NSActivityBackground reason:@(reason)];
31 //NSLog(@"enableAppNap");
32 [[NSProcessInfo processInfo] endActivity:activity];
39 void disableAppNap(const char* reason) { }
40 void enableAppNap() { }
43 //OS X Version 10.6 is defined in OS X 10.6 and later
44 #if defined(MAC_OS_X_VERSION_10_6)
45 void makeUnfocusable() {
46 [NSApp setActivationPolicy:NSApplicationActivationPolicyProhibited];
49 void makeFocusable() {
50 [NSApp setActivationPolicy:NSApplicationActivationPolicyRegular];
53 void makeUnfocusable() { }
54 void makeFocusable() { }