diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 000000000..a81bc8174 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "src/3rdparty/qt5-x11embed"] + path = src/3rdparty/qt5-x11embed + url = https://github.com/Lukas-W/qt5-x11embed.git diff --git a/.travis/linux..install.sh b/.travis/linux..install.sh index f5988a83d..cf446fb8c 100644 --- a/.travis/linux..install.sh +++ b/.travis/linux..install.sh @@ -2,11 +2,13 @@ PACKAGES="cmake libsndfile-dev fftw3-dev libvorbis-dev libogg-dev libmp3lame-dev libasound2-dev libjack-dev libsdl-dev libsamplerate0-dev libstk0-dev - libfluidsynth-dev portaudio19-dev wine-dev g++-multilib libfltk1.3-dev + libfluidsynth-dev portaudio19-dev g++-multilib libfltk1.3-dev libgig-dev libsoundio-dev" +VST_PACKAGES="wine-dev libqt5x11extras5-dev qtbase5-private-dev libxcb-util0-dev libxcb-keysyms1-dev" + # Help with unmet dependencies -PACKAGES="$PACKAGES libjack0" +PACKAGES="$PACKAGES $VST_PACKAGES libjack0" if [ $QT5 ]; then PACKAGES="$PACKAGES qtbase5-dev qttools5-dev-tools qttools5-dev" diff --git a/include/RemotePlugin.h b/include/RemotePlugin.h index f3bc718b5..a23212018 100644 --- a/include/RemotePlugin.h +++ b/include/RemotePlugin.h @@ -796,19 +796,6 @@ public: unlock(); } - void showUI() - { - lock(); - sendMessage( IdShowUI ); - unlock(); - } - - void hideUI() - { - lock(); - sendMessage( IdHideUI ); - unlock(); - } void toggleUI() { @@ -841,6 +828,9 @@ public: m_commMutex.unlock(); } +public slots: + void showUI(); + void hideUI(); protected: inline void setSplittedChannels( bool _on ) diff --git a/plugins/vst_base/CMakeLists.txt b/plugins/vst_base/CMakeLists.txt index 995731a5f..bf98abfa0 100644 --- a/plugins/vst_base/CMakeLists.txt +++ b/plugins/vst_base/CMakeLists.txt @@ -28,6 +28,7 @@ SET(REMOTE_VST_PLUGIN_FILEPATH "RemoteVstPlugin" CACHE STRING "Relative file pat ADD_DEFINITIONS(-DREMOTE_VST_PLUGIN_FILEPATH="${REMOTE_VST_PLUGIN_FILEPATH}") BUILD_PLUGIN(vstbase vst_base.cpp VstPlugin.cpp VstPlugin.h communication.h MOCFILES VstPlugin.h) +TARGET_LINK_LIBRARIES(vstbase qx11embedcontainer) IF(LMMS_BUILD_LINUX AND NOT WANT_VST_NOWINE) diff --git a/plugins/vst_base/RemoteVstPlugin.cpp b/plugins/vst_base/RemoteVstPlugin.cpp index a08af9826..e29487839 100644 --- a/plugins/vst_base/RemoteVstPlugin.cpp +++ b/plugins/vst_base/RemoteVstPlugin.cpp @@ -454,6 +454,15 @@ bool RemoteVstPlugin::processMessage( const message & _m ) { switch( _m.id ) { + +#ifdef LMMS_EMBED_VST_X11 + case IdShowUI: + ShowWindow( m_window, SW_SHOWNORMAL ); + UpdateWindow( m_window ); + break; +#endif + +#ifndef LMMS_EMBED_VST case IdShowUI: initEditor(); break; @@ -477,6 +486,7 @@ bool RemoteVstPlugin::processMessage( const message & _m ) sendMessage( message( IdIsUIVisible ) .addInt( m_window ? 1 : 0 ) ); break; +#endif case IdVstLoadPlugin: init( _m.getString() ); @@ -667,7 +677,7 @@ void RemoteVstPlugin::initEditor() wc.hInstance = hInst; wc.hIcon = LoadIcon( NULL, IDI_APPLICATION ); wc.hCursor = LoadCursor( NULL, IDC_ARROW ); - wc.hbrBackground = (HBRUSH) GetStockObject( BLACK_BRUSH ); + wc.hbrBackground = NULL; wc.lpszMenuName = NULL; wc.lpszClassName = "LVSL"; @@ -705,7 +715,10 @@ void RemoteVstPlugin::initEditor() SWP_NOMOVE | SWP_NOZORDER ); pluginDispatch( effEditTop ); +#ifndef LMMS_EMBED_VST_X11 ShowWindow( m_window, SW_SHOWNORMAL ); +#endif + #ifdef LMMS_BUILD_LINUX m_windowID = (intptr_t) GetProp( m_window, "__wine_x11_whole_window" ); #else diff --git a/plugins/vst_base/VstPlugin.cpp b/plugins/vst_base/VstPlugin.cpp index 463b13602..a78116f49 100644 --- a/plugins/vst_base/VstPlugin.cpp +++ b/plugins/vst_base/VstPlugin.cpp @@ -36,6 +36,7 @@ #include #include #else +#include "X11EmbedContainer.h" #include #endif #else @@ -55,8 +56,7 @@ #include "templates.h" #include "FileDialog.h" - -#if QT_VERSION < 0x050000 +#ifdef LMMS_EMBED_VST class vstSubWin : public QMdiSubWindow { public: @@ -175,8 +175,6 @@ void VstPlugin::tryLoad( const QString &remoteVstPluginExecutable ) } - - #ifdef LMMS_EMBED_VST void VstPlugin::showEditor( QWidget * _parent, bool isEffect ) { @@ -206,49 +204,47 @@ void VstPlugin::showEditor( QWidget * _parent, bool isEffect ) return; } -#if QT_VERSION < 0x050000 - m_pluginWidget = new QWidget( _parent ); - m_pluginWidget->setFixedSize( m_pluginGeometry ); - m_pluginWidget->setWindowTitle( name() ); - if( _parent == NULL ) - { - vstSubWin * sw = new vstSubWin( - gui->mainWindow()->workspace() ); - if( isEffect ) - { - sw->setAttribute( Qt::WA_TranslucentBackground ); - sw->setWindowFlags( Qt::FramelessWindowHint ); - sw->setWidget( m_pluginWidget ); - QX11EmbedContainer * xe = new QX11EmbedContainer( sw ); - xe->embedClient( m_pluginWindowID ); - xe->setFixedSize( m_pluginGeometry ); - xe->show(); - } - else - { - sw->setWindowFlags( Qt::WindowCloseButtonHint ); - sw->setWidget( m_pluginWidget ); + vstSubWin * sw = new vstSubWin( gui->mainWindow()->workspace() ); + //auto sw = new SubWindow(); - QX11EmbedContainer * xe = new QX11EmbedContainer( sw ); - xe->embedClient( m_pluginWindowID ); - xe->setFixedSize( m_pluginGeometry ); - xe->move( 4, 24 ); - xe->show(); - } - } +#ifdef LMMS_EMBED_VST_X11 + QX11EmbedContainer * container = new QX11EmbedContainer( sw ); + connect(container, SIGNAL(clientIsEmbedded()), this, SLOT(showUI())); + container->embedClient( m_pluginWindowID ); #else - QWindow * window = QWindow::fromWinId( m_pluginWindowID ); - m_pluginWidget = QWidget::createWindowContainer( window, _parent, - Qt::Window ); - m_pluginWidget->setFixedSize( m_pluginGeometry ); - m_pluginWidget->setWindowTitle( name() ); + 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(); + //m_pluginWidget->show(); } @@ -268,7 +264,7 @@ void VstPlugin::hideEditor() void VstPlugin::toggleEditor() { - QWidget * w = m_pluginWidget; + QWidget * w = pluginWidget(); if( w ) { w->setVisible( !w->isVisible() ); diff --git a/plugins/vst_base/VstPlugin.h b/plugins/vst_base/VstPlugin.h index 0078a9f3f..f30335bda 100644 --- a/plugins/vst_base/VstPlugin.h +++ b/plugins/vst_base/VstPlugin.h @@ -96,7 +96,7 @@ public: inline QWidget * pluginWidget( bool _top_widget = true ) { -#if QT_VERSION < 0x050000 +#ifdef LMMS_EMBED_VST if( _top_widget && m_pluginWidget ) { if( m_pluginWidget->parentWidget() ) diff --git a/src/3rdparty/CMakeLists.txt b/src/3rdparty/CMakeLists.txt new file mode 100644 index 000000000..f1d7a9ba1 --- /dev/null +++ b/src/3rdparty/CMakeLists.txt @@ -0,0 +1,8 @@ +include(ExternalProject) + +IF(QT5 AND LMMS_BUILD_LINUX) + set(BUILD_SHARED_LIBS OFF) + add_subdirectory(qt5-x11embed) +ELSE() + add_library(qx11embedcontainer STATIC /dev/null) +ENDIF() diff --git a/src/3rdparty/qt5-x11embed b/src/3rdparty/qt5-x11embed new file mode 160000 index 000000000..dad35c07c --- /dev/null +++ b/src/3rdparty/qt5-x11embed @@ -0,0 +1 @@ +Subproject commit dad35c07cdb704f3e9306e6301f7eb4c098552a2 diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 154ff4f85..82dd14d7a 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -14,6 +14,7 @@ IF(LMMS_BUILD_APPLE) SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++") ENDIF() +ADD_SUBDIRECTORY(3rdparty) ADD_SUBDIRECTORY(core) ADD_SUBDIRECTORY(gui) ADD_SUBDIRECTORY(tracks) @@ -132,7 +133,7 @@ IF(LMMS_BUILD_HAIKU) SET(EXTRA_LIBRARIES "-lnetwork") ENDIF() -SET(LMMS_REQUIRED_LIBS +SET(LMMS_REQUIRED_LIBS ${LMMS_REQUIRED_LIBS} ${CMAKE_THREAD_LIBS_INIT} ${QT_LIBRARIES} ${ASOUND_LIBRARY} diff --git a/src/core/RemotePlugin.cpp b/src/core/RemotePlugin.cpp index bb7e39c6a..064d77b2c 100644 --- a/src/core/RemotePlugin.cpp +++ b/src/core/RemotePlugin.cpp @@ -392,6 +392,20 @@ void RemotePlugin::processMidiEvent( const MidiEvent & _e, unlock(); } +void RemotePlugin::showUI() +{ + lock(); + sendMessage( IdShowUI ); + unlock(); +} + +void RemotePlugin::hideUI() +{ + lock(); + sendMessage( IdHideUI ); + unlock(); +} + diff --git a/src/gui/SubWindow.cpp b/src/gui/SubWindow.cpp index e92c4cbcb..284e116d8 100644 --- a/src/gui/SubWindow.cpp +++ b/src/gui/SubWindow.cpp @@ -97,7 +97,10 @@ void SubWindow::paintEvent( QPaintEvent * ) { QPainter p( this ); QRect rect( 0, 0, width(), m_titleBarHeight ); - bool isActive = SubWindow::mdiArea()->activeSubWindow() == this; + + bool isActive = mdiArea() + ? mdiArea()->activeSubWindow() == this + : false; p.fillRect( rect, isActive ? activeColor() : p.pen().brush() );