mirror of
https://github.com/kovidgoyal/kitty
synced 2026-06-08 14:18:26 +02:00
No need to use a block as Apple docs guarantee that NSApplicationDidChangeScreenParametersNotification is posted on the main thread
This commit is contained in:
@@ -1622,12 +1622,6 @@ void _glfwPlatformUpdateIMEState(_GLFWwindow *w, const GLFWIMEUpdateEvent *ev) {
|
|||||||
|
|
||||||
@implementation GLFWWindow
|
@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
|
- (instancetype)initWithGlfwWindow:(NSRect)contentRect
|
||||||
styleMask:(NSWindowStyleMask)style
|
styleMask:(NSWindowStyleMask)style
|
||||||
backing:(NSBackingStoreType)backingStoreType
|
backing:(NSBackingStoreType)backingStoreType
|
||||||
@@ -1638,16 +1632,16 @@ handle_screen_size_change(_GLFWwindow *window, NSNotification *notification UNUS
|
|||||||
glfw_window = initWindow;
|
glfw_window = initWindow;
|
||||||
self.tabbingMode = NSWindowTabbingModeDisallowed;
|
self.tabbingMode = NSWindowTabbingModeDisallowed;
|
||||||
NSNotificationCenter *center = [NSNotificationCenter defaultCenter];
|
NSNotificationCenter *center = [NSNotificationCenter defaultCenter];
|
||||||
[center addObserverForName:NSApplicationDidChangeScreenParametersNotification
|
[center addObserver:self selector:@selector(screenParametersDidChange:) name:NSApplicationDidChangeScreenParametersNotification object:nil];
|
||||||
object:nil
|
|
||||||
queue:[NSOperationQueue mainQueue]
|
|
||||||
usingBlock:^(NSNotification * _Nonnull notification) {
|
|
||||||
handle_screen_size_change(glfw_window, notification);
|
|
||||||
}];
|
|
||||||
}
|
}
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void)screenParametersDidChange:(NSNotification *)notification {
|
||||||
|
if (!glfw_window || !glfw_window->ns.layer_shell.is_active) return;
|
||||||
|
_glfwPlatformSetLayerShellConfig(glfw_window, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
- (void) removeGLFWWindow
|
- (void) removeGLFWWindow
|
||||||
{
|
{
|
||||||
glfw_window = NULL;
|
glfw_window = NULL;
|
||||||
|
|||||||
Reference in New Issue
Block a user