[libadwaita/wip/exalm/tab-hover: 3/3] tab-box: Handle middle click on release instead of press




commit 85e49e87b8aac6f6b3eb4e0e4ad772c4f7fea682
Author: Alexander Mikhaylenko <alexm gnome org>
Date:   Sun Oct 24 01:38:49 2021 +0500

    tab-box: Handle middle click on release instead of press
    
    Fixes https://gitlab.gnome.org/GNOME/libadwaita/-/issues/294

 src/adw-tab-box.c | 28 +++++++++++++++++++---------
 1 file changed, 19 insertions(+), 9 deletions(-)
---
diff --git a/src/adw-tab-box.c b/src/adw-tab-box.c
index af6fc84f..cf9a9f0a 100644
--- a/src/adw-tab-box.c
+++ b/src/adw-tab-box.c
@@ -2767,12 +2767,8 @@ pressed_cb (AdwTabBox  *self,
 
   button = gtk_gesture_single_get_current_button (GTK_GESTURE_SINGLE (gesture));
 
-  if (button == GDK_BUTTON_MIDDLE) {
-    gtk_gesture_set_state (gesture, GTK_EVENT_SEQUENCE_CLAIMED);
-    adw_tab_view_close_page (self->view, info->page);
-
+  if (button == GDK_BUTTON_MIDDLE)
     return;
-  }
 
   if (button != GDK_BUTTON_PRIMARY) {
     gtk_gesture_set_state (gesture, GTK_EVENT_SEQUENCE_DENIED);
@@ -2791,12 +2787,16 @@ released_cb (AdwTabBox  *self,
              GtkGesture *gesture)
 {
   TabInfo *info;
-
-  if (!is_touchscreen (gesture))
-    return;
+  guint button;
 
   x += gtk_adjustment_get_value (self->adjustment);
 
+  if (y < 0 || y > gtk_widget_get_height (GTK_WIDGET (self))) {
+    gtk_gesture_set_state (gesture, GTK_EVENT_SEQUENCE_DENIED);
+
+    return;
+  }
+
   info = find_tab_info_at (self, x);
 
   if (!info || !info->page) {
@@ -2805,7 +2805,17 @@ released_cb (AdwTabBox  *self,
     return;
   }
 
-  handle_click (self, info, gesture);
+  button = gtk_gesture_single_get_current_button (GTK_GESTURE_SINGLE (gesture));
+
+  if (button == GDK_BUTTON_MIDDLE) {
+    gtk_gesture_set_state (gesture, GTK_EVENT_SEQUENCE_CLAIMED);
+    adw_tab_view_close_page (self->view, info->page);
+
+    return;
+  }
+
+  if (is_touchscreen (gesture))
+    handle_click (self, info, gesture);
 }
 
 /* Overrides */


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