[gtk/matthiasc/for-master] text: Claim clicks when grabbing focus



commit 4214cd26bd301f556257da64d42b5add5a74a84c
Author: Matthias Clasen <mclasen redhat com>
Date:   Sat Jul 18 11:51:45 2020 -0400

    text: Claim clicks when grabbing focus
    
    If we don't, an ancestor (such a GtkListItemWidget)
    may interpret the click as "I should grab focus!",
    and still our focus away. This was causing hard-to-focus
    entries in the property list in the inspector.

 gtk/gtktext.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
---
diff --git a/gtk/gtktext.c b/gtk/gtktext.c
index 3dda4162cd..7f91f4dc68 100644
--- a/gtk/gtktext.c
+++ b/gtk/gtktext.c
@@ -2681,6 +2681,7 @@ gtk_text_click_gesture_pressed (GtkGestureClick *gesture,
     {
       priv->in_click = TRUE;
       gtk_widget_grab_focus (widget);
+      gtk_gesture_set_state (gesture, GTK_EVENT_SEQUENCE_CLAIMED);
       priv->in_click = FALSE;
     }
 
@@ -2689,6 +2690,7 @@ gtk_text_click_gesture_pressed (GtkGestureClick *gesture,
   if (gdk_event_triggers_context_menu (event))
     {
       gtk_text_do_popup (self, widget_x, widget_y);
+      gtk_gesture_set_state (gesture, GTK_EVENT_SEQUENCE_CLAIMED);
     }
   else if (n_press == 1 && button == GDK_BUTTON_MIDDLE &&
            get_middle_click_paste (self))
@@ -2702,6 +2704,7 @@ gtk_text_click_gesture_pressed (GtkGestureClick *gesture,
         {
           gtk_widget_error_bell (widget);
         }
+      gtk_gesture_set_state (gesture, GTK_EVENT_SEQUENCE_CLAIMED);
     }
   else if (button == GDK_BUTTON_PRIMARY)
     {
@@ -2821,13 +2824,9 @@ gtk_text_click_gesture_pressed (GtkGestureClick *gesture,
             gtk_text_set_positions (self, end, start);
         }
 
-
       gtk_text_update_handles (self);
     }
 
-  if (button != GDK_BUTTON_PRIMARY || n_press >= 3)
-    gtk_gesture_set_state (priv->drag_gesture, GTK_EVENT_SEQUENCE_CLAIMED);
-
   if (n_press >= 3)
     gtk_event_controller_reset (GTK_EVENT_CONTROLLER (gesture));
 }


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