[gtk/wip/chergert/macos-iosurface: 5/7] macos: improve position of window during unmaximize
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/chergert/macos-iosurface: 5/7] macos: improve position of window during unmaximize
- Date: Mon, 14 Feb 2022 23:28:34 +0000 (UTC)
commit 8ec7a66f134da954eba364a093e39c7ab3e59dd8
Author: Christian Hergert <christian hergert me>
Date: Mon Feb 14 02:17:13 2022 -0800
macos: improve position of window during unmaximize
Previously the size would stay the same but we'd regain a shadow. This
makes it jump back to the old size like we would on Wayland.
gdk/macos/GdkMacosWindow.c | 19 ++++++++++++++++++-
1 file changed, 18 insertions(+), 1 deletion(-)
---
diff --git a/gdk/macos/GdkMacosWindow.c b/gdk/macos/GdkMacosWindow.c
index ba7c635b0a..8ccc22b560 100644
--- a/gdk/macos/GdkMacosWindow.c
+++ b/gdk/macos/GdkMacosWindow.c
@@ -231,7 +231,24 @@ typedef NSString *CALayerContentsGravity;
/* In case the window is changed when maximized remove the maximized state */
if (maximized && !inMaximizeTransition && !NSEqualRects (lastMaximizedFrame, [self frame]))
- [self windowDidUnmaximize];
+ {
+ NSRect last = lastUnmaximizedFrame;
+ NSRect newFrame = [self frame];
+
+ [self windowDidUnmaximize];
+
+ /* If we had a previous position, try to give the user something
+ * that resembles they grabbed it even though our warp could have
+ * made it a bit of a jump.
+ */
+ if (!CGRectIsNull (last))
+ {
+ newFrame.size = last.size;
+ newFrame.origin = [self mouseLocationOutsideOfEventStream];
+ newFrame.origin.x -= last.size.width / 2;
+ [self setFrame:newFrame display:NO];
+ }
+ }
_gdk_macos_surface_update_position (gdk_surface);
_gdk_macos_surface_reposition_children (gdk_surface);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]