diff options
author | Carlos Garnacho <carlosg@gnome.org> | 2020-11-19 20:12:58 +0100 |
---|---|---|
committer | Carlos Garnacho <carlosg@gnome.org> | 2020-11-19 22:58:14 +0100 |
commit | 5ab14ff7f62baac591cbf44b6af63e44446c3f1e (patch) | |
tree | 2375afaeffe6e1fc7ee37343015bed8e8253a189 | |
parent | 8482b956d697e74d62a968586e7a7a3c7ed03ec6 (diff) | |
download | gtk+-5ab14ff7f62baac591cbf44b6af63e44446c3f1e.tar.gz |
gtk/main: Do not unset active state on button release w/o implicit grab
If an active grab gets undone on button press (e.g. closing a menu), we
will receive a button release on the new target even though it didn't handle
the button press, and disable ::active state.
This causes warnings when handling the button release, as it tries to undo
::active state that is not really there.
In order to fix this, check that the pointer focus actually had an implicit
grab at the time of receiving the button release, before trying to unset
the ::active state.
-rw-r--r-- | gtk/gtkmain.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/gtk/gtkmain.c b/gtk/gtkmain.c index 8b246477be..b9d12e19aa 100644 --- a/gtk/gtkmain.c +++ b/gtk/gtkmain.c @@ -1374,6 +1374,7 @@ handle_pointing_event (GdkEvent *event) double native_x, native_y; GtkWidget *native; GdkEventType type; + gboolean has_implicit; event_widget = gtk_get_event_widget (event); device = gdk_event_get_device (event); @@ -1475,6 +1476,11 @@ handle_pointing_event (GdkEvent *event) target = gtk_window_lookup_effective_pointer_focus_widget (toplevel, device, sequence); + has_implicit = + gtk_window_lookup_pointer_focus_implicit_grab (toplevel, + device, + sequence) != NULL; + gtk_window_set_pointer_focus_grab (toplevel, device, sequence, type == GDK_BUTTON_PRESS ? target : NULL); @@ -1491,7 +1497,10 @@ handle_pointing_event (GdkEvent *event) update_pointer_focus_state (toplevel, event, new_target); } - set_widget_active_state (target, type == GDK_BUTTON_RELEASE); + if (type == GDK_BUTTON_PRESS) + set_widget_active_state (target, FALSE); + else if (has_implicit) + set_widget_active_state (target, TRUE); break; case GDK_SCROLL: |