wayland: Drop keyboard grab interface

This is now unused and may be dropped. All usage has been
replaced by MetaWaylandEventInterface.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3420>
This commit is contained in:
Carlos Garnacho 2023-11-16 13:29:39 +01:00 committed by Robert Mader
parent 5fa112c298
commit bcfb7a4a33
4 changed files with 14 additions and 93 deletions

View File

@ -272,7 +272,19 @@ static gboolean
notify_key (MetaWaylandKeyboard *keyboard, notify_key (MetaWaylandKeyboard *keyboard,
const ClutterEvent *event) const ClutterEvent *event)
{ {
return keyboard->grab->interface->key (keyboard->grab, event); gboolean is_press = clutter_event_type (event) == CLUTTER_KEY_PRESS;
guint32 code = 0;
/* Ignore autorepeat events, as autorepeat in Wayland is done on the client
* side. */
if (clutter_event_get_flags (event) & CLUTTER_EVENT_FLAG_REPEATED)
return FALSE;
code = clutter_event_get_event_code (event);
return meta_wayland_keyboard_broadcast_key (keyboard,
clutter_event_get_time (event),
code, is_press);
} }
static xkb_mod_mask_t static xkb_mod_mask_t
@ -359,11 +371,7 @@ meta_wayland_keyboard_broadcast_modifiers (MetaWaylandKeyboard *keyboard)
static void static void
notify_modifiers (MetaWaylandKeyboard *keyboard) notify_modifiers (MetaWaylandKeyboard *keyboard)
{ {
struct xkb_state *state; meta_wayland_keyboard_broadcast_modifiers (keyboard);
state = keyboard->xkb_info.state;
keyboard->grab->interface->modifiers (keyboard->grab,
xkb_state_serialize_mods (state, XKB_STATE_MODS_EFFECTIVE));
} }
static void static void
@ -494,38 +502,6 @@ settings_changed (GSettings *settings,
notify_key_repeat (keyboard); notify_key_repeat (keyboard);
} }
static gboolean
default_grab_key (MetaWaylandKeyboardGrab *grab,
const ClutterEvent *event)
{
MetaWaylandKeyboard *keyboard = grab->keyboard;
gboolean is_press = clutter_event_type (event) == CLUTTER_KEY_PRESS;
guint32 code = 0;
/* Ignore autorepeat events, as autorepeat in Wayland is done on the client
* side. */
if (clutter_event_get_flags (event) & CLUTTER_EVENT_FLAG_REPEATED)
return FALSE;
code = clutter_event_get_event_code (event);
return meta_wayland_keyboard_broadcast_key (keyboard,
clutter_event_get_time (event),
code, is_press);
}
static void
default_grab_modifiers (MetaWaylandKeyboardGrab *grab,
ClutterModifierType modifiers)
{
meta_wayland_keyboard_broadcast_modifiers (grab->keyboard);
}
static const MetaWaylandKeyboardGrabInterface default_keyboard_grab_interface = {
default_grab_key,
default_grab_modifiers
};
void void
meta_wayland_keyboard_enable (MetaWaylandKeyboard *keyboard) meta_wayland_keyboard_enable (MetaWaylandKeyboard *keyboard)
{ {
@ -571,7 +547,6 @@ meta_wayland_keyboard_disable (MetaWaylandKeyboard *keyboard)
g_signal_handlers_disconnect_by_func (backend, on_keymap_changed, keyboard); g_signal_handlers_disconnect_by_func (backend, on_keymap_changed, keyboard);
g_signal_handlers_disconnect_by_func (backend, on_keymap_layout_group_changed, keyboard); g_signal_handlers_disconnect_by_func (backend, on_keymap_layout_group_changed, keyboard);
meta_wayland_keyboard_end_grab (keyboard);
meta_wayland_keyboard_set_focus (keyboard, NULL); meta_wayland_keyboard_set_focus (keyboard, NULL);
wl_list_remove (&keyboard->resource_list); wl_list_remove (&keyboard->resource_list);
@ -887,31 +862,12 @@ meta_wayland_keyboard_can_popup (MetaWaylandKeyboard *keyboard,
keyboard->key_up_serial == serial)); keyboard->key_up_serial == serial));
} }
void
meta_wayland_keyboard_start_grab (MetaWaylandKeyboard *keyboard,
MetaWaylandKeyboardGrab *grab)
{
meta_wayland_keyboard_set_focus (keyboard, NULL);
keyboard->grab = grab;
grab->keyboard = keyboard;
}
void
meta_wayland_keyboard_end_grab (MetaWaylandKeyboard *keyboard)
{
keyboard->grab = &keyboard->default_grab;
}
static void static void
meta_wayland_keyboard_init (MetaWaylandKeyboard *keyboard) meta_wayland_keyboard_init (MetaWaylandKeyboard *keyboard)
{ {
wl_list_init (&keyboard->resource_list); wl_list_init (&keyboard->resource_list);
wl_list_init (&keyboard->focus_resource_list); wl_list_init (&keyboard->focus_resource_list);
keyboard->default_grab.interface = &default_keyboard_grab_interface;
keyboard->default_grab.keyboard = keyboard;
keyboard->grab = &keyboard->default_grab;
keyboard->focus_surface_listener.notify = keyboard->focus_surface_listener.notify =
keyboard_handle_focus_surface_destroy; keyboard_handle_focus_surface_destroy;
} }
@ -933,9 +889,3 @@ 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

@ -54,20 +54,6 @@ G_DECLARE_FINAL_TYPE (MetaWaylandKeyboard, meta_wayland_keyboard,
META, WAYLAND_KEYBOARD, META, WAYLAND_KEYBOARD,
MetaWaylandInputDevice) MetaWaylandInputDevice)
struct _MetaWaylandKeyboardGrabInterface
{
gboolean (*key) (MetaWaylandKeyboardGrab *grab,
const ClutterEvent *event);
void (*modifiers) (MetaWaylandKeyboardGrab *grab,
ClutterModifierType modifiers);
};
struct _MetaWaylandKeyboardGrab
{
const MetaWaylandKeyboardGrabInterface *interface;
MetaWaylandKeyboard *keyboard;
};
typedef struct typedef struct
{ {
struct xkb_keymap *keymap; struct xkb_keymap *keymap;
@ -99,9 +85,6 @@ struct _MetaWaylandKeyboard
xkb_mod_mask_t kbd_a11y_latched_mods; xkb_mod_mask_t kbd_a11y_latched_mods;
xkb_mod_mask_t kbd_a11y_locked_mods; xkb_mod_mask_t kbd_a11y_locked_mods;
MetaWaylandKeyboardGrab *grab;
MetaWaylandKeyboardGrab default_grab;
GSettings *settings; GSettings *settings;
}; };
@ -134,9 +117,3 @@ gboolean meta_wayland_keyboard_can_grab_surface (MetaWaylandKeyboard *keyboard,
uint32_t serial); uint32_t serial);
gboolean meta_wayland_keyboard_can_popup (MetaWaylandKeyboard *keyboard, gboolean meta_wayland_keyboard_can_popup (MetaWaylandKeyboard *keyboard,
uint32_t serial); uint32_t serial);
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);

View File

@ -669,10 +669,6 @@ meta_wayland_seat_is_grabbed (MetaWaylandSeat *seat)
meta_wayland_pointer_is_grabbed (seat->pointer)) meta_wayland_pointer_is_grabbed (seat->pointer))
return TRUE; return TRUE;
if (meta_wayland_seat_has_keyboard (seat) &&
meta_wayland_keyboard_is_grabbed (seat->keyboard))
return TRUE;
if (!meta_wayland_input_is_current_handler (seat->input_handler, if (!meta_wayland_input_is_current_handler (seat->input_handler,
seat->default_handler)) seat->default_handler))
return TRUE; return TRUE;

View File

@ -28,8 +28,6 @@ typedef struct _MetaWaylandPopupGrab MetaWaylandPopupGrab;
typedef struct _MetaWaylandPopup MetaWaylandPopup; typedef struct _MetaWaylandPopup MetaWaylandPopup;
typedef struct _MetaWaylandPopupSurface MetaWaylandPopupSurface; typedef struct _MetaWaylandPopupSurface MetaWaylandPopupSurface;
typedef struct _MetaWaylandKeyboard MetaWaylandKeyboard; typedef struct _MetaWaylandKeyboard MetaWaylandKeyboard;
typedef struct _MetaWaylandKeyboardGrab MetaWaylandKeyboardGrab;
typedef struct _MetaWaylandKeyboardGrabInterface MetaWaylandKeyboardGrabInterface;
typedef struct _MetaWaylandTouch MetaWaylandTouch; typedef struct _MetaWaylandTouch MetaWaylandTouch;
typedef struct _MetaWaylandDragDestFuncs MetaWaylandDragDestFuncs; typedef struct _MetaWaylandDragDestFuncs MetaWaylandDragDestFuncs;
typedef struct _MetaWaylandDataOffer MetaWaylandDataOffer; typedef struct _MetaWaylandDataOffer MetaWaylandDataOffer;