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.
This commit is contained in:
Kristian Rietveld 2009-10-26 09:20:28 +01:00
parent a4d932cc64
commit fa8fa48ef1
4 changed files with 36 additions and 8 deletions

View File

@ -139,14 +139,11 @@
-(void)windowDidMove:(NSNotification *)aNotification -(void)windowDidMove:(NSNotification *)aNotification
{ {
NSRect content_rect = [self contentRectForFrameRect:[self frame]];
GdkWindow *window = [[self contentView] gdkWindow]; GdkWindow *window = [[self contentView] gdkWindow];
GdkWindowObject *private = (GdkWindowObject *)window; GdkWindowObject *private = (GdkWindowObject *)window;
GdkEvent *event; GdkEvent *event;
_gdk_quartz_window_xy_to_gdk_xy (content_rect.origin.x, _gdk_quartz_window_update_position (window);
content_rect.origin.y + content_rect.size.height,
&private->x, &private->y);
/* Synthesize a configure event */ /* Synthesize a configure event */
event = gdk_event_new (GDK_CONFIGURE); event = gdk_event_new (GDK_CONFIGURE);

View File

@ -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)) #define GDK_WINDOW_IS_QUARTZ(win) (GDK_IS_WINDOW_IMPL_QUARTZ (((GdkWindowObject *)win)->impl))
/* Initialization */ /* 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_windowing_window_init (void);
void _gdk_events_init (void); void _gdk_events_init (void);
void _gdk_visual_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, void _gdk_quartz_window_set_needs_display_in_rect (GdkWindow *window,
GdkRectangle *rect); GdkRectangle *rect);
void _gdk_quartz_window_update_position (GdkWindow *window);
/* Events */ /* Events */
typedef enum { typedef enum {
GDK_QUARTZ_EVENT_SUBTYPE_EVENTLOOP GDK_QUARTZ_EVENT_SUBTYPE_EVENTLOOP

View File

@ -177,7 +177,7 @@ process_display_reconfiguration (GdkScreenQuartz *screen)
gdk_screen_quartz_calculate_layout (GDK_SCREEN_QUARTZ (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) if (screen->emit_monitors_changed)
{ {

View File

@ -1089,8 +1089,30 @@ _gdk_window_impl_new (GdkWindow *window,
} }
void 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; GdkWindowObject *private = (GdkWindowObject *)_gdk_root;
/* The size of the root window is so that it can contain all /* 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->abs_y = 0;
private->width = gdk_screen_get_width (screen); private->width = gdk_screen_get_width (screen);
private->height = gdk_screen_get_height (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 void
@ -1125,7 +1154,7 @@ _gdk_windowing_window_init (void)
impl = GDK_WINDOW_IMPL_QUARTZ (GDK_WINDOW_OBJECT (_gdk_root)->impl); 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->state = 0; /* We don't want GDK_WINDOW_STATE_WITHDRAWN here */
private->window_type = GDK_WINDOW_ROOT; private->window_type = GDK_WINDOW_ROOT;