diff options
author | Carlos Garnacho <carlosg@gnome.org> | 2017-07-25 16:18:07 +0200 |
---|---|---|
committer | Carlos Garnacho <carlosg@gnome.org> | 2017-07-26 13:20:56 +0200 |
commit | 2d3882c7ebf150caffa9161643aaf37396b1f0ae (patch) | |
tree | 24437bbb6d189573ff39e2e89362aad56bc78600 /gtk/gtklabel.c | |
parent | 21062fab022b97fb37d9ffa29eae7f3815ef6a16 (diff) | |
download | gtk+-2d3882c7ebf150caffa9161643aaf37396b1f0ae.tar.gz |
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
Diffstat (limited to 'gtk/gtklabel.c')
-rw-r--r-- | gtk/gtklabel.c | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/gtk/gtklabel.c b/gtk/gtklabel.c index 41d7c3c8db..847de2eabb 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); } |