*/
-#include <fst.h>
+#include <gtkmm.h>
#include <gtk/gtk.h>
#include <gtk/gtksocket.h>
+#include "gtkmm2ext/gui_thread.h"
+#include "fst.h"
#include "ardour/plugin_insert.h"
#include "ardour/windows_vst_plugin.h"
#include "windows_vst_plugin_ui.h"
+#ifdef PLATFORM_WINDOWS
+#include <gdk/gdkwin32.h>
+#elif defined __APPLE__
+// TODO
+#else
#include <gdk/gdkx.h>
+#endif
using namespace Gtk;
using namespace ARDOUR;
using namespace PBD;
-WindowsVSTPluginUI::WindowsVSTPluginUI (boost::shared_ptr<PluginInsert> pi, boost::shared_ptr<VSTPlugin> vp)
+WindowsVSTPluginUI::WindowsVSTPluginUI (boost::shared_ptr<PluginInsert> pi, boost::shared_ptr<VSTPlugin> vp, GtkWidget *parent)
: VSTPluginUI (pi, vp)
{
- fst_run_editor (_vst->state(), NULL);
+#ifdef GDK_WINDOWING_WIN32
+ gtk_widget_realize(parent);
+ void* hWndHost = gdk_win32_drawable_get_handle(parent->window);
+
+ fst_run_editor (_vst->state(), hWndHost);
+ // TODO pack a placeholder (compare to VSTPluginUI::VSTPluginUI X11 socket)
+ // have placeholder use VSTPluginUI::get_preferred_height(), width()
+ // TODO pack plugin_analysis_expander at the bottom.
+#else
+ fst_run_editor (_vst->state(), NULL);
pack_start (plugin_analysis_expander, true, true);
+#endif
}
WindowsVSTPluginUI::~WindowsVSTPluginUI ()
{
+ fst_destroy_editor (_vst->state());
+
// plugin destructor destroys the custom GUI, via Windows fun-and-games,
// and then our PluginUIWindow does the rest
}
+void
+WindowsVSTPluginUI::top_box_allocated (Gtk::Allocation& a)
+{
+ int h = a.get_height() + 12; // 2 * 6px spacing
+ if (_vst->state()->voffset != h) {
+#ifndef NDEBUG
+ printf("WindowsVSTPluginUI:: update voffset to %d px\n", h);
+#endif
+ _vst->state()->voffset = h;
+ resize_callback ();
+ }
+}
+
+void
+WindowsVSTPluginUI::resize_callback ()
+{
+ void* gtk_parent_window = _vst->state()->gtk_window_parent;
+ if (gtk_parent_window) {
+ int width = _vst->state()->width + _vst->state()->hoffset;
+ int height = _vst->state()->height + _vst->state()->voffset;
+#ifndef NDEBUG
+ printf ("WindowsVSTPluginUI::resize_callback %d x %d\n", width, height);
+#endif
+ set_size_request (width, height);
+ ((Gtk::Window*) gtk_parent_window)->set_size_request (width, height);
+ ((Gtk::Window*) gtk_parent_window)->resize (width, height);
+ fst_move_window_into_view (_vst->state ());
+ }
+}
+
int
WindowsVSTPluginUI::package (Gtk::Window& win)
{
+#ifndef NDEBUG
+ printf ("WindowsVSTPluginUI::package\n");
+#endif
VSTPluginUI::package (win);
+ _vst->state()->gtk_window_parent = (void*) (&win);
- fst_move_window_into_view (_vst->state ());
+ _vst->VSTSizeWindow.connect (_resize_connection, invalidator (*this), boost::bind (&WindowsVSTPluginUI::resize_callback, this), gui_context());
+
+ resize_callback ();
return 0;
}
/* buffer full */
return;
}
-
+
int special_windows_key = 0;
int character_windows_key = 0;
-
+
switch (ev->keyval) {
case GDK_Left:
special_windows_key = 0x25;
character_windows_key = ev->keyval;
break;
}
-
+
fst->pending_keys[fst->n_pending_keys].special = special_windows_key;
fst->pending_keys[fst->n_pending_keys].character = character_windows_key;
fst->n_pending_keys++;
-
+
pthread_mutex_unlock (&fst->lock);
}
return _vst->state()->xid;
}
+#ifdef GDK_WINDOWING_X11
typedef int (*error_handler_t)( Display *, XErrorEvent *);
static Display *the_gtk_display;
static error_handler_t wine_error_handler;
return wine_error_handler (disp, ev);
}
}
+#endif
void
windows_vst_gui_init (int *argc, char **argv[])
{
- wine_error_handler = XSetErrorHandler (NULL);
gtk_init (argc, argv);
+
+#ifdef GDK_WINDOWING_X11
+ wine_error_handler = XSetErrorHandler (NULL);
the_gtk_display = gdk_x11_display_get_xdisplay (gdk_display_get_default());
gtk_error_handler = XSetErrorHandler (fst_xerror_handler);
+#endif
}