From 19a8870f766ec55a5d5fa4d3f8865d4e38ea78f4 Mon Sep 17 00:00:00 2001 From: Arjan Molenaar Date: Sun, 18 Feb 2024 13:14:42 +0100 Subject: [PATCH] macos: use native zoom/unzoom logic In macOS, when moving a maximized window, it's not automatically restored to its default size. In addition, GdkMacosWindow should not check surface layout properties, since those properties are lagging, e.i. are set after the (native) window state has been updated. --- gdk/macos/GdkMacosWindow.c | 27 ++------------------------- gdk/macos/GdkMacosWindow.h | 1 - 2 files changed, 2 insertions(+), 26 deletions(-) diff --git a/gdk/macos/GdkMacosWindow.c b/gdk/macos/GdkMacosWindow.c index def6d6e693..aacddfec39 100644 --- a/gdk/macos/GdkMacosWindow.c +++ b/gdk/macos/GdkMacosWindow.c @@ -405,7 +405,6 @@ typedef NSString *CALayerContentsGravity; -(void)beginManualMove { - gboolean maximized = GDK_SURFACE (gdk_surface)->state & GDK_TOPLEVEL_STATE_MAXIMIZED; NSPoint initialMoveLocation; GdkPoint point; GdkMonitor *monitor; @@ -424,13 +423,6 @@ typedef NSString *CALayerContentsGravity; initialMoveLocation = [NSEvent mouseLocation]; - if (maximized) - [self setFrame:NSMakeRect (initialMoveLocation.x - (int)lastUnmaximizedFrame.size.width/2, - initialMoveLocation.y, - lastUnmaximizedFrame.size.width, - lastUnmaximizedFrame.size.height) - display:YES]; - _gdk_macos_display_from_display_coords ([self gdkDisplay], initialMoveLocation.x, initialMoveLocation.y, @@ -773,26 +765,11 @@ typedef NSString *CALayerContentsGravity; return rect; } +/* Implementing this method avoids new windows move around the screen. */ -(NSRect)windowWillUseStandardFrame:(NSWindow *)nsWindow defaultFrame:(NSRect)newFrame { - NSRect screenFrame = [[self screen] visibleFrame]; - GdkMacosSurface *surface = gdk_surface; - gboolean maximized = GDK_SURFACE (surface)->state & GDK_TOPLEVEL_STATE_MAXIMIZED; - - if (!maximized) - return screenFrame; - else - return lastUnmaximizedFrame; -} - -// Only called on zoom, not on unzoom --(BOOL)windowShouldZoom:(NSWindow *)nsWindow - toFrame:(NSRect)newFrame -{ - lastUnmaximizedFrame = [nsWindow frame]; - - return YES; + return newFrame; } -(NSSize)window:(NSWindow *)window willUseFullScreenContentSize:(NSSize)proposedSize diff --git a/gdk/macos/GdkMacosWindow.h b/gdk/macos/GdkMacosWindow.h index 35127f2fbc..a827f388ff 100644 --- a/gdk/macos/GdkMacosWindow.h +++ b/gdk/macos/GdkMacosWindow.h @@ -49,7 +49,6 @@ EdgeSnapping snapping; - NSRect lastUnmaximizedFrame; NSRect lastUnfullscreenFrame; BOOL inFullscreenTransition; }