From 7d5e08c8438f486b522219a7b11baa063a4bf5db Mon Sep 17 00:00:00 2001 From: Olivier Fourdan Date: Thu, 12 Oct 2017 15:14:51 +0200 Subject: [PATCH] clutter-main: Add hooks to plug kbd accessibility On X11, when AccessX is enabled, all X11 clients benefit from the AccessX features, including gnome-shell/mutter, meaning that special keys like the overview or other shortcuts are also affected. To achieve the same in Wayland, we need to implement the same features in clutter main rather than the Wayland backend, so that all depending code within the compositor but also Wayland clients (which rely on the compositor to get keyboard events) similarly benefit from the accessibility features. Add hooks to the clutter main loop to be able to implement such features. https://bugzilla.gnome.org/show_bug.cgi?id=788564 --- .../clutter/clutter-device-manager-private.h | 8 ++++++++ clutter/clutter/clutter-main.c | 17 ++++++++++++++++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/clutter/clutter/clutter-device-manager-private.h b/clutter/clutter/clutter-device-manager-private.h index 57423c41a..2364fd27c 100644 --- a/clutter/clutter/clutter-device-manager-private.h +++ b/clutter/clutter/clutter-device-manager-private.h @@ -145,6 +145,9 @@ struct _ClutterInputDevice guint is_enabled : 1; }; +typedef void (*ClutterEmitInputDeviceEvent) (ClutterEvent *event, + ClutterInputDevice *device); + struct _ClutterInputDeviceClass { GObjectClass parent_class; @@ -163,6 +166,11 @@ struct _ClutterInputDeviceClass gboolean (* is_grouped) (ClutterInputDevice *device, ClutterInputDevice *other_device); + + /* Keyboard accessbility */ + void (* process_kbd_a11y_event) (ClutterEvent *event, + ClutterInputDevice *device, + ClutterEmitInputDeviceEvent emit_event_func); }; /* Platform-dependent interface */ diff --git a/clutter/clutter/clutter-main.c b/clutter/clutter/clutter-main.c index 0f85db6eb..46537f322 100644 --- a/clutter/clutter/clutter-main.c +++ b/clutter/clutter/clutter-main.c @@ -2089,6 +2089,21 @@ emit_keyboard_event (ClutterEvent *event, } } +static inline void +process_key_event (ClutterEvent *event, + ClutterInputDevice *device) +{ + ClutterInputDeviceClass *device_class = CLUTTER_INPUT_DEVICE_GET_CLASS (device); + + if (device_class->process_kbd_a11y_event) + { + device_class->process_kbd_a11y_event (event, device, emit_keyboard_event); + return; + } + + emit_keyboard_event (event, device); +} + static gboolean is_off_stage (ClutterActor *stage, gfloat x, @@ -2176,7 +2191,7 @@ _clutter_process_event_details (ClutterActor *stage, } } - emit_keyboard_event (event, device); + process_key_event (event, device); } break;