From fa8fa48ef1fa91b40a7ad292b93d1edd72e0d2b6 Mon Sep 17 00:00:00 2001 From: Kristian Rietveld Date: Mon, 26 Oct 2009 09:20:28 +0100 Subject: [PATCH] Update position of toplevels after display reconfiguration We have to do this, especially after the screen containing the menubar has changed. Such more larger changes in monitor geometry will cause changes to how monitors are laid out in the root window. The position coordinates of the windows will have to be updated to reflect their position in the new layout. --- gdk/quartz/GdkQuartzWindow.c | 5 +---- gdk/quartz/gdkprivate-quartz.h | 4 +++- gdk/quartz/gdkscreen-quartz.c | 2 +- gdk/quartz/gdkwindow-quartz.c | 33 +++++++++++++++++++++++++++++++-- 4 files changed, 36 insertions(+), 8 deletions(-) diff --git a/gdk/quartz/GdkQuartzWindow.c b/gdk/quartz/GdkQuartzWindow.c index d38fe22a14..b43a2beaa4 100644 --- a/gdk/quartz/GdkQuartzWindow.c +++ b/gdk/quartz/GdkQuartzWindow.c @@ -139,14 +139,11 @@ -(void)windowDidMove:(NSNotification *)aNotification { - NSRect content_rect = [self contentRectForFrameRect:[self frame]]; GdkWindow *window = [[self contentView] gdkWindow]; GdkWindowObject *private = (GdkWindowObject *)window; GdkEvent *event; - _gdk_quartz_window_xy_to_gdk_xy (content_rect.origin.x, - content_rect.origin.y + content_rect.size.height, - &private->x, &private->y); + _gdk_quartz_window_update_position (window); /* Synthesize a configure event */ event = gdk_event_new (GDK_CONFIGURE); diff --git a/gdk/quartz/gdkprivate-quartz.h b/gdk/quartz/gdkprivate-quartz.h index dadec3f549..d7196b251a 100644 --- a/gdk/quartz/gdkprivate-quartz.h +++ b/gdk/quartz/gdkprivate-quartz.h @@ -105,7 +105,7 @@ extern GdkDragContext *_gdk_quartz_drag_source_context; #define GDK_WINDOW_IS_QUARTZ(win) (GDK_IS_WINDOW_IMPL_QUARTZ (((GdkWindowObject *)win)->impl)) /* Initialization */ -void _gdk_windowing_update_root_window_size (GdkScreen *screen); +void _gdk_windowing_update_window_sizes (GdkScreen *screen); void _gdk_windowing_window_init (void); void _gdk_events_init (void); void _gdk_visual_init (void); @@ -163,6 +163,8 @@ void _gdk_quartz_window_debug_highlight (GdkWindow *window, void _gdk_quartz_window_set_needs_display_in_rect (GdkWindow *window, GdkRectangle *rect); +void _gdk_quartz_window_update_position (GdkWindow *window); + /* Events */ typedef enum { GDK_QUARTZ_EVENT_SUBTYPE_EVENTLOOP diff --git a/gdk/quartz/gdkscreen-quartz.c b/gdk/quartz/gdkscreen-quartz.c index 5c3db27586..e6579c7cc4 100644 --- a/gdk/quartz/gdkscreen-quartz.c +++ b/gdk/quartz/gdkscreen-quartz.c @@ -177,7 +177,7 @@ process_display_reconfiguration (GdkScreenQuartz *screen) gdk_screen_quartz_calculate_layout (GDK_SCREEN_QUARTZ (screen)); - _gdk_windowing_update_root_window_size (GDK_SCREEN (screen)); + _gdk_windowing_update_window_sizes (GDK_SCREEN (screen)); if (screen->emit_monitors_changed) { diff --git a/gdk/quartz/gdkwindow-quartz.c b/gdk/quartz/gdkwindow-quartz.c index a97e3b4f75..0a851e8475 100644 --- a/gdk/quartz/gdkwindow-quartz.c +++ b/gdk/quartz/gdkwindow-quartz.c @@ -1089,8 +1089,30 @@ _gdk_window_impl_new (GdkWindow *window, } void -_gdk_windowing_update_root_window_size (GdkScreen *screen) +_gdk_quartz_window_update_position (GdkWindow *window) { + NSRect frame_rect; + NSRect content_rect; + GdkWindowObject *private = (GdkWindowObject *)window; + GdkWindowImplQuartz *impl = GDK_WINDOW_IMPL_QUARTZ (private->impl); + + GDK_QUARTZ_ALLOC_POOL; + + frame_rect = [impl->toplevel frame]; + content_rect = [impl->toplevel contentRectForFrameRect:frame_rect]; + + _gdk_quartz_window_xy_to_gdk_xy (content_rect.origin.x, + content_rect.origin.y + content_rect.size.height, + &private->x, &private->y); + + + GDK_QUARTZ_RELEASE_POOL; +} + +void +_gdk_windowing_update_window_sizes (GdkScreen *screen) +{ + GList *windows, *list; GdkWindowObject *private = (GdkWindowObject *)_gdk_root; /* The size of the root window is so that it can contain all @@ -1106,6 +1128,13 @@ _gdk_windowing_update_root_window_size (GdkScreen *screen) private->abs_y = 0; private->width = gdk_screen_get_width (screen); private->height = gdk_screen_get_height (screen); + + windows = gdk_screen_get_toplevel_windows (screen); + + for (list = windows; list; list = list->next) + _gdk_quartz_window_update_position (list->data); + + g_list_free (windows); } void @@ -1125,7 +1154,7 @@ _gdk_windowing_window_init (void) impl = GDK_WINDOW_IMPL_QUARTZ (GDK_WINDOW_OBJECT (_gdk_root)->impl); - _gdk_windowing_update_root_window_size (_gdk_screen); + _gdk_windowing_update_window_sizes (_gdk_screen); private->state = 0; /* We don't want GDK_WINDOW_STATE_WITHDRAWN here */ private->window_type = GDK_WINDOW_ROOT;