[quartz] GdkQuartzNSWindow: Extract func synthesize_configure_event.

To reduce duplicated code.
This commit is contained in:
John Ralls 2024-12-25 20:27:56 -08:00
parent 42783156bd
commit c79539dc8c

View File

@ -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 -(void)windowDidMove:(NSNotification *)aNotification
{ {
GdkWindow *window = [[self contentView] gdkWindow]; GdkWindow *window = [[self contentView] gdkWindow];
GdkEvent *event;
gboolean maximized = gdk_window_get_state (window) & GDK_WINDOW_STATE_MAXIMIZED; gboolean maximized = gdk_window_get_state (window) & GDK_WINDOW_STATE_MAXIMIZED;
/* In case the window is changed when maximized remove the maximized state */ /* In case the window is changed when maximized remove the maximized state */
@ -209,16 +220,7 @@
} }
_gdk_quartz_window_update_position (window); _gdk_quartz_window_update_position (window);
synthesize_configure_event(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);
[self checkSendEnterNotify]; [self checkSendEnterNotify];
} }
@ -227,7 +229,6 @@
{ {
NSRect content_rect = [self contentRectForFrameRect:[self frame]]; NSRect content_rect = [self contentRectForFrameRect:[self frame]];
GdkWindow *window = [[self contentView] gdkWindow]; GdkWindow *window = [[self contentView] gdkWindow];
GdkEvent *event;
gboolean maximized = gdk_window_get_state (window) & GDK_WINDOW_STATE_MAXIMIZED; 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. */ /* 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); const gint scale = gdk_window_get_scale_factor (window);
@ -260,16 +261,7 @@
*/ */
_gdk_quartz_window_update_position (window); _gdk_quartz_window_update_position (window);
_gdk_window_update_size (window); _gdk_window_update_size (window);
synthesize_configure_event (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);
[self checkSendEnterNotify]; [self checkSendEnterNotify];
} }