No need to use a block as Apple docs guarantee that NSApplicationDidChangeScreenParametersNotification is posted on the main thread

This commit is contained in:
Kovid Goyal 2025-09-19 08:52:09 +05:30
parent e6f61c396c
commit 24b31d96e9
No known key found for this signature in database
GPG key ID: 06BC317B515ACE7C

View file

@ -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;