window: Add get_all_monitors

Add a method that returns the indices of the monitors a window
is on.

https://bugzilla.gnome.org/show_bug.cgi?id=646861
This commit is contained in:
Adel Gadllah 2013-02-23 21:56:17 +01:00
parent b5152c3327
commit 2a773e0c85
2 changed files with 37 additions and 0 deletions

View File

@ -3647,6 +3647,42 @@ meta_window_is_fullscreen (MetaWindow *window)
return window->fullscreen; return window->fullscreen;
} }
/**
* meta_window_get_all_monitors:
* @window: The #MetaWindow
* @length: (out caller-allocates): gint holding the length, may be %NULL to
* ignore
*
* Returns: (array length=length) (element-type gint) (transfer container):
* List of the monitor indices the window is on.
*/
gint *
meta_window_get_all_monitors (MetaWindow *window, gsize *length)
{
GArray *monitors;
MetaRectangle window_rect;
int i;
monitors = g_array_new (FALSE, FALSE, sizeof (int));
meta_window_get_outer_rect (window, &window_rect);
for (i = 0; i < window->screen->n_monitor_infos; i++)
{
MetaRectangle *monitor_rect = &window->screen->monitor_infos[i].rect;
if (meta_rectangle_overlap (&window_rect, monitor_rect))
g_array_append_val (monitors, i);
}
if (length)
*length = monitors->len;
i = -1;
g_array_append_val (monitors, i);
return (gint*) g_array_free (monitors, FALSE);
}
/** /**
* meta_window_is_screen_sized: * meta_window_is_screen_sized:
* *

View File

@ -146,6 +146,7 @@ gboolean meta_window_is_monitor_sized (MetaWindow *window);
gboolean meta_window_is_on_primary_monitor (MetaWindow *window); gboolean meta_window_is_on_primary_monitor (MetaWindow *window);
gboolean meta_window_requested_bypass_compositor (MetaWindow *window); gboolean meta_window_requested_bypass_compositor (MetaWindow *window);
gboolean meta_window_requested_dont_bypass_compositor (MetaWindow *window); gboolean meta_window_requested_dont_bypass_compositor (MetaWindow *window);
gint *meta_window_get_all_monitors (MetaWindow *window, gsize *length);
gboolean meta_window_is_mapped (MetaWindow *window); gboolean meta_window_is_mapped (MetaWindow *window);
gboolean meta_window_toplevel_is_mapped (MetaWindow *window); gboolean meta_window_toplevel_is_mapped (MetaWindow *window);