[mutter/wip/carlosg/input-thread: 140/159] backends/native: Forward keyboard a11y changes via the MetaSeatImpl




commit 1a000e60749e65a63250ad66bfdb8e7dccc82576
Author: Carlos Garnacho <carlosg gnome org>
Date:   Tue Aug 11 17:11:51 2020 +0200

    backends/native: Forward keyboard a11y changes via the MetaSeatImpl
    
    These changes will happen in the input event management code, so let them
    be emitted via the MetaSeatImpl, as that's what we'll have neat access to.
    The ClutterSeat signals are now emitted from there.

 src/backends/native/meta-input-device-native.c | 30 ++++++++----------
 src/backends/native/meta-seat-impl.c           | 42 ++++++++++++++++++++++++++
 src/backends/native/meta-seat-impl.h           |  8 +++++
 src/backends/native/meta-seat-native.c         | 27 +++++++++++++++++
 4 files changed, 90 insertions(+), 17 deletions(-)
---
diff --git a/src/backends/native/meta-input-device-native.c b/src/backends/native/meta-input-device-native.c
index f5e21de60a..8e71522bba 100644
--- a/src/backends/native/meta-input-device-native.c
+++ b/src/backends/native/meta-input-device-native.c
@@ -27,7 +27,7 @@
 #include "backends/meta-backend-private.h"
 #include "backends/native/meta-input-device-tool-native.h"
 #include "backends/native/meta-input-device-native.h"
-#include "backends/native/meta-seat-native.h"
+#include "backends/native/meta-seat-impl.h"
 #include "clutter/clutter-mutter.h"
 
 G_DEFINE_TYPE (MetaInputDeviceNative,
@@ -423,10 +423,9 @@ key_event_is_modifier (ClutterEvent *event)
 static void
 notify_stickykeys_mask (MetaInputDeviceNative *device)
 {
-  g_signal_emit_by_name (device->seat_impl->seat,
-                         "kbd-a11y-mods-state-changed",
-                         device->stickykeys_latched_mask,
-                         device->stickykeys_locked_mask);
+  meta_seat_impl_notify_kbd_a11y_mods_state_changed (device->seat_impl,
+                                                     device->stickykeys_latched_mask,
+                                                     device->stickykeys_locked_mask);
 }
 
 static void
@@ -499,10 +498,9 @@ notify_stickykeys_change (MetaInputDeviceNative *device)
   device->stickykeys_depressed_mask = 0;
   update_internal_xkb_state (device, 0, 0);
 
-  g_signal_emit_by_name (CLUTTER_INPUT_DEVICE (device)->seat,
-                         "kbd-a11y-flags-changed",
-                         device->a11y_flags,
-                         META_A11Y_STICKY_KEYS_ENABLED);
+  meta_seat_impl_notify_kbd_a11y_flags_changed (device->seat_impl,
+                                                device->a11y_flags,
+                                                META_A11Y_STICKY_KEYS_ENABLED);
 }
 
 static void
@@ -532,10 +530,9 @@ set_slowkeys_off (MetaInputDeviceNative *device)
 {
   device->a11y_flags &= ~META_A11Y_SLOW_KEYS_ENABLED;
 
-  g_signal_emit_by_name (CLUTTER_INPUT_DEVICE (device)->seat,
-                         "kbd-a11y-flags-changed",
-                         device->a11y_flags,
-                         META_A11Y_SLOW_KEYS_ENABLED);
+  meta_seat_impl_notify_kbd_a11y_flags_changed (device->seat_impl,
+                                                device->a11y_flags,
+                                                META_A11Y_SLOW_KEYS_ENABLED);
 }
 
 static void
@@ -543,10 +540,9 @@ set_slowkeys_on (MetaInputDeviceNative *device)
 {
   device->a11y_flags |= META_A11Y_SLOW_KEYS_ENABLED;
 
-  g_signal_emit_by_name (CLUTTER_INPUT_DEVICE (device)->seat,
-                         "kbd-a11y-flags-changed",
-                         device->a11y_flags,
-                         META_A11Y_SLOW_KEYS_ENABLED);
+  meta_seat_impl_notify_kbd_a11y_flags_changed (device->seat_impl,
+                                                device->a11y_flags,
+                                                META_A11Y_SLOW_KEYS_ENABLED);
 }
 
 static void
diff --git a/src/backends/native/meta-seat-impl.c b/src/backends/native/meta-seat-impl.c
index 94c41cf935..1e434af2f1 100644
--- a/src/backends/native/meta-seat-impl.c
+++ b/src/backends/native/meta-seat-impl.c
@@ -105,6 +105,15 @@ enum
 
 static GParamSpec *props[N_PROPS] = { NULL };
 
+enum
+{
+  KBD_A11Y_FLAGS_CHANGED,
+  KBD_A11Y_MODS_STATE_CHANGED,
+  N_SIGNALS
+};
+
+static guint signals[N_SIGNALS] = { 0 };
+
 G_DEFINE_TYPE (MetaSeatImpl, meta_seat_impl, G_TYPE_OBJECT)
 
 static void process_events (MetaSeatImpl *seat);
@@ -2709,6 +2718,21 @@ meta_seat_impl_class_init (MetaSeatImplClass *klass)
                          G_PARAM_READWRITE |
                          G_PARAM_CONSTRUCT_ONLY);
 
+  signals[KBD_A11Y_FLAGS_CHANGED] =
+    g_signal_new ("kbd-a11y-flags-changed",
+                  G_TYPE_FROM_CLASS (object_class),
+                  G_SIGNAL_RUN_LAST,
+                  0, NULL, NULL, NULL,
+                  G_TYPE_NONE, 2,
+                  G_TYPE_UINT, G_TYPE_UINT);
+  signals[KBD_A11Y_MODS_STATE_CHANGED] =
+    g_signal_new ("kbd-a11y-mods-state-changed",
+                  G_TYPE_FROM_CLASS (object_class),
+                  G_SIGNAL_RUN_LAST,
+                  0, NULL, NULL, NULL,
+                  G_TYPE_NONE, 2,
+                  G_TYPE_UINT, G_TYPE_UINT);
+
   g_object_class_install_properties (object_class, N_PROPS, props);
 }
 
@@ -3066,3 +3090,21 @@ meta_seat_impl_new (MetaSeatNative *seat,
                        "seat-id", seat_id,
                        NULL);
 }
+
+void
+meta_seat_impl_notify_kbd_a11y_flags_changed (MetaSeatImpl          *impl,
+                                              MetaKeyboardA11yFlags  new_flags,
+                                              MetaKeyboardA11yFlags  what_changed)
+{
+  g_signal_emit (impl, signals[KBD_A11Y_FLAGS_CHANGED], 0,
+                 new_flags, what_changed);
+}
+
+void
+meta_seat_impl_notify_kbd_a11y_mods_state_changed (MetaSeatImpl   *impl,
+                                                   xkb_mod_mask_t  new_latched_mods,
+                                                   xkb_mod_mask_t  new_locked_mods)
+{
+  g_signal_emit (impl, signals[KBD_A11Y_MODS_STATE_CHANGED], 0,
+                 new_latched_mods, new_locked_mods);
+}
diff --git a/src/backends/native/meta-seat-impl.h b/src/backends/native/meta-seat-impl.h
index 10a66426ea..52897629f4 100644
--- a/src/backends/native/meta-seat-impl.h
+++ b/src/backends/native/meta-seat-impl.h
@@ -27,6 +27,7 @@
 #include <libinput.h>
 #include <linux/input-event-codes.h>
 
+#include "backends/meta-input-settings-private.h"
 #include "backends/meta-viewport-info.h"
 #include "backends/native/meta-backend-native-types.h"
 #include "backends/native/meta-barrier-native.h"
@@ -254,4 +255,11 @@ GSList * meta_seat_impl_get_devices (MetaSeatImpl *seat);
 
 MetaKeymapNative * meta_seat_impl_get_keymap (MetaSeatImpl *seat);
 
+void meta_seat_impl_notify_kbd_a11y_flags_changed (MetaSeatImpl          *impl,
+                                                   MetaKeyboardA11yFlags  new_flags,
+                                                   MetaKeyboardA11yFlags  what_changed);
+void meta_seat_impl_notify_kbd_a11y_mods_state_changed (MetaSeatImpl   *impl,
+                                                        xkb_mod_mask_t  new_latched_mods,
+                                                        xkb_mod_mask_t  new_locked_mods);
+
 #endif /* META_SEAT_IMPL_H */
diff --git a/src/backends/native/meta-seat-native.c b/src/backends/native/meta-seat-native.c
index 3fd268091b..d648207593 100644
--- a/src/backends/native/meta-seat-native.c
+++ b/src/backends/native/meta-seat-native.c
@@ -105,12 +105,39 @@ meta_seat_native_handle_event_post (ClutterSeat        *seat,
   return FALSE;
 }
 
+static void
+proxy_kbd_a11y_flags_changed (MetaSeatImpl          *impl,
+                              MetaKeyboardA11yFlags  new_flags,
+                              MetaKeyboardA11yFlags  what_changed,
+                              MetaSeatNative        *seat_native)
+{
+  g_signal_emit_by_name (seat_native,
+                         "kbd-a11y-flags-changed",
+                         new_flags, what_changed);
+}
+
+static void
+proxy_kbd_a11y_mods_state_changed (MetaSeatImpl   *impl,
+                                   xkb_mod_mask_t  new_latched_mods,
+                                   xkb_mod_mask_t  new_locked_mods,
+                                   MetaSeatNative *seat_native)
+{
+  g_signal_emit_by_name (seat_native,
+                         "kbd-a11y-mods-state-changed",
+                         new_latched_mods,
+                         new_locked_mods);
+}
+
 static void
 meta_seat_native_constructed (GObject *object)
 {
   MetaSeatNative *seat = META_SEAT_NATIVE (object);
 
   seat->impl = meta_seat_impl_new (seat, seat->seat_id);
+  g_signal_connect (seat->impl, "kbd-a11y-flags-changed",
+                    G_CALLBACK (proxy_kbd_a11y_flags_changed), seat);
+  g_signal_connect (seat->impl, "kbd-a11y-mods-state-changed",
+                    G_CALLBACK (proxy_kbd_a11y_mods_state_changed), seat);
 
   seat->core_pointer = meta_seat_impl_get_pointer (seat->impl);
   seat->core_keyboard = meta_seat_impl_get_keyboard (seat->impl);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]