[libshumate/tintou/zoom-click: 2/2] map: set the button number directly in the Gesture




commit c0fce68cb9ff1d2cd85576a42d78017538c4a1f7
Author: Corentin Noël <tintou noel tf>
Date:   Mon Aug 1 22:47:28 2022 +0200

    map: set the button number directly in the Gesture
    
    Allows to filter the button number early.

 shumate/shumate-map.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
---
diff --git a/shumate/shumate-map.c b/shumate/shumate-map.c
index eaafc5a..6c5248f 100644
--- a/shumate/shumate-map.c
+++ b/shumate/shumate-map.c
@@ -598,13 +598,12 @@ on_rotate_gesture_update (ShumateMap *self,
 
 static void
 on_click_gesture_pressed (ShumateMap      *self,
-                          gint             n_press,
-                          gdouble          x,
-                          gdouble          y,
+                          int              n_press,
+                          double           x,
+                          double           y,
                           GtkGestureClick *click)
 {
-  guint current_button = gtk_gesture_single_get_current_button (GTK_GESTURE_SINGLE (click));
-  if (current_button == GDK_BUTTON_PRIMARY && n_press == 2)
+  if (n_press == 2)
     {
       double zoom_level = shumate_viewport_get_zoom_level (self->viewport);
       self->current_x = x;
@@ -863,6 +862,7 @@ shumate_map_init (ShumateMap *self)
   gtk_gesture_group (zoom_gesture, rotate_gesture);
 
   click_gesture = gtk_gesture_click_new ();
+  gtk_gesture_single_set_button (GTK_GESTURE_SINGLE (click_gesture), GDK_BUTTON_PRIMARY);
   g_signal_connect_swapped (click_gesture, "pressed", G_CALLBACK (on_click_gesture_pressed), self);
   gtk_widget_add_controller (GTK_WIDGET (self), GTK_EVENT_CONTROLLER (click_gesture));
 


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