wayland: Add meta_wayland_compositor_is_grabbed() method

This will return TRUE if there is an existing pointer or keyboard
grab from the wayland compositor.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2683>
This commit is contained in:
Carlos Garnacho 2022-09-29 15:05:10 +02:00 committed by Marge Bot
parent 1e990ad823
commit aed3979064
8 changed files with 40 additions and 0 deletions

View File

@ -926,3 +926,9 @@ meta_wayland_keyboard_class_init (MetaWaylandKeyboardClass *klass)
object_class->finalize = meta_wayland_keyboard_finalize; object_class->finalize = meta_wayland_keyboard_finalize;
} }
gboolean
meta_wayland_keyboard_is_grabbed (MetaWaylandKeyboard *keyboard)
{
return keyboard->grab != &keyboard->default_grab;
}

View File

@ -142,4 +142,6 @@ void meta_wayland_keyboard_start_grab (MetaWaylandKeyboard *keyboard,
MetaWaylandKeyboardGrab *grab); MetaWaylandKeyboardGrab *grab);
void meta_wayland_keyboard_end_grab (MetaWaylandKeyboard *keyboard); void meta_wayland_keyboard_end_grab (MetaWaylandKeyboard *keyboard);
gboolean meta_wayland_keyboard_is_grabbed (MetaWaylandKeyboard *keyboard);
#endif /* META_WAYLAND_KEYBOARD_H */ #endif /* META_WAYLAND_KEYBOARD_H */

View File

@ -1571,3 +1571,9 @@ meta_wayland_pointer_class_init (MetaWaylandPointerClass *klass)
NULL, NULL, NULL, NULL, NULL, NULL,
G_TYPE_NONE, 0); G_TYPE_NONE, 0);
} }
gboolean
meta_wayland_pointer_is_grabbed (MetaWaylandPointer *pointer)
{
return pointer->grab != &pointer->default_grab;
}

View File

@ -159,4 +159,6 @@ void meta_wayland_surface_cursor_update (MetaWaylandSurface *cursor_surface);
void meta_wayland_pointer_update_cursor_surface (MetaWaylandPointer *pointer); void meta_wayland_pointer_update_cursor_surface (MetaWaylandPointer *pointer);
gboolean meta_wayland_pointer_is_grabbed (MetaWaylandPointer *pointer);
#endif /* META_WAYLAND_POINTER_H */ #endif /* META_WAYLAND_POINTER_H */

View File

@ -534,3 +534,17 @@ meta_wayland_seat_get_compositor (MetaWaylandSeat *seat)
{ {
return seat->compositor; return seat->compositor;
} }
gboolean
meta_wayland_seat_is_grabbed (MetaWaylandSeat *seat)
{
if (meta_wayland_seat_has_pointer (seat) &&
meta_wayland_pointer_is_grabbed (seat->pointer))
return TRUE;
if (meta_wayland_seat_has_keyboard (seat) &&
meta_wayland_keyboard_is_grabbed (seat->keyboard))
return TRUE;
return FALSE;
}

View File

@ -84,4 +84,6 @@ gboolean meta_wayland_seat_has_touch (MetaWaylandSeat *seat);
MetaWaylandCompositor * meta_wayland_seat_get_compositor (MetaWaylandSeat *seat); MetaWaylandCompositor * meta_wayland_seat_get_compositor (MetaWaylandSeat *seat);
gboolean meta_wayland_seat_is_grabbed (MetaWaylandSeat *seat);
#endif /* META_WAYLAND_SEAT_H */ #endif /* META_WAYLAND_SEAT_H */

View File

@ -849,3 +849,9 @@ meta_wayland_compositor_get_context (MetaWaylandCompositor *compositor)
{ {
return compositor->context; return compositor->context;
} }
gboolean
meta_wayland_compositor_is_grabbed (MetaWaylandCompositor *compositor)
{
return meta_wayland_seat_is_grabbed (compositor->seat);
}

View File

@ -103,4 +103,6 @@ META_EXPORT_TEST
MetaContext * meta_wayland_compositor_get_context (MetaWaylandCompositor *compositor); MetaContext * meta_wayland_compositor_get_context (MetaWaylandCompositor *compositor);
gboolean meta_wayland_compositor_is_grabbed (MetaWaylandCompositor *compositor);
#endif #endif