870
883
return clutter_clone_new (global->root_pixmap);
887
* shell_global_get_monitors:
888
* @global: the #ShellGlobal
890
* Gets a list of the bounding boxes of the active screen's monitors.
892
* Return value: (transfer full) (element-type GdkRectangle): a list
893
* of monitor bounding boxes.
896
shell_global_get_monitors (ShellGlobal *global)
898
MetaScreen *screen = shell_global_get_screen (global);
899
GSList *monitors = NULL;
903
g_assert (sizeof (MetaRectangle) == sizeof (GdkRectangle) &&
904
G_STRUCT_OFFSET (MetaRectangle, x) == G_STRUCT_OFFSET (GdkRectangle, x) &&
905
G_STRUCT_OFFSET (MetaRectangle, y) == G_STRUCT_OFFSET (GdkRectangle, y) &&
906
G_STRUCT_OFFSET (MetaRectangle, width) == G_STRUCT_OFFSET (GdkRectangle, width) &&
907
G_STRUCT_OFFSET (MetaRectangle, height) == G_STRUCT_OFFSET (GdkRectangle, height));
909
for (i = meta_screen_get_n_monitors (screen) - 1; i >= 0; i--)
911
meta_screen_get_monitor_geometry (screen, i, &rect);
912
monitors = g_slist_prepend (monitors,
913
g_boxed_copy (GDK_TYPE_RECTANGLE, &rect));
919
* shell_global_get_primary_monitor:
920
* @global: the #ShellGlobal
922
* Gets the bounding box of the primary monitor (the one that the
925
* Return value: the bounding box of the primary monitor
928
shell_global_get_primary_monitor (ShellGlobal *global)
930
MetaScreen *screen = shell_global_get_screen (global);
933
g_assert (sizeof (MetaRectangle) == sizeof (GdkRectangle) &&
934
G_STRUCT_OFFSET (MetaRectangle, x) == G_STRUCT_OFFSET (GdkRectangle, x) &&
935
G_STRUCT_OFFSET (MetaRectangle, y) == G_STRUCT_OFFSET (GdkRectangle, y) &&
936
G_STRUCT_OFFSET (MetaRectangle, width) == G_STRUCT_OFFSET (GdkRectangle, width) &&
937
G_STRUCT_OFFSET (MetaRectangle, height) == G_STRUCT_OFFSET (GdkRectangle, height));
939
meta_screen_get_monitor_geometry (screen, 0, &rect);
940
return g_boxed_copy (GDK_TYPE_RECTANGLE, &rect);
944
* shell_global_get_focus_monitor:
945
* @global: the #ShellGlobal
947
* Gets the bounding box of the monitor containing the window that
948
* currently contains the keyboard focus.
950
* Return value: the bounding box of the focus monitor
953
shell_global_get_focus_monitor (ShellGlobal *global)
955
MetaScreen *screen = shell_global_get_screen (global);
956
MetaDisplay *display = meta_screen_get_display (screen);
957
MetaWindow *focus = meta_display_get_focus_window (display);
958
MetaRectangle rect, wrect;
963
meta_window_get_outer_rect (focus, &wrect);
964
nmonitors = meta_screen_get_n_monitors (screen);
966
/* Find the monitor that the top-left corner of @focus is on. */
967
for (i = 0; i < nmonitors; i++)
969
meta_screen_get_monitor_geometry (screen, i, &rect);
971
if (rect.x < wrect.x && rect.y < wrect.y &&
972
rect.x + rect.width > wrect.x &&
973
rect.y + rect.height > wrect.y)
974
return g_boxed_copy (GDK_TYPE_RECTANGLE, &rect);
978
meta_screen_get_monitor_geometry (screen, 0, &rect);
979
return g_boxed_copy (GDK_TYPE_RECTANGLE, &rect);
983
* shell_global_get_modifier_keys:
984
* @global: the #ShellGlobal
986
* Gets the current set of modifier keys that are pressed down;
987
* this is a wrapper around gdk_display_get_pointer() that strips
988
* out any un-declared modifier flags, to make gjs happy; see
989
* https://bugzilla.gnome.org/show_bug.cgi?id=597292.
991
* Return value: the current modifiers
994
shell_global_get_modifier_keys (ShellGlobal *global)
996
GdkModifierType mods;
998
gdk_display_get_pointer (gdk_display_get_default (), NULL, NULL, NULL, &mods);
999
return mods & GDK_MODIFIER_MASK;
1003
* shell_get_event_state:
1004
* @event: a #ClutterEvent
1006
* Gets the current state of the event (the set of modifier keys that
1007
* are pressed down). Thhis is a wrapper around
1008
* clutter_event_get_state() that strips out any un-declared modifier
1009
* flags, to make gjs happy; see
1010
* https://bugzilla.gnome.org/show_bug.cgi?id=597292.
1012
* Return value: the state from the event
1015
shell_get_event_state (ClutterEvent *event)
1017
ClutterModifierType state = clutter_event_get_state (event);
1018
return state & CLUTTER_MODIFIER_MASK;