frames: Allow for unknown mouse buttons
authorOlivier Fourdan <ofourdan@redhat.com>
Tue, 22 May 2018 09:23:13 +0000 (11:23 +0200)
committerSimon McVittie <smcv@debian.org>
Sun, 8 Jul 2018 10:32:56 +0000 (11:32 +0100)
Commit 47131b1d ("frames: Handle touch events") introduced an assert to
make sure that all mouse button actions are handled in mutter.

However, mice can have a more than 5 buttons, so simply ignore the
"other" actions instead of aborting.

(cherry picked from commit 473bf38753221dc0002fae309d2f3f217e96c5f5)

Bug: https://gitlab.gnome.org/GNOME/mutter/issues/160
Bug-Debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=899181
Origin: upstream, 3.28.3, commit:1a3f9a33234f8406ffcaa150df542b73715910f4

Gbp-Pq: Name frames-Allow-for-unknown-mouse-buttons.patch

src/ui/frames.c

index 850f2850aea60e072ef2c94e07ade4d7d2ca6079..6d7b999be0deeee94aeca0b3d4b2821bac0dc981 100644 (file)
@@ -75,7 +75,8 @@ enum {
   META_ACTION_CLICK,
   META_ACTION_RIGHT_CLICK,
   META_ACTION_MIDDLE_CLICK,
-  META_ACTION_DOUBLE_CLICK
+  META_ACTION_DOUBLE_CLICK,
+  META_ACTION_IGNORE
 };
 
 static GObject *
@@ -974,6 +975,10 @@ get_action (const ClutterEvent *event)
           return META_ACTION_RIGHT_CLICK;
         case CLUTTER_BUTTON_MIDDLE:
           return META_ACTION_MIDDLE_CLICK;
+        default:
+          meta_verbose ("No action triggered for button %u %s\n",
+                        event->button.button,
+                        (event->type == CLUTTER_BUTTON_PRESS) ? "press" : "release");
         }
     }
   else if (event->type == CLUTTER_TOUCH_BEGIN ||
@@ -983,7 +988,7 @@ get_action (const ClutterEvent *event)
       return META_ACTION_CLICK;
     }
 
-  g_assert_not_reached ();
+  return META_ACTION_IGNORE;
 }
 
 static uint32_t
@@ -1115,13 +1120,15 @@ handle_press_event (MetaUIFrame        *frame,
   g_assert (event->type == CLUTTER_BUTTON_PRESS ||
             event->type == CLUTTER_TOUCH_BEGIN);
 
+  action = get_action (event);
+  if (action == META_ACTION_IGNORE)
+    return FALSE;
+
   display = GDK_DISPLAY_XDISPLAY (gdk_display_get_default ());
 
   evtime = clutter_event_get_time (event);
   clutter_event_get_coords (event, &x, &y);
   control = get_control (frame, x, y);
-  action = get_action (event);
-
   /* don't do the rest of this if on client area */
   if (control == META_FRAME_CONTROL_CLIENT_AREA)
     return FALSE; /* not on the frame, just passed through from client */