[clutter] evdev: Swap the numbers for the middle and right buttons



commit 99a7406d0198627aa0864b039dcabf691b537507
Author: Neil Roberts <neil linux intel com>
Date:   Thu Jul 19 15:20:42 2012 +0100

    evdev: Swap the numbers for the middle and right buttons
    
    The ordering of the evdev button numbers is the opposite of the
    order in Clutter (the middle button is 3 instead of 2) so we need to
    manually map the button numbers when creating a ClutterButtonEvent.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=680255

 clutter/evdev/clutter-device-manager-evdev.c |   25 +++++++++++++++++++++++--
 1 files changed, 23 insertions(+), 2 deletions(-)
---
diff --git a/clutter/evdev/clutter-device-manager-evdev.c b/clutter/evdev/clutter-device-manager-evdev.c
index 7b090ac..64dfeeb 100644
--- a/clutter/evdev/clutter-device-manager-evdev.c
+++ b/clutter/evdev/clutter-device-manager-evdev.c
@@ -245,7 +245,7 @@ notify_button (ClutterEventSource *source,
   gint button_nr;
   static gint maskmap[8] =
     {
-      CLUTTER_BUTTON1_MASK, CLUTTER_BUTTON2_MASK, CLUTTER_BUTTON3_MASK,
+      CLUTTER_BUTTON1_MASK, CLUTTER_BUTTON3_MASK, CLUTTER_BUTTON2_MASK,
       CLUTTER_BUTTON4_MASK, CLUTTER_BUTTON5_MASK, 0, 0, 0
     };
 
@@ -255,7 +255,28 @@ notify_button (ClutterEventSource *source,
   if (!stage)
     return;
 
-  button_nr = button - BTN_LEFT + 1;
+  /* The evdev button numbers don't map sequentially to clutter button
+   * numbers (the right and middle mouse buttons are in the opposite
+   * order) so we'll map them directly with a switch statement */
+  switch (button)
+    {
+    case BTN_LEFT:
+      button_nr = CLUTTER_BUTTON_PRIMARY;
+      break;
+
+    case BTN_RIGHT:
+      button_nr = CLUTTER_BUTTON_SECONDARY;
+      break;
+
+    case BTN_MIDDLE:
+      button_nr = CLUTTER_BUTTON_MIDDLE;
+      break;
+
+    default:
+      button_nr = button - BTN_MOUSE + 1;
+      break;
+    }
+
   if (G_UNLIKELY (button_nr < 1 || button_nr > 8))
     {
       g_warning ("Unhandled button event 0x%x", button);



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