From 24b31d96e9a065eab578b7d8280f811a19768f65 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Fri, 19 Sep 2025 08:52:09 +0530 Subject: [PATCH] No need to use a block as Apple docs guarantee that NSApplicationDidChangeScreenParametersNotification is posted on the main thread --- glfw/cocoa_window.m | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/glfw/cocoa_window.m b/glfw/cocoa_window.m index 5f44c7cc6..f632e9d6f 100644 --- a/glfw/cocoa_window.m +++ b/glfw/cocoa_window.m @@ -1622,12 +1622,6 @@ void _glfwPlatformUpdateIMEState(_GLFWwindow *w, const GLFWIMEUpdateEvent *ev) { @implementation GLFWWindow -static void -handle_screen_size_change(_GLFWwindow *window, NSNotification *notification UNUSED) { - if (!window || !window->ns.layer_shell.is_active) return; - _glfwPlatformSetLayerShellConfig(window, NULL); -} - - (instancetype)initWithGlfwWindow:(NSRect)contentRect styleMask:(NSWindowStyleMask)style backing:(NSBackingStoreType)backingStoreType @@ -1638,16 +1632,16 @@ handle_screen_size_change(_GLFWwindow *window, NSNotification *notification UNUS glfw_window = initWindow; self.tabbingMode = NSWindowTabbingModeDisallowed; NSNotificationCenter *center = [NSNotificationCenter defaultCenter]; - [center addObserverForName:NSApplicationDidChangeScreenParametersNotification - object:nil - queue:[NSOperationQueue mainQueue] - usingBlock:^(NSNotification * _Nonnull notification) { - handle_screen_size_change(glfw_window, notification); - }]; + [center addObserver:self selector:@selector(screenParametersDidChange:) name:NSApplicationDidChangeScreenParametersNotification object:nil]; } return self; } +- (void)screenParametersDidChange:(NSNotification *)notification { + if (!glfw_window || !glfw_window->ns.layer_shell.is_active) return; + _glfwPlatformSetLayerShellConfig(glfw_window, NULL); +} + - (void) removeGLFWWindow { glfw_window = NULL;