Don't calculate the main window monitor every time it`s needed

The main monitor of a window is maintained as 'window->monitor' and is
updated when the window is resized or moved. Lets avoid calculating it
every time it`s needed.

https://bugzilla.gnome.org/show_bug.cgi?id=744934
This commit is contained in:
Jonas Ådahl 2015-04-09 12:20:24 +08:00
parent 441efd17ce
commit 14b0a83f64
5 changed files with 12 additions and 15 deletions

View File

@ -3186,7 +3186,7 @@ handle_move_to_monitor (MetaDisplay *display,
gint which = binding->handler->data;
const MetaMonitorInfo *current, *new;
current = meta_screen_get_monitor_for_window (screen, window);
current = window->monitor;
new = meta_screen_get_monitor_neighbor (screen, current->number, which);
if (new == NULL)

View File

@ -149,7 +149,7 @@ const MetaMonitorInfo* meta_screen_get_current_monitor_info_for_pos (MetaScree
int y);
const MetaMonitorInfo* meta_screen_get_monitor_for_rect (MetaScreen *screen,
MetaRectangle *rect);
const MetaMonitorInfo* meta_screen_get_monitor_for_window (MetaScreen *screen,
const MetaMonitorInfo* meta_screen_calculate_monitor_for_window (MetaScreen *screen,
MetaWindow *window);

View File

@ -1439,7 +1439,7 @@ meta_screen_get_monitor_for_rect (MetaScreen *screen,
}
const MetaMonitorInfo*
meta_screen_get_monitor_for_window (MetaScreen *screen,
meta_screen_calculate_monitor_for_window (MetaScreen *screen,
MetaWindow *window)
{
MetaRectangle window_rect;

View File

@ -288,8 +288,7 @@ windows_on_different_monitor (MetaWindow *a,
if (a->screen != b->screen)
return TRUE;
return meta_screen_get_monitor_for_window (a->screen, a) !=
meta_screen_get_monitor_for_window (b->screen, b);
return a->monitor != b->monitor;
}
/* Get layer ignoring any transient or group relationships */

View File

@ -981,7 +981,8 @@ _meta_window_shared_new (MetaDisplay *display,
window->compositor_private = NULL;
window->monitor = meta_screen_get_monitor_for_window (window->screen, window);
window->monitor = meta_screen_calculate_monitor_for_window (window->screen,
window);
window->preferred_output_winsys_id = window->monitor->winsys_id;
window->tile_match = NULL;
@ -3546,7 +3547,8 @@ meta_window_update_monitor (MetaWindow *window,
const MetaMonitorInfo *old;
old = window->monitor;
window->monitor = meta_screen_get_monitor_for_window (window->screen, window);
window->monitor = meta_screen_calculate_monitor_for_window (window->screen,
window);
if (old != window->monitor)
{
meta_window_on_all_workspaces_changed (window);
@ -5638,7 +5640,7 @@ update_move (MetaWindow *window,
int monitor;
window->tile_mode = META_TILE_NONE;
wmonitor = meta_screen_get_monitor_for_window (window->screen, window);
wmonitor = window->monitor;
for (monitor = 0; monitor < window->screen->n_monitor_infos; monitor++)
{
@ -6047,12 +6049,8 @@ void
meta_window_get_work_area_current_monitor (MetaWindow *window,
MetaRectangle *area)
{
const MetaMonitorInfo *monitor = NULL;
monitor = meta_screen_get_monitor_for_window (window->screen,
window);
meta_window_get_work_area_for_monitor (window,
monitor->number,
window->monitor->number,
area);
}