From 7309b20c255851dc79aece899e2b8a9517593603 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Tue, 17 Nov 2015 18:01:08 +0100 Subject: [PATCH] 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 7a5a2eaee..711e8c7bd 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 894a64dd5..7e19b558d 100644 --- a/src/wayland/meta-wayland-pointer.c +++ b/src/wayland/meta-wayland-pointer.c @@ -44,6 +44,7 @@ #include "config.h" #include +#include #include #include #include @@ -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 #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; +#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); - - 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; - } - serial = wl_display_next_serial (display); wl_resource_for_each (resource, &pointer->focus_client->pointer_resources)