diff --git a/src/wayland/meta-wayland-keyboard.c b/src/wayland/meta-wayland-keyboard.c index 5cdd3f4a5..8c12ef145 100644 --- a/src/wayland/meta-wayland-keyboard.c +++ b/src/wayland/meta-wayland-keyboard.c @@ -926,3 +926,9 @@ meta_wayland_keyboard_class_init (MetaWaylandKeyboardClass *klass) object_class->finalize = meta_wayland_keyboard_finalize; } + +gboolean +meta_wayland_keyboard_is_grabbed (MetaWaylandKeyboard *keyboard) +{ + return keyboard->grab != &keyboard->default_grab; +} diff --git a/src/wayland/meta-wayland-keyboard.h b/src/wayland/meta-wayland-keyboard.h index 5e761cde9..0600f5ae0 100644 --- a/src/wayland/meta-wayland-keyboard.h +++ b/src/wayland/meta-wayland-keyboard.h @@ -142,4 +142,6 @@ void meta_wayland_keyboard_start_grab (MetaWaylandKeyboard *keyboard, MetaWaylandKeyboardGrab *grab); void meta_wayland_keyboard_end_grab (MetaWaylandKeyboard *keyboard); +gboolean meta_wayland_keyboard_is_grabbed (MetaWaylandKeyboard *keyboard); + #endif /* META_WAYLAND_KEYBOARD_H */ diff --git a/src/wayland/meta-wayland-pointer.c b/src/wayland/meta-wayland-pointer.c index 93e0176f1..ea44dfeb3 100644 --- a/src/wayland/meta-wayland-pointer.c +++ b/src/wayland/meta-wayland-pointer.c @@ -1571,3 +1571,9 @@ meta_wayland_pointer_class_init (MetaWaylandPointerClass *klass) NULL, NULL, NULL, G_TYPE_NONE, 0); } + +gboolean +meta_wayland_pointer_is_grabbed (MetaWaylandPointer *pointer) +{ + return pointer->grab != &pointer->default_grab; +} diff --git a/src/wayland/meta-wayland-pointer.h b/src/wayland/meta-wayland-pointer.h index 5cd725db7..f7b91a5c2 100644 --- a/src/wayland/meta-wayland-pointer.h +++ b/src/wayland/meta-wayland-pointer.h @@ -159,4 +159,6 @@ void meta_wayland_surface_cursor_update (MetaWaylandSurface *cursor_surface); void meta_wayland_pointer_update_cursor_surface (MetaWaylandPointer *pointer); +gboolean meta_wayland_pointer_is_grabbed (MetaWaylandPointer *pointer); + #endif /* META_WAYLAND_POINTER_H */ diff --git a/src/wayland/meta-wayland-seat.c b/src/wayland/meta-wayland-seat.c index dd9c081f5..4aa60eefa 100644 --- a/src/wayland/meta-wayland-seat.c +++ b/src/wayland/meta-wayland-seat.c @@ -534,3 +534,17 @@ meta_wayland_seat_get_compositor (MetaWaylandSeat *seat) { 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; +} diff --git a/src/wayland/meta-wayland-seat.h b/src/wayland/meta-wayland-seat.h index a12fcf1bc..57937b936 100644 --- a/src/wayland/meta-wayland-seat.h +++ b/src/wayland/meta-wayland-seat.h @@ -84,4 +84,6 @@ gboolean meta_wayland_seat_has_touch (MetaWaylandSeat *seat); MetaWaylandCompositor * meta_wayland_seat_get_compositor (MetaWaylandSeat *seat); +gboolean meta_wayland_seat_is_grabbed (MetaWaylandSeat *seat); + #endif /* META_WAYLAND_SEAT_H */ diff --git a/src/wayland/meta-wayland.c b/src/wayland/meta-wayland.c index 6bb221afd..c1f20a735 100644 --- a/src/wayland/meta-wayland.c +++ b/src/wayland/meta-wayland.c @@ -849,3 +849,9 @@ meta_wayland_compositor_get_context (MetaWaylandCompositor *compositor) { return compositor->context; } + +gboolean +meta_wayland_compositor_is_grabbed (MetaWaylandCompositor *compositor) +{ + return meta_wayland_seat_is_grabbed (compositor->seat); +} diff --git a/src/wayland/meta-wayland.h b/src/wayland/meta-wayland.h index 679ccb536..3719e5e62 100644 --- a/src/wayland/meta-wayland.h +++ b/src/wayland/meta-wayland.h @@ -103,4 +103,6 @@ META_EXPORT_TEST MetaContext * meta_wayland_compositor_get_context (MetaWaylandCompositor *compositor); +gboolean meta_wayland_compositor_is_grabbed (MetaWaylandCompositor *compositor); + #endif