diff options
author | Matthias Clasen <mclasen@redhat.com> | 2019-03-19 20:07:53 -0400 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2019-03-19 21:33:38 -0400 |
commit | 558405e1bc9f30da2a0912a0d3f72663f42f853e (patch) | |
tree | e983764bd9a8ce03edd32a435c359a42abed719a /gtk/gtkwindow.c | |
parent | f47c376fb145bf4f7094260d918427f54c170284 (diff) | |
download | gtk+-558405e1bc9f30da2a0912a0d3f72663f42f853e.tar.gz |
window: Update state flags
When the window gets active / inactive, we
don't propagate events, but just send focus-in / -out
to the current focus_widget. Improve this by updating
its state flags as well.
Diffstat (limited to 'gtk/gtkwindow.c')
-rw-r--r-- | gtk/gtkwindow.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c index bc2a53cff2..091a432e81 100644 --- a/gtk/gtkwindow.c +++ b/gtk/gtkwindow.c @@ -6913,6 +6913,8 @@ do_focus_change (GtkWidget *widget, GdkSeat *seat; GdkDevice *device; GdkEvent *event; + GtkRoot *root; + GtkStateFlags flags; seat = gdk_display_get_default_seat (gtk_widget_get_display (widget)); device = gdk_seat_get_keyboard (seat); @@ -6929,6 +6931,16 @@ do_focus_change (GtkWidget *widget, event->focus_change.mode = GDK_CROSSING_STATE_CHANGED; event->focus_change.detail = GDK_NOTIFY_ANCESTOR; + flags = GTK_STATE_FLAG_FOCUSED; + root = gtk_widget_get_root (widget); + if (!GTK_IS_WINDOW (root) || gtk_window_get_focus_visible (GTK_WINDOW (root))) + flags |= GTK_STATE_FLAG_FOCUS_VISIBLE; + + if (in) + gtk_widget_set_state_flags (widget, flags, FALSE); + else + gtk_widget_unset_state_flags (widget, flags); + gtk_widget_set_has_focus (widget, in); gtk_widget_event (widget, event); |