From d367d94c7febe766afc7356e874ba4eb36fcae48 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Wed, 29 Dec 2010 21:58:44 +0000 Subject: [PATCH] Extremely hacky but somewhat functional passing of keys to VST plugin UIs. Sort-of fixes #3630. git-svn-id: svn://localhost/ardour2/branches/3.0@8371 d708f5d6-7413-0410-9779-e7cbd77b26cf --- gtk2_ardour/vst_pluginui.cc | 9 +++++++++ gtk2_ardour/vst_pluginui.h | 3 +++ libs/fst/fst.h | 1 + libs/fst/vstwin.c | 23 ++++++++++++++++++++--- 4 files changed, 33 insertions(+), 3 deletions(-) diff --git a/gtk2_ardour/vst_pluginui.cc b/gtk2_ardour/vst_pluginui.cc index b6902445f3..80973eb0e2 100644 --- a/gtk2_ardour/vst_pluginui.cc +++ b/gtk2_ardour/vst_pluginui.cc @@ -39,6 +39,7 @@ VSTPluginUI::VSTPluginUI (boost::shared_ptr pi, boost::shared_ptr< preset_box.set_spacing (6); preset_box.set_border_width (6); + preset_box.pack_end (focus_button, false, false); preset_box.pack_end (bypass_button, false, false, 10); preset_box.pack_end (delete_button, false, false); preset_box.pack_end (save_button, false, false); @@ -134,6 +135,14 @@ VSTPluginUI::configure_handler (GdkEventConfigure* ev, Gtk::Socket *socket) return false; } +void +VSTPluginUI::forward_key_event (GdkEventKey* ev) +{ + if (ev->type == GDK_KEY_PRESS) { + vst->fst()->pending_key = ev->keyval; + } +} + typedef int (*error_handler_t)( Display *, XErrorEvent *); static Display *the_gtk_display; static error_handler_t wine_error_handler; diff --git a/gtk2_ardour/vst_pluginui.h b/gtk2_ardour/vst_pluginui.h index c8666a4da9..cb7743439f 100644 --- a/gtk2_ardour/vst_pluginui.h +++ b/gtk2_ardour/vst_pluginui.h @@ -32,6 +32,9 @@ class VSTPluginUI : public PlugUIBase, public Gtk::VBox int package (Gtk::Window&); + void forward_key_event (GdkEventKey *); + bool non_gtk_gui () const { return true; } + private: boost::shared_ptr vst; Gtk::Socket socket; diff --git a/libs/fst/fst.h b/libs/fst/fst.h index 28ee49bd01..25fef9dd36 100644 --- a/libs/fst/fst.h +++ b/libs/fst/fst.h @@ -89,6 +89,7 @@ struct _FST int current_program; float *want_params; float *set_params; + int pending_key; int dispatcher_wantcall; int dispatcher_opcode; diff --git a/libs/fst/vstwin.c b/libs/fst/vstwin.c index 007a825d53..f1553821ad 100644 --- a/libs/fst/vstwin.c +++ b/libs/fst/vstwin.c @@ -34,11 +34,11 @@ static int gui_quit = 0; static LRESULT WINAPI my_window_proc (HWND w, UINT msg, WPARAM wp, LPARAM lp) { -#if 0 +#if 0 if (msg != WM_TIMER) { fst_error ("window callback handler, msg = 0x%x win=%p\n", msg, w); } -#endif +#endif switch (msg) { case WM_KEYUP: @@ -73,6 +73,7 @@ fst_new () fst->want_program = -1; fst->want_chunk = 0; fst->current_program = -1; + fst->pending_key = 0; return fst; } @@ -204,10 +205,26 @@ again: } pthread_mutex_unlock (&fst->lock); + } pthread_mutex_unlock (&plugin_mutex); - + } + + + for (fst = fst_first; fst; fst = fst->next) { + + if (fst->pending_key) { + msg.message = WM_CHAR; + msg.hwnd = GetFocus (); + msg.wParam = fst->pending_key; + msg.lParam = 0; + DispatchMessageA (&msg); + fst->pending_key = 0; + } + + } + } return 0;