Skip to content

Commit 24b31d9

Browse files
committed
No need to use a block as Apple docs guarantee that NSApplicationDidChangeScreenParametersNotification is posted on the main thread
1 parent e6f61c3 commit 24b31d9

File tree

1 file changed

+6
-12
lines changed

1 file changed

+6
-12
lines changed

glfw/cocoa_window.m

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1622,12 +1622,6 @@ - (void) removeGLFWWindow;
16221622

16231623
@implementation GLFWWindow
16241624

1625-
static void
1626-
handle_screen_size_change(_GLFWwindow *window, NSNotification *notification UNUSED) {
1627-
if (!window || !window->ns.layer_shell.is_active) return;
1628-
_glfwPlatformSetLayerShellConfig(window, NULL);
1629-
}
1630-
16311625
- (instancetype)initWithGlfwWindow:(NSRect)contentRect
16321626
styleMask:(NSWindowStyleMask)style
16331627
backing:(NSBackingStoreType)backingStoreType
@@ -1638,16 +1632,16 @@ - (instancetype)initWithGlfwWindow:(NSRect)contentRect
16381632
glfw_window = initWindow;
16391633
self.tabbingMode = NSWindowTabbingModeDisallowed;
16401634
NSNotificationCenter *center = [NSNotificationCenter defaultCenter];
1641-
[center addObserverForName:NSApplicationDidChangeScreenParametersNotification
1642-
object:nil
1643-
queue:[NSOperationQueue mainQueue]
1644-
usingBlock:^(NSNotification * _Nonnull notification) {
1645-
handle_screen_size_change(glfw_window, notification);
1646-
}];
1635+
[center addObserver:self selector:@selector(screenParametersDidChange:) name:NSApplicationDidChangeScreenParametersNotification object:nil];
16471636
}
16481637
return self;
16491638
}
16501639

1640+
- (void)screenParametersDidChange:(NSNotification *)notification {
1641+
if (!glfw_window || !glfw_window->ns.layer_shell.is_active) return;
1642+
_glfwPlatformSetLayerShellConfig(glfw_window, NULL);
1643+
}
1644+
16511645
- (void) removeGLFWWindow
16521646
{
16531647
glfw_window = NULL;

0 commit comments

Comments
 (0)