[gtk+] wayland: Move additional pointer buttons after the old 4-7 scrolling ones



commit 4c49c0a297d67102175fac645762682476336620
Author: Carlos Garnacho <carlosg gnome org>
Date:   Mon Nov 16 12:51:42 2015 +0100

    wayland: Move additional pointer buttons after the old 4-7 scrolling ones
    
    We were using that range for the extra buttons after left/right/middle,
    while this is harmless for clients not handling extra buttons (we
    used to translate those button events into scroll events in x11 anyway)
    this will be unexpected for clients that do handle additional mouse
    buttons themselves (eg. back/forward buttons present in some mice).
    
    In order to remain compatible with X11, those need to be assigned from
    button 8 onwards.
    
    Also, include input.h, and stop using magic numbers here.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=758072

 gdk/wayland/gdkdevice-wayland.c |   18 +++++++++++++-----
 1 files changed, 13 insertions(+), 5 deletions(-)
---
diff --git a/gdk/wayland/gdkdevice-wayland.c b/gdk/wayland/gdkdevice-wayland.c
index 84a1167..157630f 100644
--- a/gdk/wayland/gdkdevice-wayland.c
+++ b/gdk/wayland/gdkdevice-wayland.c
@@ -33,9 +33,13 @@
 
 #include <xkbcommon/xkbcommon.h>
 
+#include <linux/input.h>
+
 #include <sys/time.h>
 #include <sys/mman.h>
 
+#define BUTTON_BASE (BTN_LEFT - 1) /* Used to translate to 1-indexed buttons */
+
 typedef struct _GdkWaylandTouchData GdkWaylandTouchData;
 
 struct _GdkWaylandTouchData
@@ -1018,14 +1022,18 @@ pointer_handle_button (void              *data,
 
   switch (button)
     {
-    case 273:
-      gdk_button = 3;
+    case BTN_LEFT:
+      gdk_button = GDK_BUTTON_PRIMARY;
+      break;
+    case BTN_MIDDLE:
+      gdk_button = GDK_BUTTON_MIDDLE;
       break;
-    case 274:
-      gdk_button = 2;
+    case BTN_RIGHT:
+      gdk_button = GDK_BUTTON_SECONDARY;
       break;
     default:
-      gdk_button = button - 271;
+       /* For compatibility reasons, all additional buttons go after the old 4-7 scroll ones */
+      gdk_button = button - BUTTON_BASE + 4;
       break;
     }
 


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