summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2015-11-28 17:51:11 -0500
committerDavid Robillard <d@drobilla.net>2015-11-28 17:54:21 -0500
commit57a850cb5ccf6fe1031a6c7ea0e18a74eddcbdf2 (patch)
treebbf3ad90b92b18fe339d58515c5c06ca297c23a3
parent4c4fb2570f43371666746dde1eb4b6d97608b264 (diff)
downloadsuil-57a850cb5ccf6fe1031a6c7ea0e18a74eddcbdf2.tar.gz
suil-57a850cb5ccf6fe1031a6c7ea0e18a74eddcbdf2.tar.bz2
suil-57a850cb5ccf6fe1031a6c7ea0e18a74eddcbdf2.zip
Bubble X11 key events up to Gtk parent
-rw-r--r--NEWS3
-rw-r--r--src/x11_in_gtk2.c26
2 files changed, 23 insertions, 6 deletions
diff --git a/NEWS b/NEWS
index 88a0988..3f32b8e 100644
--- a/NEWS
+++ b/NEWS
@@ -5,6 +5,7 @@ suil (0.8.3) unstable;
* Various Windows fixes (patches from Robin Gareus)
* Center X11 UIs in Gtk (patch from Robin Gareus)
* Fix initial size of resizable X11 UIs in Gtk (patch from Robin Gareus)
+ * Bubble X11 key events up to Gtk parent (patch from Filipe Coelho)
* Add Gtk2 and X11 in Qt5 wrappers (patch from Rui Nuno Capela)
* Fix compilation with -Wl,--no-undefined
* Fix a few minor/unlikely memory errors
@@ -12,7 +13,7 @@ suil (0.8.3) unstable;
* Only report suil_ui_supported() if necessary wrapper is compiled in
* Upgrade to waf 1.8.14
- -- David Robillard <d@drobilla.net> Sat, 28 Nov 2015 15:26:47 -0500
+ -- David Robillard <d@drobilla.net> Sat, 28 Nov 2015 17:50:49 -0500
suil (0.8.2) stable;
diff --git a/src/x11_in_gtk2.c b/src/x11_in_gtk2.c
index 6cd8677..848b258 100644
--- a/src/x11_in_gtk2.c
+++ b/src/x11_in_gtk2.c
@@ -133,28 +133,45 @@ suil_x11_wrapper_show(GtkWidget* w)
gtk_widget_show(GTK_WIDGET(wrap->plug));
}
-static void
+static gboolean
forward_key_event(SuilX11Wrapper* socket,
GdkEvent* gdk_event)
{
GdkWindow* window = gtk_widget_get_window(GTK_WIDGET(socket->plug));
GdkScreen* screen = gdk_visual_get_screen(gdk_window_get_visual(window));
+ Window target_window;
+ if (gdk_event->any.window == window) {
+ // Event sent up to the plug window, forward it up to the parent
+ GtkWidget* widget = GTK_WIDGET(socket->instance->host_widget);
+ GdkWindow* parent = gtk_widget_get_parent_window(widget);
+ if (parent) {
+ target_window = GDK_WINDOW_XID(parent);
+ } else {
+ return FALSE; // Wrapper is a top-level window, do nothing
+ }
+ } else {
+ // Event sent anywhere else, send to the plugin
+ target_window = (Window)socket->instance->ui_widget;
+ }
+
XKeyEvent xev;
memset(&xev, 0, sizeof(xev));
xev.type = (gdk_event->type == GDK_KEY_PRESS) ? KeyPress : KeyRelease;
xev.root = GDK_WINDOW_XID(gdk_screen_get_root_window(screen));
- xev.window = GDK_WINDOW_XID(window);
+ xev.window = target_window;
xev.subwindow = None;
xev.time = gdk_event->key.time;
xev.state = gdk_event->key.state;
xev.keycode = gdk_event->key.hardware_keycode;
XSendEvent(GDK_WINDOW_XDISPLAY(window),
- (Window)socket->instance->ui_widget,
+ target_window,
False,
NoEventMask,
(XEvent*)&xev);
+
+ return (gdk_event->any.window != window);
}
static gboolean
@@ -223,8 +240,7 @@ suil_x11_wrapper_key_event(GtkWidget* widget,
SuilX11Wrapper* const self = SUIL_X11_WRAPPER(widget);
if (self->plug) {
- forward_key_event(self, (GdkEvent*)event);
- return TRUE;
+ return forward_key_event(self, (GdkEvent*)event);
}
return FALSE;