diff --git a/plugins/vst_base/RemoteVstPlugin.cpp b/plugins/vst_base/RemoteVstPlugin.cpp index bca09b1a2..4e8f34ac8 100644 --- a/plugins/vst_base/RemoteVstPlugin.cpp +++ b/plugins/vst_base/RemoteVstPlugin.cpp @@ -134,6 +134,8 @@ public: 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; } diff --git a/plugins/vst_base/VstPlugin.cpp b/plugins/vst_base/VstPlugin.cpp index d9d9cc9f7..26c789275 100644 --- a/plugins/vst_base/VstPlugin.cpp +++ b/plugins/vst_base/VstPlugin.cpp @@ -34,9 +34,9 @@ #include #ifdef LMMS_BUILD_LINUX +# include # if QT_VERSION < 0x050000 # include -# include # else # include "X11EmbedContainer.h" # include @@ -62,6 +62,10 @@ #include "templates.h" #include "FileDialog.h" +#ifdef LMMS_BUILD_LINUX +# include +#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: