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
This commit is contained in:
Jonas Ådahl 2016-12-01 13:01:39 +08:00
parent 5a8509f895
commit 98ee85ce82
5 changed files with 16 additions and 23 deletions

View File

@ -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);

View File

@ -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)

View File

@ -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;

View File

@ -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;

View File

@ -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