From 98ee85ce82a81353a8b8b582eafd947f10d1f777 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20=C3=85dahl?= Date: Thu, 1 Dec 2016 13:01:39 +0800 Subject: [PATCH] Let the MetaWindow calculate its main logical monitor itself There is no point in going via a MetaScreen API to calculate the "main monitor" of a window, so let the window do that calculation itself. https://bugzilla.gnome.org/show_bug.cgi?id=777732 --- src/core/screen-private.h | 3 --- src/core/screen.c | 15 --------------- src/core/window.c | 16 ++++++++++++++-- src/wayland/meta-window-wayland.c | 2 +- src/x11/window-x11.c | 3 +-- 5 files changed, 16 insertions(+), 23 deletions(-) diff --git a/src/core/screen-private.h b/src/core/screen-private.h index 8c0d00ae7..1bc2e2441 100644 --- a/src/core/screen-private.h +++ b/src/core/screen-private.h @@ -130,9 +130,6 @@ void meta_screen_hide_tile_preview (MetaScreen *screen); MetaWindow* meta_screen_get_mouse_window (MetaScreen *screen, MetaWindow *not_this_one); -MetaLogicalMonitor * meta_screen_calculate_logical_monitor_for_window (MetaScreen *screen, - MetaWindow *window); - MetaLogicalMonitor * meta_screen_get_monitor_neighbor (MetaScreen *screen, int which_monitor, MetaScreenDirection dir); diff --git a/src/core/screen.c b/src/core/screen.c index b4bfe93a7..eea7f23eb 100644 --- a/src/core/screen.c +++ b/src/core/screen.c @@ -1401,21 +1401,6 @@ meta_screen_get_mouse_window (MetaScreen *screen, return window; } -MetaLogicalMonitor * -meta_screen_calculate_logical_monitor_for_window (MetaScreen *screen, - MetaWindow *window) -{ - MetaBackend *backend = meta_get_backend (); - MetaMonitorManager *monitor_manager = - meta_backend_get_monitor_manager (backend); - MetaRectangle window_rect; - - meta_window_get_frame_rect (window, &window_rect); - - return meta_monitor_manager_get_logical_monitor_from_rect (monitor_manager, - &window_rect); -} - int meta_screen_get_monitor_index_for_rect (MetaScreen *screen, MetaRectangle *rect) diff --git a/src/core/window.c b/src/core/window.c index 15c312a75..0aedf35d1 100644 --- a/src/core/window.c +++ b/src/core/window.c @@ -829,6 +829,19 @@ meta_window_main_monitor_changed (MetaWindow *window, window->monitor->number, window); } +MetaLogicalMonitor * +meta_window_calculate_main_logical_monitor (MetaWindow *window) +{ + MetaBackend *backend = meta_get_backend (); + MetaMonitorManager *monitor_manager = + meta_backend_get_monitor_manager (backend); + MetaRectangle window_rect; + + meta_window_get_frame_rect (window, &window_rect); + return meta_monitor_manager_get_logical_monitor_from_rect (monitor_manager, + &window_rect); +} + MetaWindow * _meta_window_shared_new (MetaDisplay *display, MetaScreen *screen, @@ -1026,8 +1039,7 @@ _meta_window_shared_new (MetaDisplay *display, window->compositor_private = NULL; - window->monitor = - meta_screen_calculate_logical_monitor_for_window (window->screen, window); + window->monitor = meta_window_calculate_main_logical_monitor (window); window->preferred_output_winsys_id = window->monitor->winsys_id; window->tile_match = NULL; diff --git a/src/wayland/meta-window-wayland.c b/src/wayland/meta-window-wayland.c index 9ac45734b..f80e01d2a 100644 --- a/src/wayland/meta-window-wayland.c +++ b/src/wayland/meta-window-wayland.c @@ -361,7 +361,7 @@ meta_window_wayland_update_main_monitor (MetaWindow *window) * needed to avoid jumping back and forth between the new and the old, since * changing main monitor may cause the window to be resized so that it no * longer have that same new main monitor. */ - to = meta_screen_calculate_logical_monitor_for_window (window->screen, window); + to = meta_window_calculate_main_logical_monitor (window); if (from == to) return; diff --git a/src/x11/window-x11.c b/src/x11/window-x11.c index 7f1c02b97..b46033c02 100644 --- a/src/x11/window-x11.c +++ b/src/x11/window-x11.c @@ -1457,8 +1457,7 @@ meta_window_x11_update_icon (MetaWindow *window, static void meta_window_x11_update_main_monitor (MetaWindow *window) { - window->monitor = - meta_screen_calculate_logical_monitor_for_window (window->screen, window); + window->monitor = meta_window_calculate_main_logical_monitor (window); } static void