forked from HumbleUI/JWM
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathThemeMac.mm
35 lines (31 loc) · 1.36 KB
/
ThemeMac.mm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#import <Cocoa/Cocoa.h>
#include <jni.h>
const CFStringRef WhiteOnBlack = CFSTR("whiteOnBlack");
const CFStringRef UniversalAccessDomain = CFSTR("com.apple.universalaccess");
extern "C" JNIEXPORT bool JNICALL Java_io_github_humbleui_jwm_Theme__1nIsHighContrast
(JNIEnv* env, jclass jclass) {
NSWorkspace* workspace = [NSWorkspace sharedWorkspace];
if ([workspace respondsToSelector:@selector (accessibilityDisplayShouldIncreaseContrast)]) {
return workspace.accessibilityDisplayShouldIncreaseContrast;
}
return false;
}
extern "C" JNIEXPORT bool JNICALL Java_io_github_humbleui_jwm_Theme__1nIsDark
(JNIEnv* env, jclass jclass) {
if (@available(macOS 10.14, *)) {
NSAppearanceName appearance = [[NSApp effectiveAppearance] bestMatchFromAppearancesWithNames:@[
NSAppearanceNameAqua, NSAppearanceNameDarkAqua
]];
return [appearance isEqual:NSAppearanceNameDarkAqua];
}
return false;
}
extern "C" JNIEXPORT bool JNICALL Java_io_github_humbleui_jwm_Theme__1nIsInverted
(JNIEnv* env, jclass jclass) {
CFPreferencesAppSynchronize(UniversalAccessDomain);
Boolean keyExistsAndHasValidFormat = false;
Boolean is_inverted = CFPreferencesGetAppBooleanValue(WhiteOnBlack, UniversalAccessDomain, &keyExistsAndHasValidFormat);
if (!keyExistsAndHasValidFormat)
return false;
return is_inverted;
}