diff --git a/platform/macos/godot_application_delegate.mm b/platform/macos/godot_application_delegate.mm index bedd27ccdb8..c85f4b0b9ac 100644 --- a/platform/macos/godot_application_delegate.mm +++ b/platform/macos/godot_application_delegate.mm @@ -57,6 +57,17 @@ if (self) { os_mac = os; } + + [[NSWorkspace sharedWorkspace] addObserver:self forKeyPath:@"voiceOverEnabled" options:(NSKeyValueObservingOptionNew | NSKeyValueObservingOptionOld) context:(void *)godot_ac_ctx]; + [[[NSWorkspace sharedWorkspace] notificationCenter] addObserver:self selector:@selector(accessibilityDisplayOptionsChange:) name:NSWorkspaceAccessibilityDisplayOptionsDidChangeNotification object:nil]; + high_contrast = [[NSWorkspace sharedWorkspace] accessibilityDisplayShouldIncreaseContrast]; + reduce_motion = [[NSWorkspace sharedWorkspace] accessibilityDisplayShouldReduceMotion]; + reduce_transparency = [[NSWorkspace sharedWorkspace] accessibilityDisplayShouldReduceTransparency]; + voice_over = [[NSWorkspace sharedWorkspace] isVoiceOverEnabled]; + + [[NSDistributedNotificationCenter defaultCenter] addObserver:self selector:@selector(system_theme_changed:) name:@"AppleInterfaceThemeChangedNotification" object:nil]; + [[NSDistributedNotificationCenter defaultCenter] addObserver:self selector:@selector(system_theme_changed:) name:@"AppleColorPreferencesChangedNotification" object:nil]; + return self; } @@ -130,22 +141,6 @@ static const char *godot_ac_ctx = "gd_accessibility_observer_ctx"; -- (id)init { - self = [super init]; - - [[NSWorkspace sharedWorkspace] addObserver:self forKeyPath:@"voiceOverEnabled" options:(NSKeyValueObservingOptionNew | NSKeyValueObservingOptionOld) context:(void *)godot_ac_ctx]; - [[[NSWorkspace sharedWorkspace] notificationCenter] addObserver:self selector:@selector(accessibilityDisplayOptionsChange:) name:NSWorkspaceAccessibilityDisplayOptionsDidChangeNotification object:nil]; - high_contrast = [[NSWorkspace sharedWorkspace] accessibilityDisplayShouldIncreaseContrast]; - reduce_motion = [[NSWorkspace sharedWorkspace] accessibilityDisplayShouldReduceMotion]; - reduce_transparency = [[NSWorkspace sharedWorkspace] accessibilityDisplayShouldReduceTransparency]; - voice_over = [[NSWorkspace sharedWorkspace] isVoiceOverEnabled]; - - [[NSDistributedNotificationCenter defaultCenter] addObserver:self selector:@selector(system_theme_changed:) name:@"AppleInterfaceThemeChangedNotification" object:nil]; - [[NSDistributedNotificationCenter defaultCenter] addObserver:self selector:@selector(system_theme_changed:) name:@"AppleColorPreferencesChangedNotification" object:nil]; - - return self; -} - - (void)dealloc { [[NSDistributedNotificationCenter defaultCenter] removeObserver:self name:@"AppleInterfaceThemeChangedNotification" object:nil]; [[NSDistributedNotificationCenter defaultCenter] removeObserver:self name:@"AppleColorPreferencesChangedNotification" object:nil];