diff options
author | David Robillard <d@drobilla.net> | 2013-02-22 18:14:30 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2013-02-22 18:14:30 +0000 |
commit | 61a8166c4fda5e3486ae9d19ff102e36a14bfcb0 (patch) | |
tree | eb19360d8ea5be0e266b55453a375c45c1942ee3 | |
parent | 701cc9265c3958473e2dc20e62da6c82890b2cd0 (diff) | |
download | suil-61a8166c4fda5e3486ae9d19ff102e36a14bfcb0.tar.gz suil-61a8166c4fda5e3486ae9d19ff102e36a14bfcb0.tar.bz2 suil-61a8166c4fda5e3486ae9d19ff102e36a14bfcb0.zip |
Maybe fix crash on close caused by key filter for X11 in Gtk.
git-svn-id: http://svn.drobilla.net/lad/trunk/suil@5063 a436a847-0d15-0410-975c-d299462d15a1
-rw-r--r-- | AUTHORS | 1 | ||||
-rw-r--r-- | NEWS | 3 | ||||
-rw-r--r-- | src/x11_in_gtk2.c | 39 |
3 files changed, 25 insertions, 18 deletions
@@ -6,3 +6,4 @@ Contributors: * Fix reparenting of Gtk UIs in Qt * Peter Nelson <peter@fuzzle.org> * Fix crash when a broken UI returns a NULL descriptor + * Fix crash on close caused by key filter for X11 in Gtk @@ -1,10 +1,11 @@ suil (0.6.11) unstable; * Add compile time option to disable explicit Gtk to X11 key forwarding + * Fix crash on close caused by key filter for X11 in Gtk * Fix crash when a broken UI returns a NULL descriptor * Fix compilation on BSD - -- David Robillard <d@drobilla.net> Fri, 22 Feb 2013 12:51:26 -0500 + -- David Robillard <d@drobilla.net> Fri, 22 Feb 2013 13:03:48 -0500 suil (0.6.10) stable; diff --git a/src/x11_in_gtk2.c b/src/x11_in_gtk2.c index 2e3cdf9..0adc408 100644 --- a/src/x11_in_gtk2.c +++ b/src/x11_in_gtk2.c @@ -42,11 +42,33 @@ GType suil_x11_wrapper_get_type(void); // Accessor for SUIL_TYPE_X11_WRAPPER G_DEFINE_TYPE(SuilX11Wrapper, suil_x11_wrapper, GTK_TYPE_SOCKET) +#ifdef SUIL_FORWARD_KEYS +static GdkFilterReturn +event_filter(GdkXEvent* xevent, GdkEvent* event, gpointer data) +{ + SuilX11Wrapper* wrap = (SuilX11Wrapper*)data; + XEvent* ev = (XEvent*)xevent; + if (wrap->instance && + wrap->instance->handle && + (ev->type == KeyPress || ev->type == KeyRelease)) { + // Forward keyboard events to UI window + XSendEvent(ev->xkey.display, (Window)wrap->instance->ui_widget, 1, 0, ev); + XSync(ev->xkey.display, TRUE); + } + return GDK_FILTER_CONTINUE; +} +#endif + static gboolean on_plug_removed(GtkSocket* sock, gpointer data) { SuilX11Wrapper* const self = SUIL_X11_WRAPPER(sock); +#ifdef SUIL_FORWARD_KEYS + GdkWindow* window = gtk_widget_get_window(GTK_WIDGET(self)); + gdk_window_remove_filter(window, event_filter, self); +#endif + if (self->instance->handle) { self->instance->descriptor->cleanup(self->instance->handle); self->instance->handle = NULL; @@ -130,23 +152,6 @@ wrapper_free(SuilWrapper* wrapper) } } -#ifdef SUIL_FORWARD_KEYS -static GdkFilterReturn -event_filter(GdkXEvent* xevent, GdkEvent* event, gpointer data) -{ - SuilX11Wrapper* wrap = (SuilX11Wrapper*)data; - XEvent* ev = (XEvent*)xevent; - if (wrap->instance && - wrap->instance->handle && - (ev->type == KeyPress || ev->type == KeyRelease)) { - // Forward keyboard events to UI window - XSendEvent(ev->xkey.display, (Window)wrap->instance->ui_widget, 1, 0, ev); - XSync(ev->xkey.display, TRUE); - } - return GDK_FILTER_CONTINUE; -} -#endif - SUIL_LIB_EXPORT SuilWrapper* suil_wrapper_new(SuilHost* host, |