From 44cfceba00d6cc8532cef7b9a8f3e3acef0ca5ca Mon Sep 17 00:00:00 2001 From: Alexander Larsson Date: Fri, 25 Feb 2011 16:37:05 +0100 Subject: [PATCH] Track the monitor for each window https://bugzilla.gnome.org/show_bug.cgi?id=609258 --- src/core/screen.c | 17 ++++++++++++++++- src/core/window-private.h | 2 ++ src/core/window.c | 12 ++++++++++++ 3 files changed, 30 insertions(+), 1 deletion(-) diff --git a/src/core/screen.c b/src/core/screen.c index 252c3e329..8affdd041 100644 --- a/src/core/screen.c +++ b/src/core/screen.c @@ -2816,7 +2816,9 @@ void meta_screen_resize (MetaScreen *screen, int width, int height) -{ +{ + GSList *windows, *tmp; + screen->rect.width = width; screen->rect.height = height; @@ -2830,6 +2832,19 @@ meta_screen_resize (MetaScreen *screen, /* Queue a resize on all the windows */ meta_screen_foreach_window (screen, meta_screen_resize_func, 0); + /* Fix up monitor for all windows on this screen */ + windows = meta_display_list_windows (screen->display, + META_LIST_INCLUDE_OVERRIDE_REDIRECT); + for (tmp = windows; tmp != NULL; tmp = tmp->next) + { + MetaWindow *window = tmp->data; + + if (window->screen == screen) + meta_window_update_monitor (window); + } + + g_slist_free (windows); + g_signal_emit (screen, screen_signals[MONITORS_CHANGED], 0, index); } diff --git a/src/core/window-private.h b/src/core/window-private.h index e75f13aa3..5fe10d80a 100644 --- a/src/core/window-private.h +++ b/src/core/window-private.h @@ -67,6 +67,7 @@ struct _MetaWindow MetaDisplay *display; MetaScreen *screen; + const MetaMonitorInfo *monitor; MetaWorkspace *workspace; Window xwindow; /* may be NULL! not all windows get decorated */ @@ -625,5 +626,6 @@ void meta_window_update_icon_now (MetaWindow *window); void meta_window_update_role (MetaWindow *window); void meta_window_update_net_wm_type (MetaWindow *window); +void meta_window_update_monitor (MetaWindow *window); #endif diff --git a/src/core/window.c b/src/core/window.c index 7f7abdfd6..1bf47997f 100644 --- a/src/core/window.c +++ b/src/core/window.c @@ -880,6 +880,8 @@ meta_window_new_with_attrs (MetaDisplay *display, window->compositor_private = NULL; + window->monitor = meta_screen_get_monitor_for_window (window->screen, window); + if (window->override_redirect) { window->decorated = FALSE; @@ -3993,6 +3995,12 @@ move_attached_dialog (MetaWindow *window, return FALSE; } +void +meta_window_update_monitor (MetaWindow *window) +{ + window->monitor = meta_screen_get_monitor_for_window (window->screen, window); +} + static void meta_window_move_resize_internal (MetaWindow *window, MetaMoveResizeFlags flags, @@ -4444,6 +4452,8 @@ meta_window_move_resize_internal (MetaWindow *window, meta_window_refresh_resize_popup (window); + meta_window_update_monitor (window); + /* Invariants leaving this function are: * a) window->rect and frame->rect reflect the actual * server-side size/pos of window->xwindow and frame->xwindow @@ -4659,6 +4669,8 @@ meta_window_configure_notify (MetaWindow *window, window->rect.y = event->y; window->rect.width = event->width; window->rect.height = event->height; + meta_window_update_monitor (window); + if (!event->override_redirect && !event->send_event) meta_warning ("Unhandled change of windows override redirect status\n");