[clutter: 2/3] wayland: Use CLUTTER_BUTTON_* defines instead of magic numbers




commit 8f0fa2ec8697fa188cc8ccc6aca5c7076aea2eb6
Author: Jason Gerecke <killertofu gmail com>
Date:   Wed Jun 14 09:56:43 2017 -0700

    wayland: Use CLUTTER_BUTTON_* defines instead of magic numbers
    
    https://bugzilla.gnome.org/show_bug.cgi?id=783791

 clutter/mir/clutter-event-mir.c                |  8 ++++----
 clutter/osx/clutter-event-osx.c                |  6 +++---
 clutter/wayland/clutter-input-device-wayland.c | 13 +++++++------
 clutter/win32/clutter-event-win32.c            | 18 +++++++++---------
 4 files changed, 23 insertions(+), 22 deletions(-)
---
diff --git a/clutter/mir/clutter-event-mir.c b/clutter/mir/clutter-event-mir.c
index 296430bb9..779ed728c 100644
--- a/clutter/mir/clutter-event-mir.c
+++ b/clutter/mir/clutter-event-mir.c
@@ -265,17 +265,17 @@ _clutter_mir_handle_event (ClutterBackend *backend,
                                           CLUTTER_BUTTON_PRESS :
                                           CLUTTER_BUTTON_RELEASE);
 
-              event->button.button = 1;
+              event->button.button = CLUTTER_BUTTON_PRIMARY;
               event->button.click_count = 1;
 
               button_state ^= mir_event->motion.button_state;
 
               if (button_state == 0 || (button_state & mir_motion_button_primary))
-                event->button.button = 1;
+                event->button.button = CLUTTER_BUTTON_PRIMARY;
               else if (button_state & mir_motion_button_secondary)
-                event->button.button = 3;
+                event->button.button = CLUTTER_BUTTON_SECONDARY;
               else if (button_state & mir_motion_button_tertiary)
-                event->button.button = 2;
+                event->button.button = CLUTTER_BUTTON_MIDDLE;
               else if (button_state & mir_motion_button_back)
                 event->button.button = 8;
               else if (button_state & mir_motion_button_forward)
diff --git a/clutter/osx/clutter-event-osx.c b/clutter/osx/clutter-event-osx.c
index 4b53fefad..43051c487 100644
--- a/clutter/osx/clutter-event-osx.c
+++ b/clutter/osx/clutter-event-osx.c
@@ -60,9 +60,9 @@
 {
   switch ([self buttonNumber])
     {
-    case 0: return 1;   /* left   */
-    case 1: return 3;   /* right  */
-    case 2: return 2;   /* middle */
+    case 0: return CLUTTER_BUTTON_PRIMARY;   /* left   */
+    case 1: return CLUTTER_BUTTON_SECONDARY; /* right  */
+    case 2: return CLUTTER_BUTTON_MIDDLE;    /* middle */
     default: return 1 + [self buttonNumber];
     }
 }
diff --git a/clutter/wayland/clutter-input-device-wayland.c b/clutter/wayland/clutter-input-device-wayland.c
index 4a89d7391..168a6839b 100644
--- a/clutter/wayland/clutter-input-device-wayland.c
+++ b/clutter/wayland/clutter-input-device-wayland.c
@@ -30,6 +30,7 @@
 
 #include <stdlib.h>
 #include <unistd.h>
+#include <linux/input.h>
 #include <sys/mman.h>
 #include <wayland-util.h>
 #include <wayland-client.h>
@@ -129,16 +130,16 @@ clutter_wayland_handle_button (void *data,
 
   /* evdev button codes */
   switch (button) {
-  case 272:
-    event->button.button = 1;
+  case BTN_LEFT:
+    event->button.button = CLUTTER_BUTTON_PRIMARY;
     modifier_mask = CLUTTER_BUTTON1_MASK;
     break;
-  case 273:
-    event->button.button = 3;
+  case BTN_RIGHT:
+    event->button.button = CLUTTER_BUTTON_SECONDARY;
     modifier_mask = CLUTTER_BUTTON3_MASK;
     break;
-  case 274:
-    event->button.button = 2;
+  case BTN_MIDDLE:
+    event->button.button = CLUTTER_BUTTON_MIDDLE;
     modifier_mask = CLUTTER_BUTTON2_MASK;
     break;
   }
diff --git a/clutter/win32/clutter-event-win32.c b/clutter/win32/clutter-event-win32.c
index 7a360c625..391cadc58 100644
--- a/clutter/win32/clutter-event-win32.c
+++ b/clutter/win32/clutter-event-win32.c
@@ -465,39 +465,39 @@ clutter_win32_handle_event (const MSG *msg)
       break;
 
     case WM_LBUTTONDOWN:
-      make_button_event (msg, stage, 1, 1, FALSE, core_pointer);
+      make_button_event (msg, stage, CLUTTER_BUTTON_PRIMARY, 1, FALSE, core_pointer);
       break;
 
     case WM_MBUTTONDOWN:
-      make_button_event (msg, stage, 2, 1, FALSE, core_pointer);
+      make_button_event (msg, stage, CLUTTER_BUTTON_MIDDLE, 1, FALSE, core_pointer);
       break;
 
     case WM_RBUTTONDOWN:
-      make_button_event (msg, stage, 3, 1, FALSE, core_pointer);
+      make_button_event (msg, stage, CLUTTER_BUTTON_SECONDARY, 1, FALSE, core_pointer);
       break;
 
     case WM_LBUTTONUP:
-      make_button_event (msg, stage, 1, 1, TRUE, core_pointer);
+      make_button_event (msg, stage, CLUTTER_BUTTON_PRIMARY, 1, TRUE, core_pointer);
       break;
 
     case WM_MBUTTONUP:
-      make_button_event (msg, stage, 2, 1, TRUE, core_pointer);
+      make_button_event (msg, stage, CLUTTER_BUTTON_MIDDLE, 1, TRUE, core_pointer);
       break;
 
     case WM_RBUTTONUP:
-      make_button_event (msg, stage, 3, 1, TRUE, core_pointer);
+      make_button_event (msg, stage, CLUTTER_BUTTON_SECONDARY, 1, TRUE, core_pointer);
       break;
 
     case WM_LBUTTONDBLCLK:
-      make_button_event (msg, stage, 1, 2, FALSE, core_pointer);
+      make_button_event (msg, stage, CLUTTER_BUTTON_PRIMARY, 2, FALSE, core_pointer);
       break;
 
     case WM_MBUTTONDBLCLK:
-      make_button_event (msg, stage, 2, 2, FALSE, core_pointer);
+      make_button_event (msg, stage, CLUTER_BUTTON_MIDDLE, 2, FALSE, core_pointer);
       break;
 
     case WM_RBUTTONDBLCLK:
-      make_button_event (msg, stage, 3, 2, FALSE, core_pointer);
+      make_button_event (msg, stage, CLUTTER_BUTTON_SECONDARY, 2, FALSE, core_pointer);
       break;
 
     case WM_MOUSEWHEEL:


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