Prepare moving to a dedicated x-thread signal for VST UI resizing

(this changes the internal API, pending follow-up GUI update)
This commit is contained in:
Robin Gareus 2017-03-07 03:22:13 +01:00
parent 50f408adf2
commit 4b982ef895
4 changed files with 70 additions and 41 deletions

View File

@ -62,6 +62,7 @@ public:
std::set<Evoral::Parameter> automatable() const;
PBD::Signal0<void> LoadPresetProgram;
PBD::Signal0<void> VSTSizeWindow;
bool parameter_is_audio (uint32_t) const { return false; }
bool parameter_is_control (uint32_t) const { return true; }

View File

@ -77,24 +77,21 @@ typedef struct _VSTHandle VSTHandle;
struct LIBARDOUR_API _VSTState
{
AEffect* plugin;
AEffect* plugin;
VSTHandle* handle;
audioMasterCallback amc;
/* Linux */
void* gtk_window_parent;
int xid; ///< X11 XWindow (wine + lxvst)
/* LXVST/X11 */
int linux_window; ///< The plugin's parent X11 XWindow
int linux_plugin_ui_window; ///< The ID of the plugin UI window created by the plugin
void (* eventProc) (void * event); ///< X11 UI _XEventProc
/* Windows */
void* windows_window;
int xid; ///< X11 XWindow
int want_resize; ///< Set to signal the plugin resized its UI
void* extra_data; ///< Pointer to any extra data
void * event_callback_thisptr;
void (* eventProc) (void * event);
VSTHandle* handle;
int width;
int height;
@ -107,33 +104,32 @@ struct LIBARDOUR_API _VSTState
int vst_version;
int has_editor;
int program_set_without_editor;
int program_set_without_editor;
int want_program;
int want_chunk;
int n_pending_keys;
unsigned char* wanted_chunk;
int wanted_chunk_size;
float* want_params;
float* set_params;
int want_program;
int want_chunk;
int n_pending_keys;
unsigned char * wanted_chunk;
int wanted_chunk_size;
float * want_params;
float * set_params;
VSTKey pending_keys[16];
VSTKey pending_keys[16];
int dispatcher_wantcall;
int dispatcher_opcode;
int dispatcher_index;
int dispatcher_val;
void* dispatcher_ptr;
float dispatcher_opt;
int dispatcher_retval;
int dispatcher_wantcall;
int dispatcher_opcode;
int dispatcher_index;
int dispatcher_val;
void * dispatcher_ptr;
float dispatcher_opt;
int dispatcher_retval;
struct _VSTState * next;
pthread_mutex_t lock;
pthread_mutex_t state_lock;
pthread_cond_t window_status_change;
pthread_cond_t plugin_dispatcher_called;
pthread_cond_t window_created;
int been_activated;
struct _VSTState* next;
pthread_mutex_t lock;
pthread_mutex_t state_lock;
pthread_cond_t window_status_change;
pthread_cond_t plugin_dispatcher_called;
pthread_cond_t window_created;
int been_activated;
};
typedef struct _VSTState VSTState;

View File

@ -337,9 +337,14 @@ intptr_t Session::vst_callback (
case audioMasterSizeWindow:
SHOW_CALLBACK ("audioMasterSizeWindow");
if (plug && plug->state()) {
plug->state()->width = index;
plug->state()->height = value;
plug->state()->want_resize = 1;
if (plug->state()->width != index || plug->state()->height != value) {
plug->state()->width = index;
plug->state()->height = value;
#ifndef NDEBUG
printf ("audioMasterSizeWindow %d %d\n", plug->state()->width, plug->state()->height);
#endif
plug->VSTSizeWindow (); /* EMIT SIGNAL */
}
}
return 0;

View File

@ -48,6 +48,27 @@ vstedit_wndproc (HWND w, UINT msg, WPARAM wp, LPARAM lp)
case WM_KEYDOWN:
break;
case WM_SIZE:
#ifdef PLATFORM_WINDOWS
{
LRESULT rv = DefWindowProcA (w, msg, wp, lp);
RECT rect;
GetClientRect(w, &rect);
#ifndef NDEBUG
printf("VST WM_SIZE.. %ld %ld %ld %ld\n", rect.top, rect.left, (rect.right - rect.left), (rect.bottom - rect.top));
#endif
VSTState* fst = (VSTState*) GetProp (w, "fst_ptr");
if (fst) {
int32_t width = (rect.right - rect.left);
int32_t height = (rect.bottom - rect.top);
if (width > 0 && height > 0) {
fst->amc (fst->plugin, 15 /*audioMasterSizeWindow */, width, height, NULL, 0);
}
}
return rv;
}
#endif
break;
case WM_CLOSE:
/* we don't care about windows closing ...
* WM_CLOSE is used for minimizing the window.
@ -68,7 +89,7 @@ vstedit_wndproc (HWND w, UINT msg, WPARAM wp, LPARAM lp)
break;
}
return DefWindowProcA (w, msg, wp, lp );
return DefWindowProcA (w, msg, wp, lp);
}
@ -196,7 +217,7 @@ fst_new (void)
vststate_init (fst);
#ifdef PLATFORM_WINDOWS
fst->voffset = 50;
fst->voffset = 45;
fst->hoffset = 0;
#else /* linux + wine */
fst->voffset = 24;
@ -441,11 +462,16 @@ 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->hoffset, fst->height + fst->voffset, 0);
SetWindowPos ((HWND)(fst->windows_window),
HWND_TOP /*0*/,
fst->hoffset, fst->voffset,
fst->width, fst->height,
SWP_NOACTIVATE|SWP_NOOWNERZORDER);
#else /* linux + wine */
SetWindowPos ((HWND)(fst->windows_window), 0, 0, 0, fst->width + fst->hoffset, fst->height + fst->voffset, 0);
#endif
ShowWindow ((HWND)(fst->windows_window), SW_SHOWNA);
UpdateWindow ((HWND)(fst->windows_window));
}
}
@ -534,6 +560,7 @@ fst_instantiate (VSTHandle* fhandle, audioMasterCallback amc, void* userptr)
}
fst = fst_new ();
fst->amc = amc;
if ((fst->plugin = fhandle->main_entry (amc)) == NULL) {
fst_error ("fst_instantiate: %s could not be instantiated\n", fhandle->name);