[mutter] clutter/evdev: disable mousekeys with Numlock ON



commit 471b61bd1400435b7af977c47c21b8fc747530d9
Author: Olivier Fourdan <ofourdan redhat com>
Date:   Tue Apr 9 13:39:59 2019 +0200

    clutter/evdev: disable mousekeys with Numlock ON
    
    The clutter/evdev implementation of mousekeys is designed after the
    current implementation in X11, and works when the setting is enabled
    regardless of the status of NumLock.
    
    The GNOME documentation on accessibility features states however that
    mousekeys work only when NumLock is OFF:
    
      https://help.gnome.org/users/gnome-help/stable/mouse-mousekeys.html
    
    Change the clutter/evdev implementation to match the documentation, i.e.
    disable mousekeys when NumLock in ON so that switching NumLock ON
    restores the numeric keypad behaviour.
    
    Closes: https://gitlab.gnome.org/GNOME/mutter/issues/530

 clutter/clutter/evdev/clutter-input-device-evdev.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
---
diff --git a/clutter/clutter/evdev/clutter-input-device-evdev.c 
b/clutter/clutter/evdev/clutter-input-device-evdev.c
index 2ac2e119d..73072b4c7 100644
--- a/clutter/clutter/evdev/clutter-input-device-evdev.c
+++ b/clutter/clutter/evdev/clutter-input-device-evdev.c
@@ -855,6 +855,14 @@ emulate_pointer_motion (ClutterInputDeviceEvdev *device,
   clutter_virtual_input_device_notify_relative_motion (device->mousekeys_virtual_device,
                                                        time_us, dx_motion, dy_motion);
 }
+static gboolean
+is_numlock_active (ClutterInputDeviceEvdev *device)
+{
+  ClutterSeatEvdev *seat = device->seat;
+  return xkb_state_mod_name_is_active (seat->xkb,
+                                       "Mod2",
+                                       XKB_STATE_MODS_LOCKED);
+}
 
 static void
 enable_mousekeys (ClutterInputDeviceEvdev *device)
@@ -1013,6 +1021,10 @@ handle_mousekeys_press (ClutterEvent            *event,
   if (!(event->key.flags & CLUTTER_EVENT_FLAG_SYNTHETIC))
     stop_mousekeys_move (device);
 
+  /* Do not handle mousekeys if NumLock is ON */
+  if (is_numlock_active (device))
+    return FALSE;
+
   /* Button selection */
   switch (event->key.keyval)
     {
@@ -1084,6 +1096,10 @@ static gboolean
 handle_mousekeys_release (ClutterEvent            *event,
                           ClutterInputDeviceEvdev *device)
 {
+  /* Do not handle mousekeys if NumLock is ON */
+  if (is_numlock_active (device))
+    return FALSE;
+
   switch (event->key.keyval)
     {
     case XKB_KEY_KP_0:


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