[gtk+/gestures: 166/202] entry: Improve touch popover interaction



commit 10c47fa6d60aaf6a12b8cdaf5de2b2290b735932
Author: Carlos Garnacho <carlosg gnome org>
Date:   Fri May 16 17:35:53 2014 +0200

    entry: Improve touch popover interaction
    
    Presses alternatively show and dismiss the popover, the popover is still
    always shown invariably after any dragging happens (either text selection,
    or dragging a text handle)

 gtk/gtkentry.c |   28 +++++++++++++++++-----------
 1 files changed, 17 insertions(+), 11 deletions(-)
---
diff --git a/gtk/gtkentry.c b/gtk/gtkentry.c
index 27368cc..75ddb9c 100644
--- a/gtk/gtkentry.c
+++ b/gtk/gtkentry.c
@@ -4347,8 +4347,6 @@ gtk_entry_multipress_gesture_pressed (GtkGestureMultiPress *gesture,
   guint button;
   gint tmp_pos;
 
-  gtk_entry_selection_bubble_popup_unset (entry);
-
   button = gtk_gesture_single_get_current_button (GTK_GESTURE_SINGLE (gesture));
   current = gtk_gesture_single_get_current_sequence (GTK_GESTURE_SINGLE (gesture));
   event = gtk_gesture_get_last_event (GTK_GESTURE (gesture), current);
@@ -4545,6 +4543,8 @@ gtk_entry_drag_gesture_update (GtkGestureDrag *gesture,
   const GdkEvent *event;
   gint x, y;
 
+  gtk_entry_selection_bubble_popup_unset (entry);
+
   gesture_get_current_point (GTK_GESTURE_SINGLE (gesture), entry, &x, &y);
   sequence = gtk_gesture_single_get_current_sequence (GTK_GESTURE_SINGLE (gesture));
   event = gtk_gesture_get_last_event (GTK_GESTURE (gesture), sequence);
@@ -4701,15 +4701,21 @@ gtk_entry_drag_gesture_end (GtkGestureDrag *gesture,
   if (priv->magnifier_popover)
     gtk_widget_hide (priv->magnifier_popover);
 
-  /* Check whether the drag was cancelled rather than finished */
-  if (!gtk_gesture_handles_sequence (GTK_GESTURE (gesture), sequence))
-    return;
-
   event = gtk_gesture_get_last_event (GTK_GESTURE (gesture), sequence);
   source = gdk_event_get_source_device (event);
   is_touchscreen = (test_touchscreen ||
                     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);
+
+  /* Check whether the drag was cancelled rather than finished */
+  if (!gtk_gesture_handles_sequence (GTK_GESTURE (gesture), sequence))
+    return;
+
   if (in_drag)
     {
       gint tmp_pos = gtk_entry_find_position (entry, priv->drag_start_x);
@@ -4719,10 +4725,6 @@ gtk_entry_drag_gesture_end (GtkGestureDrag *gesture,
       if (is_touchscreen)
         gtk_entry_update_handles (entry, GTK_TEXT_HANDLE_MODE_CURSOR);
     }
-  else if (is_touchscreen)
-    {
-      gtk_entry_selection_bubble_popup_set (entry);
-    }
 
   gtk_entry_update_primary_selection (entry);
 }
@@ -6612,7 +6614,11 @@ gtk_entry_handle_drag_finished (GtkTextHandle         *handle,
                                 GtkTextHandlePosition  pos,
                                 GtkEntry              *entry)
 {
-  gtk_entry_selection_bubble_popup_set (entry);
+  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);
 
   if (entry->priv->magnifier_popover)
     gtk_widget_hide (entry->priv->magnifier_popover);


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