[gtk+] popover: Forward key events to focus widget while visible/modal
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] popover: Forward key events to focus widget while visible/modal
- Date: Tue, 25 Nov 2014 13:13:53 +0000 (UTC)
commit dde77704ed85dfc404ecf7275af77ee4ec3cd7d8
Author: Carlos Garnacho <carlosg gnome org>
Date: Tue Nov 25 13:54:25 2014 +0100
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.
gtk/gtkpopover.c | 15 +++++++++++++++
1 files changed, 15 insertions(+), 0 deletions(-)
---
diff --git a/gtk/gtkpopover.c b/gtk/gtkpopover.c
index 550aa14..241eef5 100644
--- a/gtk/gtkpopover.c
+++ b/gtk/gtkpopover.c
@@ -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;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]