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
This commit is contained in:
Matthias Clasen 2020-09-19 16:45:56 -04:00
parent 6b708e9b60
commit 661da6baec

View File

@ -1477,17 +1477,19 @@ handle_pointing_event (GdkEvent *event)
device, device,
sequence); sequence);
gtk_window_set_pointer_focus_grab (toplevel, device, sequence, gtk_window_set_pointer_focus_grab (toplevel, device, sequence,
type == GDK_BUTTON_PRESS ? type == GDK_BUTTON_PRESS ? target : NULL);
target : NULL);
if (type == GDK_BUTTON_RELEASE) if (type == GDK_BUTTON_RELEASE)
{ {
GtkWidget *new_target = gtk_widget_pick (native, x, y, GTK_PICK_DEFAULT); GtkWidget *new_target = gtk_widget_pick (native, x, y, GTK_PICK_DEFAULT);
if (new_target == NULL) if (new_target == NULL)
new_target = GTK_WIDGET (toplevel); new_target = GTK_WIDGET (toplevel);
gtk_synthesize_crossing_events (GTK_ROOT (toplevel), GTK_CROSSING_POINTER, target, new_target, gtk_synthesize_crossing_events (GTK_ROOT (toplevel), GTK_CROSSING_POINTER, target, new_target,
event, GDK_CROSSING_UNGRAB, NULL); event, GDK_CROSSING_UNGRAB, NULL);
gtk_window_maybe_update_cursor (toplevel, NULL, device); 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); set_widget_active_state (target, type == GDK_BUTTON_RELEASE);