Make Dropdown menus at least as wide as the button
[ardour.git] / gtk2_ardour / windows_vst_plugin_ui.cc
index 0652168f5bb7f5173a0bcd3c46a49e80cd24e71d..52818909639c42ce1cf273cd65bc75923707bdd0 100644 (file)
 
 */
 
-#include <fst.h>
+#include <gtkmm.h>
 #include <gtk/gtk.h>
 #include <gtk/gtksocket.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());
 
+#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 ()
@@ -69,10 +86,10 @@ WindowsVSTPluginUI::forward_key_event (GdkEventKey* ev)
                /* buffer full */
                return;
        }
-       
+
        int special_windows_key = 0;
        int character_windows_key = 0;
-       
+
        switch (ev->keyval) {
        case GDK_Left:
                special_windows_key = 0x25;
@@ -94,11 +111,11 @@ WindowsVSTPluginUI::forward_key_event (GdkEventKey* ev)
                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);
 }
 
@@ -108,6 +125,7 @@ WindowsVSTPluginUI::get_XID ()
        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;
@@ -124,13 +142,17 @@ fst_xerror_handler (Display* disp, XErrorEvent* ev)
                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
 }