summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/win_in_gtk2.c26
-rw-r--r--src/x11_in_gtk2.c17
2 files changed, 30 insertions, 13 deletions
diff --git a/src/win_in_gtk2.c b/src/win_in_gtk2.c
index 8367996..159639a 100644
--- a/src/win_in_gtk2.c
+++ b/src/win_in_gtk2.c
@@ -65,19 +65,6 @@ suil_win_wrapper_init(SuilWinWrapper* self)
self->instance = NULL;
}
-GdkFilterReturn
-event_filter(GdkXEvent* xevent, GdkEvent* event, gpointer data)
-{
- SuilWinWrapper* wrap = (SuilWinWrapper*)data;
- MSG* msg = (MSG*)xevent;
- if (msg->message == WM_KEYDOWN || msg->message == WM_KEYUP) {
- // Forward keyboard events to UI window
- PostMessage((HWND)wrap->instance->ui_widget,
- msg->message, msg->wParam, msg->lParam);
- }
- return GDK_FILTER_CONTINUE;
-}
-
static int
wrapper_resize(LV2UI_Feature_Handle handle, int width, int height)
{
@@ -107,6 +94,19 @@ wrapper_free(SuilWrapper* wrapper)
}
}
+static GdkFilterReturn
+event_filter(GdkXEvent* xevent, GdkEvent* event, gpointer data)
+{
+ SuilWinWrapper* wrap = (SuilWinWrapper*)data;
+ MSG* msg = (MSG*)xevent;
+ if (msg->message == WM_KEYDOWN || msg->message == WM_KEYUP) {
+ // Forward keyboard events to UI window
+ PostMessage((HWND)wrap->instance->ui_widget,
+ msg->message, msg->wParam, msg->lParam);
+ }
+ return GDK_FILTER_CONTINUE;
+}
+
SUIL_API
SuilWrapper*
suil_wrapper_new(SuilHost* host,
diff --git a/src/x11_in_gtk2.c b/src/x11_in_gtk2.c
index abb58f6..c2c73e3 100644
--- a/src/x11_in_gtk2.c
+++ b/src/x11_in_gtk2.c
@@ -17,6 +17,7 @@
#include <string.h>
#include <gtk/gtk.h>
+#include <gdk/gdkx.h>
#include "./suil_internal.h"
@@ -129,6 +130,19 @@ wrapper_free(SuilWrapper* wrapper)
}
}
+static GdkFilterReturn
+event_filter(GdkXEvent* xevent, GdkEvent* event, gpointer data)
+{
+ SuilX11Wrapper* wrap = (SuilX11Wrapper*)data;
+ XEvent* ev = (XEvent*)xevent;
+ if (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;
+}
+
SUIL_API
SuilWrapper*
suil_wrapper_new(SuilHost* host,
@@ -150,6 +164,9 @@ suil_wrapper_new(SuilHost* host,
wrapper->resize.handle = wrap;
wrapper->resize.ui_resize = wrapper_resize;
+ GdkWindow* window = gtk_widget_get_window(GTK_WIDGET(wrap));
+ gdk_window_add_filter(window, event_filter, wrap);
+
suil_add_feature(features, &n_features, LV2_UI__parent,
(void*)(intptr_t)gtk_plug_get_id(wrap->plug));