From 661da6baec21f390466c7f59249fe7b2d5027320 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Sat, 19 Sep 2020 16:45:56 -0400 Subject: [PATCH] main: Update pointer focus state for button releases Failure to do so makes the old pointer focus target 'sticky', because we end up ignoring the result of picking the pointer focus until a motion event comes in. Fixes: #3172 --- gtk/gtkmain.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/gtk/gtkmain.c b/gtk/gtkmain.c index a72801e8dd..10780b7684 100644 --- a/gtk/gtkmain.c +++ b/gtk/gtkmain.c @@ -1477,17 +1477,19 @@ handle_pointing_event (GdkEvent *event) device, sequence); gtk_window_set_pointer_focus_grab (toplevel, device, sequence, - type == GDK_BUTTON_PRESS ? - target : NULL); + type == GDK_BUTTON_PRESS ? target : NULL); if (type == GDK_BUTTON_RELEASE) { GtkWidget *new_target = gtk_widget_pick (native, x, y, GTK_PICK_DEFAULT); + if (new_target == NULL) new_target = GTK_WIDGET (toplevel); + gtk_synthesize_crossing_events (GTK_ROOT (toplevel), GTK_CROSSING_POINTER, target, new_target, event, GDK_CROSSING_UNGRAB, NULL); gtk_window_maybe_update_cursor (toplevel, NULL, device); + update_pointer_focus_state (toplevel, event, new_target); } set_widget_active_state (target, type == GDK_BUTTON_RELEASE);