Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add X11EmbedContainer Qt5 port #3475

Closed
wants to merge 13 commits into from
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "src/3rdparty/qt5-x11embed"]
path = src/3rdparty/qt5-x11embed
url = https://github.com/Lukas-W/qt5-x11embed.git
6 changes: 4 additions & 2 deletions .travis/linux..install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@ set -e

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"
Expand Down
16 changes: 3 additions & 13 deletions include/RemotePlugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -787,19 +787,6 @@ class EXPORT RemotePlugin : public QObject, public RemotePluginBase
unlock();
}

void showUI()
{
lock();
sendMessage( IdShowUI );
unlock();
}

void hideUI()
{
lock();
sendMessage( IdHideUI );
unlock();
}

inline bool failed() const
{
Expand All @@ -816,6 +803,9 @@ class EXPORT RemotePlugin : public QObject, public RemotePluginBase
m_commMutex.unlock();
}

public slots:
void showUI();
void hideUI();

protected:
inline void setSplittedChannels( bool _on )
Expand Down
1 change: 1 addition & 0 deletions plugins/vst_base/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
10 changes: 6 additions & 4 deletions plugins/vst_base/RemoteVstPlugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -556,6 +556,11 @@ bool RemoteVstPlugin::processMessage( const message & _m )
break;
}

case IdShowUI:
ShowWindow( m_window, SW_SHOWNORMAL );
UpdateWindow( m_window );
break;

default:
return RemotePluginClient::processMessage( _m );
}
Expand Down Expand Up @@ -643,7 +648,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";

Expand Down Expand Up @@ -687,9 +692,6 @@ void RemoteVstPlugin::initEditor()
SWP_NOMOVE | SWP_NOZORDER );
pluginDispatch( effEditTop );

ShowWindow( m_window, SW_SHOWNORMAL );
UpdateWindow( m_window );

#ifdef LMMS_BUILD_LINUX
m_windowID = (intptr_t) GetProp( m_window, "__wine_x11_whole_window" );
#endif
Expand Down
37 changes: 13 additions & 24 deletions plugins/vst_base/VstPlugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,7 @@
#include <QMdiArea>
#include <QMdiSubWindow>
#ifdef LMMS_BUILD_LINUX
#if QT_VERSION < 0x050000
#include <QX11EmbedContainer>
#include <QX11Info>
#endif
#include "X11EmbedContainer.h"
#else
#include <QLayout>
#endif
Expand Down Expand Up @@ -232,39 +229,31 @@ void VstPlugin::showEditor( QWidget * _parent, bool isEffect )
return;
}

m_pluginWidget = new QWidget( _parent );
vstSubWin * sw = new vstSubWin( gui->mainWindow()->workspace() );

QX11EmbedContainer * xe = new QX11EmbedContainer(sw);
m_pluginWidget = xe;
m_pluginWidget->setFixedSize( m_pluginGeometry );
m_pluginWidget->setWindowTitle( name() );

connect(xe, SIGNAL(clientIsEmbedded()), this, SLOT(showUI()));

if( _parent == NULL )
{
vstSubWin * sw = new vstSubWin(
gui->mainWindow()->workspace() );
sw->setWidget( m_pluginWidget );

if( isEffect )
{
sw->setAttribute( Qt::WA_TranslucentBackground );
sw->setWindowFlags( Qt::FramelessWindowHint );
sw->setWidget( m_pluginWidget );
#if QT_VERSION < 0x050000
QX11EmbedContainer * xe = new QX11EmbedContainer( sw );
xe->embedClient( m_pluginWindowID );
xe->setFixedSize( m_pluginGeometry );
xe->show();
#endif
}
}
else
{
sw->setWindowFlags( Qt::WindowCloseButtonHint );
sw->setWidget( m_pluginWidget );

#if QT_VERSION < 0x050000
QX11EmbedContainer * xe = new QX11EmbedContainer( sw );
xe->embedClient( m_pluginWindowID );
xe->setFixedSize( m_pluginGeometry );
xe->move( 4, 24 );
xe->show();
#endif
}
}
xe->embedClient( m_pluginWindowID );
xe->setFixedSize( m_pluginGeometry );

#endif

Expand Down
8 changes: 8 additions & 0 deletions src/3rdparty/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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()
1 change: 1 addition & 0 deletions src/3rdparty/qt5-x11embed
Submodule qt5-x11embed added at dad35c
3 changes: 2 additions & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -129,7 +130,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}
Expand Down
14 changes: 14 additions & 0 deletions src/core/RemotePlugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}




Expand Down
5 changes: 4 additions & 1 deletion src/gui/SubWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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() );

Expand Down