[gtk/new-style-menu] gdk: Always deliver key events to toplevels
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/new-style-menu] gdk: Always deliver key events to toplevels
- Date: Sat, 8 Jun 2019 13:48:46 +0000 (UTC)
commit 3958f77241c5a255d39fda3dc8819565ca26b9ef
Author: Matthias Clasen <mclasen redhat com>
Date: Sat Jun 8 13:39:53 2019 +0000
gdk: Always deliver key events to toplevels
This is just a hack to see that this works.
Eventually, the backends should do the right
thing.
gdk/gdksurface.c | 28 ++++++++++++++++++++++++++++
1 file changed, 28 insertions(+)
---
diff --git a/gdk/gdksurface.c b/gdk/gdksurface.c
index 3beff1e9cf..333c5d39a6 100644
--- a/gdk/gdksurface.c
+++ b/gdk/gdksurface.c
@@ -4030,6 +4030,32 @@ check_autohide (GdkEvent *event)
return FALSE;
}
+static gboolean
+is_key_event (GdkEvent *event)
+{
+ switch ((guint) gdk_event_get_event_type (event))
+ {
+ case GDK_KEY_PRESS:
+ case GDK_KEY_RELEASE:
+ return TRUE;
+ default:;
+ }
+
+ return FALSE;
+}
+
+static void
+rewrite_event_for_toplevel (GdkEvent *event)
+{
+ GdkSurface *surface;
+
+ surface = gdk_event_get_surface (event);
+ while (surface->parent)
+ surface = surface->parent;
+
+ g_set_object (&event->any.surface, surface);
+}
+
gboolean
gdk_surface_handle_event (GdkEvent *event)
{
@@ -4046,6 +4072,8 @@ gdk_surface_handle_event (GdkEvent *event)
}
else
{
+ if (is_key_event (event))
+ rewrite_event_for_toplevel (event);
g_signal_emit (gdk_event_get_surface (event), signals[EVENT], 0, event, &handled);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]