Permalink
Browse files

Preserve VST GUI positions and keep them on top

  • Loading branch information...
DomClark authored and PhysSong committed Apr 20, 2018
1 parent ee18011 commit fcc883f8873974cdb8f3f09e715912a8ec039139
Showing with 53 additions and 10 deletions.
  1. +32 −9 plugins/vst_base/RemoteVstPlugin.cpp
  2. +21 −1 plugins/vst_base/VstPlugin.cpp
@@ -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 );
@@ -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;
}
}
@@ -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 )
@@ -733,7 +736,7 @@ void RemoteVstPlugin::initEditor()
pluginDispatch( effEditTop );
if (! EMBED) {
ShowWindow( m_window, SW_SHOWNORMAL );
showEditor();
}
#ifdef LMMS_BUILD_LINUX
@@ -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 )
@@ -1947,7 +1970,7 @@ LRESULT CALLBACK RemoteVstPlugin::wndProc( HWND hwnd, UINT uMsg,
}
else if( uMsg == WM_SYSCOMMAND && wParam == SC_CLOSE )
{
__plugin->destroyEditor();
__plugin->hideEditor();
return 0;
}
@@ -34,9 +34,9 @@
#include <QMdiSubWindow>
#ifdef LMMS_BUILD_LINUX
# include <QX11Info>
# if QT_VERSION < 0x050000
# include <QX11EmbedContainer>
# include <QX11Info>
# else
# include "X11EmbedContainer.h"
# include <QWindow>
@@ -62,6 +62,10 @@
#include "templates.h"
#include "FileDialog.h"
#ifdef LMMS_BUILD_LINUX
# include <X11/Xlib.h>
#endif
VstPlugin::VstPlugin( const QString & _plugin ) :
m_plugin( _plugin ),
@@ -324,6 +328,22 @@ bool VstPlugin::processMessage( const message & _m )
case IdVstPluginWindowID:
m_pluginWindowID = _m.getInt();
if( m_embedMethod == "none" )
{
#ifdef LMMS_BUILD_WIN32
// 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
#ifdef LMMS_BUILD_LINUX
XSetTransientForHint( QX11Info::display(),
m_pluginWindowID,
gui->mainWindow()->winId() );
#endif
}
break;
case IdVstPluginEditorGeometry:

0 comments on commit fcc883f

Please sign in to comment.