diff --git a/include/ConfigManager.h b/include/ConfigManager.h index 4c0a73e05..ad3a12373 100644 --- a/include/ConfigManager.h +++ b/include/ConfigManager.h @@ -210,6 +210,8 @@ public: return m_recentlyOpenedProjects; } + QString vstEmbedMethod() const; + // returns true if the working dir (e.g. ~/lmms) exists on disk bool hasWorkingDir() const; diff --git a/include/RemotePlugin.h b/include/RemotePlugin.h index 3493a9e6f..58dcbc706 100644 --- a/include/RemotePlugin.h +++ b/include/RemotePlugin.h @@ -771,7 +771,7 @@ public: #endif } - bool init( const QString &pluginExecutable, bool waitForInitDoneMsg ); + bool init( const QString &pluginExecutable, bool waitForInitDoneMsg, QStringList extraArgs = {} ); inline void waitForHostInfoGotten() { @@ -798,7 +798,7 @@ public: } - void toggleUI() + virtual void toggleUI() { lock(); sendMessage( IdToggleUI ); @@ -830,8 +830,8 @@ public: } public slots: - void showUI(); - void hideUI(); + virtual void showUI(); + virtual void hideUI(); protected: inline void setSplittedChannels( bool _on ) diff --git a/include/SetupDialog.h b/include/SetupDialog.h index e34035d2e..ebaa90f01 100644 --- a/include/SetupDialog.h +++ b/include/SetupDialog.h @@ -204,7 +204,8 @@ private: MswMap m_midiIfaceSetupWidgets; trMap m_midiIfaceNames; - + QComboBox* m_vstEmbedComboBox; + QString m_vstEmbedMethod; } ; diff --git a/plugins/VstEffect/VstEffectControlDialog.cpp b/plugins/VstEffect/VstEffectControlDialog.cpp index 54260c278..3320b05ce 100644 --- a/plugins/VstEffect/VstEffectControlDialog.cpp +++ b/plugins/VstEffect/VstEffectControlDialog.cpp @@ -30,6 +30,7 @@ #include "VstEffectControlDialog.h" #include "VstEffect.h" +#include "ConfigManager.h" #include "PixmapButton.h" #include "embed.h" #include "ToolTip.h" @@ -43,9 +44,7 @@ VstEffectControlDialog::VstEffectControlDialog( VstEffectControls * _ctl ) : EffectControlDialog( _ctl ), -#ifdef LMMS_EMBED_VST m_pluginWidget( NULL ), -#endif m_plugin( NULL ), tbLabel( NULL ) { @@ -54,46 +53,43 @@ VstEffectControlDialog::VstEffectControlDialog( VstEffectControls * _ctl ) : l->setVerticalSpacing( 2 ); l->setHorizontalSpacing( 2 ); + bool embed_vst = ConfigManager::inst()->vstEmbedMethod() != "none"; + if( _ctl != NULL && _ctl->m_effect != NULL && _ctl->m_effect->m_plugin != NULL ) { m_plugin = _ctl->m_effect->m_plugin; -#ifdef LMMS_EMBED_VST - m_plugin->showEditor( NULL, true ); - m_pluginWidget = m_plugin->pluginWidget(); + + if (embed_vst) { + m_plugin->createUI( nullptr, true ); + m_pluginWidget = m_plugin->pluginWidget( false ); #ifdef LMMS_BUILD_WIN32 + if( !m_pluginWidget ) + { + m_pluginWidget = m_plugin->pluginWidget( false ); + } +#endif - if( !m_pluginWidget ) - { - m_pluginWidget = m_plugin->pluginWidget( false ); } -#endif - -#else // LMMS_EMBED_VST - m_plugin->showUI(); -#endif } -#ifdef LMMS_EMBED_VST - if( m_pluginWidget ) -#else - if( m_plugin ) -#endif + if ( m_plugin && (!embed_vst || m_pluginWidget) ) { setWindowTitle( m_plugin->name() ); setMinimumWidth( 250 ); QPushButton * btn = new QPushButton( tr( "Show/hide" ) ); -#ifdef LMMS_EMBED_VST - btn->setCheckable( true ); - connect( btn, SIGNAL( toggled( bool ) ), - SLOT( togglePluginUI( bool ) ) ); - emit btn->click(); -#else - connect( btn, SIGNAL( clicked( bool ) ), - SLOT( togglePluginUI( bool ) ) ); -#endif + + if (embed_vst) { + btn->setCheckable( true ); + btn->setChecked( true ); + connect( btn, SIGNAL( toggled( bool ) ), + SLOT( togglePluginUI( bool ) ) ); + } else { + connect( btn, SIGNAL( clicked( bool ) ), + SLOT( togglePluginUI( bool ) ) ); + } btn->setMinimumWidth( 78 ); btn->setMaximumWidth( 78 ); @@ -222,12 +218,15 @@ VstEffectControlDialog::VstEffectControlDialog( VstEffectControls * _ctl ) : m_savePresetButton->setMinimumHeight( 21 ); m_savePresetButton->setMaximumHeight( 21 ); -#ifdef LMMS_EMBED_VST - int newSize = m_pluginWidget->width() + 20; - newSize = (newSize < 250) ? 250 : newSize; -#else - int newSize = 250; -#endif + int newSize; + + if (embed_vst) { + newSize = m_pluginWidget->width() + 20; + newSize = (newSize < 250) ? 250 : newSize; + } else { + newSize = 250; + } + QWidget* resize = new QWidget(this); resize->resize( newSize, 10 ); QWidget* space0 = new QWidget(this); @@ -239,9 +238,9 @@ VstEffectControlDialog::VstEffectControlDialog( VstEffectControls * _ctl ) : l->addItem( new QSpacerItem( newSize - 20, 30, QSizePolicy::Fixed, QSizePolicy::Fixed ), 1, 0 ); l->addWidget( resize, 2, 0, 1, 1, Qt::AlignCenter ); -#ifdef LMMS_EMBED_VST - l->addWidget( m_pluginWidget, 3, 0, 1, 1, Qt::AlignCenter ); -#endif + if (embed_vst) { + l->addWidget( m_pluginWidget, 3, 0, 1, 1, Qt::AlignCenter ); + } l->setRowStretch( 5, 1 ); l->setColumnStretch( 1, 1 ); @@ -291,20 +290,17 @@ VstEffectControlDialog::~VstEffectControlDialog() void VstEffectControlDialog::togglePluginUI( bool checked ) { - if( m_plugin ) + if( !m_plugin ) { + return; + } + + if( ConfigManager::inst()->vstEmbedMethod() != "none" ) + { + m_pluginWidget->setVisible( checked ); + } + else { -#ifdef LMMS_EMBED_VST - if( checked ) - { - m_plugin->showEditor( NULL, true ); - } - else - { - m_plugin->hideEditor(); - } -#else m_plugin->toggleUI(); -#endif } } diff --git a/plugins/VstEffect/VstEffectControlDialog.h b/plugins/VstEffect/VstEffectControlDialog.h index 69263a804..ae86315ab 100644 --- a/plugins/VstEffect/VstEffectControlDialog.h +++ b/plugins/VstEffect/VstEffectControlDialog.h @@ -51,9 +51,7 @@ protected: virtual void paintEvent( QPaintEvent * _pe ); private: -#ifdef LMMS_EMBED_VST QWidget * m_pluginWidget; -#endif PixmapButton * m_openPresetButton; PixmapButton * m_rolLPresetButton; diff --git a/plugins/vestige/vestige.cpp b/plugins/vestige/vestige.cpp index 59f29be9e..4fa3bd4e9 100644 --- a/plugins/vestige/vestige.cpp +++ b/plugins/vestige/vestige.cpp @@ -262,11 +262,7 @@ void vestigeInstrument::loadFile( const QString & _file ) return; } -#ifdef LMMS_EMBED_VST - m_plugin->showEditor( NULL, false ); -#else m_plugin->showUI(); -#endif if( set_ch_name ) { @@ -743,11 +739,7 @@ void VestigeInstrumentView::toggleGUI( void ) { return; } -#ifdef LMMS_EMBED_VST - m_vi->m_plugin->toggleEditor(); -#else m_vi->m_plugin->toggleUI(); -#endif } diff --git a/plugins/vst_base/RemoteVstPlugin.cpp b/plugins/vst_base/RemoteVstPlugin.cpp index 8b594a4b2..3a5eeed00 100644 --- a/plugins/vst_base/RemoteVstPlugin.cpp +++ b/plugins/vst_base/RemoteVstPlugin.cpp @@ -66,7 +66,7 @@ #include #include #include - +#include #include @@ -103,8 +103,12 @@ struct ERect #include #endif +using namespace std; + static VstHostLanguages hlang = LanguageEnglish; +static bool EMBED = false; +static bool EMBED_X11 = false; class RemoteVstPlugin; @@ -521,24 +525,17 @@ RemoteVstPlugin::~RemoteVstPlugin() bool RemoteVstPlugin::processMessage( const message & _m ) { - switch( _m.id ) + if (! EMBED) { - -#ifdef LMMS_EMBED_VST_X11 - case IdShowUI: - ShowWindow( m_window, SW_SHOWNORMAL ); - UpdateWindow( m_window ); - break; -#endif - -#ifndef LMMS_EMBED_VST + switch( _m.id ) + { case IdShowUI: initEditor(); - break; + return true; case IdHideUI: destroyEditor(); - break; + return true; case IdToggleUI: if( m_window ) @@ -549,14 +546,23 @@ bool RemoteVstPlugin::processMessage( const message & _m ) { initEditor(); } - break; + return true; case IdIsUIVisible: sendMessage( message( IdIsUIVisible ) - .addInt( m_window ? 1 : 0 ) ); - break; -#endif + .addInt( m_window ? 1 : 0 ) ); + return true; + } + } + else if (EMBED && _m.id == IdShowUI) + { + ShowWindow( m_window, SW_SHOWNORMAL ); + UpdateWindow( m_window ); + return true; + } + switch( _m.id ) + { case IdVstLoadPlugin: init( _m.getString() ); break; @@ -757,12 +763,15 @@ void RemoteVstPlugin::initEditor() m_registeredWindowClass = true; } + DWORD dwStyle; + if (EMBED) { + dwStyle = WS_POPUP | WS_SYSMENU | WS_BORDER; + } else { + dwStyle = WS_OVERLAPPEDWINDOW & ~WS_MAXIMIZEBOX; + } + m_window = CreateWindowEx( 0, "LVSL", pluginName(), -#ifdef LMMS_EMBED_VST - WS_POPUP | WS_SYSMENU | WS_BORDER, -#else - WS_OVERLAPPEDWINDOW & ~WS_MAXIMIZEBOX, -#endif + dwStyle, 0, 0, 10, 10, NULL, NULL, hInst, NULL ); if( m_window == NULL ) { @@ -784,9 +793,9 @@ void RemoteVstPlugin::initEditor() SWP_NOMOVE | SWP_NOZORDER ); pluginDispatch( effEditTop ); -#ifndef LMMS_EMBED_VST_X11 - ShowWindow( m_window, SW_SHOWNORMAL ); -#endif + if (! EMBED) { + ShowWindow( m_window, SW_SHOWNORMAL ); + } #ifdef LMMS_BUILD_LINUX m_windowID = (intptr_t) GetProp( m_window, "__wine_x11_whole_window" ); @@ -2030,9 +2039,9 @@ LRESULT CALLBACK RemoteVstPlugin::messageWndProc( HWND hwnd, UINT uMsg, int main( int _argc, char * * _argv ) { #ifdef SYNC_WITH_SHM_FIFO - if( _argc < 3 ) + if( _argc < 4 ) #else - if( _argc < 2 ) + if( _argc < 3 ) #endif { fprintf( stderr, "not enough arguments\n" ); @@ -2064,6 +2073,35 @@ int main( int _argc, char * * _argv ) } #endif + { + #ifdef SYNC_WITH_SHM_FIFO + int embedMethodIndex = 3; + #else + int embedMethodIndex = 2; + #endif + std::string embedMethod = _argv[embedMethodIndex]; + + if ( embedMethod == "none" ) + { + cerr << "Starting detached." << endl; + EMBED = EMBED_X11 = false; + } + else if ( embedMethod == "qt" ) + { + cerr << "Starting using Qt-native embedding." << endl; + EMBED = true; EMBED_X11 = false; + } + else if ( embedMethod == "xembed" ) + { + cerr << "Starting using X11Embed protocol." << endl; + EMBED = true; EMBED_X11 = true; + } + else + { + cerr << "Unknown embed method " << embedMethod << ". Starting detached instead." << endl; + } + } + // constructor automatically will process messages until it receives // a IdVstLoadPlugin message and processes it #ifdef SYNC_WITH_SHM_FIFO diff --git a/plugins/vst_base/VstPlugin.cpp b/plugins/vst_base/VstPlugin.cpp index bb4116cc6..10863ad59 100644 --- a/plugins/vst_base/VstPlugin.cpp +++ b/plugins/vst_base/VstPlugin.cpp @@ -2,7 +2,7 @@ * VstPlugin.cpp - implementation of VstPlugin class * * Copyright (c) 2005-2014 Tobias Doerffel - * + * * This file is part of LMMS - https://lmms.io * * This program is free software; you can redistribute it and/or @@ -24,6 +24,7 @@ #include "VstPlugin.h" +#include #include #include #include @@ -56,7 +57,6 @@ #include "templates.h" #include "FileDialog.h" -#ifdef LMMS_EMBED_VST class vstSubWin : public QMdiSubWindow { public: @@ -78,9 +78,6 @@ public: e->ignore(); } } ; -#endif - - VstPlugin::VstPlugin( const QString & _plugin ) : @@ -136,7 +133,7 @@ VstPlugin::~VstPlugin() void VstPlugin::tryLoad( const QString &remoteVstPluginExecutable ) { - init( remoteVstPluginExecutable, false ); + init( remoteVstPluginExecutable, false, {ConfigManager::inst()->vstEmbedMethod()} ); waitForHostInfoGotten(); if( failed() ) @@ -175,79 +172,6 @@ void VstPlugin::tryLoad( const QString &remoteVstPluginExecutable ) } -#ifdef LMMS_EMBED_VST -void VstPlugin::showEditor( QWidget * _parent, bool isEffect ) -{ - QWidget * w = pluginWidget(); - if( w ) - { -#ifdef LMMS_BUILD_WIN32 - // hide sw, plugin window wrapper on win32 - // this is obtained from pluginWidget() - if( isEffect ) - { - w->setWindowFlags( Qt::FramelessWindowHint ); - w->setAttribute( Qt::WA_TranslucentBackground ); - } - else - { - w->setWindowFlags( Qt::WindowCloseButtonHint ); - } -#endif - w->show(); - return; - } - -#ifdef LMMS_BUILD_LINUX - if( m_pluginWindowID == 0 ) - { - return; - } - - vstSubWin * sw = new vstSubWin( gui->mainWindow()->workspace() ); - //auto sw = new SubWindow(); - -#ifdef LMMS_EMBED_VST_X11 - QX11EmbedContainer * container = new QX11EmbedContainer( sw ); - connect(container, SIGNAL(clientIsEmbedded()), this, SLOT(showUI())); - container->embedClient( m_pluginWindowID ); -#else - QWindow* vw = QWindow::fromWinId(m_pluginWindowID); - QWidget* container = QWidget::createWindowContainer(vw, sw ); - // TODO: Synchronize show - // Tell remote that it is embedded - // Wait for remote reply -#endif - - container->setFixedSize( m_pluginGeometry ); - container->setWindowTitle( name() ); - - if( _parent == NULL ) - { - m_pluginWidget = container; - - sw->setWidget(container); - - if( isEffect ) - { - sw->setAttribute( Qt::WA_TranslucentBackground ); - sw->setWindowFlags( Qt::FramelessWindowHint ); - } - else - { - sw->setWindowFlags( Qt::WindowCloseButtonHint ); - } - }; - -#ifdef LMMS_EMBED_VST_X11 -#endif - container->setFixedSize( m_pluginGeometry ); -#endif - - //m_pluginWidget->show(); -} - - void VstPlugin::hideEditor() @@ -270,26 +194,12 @@ void VstPlugin::toggleEditor() w->setVisible( !w->isVisible() ); } } -#endif void VstPlugin::loadSettings( const QDomElement & _this ) { -#ifdef LMMS_EMBED_VST - if( pluginWidget() != NULL ) - { - if( _this.attribute( "guivisible" ).toInt() ) - { - showEditor( NULL, false ); - } - else - { - hideEditor(); - } - } -#else if( _this.attribute( "guivisible" ).toInt() ) { showUI(); @@ -298,7 +208,6 @@ void VstPlugin::loadSettings( const QDomElement & _this ) { hideUI(); } -#endif const int num_params = _this.attribute( "numparams" ).toInt(); // if it exists try to load settings chunk @@ -331,18 +240,21 @@ void VstPlugin::loadSettings( const QDomElement & _this ) void VstPlugin::saveSettings( QDomDocument & _doc, QDomElement & _this ) { -#ifdef LMMS_EMBED_VST - if( pluginWidget() != NULL ) + if ( ConfigManager::inst()->vstEmbedMethod() != "none" ) { - _this.setAttribute( "guivisible", pluginWidget()->isVisible() ); + if( pluginWidget() != NULL ) + { + _this.setAttribute( "guivisible", pluginWidget()->isVisible() ); + } } -#else - int visible = isUIVisible(); - if ( visible != -1 ) + else { - _this.setAttribute( "guivisible", visible ); + int visible = isUIVisible(); + if ( visible != -1 ) + { + _this.setAttribute( "guivisible", visible ); + } } -#endif // try to save all settings in a chunk QByteArray chunk = saveChunk(); @@ -366,6 +278,18 @@ void VstPlugin::saveSettings( QDomDocument & _doc, QDomElement & _this ) _this.setAttribute( "program", currentProgram() ); } +void VstPlugin::toggleUI() +{ + if ( ConfigManager::inst()->vstEmbedMethod() == "none" ) + { + RemotePlugin::toggleUI(); + } + else if (pluginWidget()) + { + toggleEditor(); + } +} + @@ -437,6 +361,21 @@ void VstPlugin::setParameterDump( const QMap & _pdump ) unlock(); } +QWidget *VstPlugin::pluginWidget(bool _top_widget) +{ + if ( ConfigManager::inst()->vstEmbedMethod() != "none" ) + { + if( _top_widget && m_pluginWidget ) + { + if( m_pluginWidget->parentWidget() ) + { + return m_pluginWidget->parentWidget(); + } + } + } + return m_pluginWidget; +} + @@ -444,17 +383,17 @@ bool VstPlugin::processMessage( const message & _m ) { switch( _m.id ) { - case IdVstBadDllFormat: - m_badDllFormat = true; - break; + case IdVstBadDllFormat: + m_badDllFormat = true; + break; - case IdVstPluginWindowID: - m_pluginWindowID = _m.getInt(); - break; + case IdVstPluginWindowID: + m_pluginWindowID = _m.getInt(); + break; - case IdVstPluginEditorGeometry: - m_pluginGeometry = QSize( _m.getInt( 0 ), - _m.getInt( 1 ) ); + case IdVstPluginEditorGeometry: + m_pluginGeometry = QSize( _m.getInt( 0 ), + _m.getInt( 1 ) ); break; case IdVstPluginName: @@ -629,6 +568,60 @@ void VstPlugin::idleUpdate() unlock(); } +void VstPlugin::showUI() +{ + QString embedMethod = ConfigManager::inst()->vstEmbedMethod(); + if ( embedMethod == "none" ) + { + RemotePlugin::showUI(); + } + else + { + if (! pluginWidget()) { + createUI( NULL, false ); + } + + QWidget * w = pluginWidget(); + if( w ) + { +# ifdef LMMS_BUILD_WIN32 + // hide sw, plugin window wrapper on win32 + // this is obtained from pluginWidget() + if( isEffect ) + { + w->setWindowFlags( Qt::FramelessWindowHint ); + w->setAttribute( Qt::WA_TranslucentBackground ); + } + else + { + w->setWindowFlags( Qt::WindowCloseButtonHint ); + } +# endif + w->show(); + } + } +} + +void VstPlugin::hideUI() +{ + RemotePlugin::hideUI(); + if ( ConfigManager::inst()->vstEmbedMethod() == "none" ) + { + } + else if ( pluginWidget() != nullptr ) + { + hideEditor(); + } +} + +// X11Embed only +void VstPlugin::handleClientEmbed() +{ + lock(); + sendMessage( IdShowUI ); + unlock(); +} + void VstPlugin::loadChunk( const QByteArray & _chunk ) @@ -672,6 +665,66 @@ QByteArray VstPlugin::saveChunk() return a; } +void VstPlugin::createUI( QWidget * parent, bool isEffect ) +{ + if( m_pluginWindowID == 0 ) + { + return; + } + + QWidget* container = nullptr; + m_pluginSubWindow = new vstSubWin( gui->mainWindow()->workspace() ); + auto sw = m_pluginSubWindow.data(); + + QString embedMethod = ConfigManager::inst()->vstEmbedMethod(); + if (embedMethod == "qt" ) + { + QWindow* vw = QWindow::fromWinId(m_pluginWindowID); + container = QWidget::createWindowContainer(vw, sw ); + RemotePlugin::showUI(); + // TODO: Synchronize show + // Tell remote that it is embedded + // Wait for remote reply + } +#ifdef LMMS_BUILD_LINUX + else if (embedMethod == "xembed" ) + { + QX11EmbedContainer * embedContainer = new QX11EmbedContainer( sw ); + connect(embedContainer, SIGNAL(clientIsEmbedded()), this, SLOT(handleClientEmbed())); + embedContainer->embedClient( m_pluginWindowID ); + container = embedContainer; + } +#endif + else + { + qCritical() << "Unknown embed method" << embedMethod; + delete m_pluginSubWindow; + return; + } + + container->setFixedSize( m_pluginGeometry ); + container->setWindowTitle( name() ); + + if( parent == NULL ) + { + m_pluginWidget = container; + + sw->setWidget(container); + + if( isEffect ) + { + sw->setAttribute( Qt::WA_TranslucentBackground ); + sw->setWindowFlags( Qt::FramelessWindowHint ); + } + else + { + sw->setWindowFlags( Qt::WindowCloseButtonHint ); + } + }; + + container->setFixedSize( m_pluginGeometry ); +} + diff --git a/plugins/vst_base/VstPlugin.h b/plugins/vst_base/VstPlugin.h index f30335bda..09b001579 100644 --- a/plugins/vst_base/VstPlugin.h +++ b/plugins/vst_base/VstPlugin.h @@ -35,6 +35,8 @@ #include "JournallingObject.h" #include "communication.h" +class vstSubWin; + class PLUGIN_EXPORT VstPlugin : public RemotePlugin, public JournallingObject { @@ -52,11 +54,8 @@ public: return m_pluginWindowID != 0; } -#ifdef LMMS_EMBED_VST - void showEditor( QWidget * _parent = NULL, bool isEffect = false ); void hideEditor(); void toggleEditor(); -#endif inline const QString & name() const { @@ -94,19 +93,7 @@ public: void setParameterDump( const QMap & _pdump ); - inline QWidget * pluginWidget( bool _top_widget = true ) - { -#ifdef LMMS_EMBED_VST - if( _top_widget && m_pluginWidget ) - { - if( m_pluginWidget->parentWidget() ) - { - return m_pluginWidget->parentWidget(); - } - } -#endif - return m_pluginWidget; - } + QWidget * pluginWidget( bool _top_widget = true ); virtual void loadSettings( const QDomElement & _this ); virtual void saveSettings( QDomDocument & _doc, QDomElement & _this ); @@ -116,6 +103,9 @@ public: return "vstplugin"; } + void toggleUI() override; + + void createUI( QWidget *parent, bool isEffect ); public slots: void setTempo( bpm_t _bpm ); @@ -128,6 +118,10 @@ public slots: void setParam( int i, float f ); void idleUpdate(); + void showUI() override; + void hideUI() override; + + void handleClientEmbed(); private: void loadChunk( const QByteArray & _chunk ); @@ -135,6 +129,7 @@ private: QString m_plugin; QPointer m_pluginWidget; + QPointer m_pluginSubWindow; int m_pluginWindowID; QSize m_pluginGeometry; diff --git a/plugins/vst_base/communication.h b/plugins/vst_base/communication.h index ab7a97dfe..3e85007e7 100644 --- a/plugins/vst_base/communication.h +++ b/plugins/vst_base/communication.h @@ -30,8 +30,6 @@ #include "RemotePlugin.h" -//#define LMMS_EMBED_VST - struct VstParameterDumpItem { diff --git a/src/core/ConfigManager.cpp b/src/core/ConfigManager.cpp index 5ccb4d345..aceb57bc2 100644 --- a/src/core/ConfigManager.cpp +++ b/src/core/ConfigManager.cpp @@ -35,6 +35,10 @@ #include "lmmsversion.h" +#ifdef LMMS_BUILD_LINUX +#include +#endif + static inline QString ensureTrailingSlash( const QString & s ) { if( ! s.isEmpty() && !s.endsWith('/') && !s.endsWith('\\') ) @@ -186,6 +190,18 @@ QString ConfigManager::defaultVersion() const return LMMS_VERSION; } +QString ConfigManager::vstEmbedMethod() const +{ + QString defaultMethod = "qt"; +#ifdef LMMS_BUILD_LINUX + if (QX11Info::isPlatformX11()) { + defaultMethod = "xembed"; + } +#endif + + return value( "ui", "vstembedmethod", defaultMethod ); +} + bool ConfigManager::hasWorkingDir() const { return QDir( m_workingDir ).exists(); diff --git a/src/core/RemotePlugin.cpp b/src/core/RemotePlugin.cpp index ac2cf3f91..d0eafbfa3 100644 --- a/src/core/RemotePlugin.cpp +++ b/src/core/RemotePlugin.cpp @@ -164,8 +164,8 @@ RemotePlugin::~RemotePlugin() -bool RemotePlugin::init( const QString &pluginExecutable, - bool waitForInitDoneMsg ) +bool RemotePlugin::init(const QString &pluginExecutable, + bool waitForInitDoneMsg , QStringList extraArgs) { lock(); if( m_failed ) @@ -208,6 +208,7 @@ bool RemotePlugin::init( const QString &pluginExecutable, #else args << m_socketFile; #endif + args << extraArgs; #ifndef DEBUG_REMOTE_PLUGIN m_process.setProcessChannelMode( QProcess::ForwardedChannels ); m_process.setWorkingDirectory( QCoreApplication::applicationDirPath() ); diff --git a/src/gui/SetupDialog.cpp b/src/gui/SetupDialog.cpp index 879c1b7b9..9a4851b49 100644 --- a/src/gui/SetupDialog.cpp +++ b/src/gui/SetupDialog.cpp @@ -67,7 +67,9 @@ #include "MidiApple.h" #include "MidiDummy.h" - +#ifdef LMMS_BUILD_LINUX +#include +#endif inline void labelWidget( QWidget * _w, const QString & _txt ) { @@ -137,12 +139,14 @@ SetupDialog::SetupDialog( ConfigTabs _tab_to_open ) : m_displayWaveform(ConfigManager::inst()->value( "ui", "displaywaveform").toInt() ), m_disableAutoQuit(ConfigManager::inst()->value( "ui", - "disableautoquit").toInt() ) + "disableautoquit").toInt() ), + m_vstEmbedMethod(ConfigManager::inst()->value( "ui", + "vstembedmethod", "xembed")) { setWindowIcon( embed::getIconPixmap( "setup_general" ) ); setWindowTitle( tr( "Setup LMMS" ) ); setModal( true ); - setFixedSize( 452, 520 ); + setFixedSize( 452, 570 ); Engine::projectJournal()->setJournalling( false ); @@ -159,7 +163,7 @@ SetupDialog::SetupDialog( ConfigTabs _tab_to_open ) : m_tabBar->setFixedWidth( 72 ); QWidget * ws = new QWidget( settings ); - int wsHeight = 370; + int wsHeight = 420; #ifdef LMMS_HAVE_STK wsHeight += 50; #endif @@ -168,7 +172,7 @@ SetupDialog::SetupDialog( ConfigTabs _tab_to_open ) : #endif ws->setFixedSize( 360, wsHeight ); QWidget * general = new QWidget( ws ); - general->setFixedSize( 360, 240 ); + general->setFixedSize( 360, 290 ); QVBoxLayout * gen_layout = new QVBoxLayout( general ); gen_layout->setSpacing( 0 ); gen_layout->setMargin( 0 ); @@ -335,6 +339,19 @@ SetupDialog::SetupDialog( ConfigTabs _tab_to_open ) : misc_tw->setFixedHeight( YDelta*labelNumber + HeaderSize ); + TabWidget* embed_tw = new TabWidget( tr( "PLUGIN EMBEDDING" ), general); + embed_tw->setFixedHeight( 48 ); + m_vstEmbedComboBox = new QComboBox( embed_tw ); + m_vstEmbedComboBox->move( XDelta, YDelta ); + m_vstEmbedComboBox->addItem( tr( "No embedding" ), "none" ); + m_vstEmbedComboBox->addItem( tr( "Embed using Qt API" ), "qt" ); +#ifdef LMMS_BUILD_LINUX + if ( QX11Info::isPlatformX11() ) { + m_vstEmbedComboBox->addItem( tr( "Embed using XEmbed protocol" ), "xembed" ); + } +#endif + m_vstEmbedComboBox->setCurrentIndex( m_vstEmbedComboBox->findData( m_vstEmbedMethod ) ); + TabWidget * lang_tw = new TabWidget( tr( "LANGUAGE" ), general ); lang_tw->setFixedHeight( 48 ); QComboBox * changeLang = new QComboBox( lang_tw ); @@ -380,13 +397,15 @@ SetupDialog::SetupDialog( ConfigTabs _tab_to_open ) : gen_layout->addSpacing( 10 ); gen_layout->addWidget( misc_tw ); gen_layout->addSpacing( 10 ); + gen_layout->addWidget( embed_tw ); + gen_layout->addSpacing( 10 ); gen_layout->addWidget( lang_tw ); gen_layout->addStretch(); QWidget * paths = new QWidget( ws ); - int pathsHeight = 370; + int pathsHeight = 420; #ifdef LMMS_HAVE_STK pathsHeight += 55; #endif @@ -1044,6 +1063,8 @@ void SetupDialog::accept() ConfigManager::inst()->setValue( "ui", "disableautoquit", QString::number( m_disableAutoQuit ) ); ConfigManager::inst()->setValue( "app", "language", m_lang ); + ConfigManager::inst()->setValue( "ui", "vstembedmethod", + m_vstEmbedComboBox->currentData().toString() ); ConfigManager::inst()->setWorkingDir(QDir::fromNativeSeparators(m_workingDir));