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.
This commit is contained in:
Matthias Clasen 2020-07-18 11:51:45 -04:00
parent 76d80ef516
commit 2e2336ffce

View File

@ -2681,6 +2681,7 @@ gtk_text_click_gesture_pressed (GtkGestureClick *gesture,
{ {
priv->in_click = TRUE; priv->in_click = TRUE;
gtk_widget_grab_focus (widget); gtk_widget_grab_focus (widget);
gtk_gesture_set_state (GTK_GESTURE (gesture), GTK_EVENT_SEQUENCE_CLAIMED);
priv->in_click = FALSE; priv->in_click = FALSE;
} }
@ -2689,6 +2690,7 @@ gtk_text_click_gesture_pressed (GtkGestureClick *gesture,
if (gdk_event_triggers_context_menu (event)) if (gdk_event_triggers_context_menu (event))
{ {
gtk_text_do_popup (self, widget_x, widget_y); gtk_text_do_popup (self, widget_x, widget_y);
gtk_gesture_set_state (GTK_GESTURE (gesture), GTK_EVENT_SEQUENCE_CLAIMED);
} }
else if (n_press == 1 && button == GDK_BUTTON_MIDDLE && else if (n_press == 1 && button == GDK_BUTTON_MIDDLE &&
get_middle_click_paste (self)) get_middle_click_paste (self))
@ -2702,6 +2704,8 @@ gtk_text_click_gesture_pressed (GtkGestureClick *gesture,
{ {
gtk_widget_error_bell (widget); gtk_widget_error_bell (widget);
} }
gtk_gesture_set_state (GTK_GESTURE (gesture), GTK_EVENT_SEQUENCE_CLAIMED);
} }
else if (button == GDK_BUTTON_PRIMARY) else if (button == GDK_BUTTON_PRIMARY)
{ {
@ -2821,13 +2825,9 @@ gtk_text_click_gesture_pressed (GtkGestureClick *gesture,
gtk_text_set_positions (self, end, start); gtk_text_set_positions (self, end, start);
} }
gtk_text_update_handles (self); 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) if (n_press >= 3)
gtk_event_controller_reset (GTK_EVENT_CONTROLLER (gesture)); gtk_event_controller_reset (GTK_EVENT_CONTROLLER (gesture));
} }