Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
mstr2 committed Oct 4, 2024
1 parent 15fcee6 commit 55cca80
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,9 @@ public Map<String, PreferenceMapping<?>> getPlatformKeyMappings() {
return Map.of(
"macOS.NSColor.textColor", new PreferenceMapping<>("foregroundColor", Color.class),
"macOS.NSColor.textBackgroundColor", new PreferenceMapping<>("backgroundColor", Color.class),
"macOS.NSColor.controlAccentColor", new PreferenceMapping<>("accentColor", Color.class)
"macOS.NSColor.controlAccentColor", new PreferenceMapping<>("accentColor", Color.class),
"macOS.NSWorkspace.accessibilityDisplayShouldReduceMotion", new PreferenceMapping<>("reducedMotion", Boolean.class),
"macOS.NSWorkspace.accessibilityDisplayShouldReduceTransparency", new PreferenceMapping<>("reducedTransparency", Boolean.class)
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -549,6 +549,8 @@ public static Preferences getPreferences() {
* <tr><td>{@code macOS.NSColor.systemRedColor}</td><td>{@link Color}</td></tr>
* <tr><td>{@code macOS.NSColor.systemTealColor}</td><td>{@link Color}</td></tr>
* <tr><td>{@code macOS.NSColor.systemYellowColor}</td><td>{@link Color}</td></tr>
* <tr><td>{@code macOS.NSWorkspace.accessibilityDisplayShouldReduceMotion}</td><td>{@link Boolean}</td></tr>
* <tr><td>{@code macOS.NSWorkspace.accessibilityDisplayShouldReduceTransparency}</td><td>{@link Boolean}</td></tr>
* <tr></tr>
* </tbody>
* </table>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,12 @@ - (void)applicationWillFinishLaunching:(NSNotification *)aNotification
name:@"AppleColorPreferencesChangedNotification"
object:nil];

[[[NSWorkspace sharedWorkspace] notificationCenter]
addObserver:self
selector:@selector(platformPreferencesDidChange)
name:NSWorkspaceAccessibilityDisplayOptionsDidChangeNotification
object:nil];

// localMonitor = [NSEvent addLocalMonitorForEventsMatchingMask: NSRightMouseDownMask
// handler:^(NSEvent *incomingEvent) {
// NSEvent *result = incomingEvent;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,16 @@ + (jobject)collectPreferences {
[PlatformSupport queryNSColors:preferences];
[NSAppearance setCurrentAppearance:lastAppearance];

bool reduceMotion = [[NSWorkspace sharedWorkspace] accessibilityDisplayShouldReduceMotion];
[PlatformSupport putBoolean:preferences
key:"macOS.NSWorkspace.accessibilityDisplayShouldReduceMotion"
value:reduceMotion];

bool reduceTransparency = [[NSWorkspace sharedWorkspace] accessibilityDisplayShouldReduceTransparency];
[PlatformSupport putBoolean:preferences
key:"macOS.NSWorkspace.accessibilityDisplayShouldReduceTransparency"
value:reduceTransparency];

return preferences;
}

Expand Down Expand Up @@ -222,6 +232,19 @@ + (void)updatePreferences:(jobject)application {
(*env)->DeleteLocalRef(env, newPreferences);
}

+ (void)putBoolean:(jobject)preferences key:(const char*)key value:(bool)value {
GET_MAIN_JENV;

jobject prefKey = (*env)->NewStringUTF(env, key);
GLASS_CHECK_NONNULL_EXCEPTION_RETURN(env, prefKey);

jobject prefValue = (*env)->GetStaticObjectField(env, jBooleanClass, value ? jBooleanTRUE : jBooleanFALSE);
GLASS_CHECK_NONNULL_EXCEPTION_RETURN(env, prefValue);

(*env)->CallObjectMethod(env, preferences, jMapPutMethod, prefKey, prefValue);
GLASS_CHECK_EXCEPTION(env);
}

+ (void)putString:(jobject)preferences key:(const char*)key value:(const char*)value {
GET_MAIN_JENV;

Expand Down

0 comments on commit 55cca80

Please sign in to comment.