screen: Add new public meta_screen_get_current_monitor API

Similar to meta_screen_get_primary_monitor, this returns a monitor index.
The monitor that the pointer is on. The previous private implementation
has been renamed to meta_screen_get_current_monitor_info.

https://bugzilla.gnome.org/show_bug.cgi?id=642591
This commit is contained in:
Tim L 2012-06-08 18:21:10 +10:00 committed by Jasper St. Pierre
parent 50cf3dd1a5
commit 4595209346
5 changed files with 25 additions and 8 deletions

View File

@ -137,7 +137,7 @@ find_next_cascade (MetaWindow *window,
*/
current = meta_screen_get_current_monitor (window->screen);
meta_window_get_work_area_for_monitor (window, current->number, &work_area);
meta_window_get_work_area_for_monitor (window, current, &work_area);
cascade_x = MAX (0, work_area.x);
cascade_y = MAX (0, work_area.y);
@ -815,7 +815,7 @@ meta_window_place (MetaWindow *window,
int w, h;
/* Warning, this function is a round trip! */
xi = meta_screen_get_current_monitor (window->screen);
xi = meta_screen_get_current_monitor_info (window->screen);
w = xi->rect.width;
h = xi->rect.height;
@ -860,7 +860,7 @@ meta_window_place (MetaWindow *window,
}
/* Warning, this is a round trip! */
xi = meta_screen_get_current_monitor (window->screen);
xi = meta_screen_get_current_monitor_info (window->screen);
/* "Origin" placement algorithm */
x = xi->rect.x;

View File

@ -184,7 +184,7 @@ void meta_screen_tile_preview_hide (MetaScreen *screen);
MetaWindow* meta_screen_get_mouse_window (MetaScreen *screen,
MetaWindow *not_this_one);
const MetaMonitorInfo* meta_screen_get_current_monitor (MetaScreen *screen);
const MetaMonitorInfo* meta_screen_get_current_monitor_info (MetaScreen *screen);
const MetaMonitorInfo* meta_screen_get_monitor_for_rect (MetaScreen *screen,
MetaRectangle *rect);
const MetaMonitorInfo* meta_screen_get_monitor_for_window (MetaScreen *screen,

View File

@ -2054,7 +2054,7 @@ meta_screen_get_natural_monitor_list (MetaScreen *screen,
visited[i] = FALSE;
}
current = meta_screen_get_current_monitor (screen);
current = meta_screen_get_current_monitor_info (screen);
monitor_queue = g_queue_new ();
g_queue_push_tail (monitor_queue, (gpointer) current);
visited[current->number] = TRUE;
@ -2121,6 +2121,22 @@ meta_screen_get_natural_monitor_list (MetaScreen *screen,
}
const MetaMonitorInfo*
meta_screen_get_current_monitor_info (MetaScreen *screen)
{
int monitor_index;
monitor_index = meta_screen_get_current_monitor (screen);
return &screen->monitor_infos[monitor_index];
}
/**
* meta_screen_get_current_monitor:
* @screen: a #MetaScreen
*
* Gets the index of the monitor that currently has the mouse pointer.
*
* Return value: a monitor index
*/
int
meta_screen_get_current_monitor (MetaScreen *screen)
{
if (screen->n_monitor_infos == 1)
@ -2166,7 +2182,7 @@ meta_screen_get_current_monitor (MetaScreen *screen)
screen->last_monitor_index);
}
return &screen->monitor_infos[screen->last_monitor_index];
return screen->last_monitor_index;
}
/**

View File

@ -3682,7 +3682,7 @@ meta_window_can_tile_side_by_side (MetaWindow *window)
return FALSE;
monitor = meta_screen_get_current_monitor (window->screen);
meta_window_get_work_area_for_monitor (window, monitor->number, &tile_area);
meta_window_get_work_area_for_monitor (window, monitor, &tile_area);
/* Do not allow tiling in portrait orientation */
if (tile_area.height > tile_area.width)
@ -8620,7 +8620,7 @@ update_move (MetaWindow *window,
* refers to the monitor which contains the largest part of the window,
* the latter to the one where the pointer is located.
*/
monitor = meta_screen_get_current_monitor (window->screen);
monitor = meta_screen_get_current_monitor_info (window->screen);
meta_window_get_work_area_for_monitor (window,
monitor->number,
&work_area);

View File

@ -77,6 +77,7 @@ MetaWorkspace * meta_screen_get_active_workspace (MetaScreen *screen);
int meta_screen_get_n_monitors (MetaScreen *screen);
int meta_screen_get_primary_monitor (MetaScreen *screen);
int meta_screen_get_current_monitor (MetaScreen *screen);
void meta_screen_get_monitor_geometry (MetaScreen *screen,
int monitor,
MetaRectangle *geometry);