From c79539dc8c879bde976d11bc0d9227d91d183c1c Mon Sep 17 00:00:00 2001 From: John Ralls Date: Wed, 25 Dec 2024 20:27:56 -0800 Subject: [PATCH 1/2] [quartz] GdkQuartzNSWindow: Extract func synthesize_configure_event. To reduce duplicated code. --- gdk/quartz/GdkQuartzNSWindow.c | 38 ++++++++++++++-------------------- 1 file changed, 15 insertions(+), 23 deletions(-) diff --git a/gdk/quartz/GdkQuartzNSWindow.c b/gdk/quartz/GdkQuartzNSWindow.c index 6a3d2919c1..61839556f8 100644 --- a/gdk/quartz/GdkQuartzNSWindow.c +++ b/gdk/quartz/GdkQuartzNSWindow.c @@ -192,12 +192,23 @@ } } } +static void +synthesize_configure_event(GdkWindow *window) +{ + GdkEvent *event = gdk_event_new (GDK_CONFIGURE); + + event->configure.window = g_object_ref (window); + event->configure.x = window->x; + event->configure.y = window->y; + event->configure.width = window->width; + event->configure.height = window->height; + + _gdk_event_queue_append (gdk_display_get_default (), event); +} -(void)windowDidMove:(NSNotification *)aNotification { GdkWindow *window = [[self contentView] gdkWindow]; - GdkEvent *event; - gboolean maximized = gdk_window_get_state (window) & GDK_WINDOW_STATE_MAXIMIZED; /* In case the window is changed when maximized remove the maximized state */ @@ -209,16 +220,7 @@ } _gdk_quartz_window_update_position (window); - - /* Synthesize a configure event */ - event = gdk_event_new (GDK_CONFIGURE); - event->configure.window = g_object_ref (window); - event->configure.x = window->x; - event->configure.y = window->y; - event->configure.width = window->width; - event->configure.height = window->height; - - _gdk_event_queue_append (gdk_display_get_default (), event); + synthesize_configure_event(window); [self checkSendEnterNotify]; } @@ -227,7 +229,6 @@ { NSRect content_rect = [self contentRectForFrameRect:[self frame]]; GdkWindow *window = [[self contentView] gdkWindow]; - GdkEvent *event; gboolean maximized = gdk_window_get_state (window) & GDK_WINDOW_STATE_MAXIMIZED; /* Alignment to 4 pixels is on scaled pixels and these are unscaled pixels so divide by scale to compensate. */ const gint scale = gdk_window_get_scale_factor (window); @@ -260,16 +261,7 @@ */ _gdk_quartz_window_update_position (window); _gdk_window_update_size (window); - - /* Synthesize a configure event */ - event = gdk_event_new (GDK_CONFIGURE); - event->configure.window = g_object_ref (window); - event->configure.x = window->x; - event->configure.y = window->y; - event->configure.width = window->width; - event->configure.height = window->height; - - _gdk_event_queue_append (gdk_display_get_default (), event); + synthesize_configure_event (window); [self checkSendEnterNotify]; } From 41bd9e4290373a032a506dd736e466708074f47c Mon Sep 17 00:00:00 2001 From: John Ralls Date: Wed, 25 Dec 2024 20:29:19 -0800 Subject: [PATCH 2/2] [quartz] GdkQuartzNSWindow: Pad only the content_rect width. On Quartz the drawing region must be padded out to a multiple of 4 px on regular displays and 8 px on Retina ones. Failing to do so used to cause smearing on multi-monitor mixed-DPI systems but that seems to have been fixed. There remains a visible flicker in animations. Padding the GdkWindow width as well as the content frame and cairo surface causes the frame clock to get frozen if multiple calls to gtk_window_resize use the same size because gdk_window_move_resize_internal sees a difference between the window size and the requested size (the latter isn't padded out) and freezes updates. GdkQuartzNSWindow windowDidResize is supposed to thaw them, but because the padded-out width set for the frame doesn't change the window isn't resized and the frame clock is never thawed. Fixes https://gitlab.gnome.org/GNOME/gtk/-/issues/7188 --- gdk/quartz/GdkQuartzNSWindow.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/gdk/quartz/GdkQuartzNSWindow.c b/gdk/quartz/GdkQuartzNSWindow.c index 61839556f8..b00175871f 100644 --- a/gdk/quartz/GdkQuartzNSWindow.c +++ b/gdk/quartz/GdkQuartzNSWindow.c @@ -246,10 +246,7 @@ synthesize_configure_event(GdkWindow *window) window->height = content_rect.size.height; if(window->width % align) - { - window->width += align - window->width % align; - content_rect.size.width = window->width; - } + content_rect.size.width = window->width + align - window->width % align; content_rect.origin.x = 0; content_rect.origin.y = 0;