[mutter] wayland: Fetch pointer button event codes from the ClutterEvent



commit 7309b20c255851dc79aece899e2b8a9517593603
Author: Carlos Garnacho <carlosg gnome org>
Date:   Tue Nov 17 18:01:08 2015 +0100

    wayland: Fetch pointer button event codes from the ClutterEvent
    
    When running as a native compositor, we can just do that. However, the
    previous code must stay for whenever it's run as a X11 client.
    
    Additionally, the fallback switch{} that transforms clutter 1-indexed
    buttons into input.h event codes had to be adapted to the change introduced
    in clutter commit 83b738c0e, where the 4-7 button range is kept clear for
    compatibility with the X11 backend.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=758239

 configure.ac                       |    2 +-
 src/wayland/meta-wayland-pointer.c |   54 +++++++++++++++++++++++------------
 2 files changed, 36 insertions(+), 20 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 7a5a2ea..711e8c7 100644
--- a/configure.ac
+++ b/configure.ac
@@ -63,7 +63,7 @@ MUTTER_PC_MODULES="
    pango >= 1.2.0
    cairo >= 1.10.0
    gsettings-desktop-schemas >= 3.15.92
-   $CLUTTER_PACKAGE >= 1.23.4
+   $CLUTTER_PACKAGE >= 1.25.1
    cogl-1.0 >= 1.17.1
    upower-glib >= 0.99.0
    gnome-desktop-3.0
diff --git a/src/wayland/meta-wayland-pointer.c b/src/wayland/meta-wayland-pointer.c
index 894a64d..7e19b55 100644
--- a/src/wayland/meta-wayland-pointer.c
+++ b/src/wayland/meta-wayland-pointer.c
@@ -44,6 +44,7 @@
 #include "config.h"
 
 #include <clutter/clutter.h>
+#include <clutter/evdev/clutter-evdev.h>
 #include <cogl/cogl.h>
 #include <cogl/cogl-wayland-server.h>
 #include <linux/input.h>
@@ -62,6 +63,10 @@
 #include "backends/meta-cursor-tracker-private.h"
 #include "backends/meta-cursor-renderer.h"
 
+#ifdef HAVE_NATIVE_BACKEND
+#include "backends/native/meta-backend-native.h"
+#endif
+
 #include <string.h>
 
 #define DEFAULT_AXIS_STEP_DISTANCE wl_fixed_from_int (10)
@@ -277,26 +282,37 @@ meta_wayland_pointer_send_button (MetaWaylandPointer *pointer,
       uint32_t button;
       uint32_t serial;
 
-      time = clutter_event_get_time (event);
-
-      button = clutter_event_get_button (event);
-      switch (button)
-       {
-         /* The evdev input right and middle button numbers are swapped
-            relative to how Clutter numbers them */
-       case 2:
-         button = BTN_MIDDLE;
-         break;
-
-       case 3:
-         button = BTN_RIGHT;
-         break;
-
-       default:
-         button = button + BTN_LEFT - 1;
-         break;
-       }
+#ifdef HAVE_NATIVE_BACKEND
+      MetaBackend *backend = meta_get_backend ();
+      if (META_IS_BACKEND_NATIVE (backend))
+        button = clutter_evdev_event_get_event_code (event);
+      else
+#endif
+        {
+          button = clutter_event_get_button (event);
+          switch (button)
+            {
+            case 1:
+              button = BTN_LEFT;
+              break;
+
+              /* The evdev input right and middle button numbers are swapped
+                 relative to how Clutter numbers them */
+            case 2:
+              button = BTN_MIDDLE;
+              break;
+
+            case 3:
+              button = BTN_RIGHT;
+              break;
+
+            default:
+              button = button + (BTN_LEFT - 1) + 4;
+              break;
+            }
+        }
 
+      time = clutter_event_get_time (event);
       serial = wl_display_next_serial (display);
 
       wl_resource_for_each (resource, &pointer->focus_client->pointer_resources)


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