mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-11-16 21:50:34 +00:00
popover: Forward key events to focus widget while visible/modal
This is the expected behavior while the popover keeps the grab, leaving this up to the toplevel implementation gives place to key handlers connected there to handle the event otherwise, and maybe redirect key events somewhere else.
This commit is contained in:
parent
f71831c780
commit
dde77704ed
@ -1200,12 +1200,27 @@ static gboolean
|
||||
gtk_popover_key_press (GtkWidget *widget,
|
||||
GdkEventKey *event)
|
||||
{
|
||||
GtkWidget *toplevel, *focus;
|
||||
|
||||
if (event->keyval == GDK_KEY_Escape)
|
||||
{
|
||||
gtk_widget_hide (widget);
|
||||
return GDK_EVENT_STOP;
|
||||
}
|
||||
|
||||
if (!GTK_POPOVER (widget)->priv->modal)
|
||||
return GDK_EVENT_PROPAGATE;
|
||||
|
||||
toplevel = gtk_widget_get_toplevel (widget);
|
||||
|
||||
if (GTK_IS_WINDOW (toplevel))
|
||||
{
|
||||
focus = gtk_window_get_focus (GTK_WINDOW (toplevel));
|
||||
|
||||
if (focus && gtk_widget_is_ancestor (focus, widget))
|
||||
return gtk_window_propagate_key_event (GTK_WINDOW (toplevel), event);
|
||||
}
|
||||
|
||||
return GDK_EVENT_PROPAGATE;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user