diff --git a/glfw/cocoa_window.m b/glfw/cocoa_window.m index 02c1af0ec..6d322a932 100644 --- a/glfw/cocoa_window.m +++ b/glfw/cocoa_window.m @@ -1621,6 +1621,12 @@ - (void) removeGLFWWindow; @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 @@ -1630,6 +1636,13 @@ - (instancetype)initWithGlfwWindow:(NSRect)contentRect if (self != nil) { 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); + }]; } return self; } @@ -1637,6 +1650,7 @@ - (instancetype)initWithGlfwWindow:(NSRect)contentRect - (void) removeGLFWWindow { glfw_window = NULL; + [[NSNotificationCenter defaultCenter] removeObserver:self]; } - (BOOL)validateMenuItem:(NSMenuItem *)item {