add API to use a plugin provided bypass control port
[ardour.git] / libs / fst / vstwin.c
index 37b6acd5e146229ab7627f2972ba0f74c6013a15..3a1f624934eff4335ce4d2d126ded79204d740a5 100644 (file)
@@ -8,7 +8,6 @@
 
 #include <pthread.h>
 static UINT_PTR idle_timer_id   = 0;
-//extern char* basename(char *path);  //
 
 #else /* linux + wine */
 
@@ -21,9 +20,11 @@ static unsigned int idle_id = 0;
 
 #endif
 
+#ifndef COMPILER_MSVC
 extern char * strdup (const char *);
+#endif
+
 #include <glib.h>
-#include <glibmm/miscutils.h>  //basename
 #include "fst.h"
 
 struct ERect {
@@ -225,7 +226,7 @@ fst_new (void)
        fst->n_pending_keys = 0;
        fst->has_editor = 0;
 #ifdef PLATFORM_WINDOWS
-       fst->voffset = 36;
+       fst->voffset = 50;
        fst->hoffset = 0;
 #else /* linux + wine */
        fst->voffset = 24;
@@ -321,20 +322,20 @@ fst_init (void* possible_hmodule)
        return 0;
 }
 
-#ifndef PLATFORM_WINDOWS /* linux + wine */
 void
 fst_start_threading(void)
 {
+#ifndef PLATFORM_WINDOWS /* linux + wine */
        if (idle_id == 0) {
                gui_quit = 0;
                idle_id = g_idle_add (g_idle_call, NULL);
        }
-}
 #endif
+}
 
-#ifndef PLATFORM_WINDOWS /* linux + wine */
 void
 fst_stop_threading(void) {
+#ifndef PLATFORM_WINDOWS /* linux + wine */
        if (idle_id != 0) {
                gui_quit = 1;
                PostQuitMessage (0);
@@ -342,8 +343,8 @@ fst_stop_threading(void) {
                //g_source_remove(idle_id);
                idle_id = 0;
        }
-}
 #endif
+}
 
 void
 fst_exit (void)
@@ -376,7 +377,7 @@ fst_run_editor (VSTState* fst, void* window_parent)
        if (fst->windows_window == NULL) {
                HMODULE hInst;
                HWND window;
-               struct ERect* er;
+               struct ERect* er = NULL;
 
                if (!(fst->plugin->flags & effFlagsHasEditor)) {
                        fst_error ("Plugin \"%s\" has no editor", fst->handle->name);
@@ -423,9 +424,10 @@ fst_run_editor (VSTState* fst, void* window_parent)
                fst->plugin->dispatcher (fst->plugin, effEditOpen, 0, 0, fst->windows_window, 0 );
                fst->plugin->dispatcher (fst->plugin, effEditGetRect, 0, 0, &er, 0 );
 
-               fst->width =  er->right-er->left;
-               fst->height =  er->bottom-er->top;
-
+               if (er != NULL) {
+                       fst->width = er->right - er->left;
+                       fst->height = er->bottom - er->top;
+               }
 
                fst->been_activated = TRUE;
 
@@ -467,7 +469,7 @@ fst_move_window_into_view (VSTState* fst)
 {
        if (fst->windows_window) {
 #ifdef PLATFORM_WINDOWS
-               SetWindowPos ((HWND)(fst->windows_window), 0, fst->hoffset, fst->voffset, fst->width, fst->height, 0);
+               SetWindowPos ((HWND)(fst->windows_window), 0, fst->hoffset, fst->voffset, fst->width + fst->hoffset, fst->height + fst->voffset, 0);
 #else /* linux + wine */
                SetWindowPos ((HWND)(fst->windows_window), 0, 0, 0, fst->width + fst->hoffset, fst->height + fst->voffset, 0);
 #endif
@@ -491,9 +493,8 @@ fst_load (const char *path)
        if ((strlen(path)) && (NULL != (fhandle = fst_handle_new ())))
        {
                char* period;
-               fhandle->nameptr = strdup (path);
                fhandle->path = strdup (path);
-               fhandle->name = strdup (Glib::path_get_basename(fhandle->nameptr).c_str());
+               fhandle->name = g_path_get_basename(path);
                if ((period = strrchr (fhandle->name, '.'))) {
                        *period = '\0';
                }
@@ -542,9 +543,8 @@ fst_unload (VSTHandle** fhandle)
                (*fhandle)->path = NULL;
        }
 
-       if ((*fhandle)->nameptr) {
-               free ((*fhandle)->nameptr);
-               (*fhandle)->nameptr = NULL;
+       if ((*fhandle)->name) {
+               free ((*fhandle)->name);
                (*fhandle)->name = NULL;
        }