summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--AUTHORS1
-rw-r--r--NEWS3
-rw-r--r--src/x11_in_gtk2.c39
3 files changed, 25 insertions, 18 deletions
diff --git a/AUTHORS b/AUTHORS
index 70cccdb..2a82a14 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -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
diff --git a/NEWS b/NEWS
index 05183e9..4df90a0 100644
--- a/NEWS
+++ b/NEWS
@@ -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,