From 79b09cccce6565d25b217826b78824b1ff2fe1f5 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Sun, 7 Jun 2015 19:31:06 -0400 Subject: [PATCH] entry: Make handles come back reliably We were setting the text handle mode to NONE too aggressively. --- gtk/gtkentry.c | 44 +++++++++++++++++++++++++++----------------- 1 file changed, 27 insertions(+), 17 deletions(-) diff --git a/gtk/gtkentry.c b/gtk/gtkentry.c index d81bbeaede..1d7bc8400d 100644 --- a/gtk/gtkentry.c +++ b/gtk/gtkentry.c @@ -4450,7 +4450,7 @@ gtk_entry_multipress_gesture_pressed (GtkGestureMultiPress *gesture, else if (button == GDK_BUTTON_PRIMARY) { gboolean have_selection = gtk_editable_get_selection_bounds (editable, &sel_start, &sel_end); - GtkTextHandleMode mode = GTK_TEXT_HANDLE_MODE_NONE; + GtkTextHandleMode mode; gboolean is_touchscreen, extend_selection; GdkDevice *source; @@ -4459,6 +4459,13 @@ gtk_entry_multipress_gesture_pressed (GtkGestureMultiPress *gesture, (gtk_get_debug_flags () & GTK_DEBUG_TOUCHSCREEN) != 0 || gdk_device_get_source (source) == GDK_SOURCE_TOUCHSCREEN; + if (!is_touchscreen) + mode = GTK_TEXT_HANDLE_MODE_NONE; + else if (have_selection) + mode = GTK_TEXT_HANDLE_MODE_SELECTION; + else + mode = GTK_TEXT_HANDLE_MODE_CURSOR; + if (is_touchscreen) gtk_entry_ensure_text_handles (entry); @@ -4476,12 +4483,23 @@ gtk_entry_multipress_gesture_pressed (GtkGestureMultiPress *gesture, case 1: if (in_selection (entry, x + priv->scroll_offset)) { - /* Click inside the selection - we'll either start a drag, or - * clear the selection - */ - priv->in_drag = TRUE; - priv->drag_start_x = x + priv->scroll_offset; - priv->drag_start_y = y; + if (is_touchscreen) + { + if (entry->priv->selection_bubble && + gtk_widget_get_visible (entry->priv->selection_bubble)) + gtk_entry_selection_bubble_popup_unset (entry); + else + gtk_entry_selection_bubble_popup_set (entry); + } + else + { + /* Click inside the selection - we'll either start a drag, or + * clear the selection + */ + priv->in_drag = TRUE; + priv->drag_start_x = x + priv->scroll_offset; + priv->drag_start_y = y; + } } else if (!extend_selection) { @@ -4756,10 +4774,7 @@ gtk_entry_drag_gesture_end (GtkGestureDrag *gesture, /* Check whether the drag was cancelled rather than finished */ if (!gtk_gesture_handles_sequence (GTK_GESTURE (gesture), sequence)) - { - gtk_entry_selection_bubble_popup_unset (entry); - return; - } + return; event = gtk_gesture_get_last_event (GTK_GESTURE (gesture), sequence); source = gdk_event_get_source_device (event); @@ -4767,12 +4782,6 @@ gtk_entry_drag_gesture_end (GtkGestureDrag *gesture, (gtk_get_debug_flags () & GTK_DEBUG_TOUCHSCREEN) != 0 || gdk_device_get_source (source) == GDK_SOURCE_TOUCHSCREEN); - if (priv->selection_bubble && - gtk_widget_get_visible (priv->selection_bubble)) - gtk_entry_selection_bubble_popup_unset (entry); - else if (is_touchscreen) - gtk_entry_selection_bubble_popup_set (entry); - if (in_drag) { gint tmp_pos = gtk_entry_find_position (entry, priv->drag_start_x); @@ -6699,6 +6708,7 @@ gtk_entry_handle_dragged (GtkTextHandle *handle, gtk_entry_show_magnifier (entry, x, y); } + static void gtk_entry_handle_drag_finished (GtkTextHandle *handle, GtkTextHandlePosition pos,