Skip to content

Commit

Permalink
Preserve VST GUI positions and keep them on top
Browse files Browse the repository at this point in the history
  • Loading branch information
DomClark committed Apr 20, 2018
1 parent eb560a7 commit c4d610e
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 9 deletions.
41 changes: 32 additions & 9 deletions plugins/vst_base/RemoteVstPlugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,8 @@ class RemoteVstPlugin : public RemotePluginClient

void init( const std::string & _plugin_file );
void initEditor();
void showEditor();
void hideEditor();
void destroyEditor();

virtual void process( const sampleFrame * _in, sampleFrame * _out );
Expand Down Expand Up @@ -507,27 +509,28 @@ bool RemoteVstPlugin::processMessage( const message & _m )
switch( _m.id )
{
case IdShowUI:
initEditor();
showEditor();
return true;

case IdHideUI:
destroyEditor();
hideEditor();
return true;

case IdToggleUI:
if( m_window )
if( m_window && IsWindowVisible( m_window ) )
{
destroyEditor();
hideEditor();
}
else
{
initEditor();
showEditor();
}
return true;

case IdIsUIVisible:
bool visible = m_window && IsWindowVisible( m_window );
sendMessage( message( IdIsUIVisible )
.addInt( m_window ? 1 : 0 ) );
.addInt( visible ? 1 : 0 ) );
return true;
}
}
Expand Down Expand Up @@ -709,7 +712,7 @@ void RemoteVstPlugin::initEditor()
dwStyle = WS_OVERLAPPEDWINDOW & ~WS_MAXIMIZEBOX;
}

m_window = CreateWindowEx( 0, "LVSL", pluginName(),
m_window = CreateWindowEx( WS_EX_APPWINDOW, "LVSL", pluginName(),
dwStyle,
0, 0, 10, 10, NULL, NULL, hInst, NULL );
if( m_window == NULL )
Expand All @@ -733,7 +736,7 @@ void RemoteVstPlugin::initEditor()
pluginDispatch( effEditTop );

if (! EMBED) {
ShowWindow( m_window, SW_SHOWNORMAL );
showEditor();
}

#ifdef LMMS_BUILD_LINUX
Expand All @@ -747,6 +750,26 @@ void RemoteVstPlugin::initEditor()



void RemoteVstPlugin::showEditor() {
if( !EMBED && !HEADLESS && m_window )
{
ShowWindow( m_window, SW_SHOWNORMAL );
}
}




void RemoteVstPlugin::hideEditor() {
if( !EMBED && !HEADLESS && m_window )
{
ShowWindow( m_window, SW_HIDE );
}
}




void RemoteVstPlugin::destroyEditor()
{
if( m_window == NULL )
Expand Down Expand Up @@ -1948,7 +1971,7 @@ LRESULT CALLBACK RemoteVstPlugin::wndProc( HWND hwnd, UINT uMsg,
}
else if( uMsg == WM_SYSCOMMAND && wParam == SC_CLOSE )
{
__plugin->destroyEditor();
__plugin->hideEditor();
return 0;
}

Expand Down
10 changes: 10 additions & 0 deletions plugins/vst_base/VstPlugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,16 @@ bool VstPlugin::processMessage( const message & _m )

case IdVstPluginWindowID:
m_pluginWindowID = _m.getInt();
#ifdef LMMS_BUILD_WIN32
if( m_embedMethod == "none" )
{
// We're changing the owner, not the parent,
// so this is legal despite MSDN's warning
SetWindowLongPtr( (HWND)(intptr_t) m_pluginWindowID,
GWLP_HWNDPARENT,
(LONG_PTR) gui->mainWindow()->winId() );
}
#endif
break;

case IdVstPluginEditorGeometry:
Expand Down

0 comments on commit c4d610e

Please sign in to comment.