[gtk+] gtklabel: Fix touch link handling under wayland



commit 2d3882c7ebf150caffa9161643aaf37396b1f0ae
Author: Carlos Garnacho <carlosg gnome org>
Date:   Tue Jul 25 16:18:07 2017 +0200

    gtklabel: Fix touch link handling under wayland
    
    Refactor the code updating the active link under the current coordinates
    into a separate function, and call it on GtkGestureMultiPress::pressed
    so the link is updated on GDK_TOUCH_BEGIN. Based on a patch by
    Jan-Michael Brummer <jan brummer tabos org>.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=776903

 gtk/gtklabel.c |   25 ++++++++++++++++++++-----
 1 files changed, 20 insertions(+), 5 deletions(-)
---
diff --git a/gtk/gtklabel.c b/gtk/gtklabel.c
index 41d7c3c..847de2e 100644
--- a/gtk/gtklabel.c
+++ b/gtk/gtklabel.c
@@ -459,6 +459,9 @@ static void gtk_label_select_region_index (GtkLabel *label,
                                            gint      anchor_index,
                                            gint      end_index);
 
+static void gtk_label_update_active_link  (GtkWidget *widget,
+                                           gdouble    x,
+                                           gdouble    y);
 
 static gboolean gtk_label_mnemonic_activate (GtkWidget         *widget,
                                             gboolean           group_cycling);
@@ -4514,6 +4517,7 @@ gtk_label_multipress_gesture_pressed (GtkGestureMultiPress *gesture,
   button = gtk_gesture_single_get_current_button (GTK_GESTURE_SINGLE (gesture));
   sequence = gtk_gesture_single_get_current_sequence (GTK_GESTURE_SINGLE (gesture));
   event = gtk_gesture_get_last_event (GTK_GESTURE (gesture), sequence);
+  gtk_label_update_active_link (widget, widget_x, widget_y);
 
   gtk_gesture_set_state (GTK_GESTURE (gesture), GTK_EVENT_SEQUENCE_CLAIMED);
 
@@ -4854,9 +4858,10 @@ gtk_label_drag_gesture_update (GtkGestureDrag *gesture,
     }
 }
 
-static gboolean
-gtk_label_motion (GtkWidget      *widget,
-                  GdkEventMotion *event)
+static void
+gtk_label_update_active_link (GtkWidget *widget,
+                              gdouble    x,
+                              gdouble    y)
 {
   GtkLabel *label = GTK_LABEL (widget);
   GtkLabelPrivate *priv = label->priv;
@@ -4864,7 +4869,7 @@ gtk_label_motion (GtkWidget      *widget,
   gint index;
 
   if (info == NULL)
-    return FALSE;
+    return;
 
   if (info->links && !info->in_drag)
     {
@@ -4874,7 +4879,7 @@ gtk_label_motion (GtkWidget      *widget,
 
       if (info->selection_anchor == info->selection_end)
         {
-          if (get_layout_index (label, event->x, event->y, &index))
+          if (get_layout_index (label, x, y, &index))
             {
               for (l = info->links; l != NULL; l = l->next)
                 {
@@ -4912,6 +4917,16 @@ gtk_label_motion (GtkWidget      *widget,
             }
         }
     }
+}
+
+static gboolean
+gtk_label_motion (GtkWidget      *widget,
+                  GdkEventMotion *event)
+{
+  gdouble x, y;
+
+  gdk_event_get_coords ((GdkEvent *) event, &x, &y);
+  gtk_label_update_active_link (widget, x, y);
 
   return GTK_WIDGET_CLASS (gtk_label_parent_class)->motion_notify_event (widget, event);
 }


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