[mutter/wip/carlosg/input-thread: 83/88] backends/native: Update keyboard a11y status in seat impl
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter/wip/carlosg/input-thread: 83/88] backends/native: Update keyboard a11y status in seat impl
- Date: Thu, 26 Nov 2020 19:12:13 +0000 (UTC)
commit 0abcc2e8c81f85149cfaa0bf5dd18923a3b80e08
Author: Carlos Garnacho <carlosg gnome org>
Date: Thu Nov 19 23:58:56 2020 +0100
backends/native: Update keyboard a11y status in seat impl
Instead of going through the event queue, stage handling code, and
back to the input device via a vmethod call, do this directly in the
MetaSeatImpl. This is not too different from X11, where everything
happens inside the backend.
clutter/clutter/clutter-input-device.h | 8 ----
clutter/clutter/clutter-main.c | 19 +--------
src/backends/native/meta-input-device-native.c | 54 ++++++++++----------------
src/backends/native/meta-input-device-native.h | 2 +
src/backends/native/meta-seat-impl.c | 14 +++++--
src/backends/native/meta-xkb-utils.c | 9 ++++-
src/backends/native/meta-xkb-utils.h | 1 +
7 files changed, 44 insertions(+), 63 deletions(-)
---
diff --git a/clutter/clutter/clutter-input-device.h b/clutter/clutter/clutter-input-device.h
index 28ab0443b3..5e377cdcc1 100644
--- a/clutter/clutter/clutter-input-device.h
+++ b/clutter/clutter/clutter-input-device.h
@@ -34,9 +34,6 @@
G_BEGIN_DECLS
-typedef void (*ClutterEmitInputDeviceEvent) (ClutterEvent *event,
- ClutterInputDevice *device);
-
struct _ClutterInputDeviceClass
{
GObjectClass parent_class;
@@ -53,11 +50,6 @@ struct _ClutterInputDeviceClass
int (* get_pad_feature_group) (ClutterInputDevice *device,
ClutterInputDevicePadFeature feature,
int n_feature);
-
- /* Keyboard accessbility */
- void (* process_kbd_a11y_event) (ClutterEvent *event,
- ClutterInputDevice *device,
- ClutterEmitInputDeviceEvent emit_event_func);
};
#define CLUTTER_TYPE_INPUT_DEVICE (clutter_input_device_get_type ())
diff --git a/clutter/clutter/clutter-main.c b/clutter/clutter/clutter-main.c
index 035ed94441..e21d3d3fa0 100644
--- a/clutter/clutter/clutter-main.c
+++ b/clutter/clutter/clutter-main.c
@@ -1488,8 +1488,8 @@ emit_touch_event (ClutterEvent *event,
}
static inline void
-emit_keyboard_event (ClutterEvent *event,
- ClutterInputDevice *device)
+process_key_event (ClutterEvent *event,
+ ClutterInputDevice *device)
{
if (_clutter_event_process_filters (event))
return;
@@ -1500,21 +1500,6 @@ emit_keyboard_event (ClutterEvent *event,
emit_event_chain (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,
diff --git a/src/backends/native/meta-input-device-native.c b/src/backends/native/meta-input-device-native.c
index 86a61be128..899c2613b9 100644
--- a/src/backends/native/meta-input-device-native.c
+++ b/src/backends/native/meta-input-device-native.c
@@ -48,7 +48,6 @@ typedef struct _SlowKeysEventPending
{
MetaInputDeviceNative *device;
ClutterEvent *event;
- ClutterEmitInputDeviceEvent emit_event_func;
guint timer;
} SlowKeysEventPending;
@@ -242,8 +241,7 @@ trigger_slow_keys (gpointer data)
/* Alter timestamp and emit the event */
key_event->time = us2ms (g_get_monotonic_time ());
- slow_keys_event->emit_event_func (slow_keys_event->event,
- CLUTTER_INPUT_DEVICE (device));
+ _clutter_event_push (slow_keys_event->event, TRUE);
/* Then remote the pending event */
device->slow_keys_list = g_list_remove (device->slow_keys_list, slow_keys_event);
@@ -266,21 +264,19 @@ find_pending_event_by_keycode (gconstpointer a,
return kb->hardware_keycode - ka->hardware_keycode;
}
-static void
-start_slow_keys (ClutterEvent *event,
- MetaInputDeviceNative *device,
- ClutterEmitInputDeviceEvent emit_event_func)
+static gboolean
+start_slow_keys (ClutterEvent *event,
+ MetaInputDeviceNative *device)
{
SlowKeysEventPending *slow_keys_event;
ClutterKeyEvent *key_event = (ClutterKeyEvent *) event;
if (key_event->flags & CLUTTER_EVENT_FLAG_REPEATED)
- return;
+ return TRUE;
slow_keys_event = g_new0 (SlowKeysEventPending, 1);
slow_keys_event->device = device;
slow_keys_event->event = clutter_event_copy (event);
- slow_keys_event->emit_event_func = emit_event_func;
slow_keys_event->timer =
clutter_threads_add_timeout (get_slow_keys_delay (CLUTTER_INPUT_DEVICE (device)),
trigger_slow_keys,
@@ -289,12 +285,13 @@ start_slow_keys (ClutterEvent *event,
if (device->a11y_flags & META_A11Y_SLOW_KEYS_BEEP_PRESS)
meta_input_device_native_bell_notify (device);
+
+ return TRUE;
}
-static void
-stop_slow_keys (ClutterEvent *event,
- MetaInputDeviceNative *device,
- ClutterEmitInputDeviceEvent emit_event_func)
+static gboolean
+stop_slow_keys (ClutterEvent *event,
+ MetaInputDeviceNative *device)
{
GList *item;
@@ -310,11 +307,11 @@ stop_slow_keys (ClutterEvent *event,
if (device->a11y_flags & META_A11Y_SLOW_KEYS_BEEP_REJECT)
meta_input_device_native_bell_notify (device);
- return;
+ return TRUE;
}
/* If no key press event was pending, just emit the key release as-is */
- emit_event_func (event, CLUTTER_INPUT_DEVICE (device));
+ return FALSE;
}
static guint
@@ -1105,17 +1102,12 @@ handle_mousekeys_release (ClutterEvent *event,
return FALSE;
}
-static void
-meta_input_device_native_process_kbd_a11y_event (ClutterEvent *event,
- ClutterInputDevice *device,
- ClutterEmitInputDeviceEvent emit_event_func)
+gboolean
+meta_input_device_native_process_kbd_a11y_event (ClutterInputDevice *device,
+ ClutterEvent *event)
{
MetaInputDeviceNative *device_evdev = META_INPUT_DEVICE_NATIVE (device);
- /* Ignore key events injected from IM */
- if (event->key.flags & CLUTTER_EVENT_FLAG_INPUT_METHOD)
- goto emit_event;
-
if (device_evdev->a11y_flags & META_A11Y_KEYBOARD_ENABLED)
{
if (event->type == CLUTTER_KEY_PRESS)
@@ -1128,10 +1120,10 @@ meta_input_device_native_process_kbd_a11y_event (ClutterEvent *eve
{
if (event->type == CLUTTER_KEY_PRESS &&
handle_mousekeys_press (event, device_evdev))
- return; /* swallow event */
+ return TRUE; /* swallow event */
if (event->type == CLUTTER_KEY_RELEASE &&
handle_mousekeys_release (event, device_evdev))
- return; /* swallow event */
+ return TRUE; /* swallow event */
}
if ((device_evdev->a11y_flags & META_A11Y_BOUNCE_KEYS_ENABLED) &&
@@ -1141,7 +1133,7 @@ meta_input_device_native_process_kbd_a11y_event (ClutterEvent *eve
{
notify_bounce_keys_reject (device_evdev);
- return;
+ return TRUE;
}
else if (event->type == CLUTTER_KEY_RELEASE)
start_bounce_keys (event, device_evdev);
@@ -1151,11 +1143,9 @@ meta_input_device_native_process_kbd_a11y_event (ClutterEvent *eve
(get_slow_keys_delay (device) != 0))
{
if (event->type == CLUTTER_KEY_PRESS)
- start_slow_keys (event, device_evdev, emit_event_func);
+ return start_slow_keys (event, device_evdev);
else if (event->type == CLUTTER_KEY_RELEASE)
- stop_slow_keys (event, device_evdev, emit_event_func);
-
- return;
+ return stop_slow_keys (event, device_evdev);
}
if (device_evdev->a11y_flags & META_A11Y_STICKY_KEYS_ENABLED)
@@ -1166,8 +1156,7 @@ meta_input_device_native_process_kbd_a11y_event (ClutterEvent *eve
handle_stickykeys_release (event, device_evdev);
}
-emit_event:
- emit_event_func (event, device);
+ return FALSE;
}
void
@@ -1230,7 +1219,6 @@ meta_input_device_native_class_init (MetaInputDeviceNativeClass *klass)
device_class->get_group_n_modes = meta_input_device_native_get_group_n_modes;
device_class->is_grouped = meta_input_device_native_is_grouped;
device_class->get_pad_feature_group = meta_input_device_native_get_pad_feature_group;
- device_class->process_kbd_a11y_event = meta_input_device_native_process_kbd_a11y_event;
obj_props[PROP_DEVICE_MATRIX] =
g_param_spec_boxed ("device-matrix",
diff --git a/src/backends/native/meta-input-device-native.h b/src/backends/native/meta-input-device-native.h
index 4203be9072..560081dfd6 100644
--- a/src/backends/native/meta-input-device-native.h
+++ b/src/backends/native/meta-input-device-native.h
@@ -149,5 +149,7 @@ void meta_input_device_native_set_coords (MetaInputDeviceNat
void meta_input_device_native_get_coords (MetaInputDeviceNative *device_native,
float *x,
float *y);
+gboolean meta_input_device_native_process_kbd_a11y_event (ClutterInputDevice *device,
+ ClutterEvent *event);
#endif /* META_INPUT_DEVICE_NATIVE_H */
diff --git a/src/backends/native/meta-seat-impl.c b/src/backends/native/meta-seat-impl.c
index 7a55aa550f..dc48aeefab 100644
--- a/src/backends/native/meta-seat-impl.c
+++ b/src/backends/native/meta-seat-impl.c
@@ -320,6 +320,7 @@ meta_seat_impl_notify_key (MetaSeatImpl *seat_impl,
{
ClutterEvent *event = NULL;
enum xkb_state_component changed_state;
+ uint32_t keycode;
if (state != AUTOREPEAT_VALUE)
{
@@ -342,12 +343,13 @@ meta_seat_impl_notify_key (MetaSeatImpl *seat_impl,
us2ms (time_us), key, state);
meta_event_native_set_event_code (event, key);
+ keycode = meta_xkb_evdev_to_keycode (key);
+
/* We must be careful and not pass multiple releases to xkb, otherwise it gets
confused and locks the modifiers */
if (state != AUTOREPEAT_VALUE)
{
- changed_state = xkb_state_update_key (seat_impl->xkb,
- event->key.hardware_keycode,
+ changed_state = xkb_state_update_key (seat_impl->xkb, keycode,
state ? XKB_KEY_DOWN : XKB_KEY_UP);
}
else
@@ -356,7 +358,11 @@ meta_seat_impl_notify_key (MetaSeatImpl *seat_impl,
clutter_event_set_flags (event, CLUTTER_EVENT_FLAG_REPEATED);
}
- queue_event (seat_impl, event);
+ if (!meta_input_device_native_process_kbd_a11y_event (seat_impl->core_keyboard,
+ event))
+ queue_event (seat_impl, event);
+ else
+ clutter_event_free (event);
if (update_keys && (changed_state & XKB_STATE_LEDS))
{
@@ -371,7 +377,7 @@ meta_seat_impl_notify_key (MetaSeatImpl *seat_impl,
if (state == 0 || /* key release */
!seat_impl->repeat ||
!xkb_keymap_key_repeats (xkb_state_get_keymap (seat_impl->xkb),
- event->key.hardware_keycode))
+ keycode))
{
meta_seat_impl_clear_repeat_timer (seat_impl);
return;
diff --git a/src/backends/native/meta-xkb-utils.c b/src/backends/native/meta-xkb-utils.c
index edee5ac2f2..45f89bec7f 100644
--- a/src/backends/native/meta-xkb-utils.c
+++ b/src/backends/native/meta-xkb-utils.c
@@ -62,7 +62,7 @@ meta_key_event_new_from_evdev (ClutterInputDevice *device,
* 0, whereas X11's minimum keycode, for really stupid reasons, is 8.
* So the evdev XKB rules are based on the keycodes all being shifted
* upwards by 8. */
- key += 8;
+ key = meta_xkb_evdev_to_keycode (key);
n = xkb_key_get_syms (xkb_state, key, &syms);
if (n == 1)
@@ -128,3 +128,10 @@ meta_xkb_keycode_to_evdev (uint32_t xkb_keycode)
*/
return xkb_keycode - 8;
}
+
+uint32_t
+meta_xkb_evdev_to_keycode (uint32_t evcode)
+{
+ /* The inverse of meta_xkb_keycode_to_evdev */
+ return evcode + 8;
+}
diff --git a/src/backends/native/meta-xkb-utils.h b/src/backends/native/meta-xkb-utils.h
index b34de1fba6..d605813e6d 100644
--- a/src/backends/native/meta-xkb-utils.h
+++ b/src/backends/native/meta-xkb-utils.h
@@ -38,5 +38,6 @@ void meta_xkb_translate_state (ClutterEvent *event,
ClutterModifierType meta_xkb_translate_modifiers (struct xkb_state *state,
ClutterModifierType button_state);
uint32_t meta_xkb_keycode_to_evdev (uint32_t hardware_keycode);
+uint32_t meta_xkb_evdev_to_keycode (uint32_t evcode);
#endif /* META_XKB_UTILS_H */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]