From ffc948c6c42d1323114ce43ba08ebd7637111265 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pa=CC=84vels=20Nadtoc=CC=8Cajevs?= <7645683+bruvzg@users.noreply.github.com> Date: Wed, 21 May 2025 13:49:07 +0300 Subject: [PATCH] Fix `GodotApplicationDelegate` init. --- platform/macos/godot_application_delegate.mm | 27 ++++++++------------ 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/platform/macos/godot_application_delegate.mm b/platform/macos/godot_application_delegate.mm index bedd27ccdb..c85f4b0b9a 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];