Add Win32 embedding

This commit is contained in:
Hyunin Song
2017-11-07 10:47:24 +09:00
parent b0f64dea7f
commit 7da7a70d60
5 changed files with 53 additions and 20 deletions

View File

@@ -109,6 +109,7 @@ static VstHostLanguages hlang = LanguageEnglish;
static bool EMBED = false;
static bool EMBED_X11 = false;
static bool EMBED_WIN32 = false;
class RemoteVstPlugin;
@@ -567,17 +568,6 @@ bool RemoteVstPlugin::processMessage( const message & _m )
init( _m.getString() );
break;
// TODO: Drop Windows hack for Qt 4
#ifdef LMMS_BUILD_WIN32
case IdVstPluginWindowInformation:
{
HWND top = FindWindowEx( NULL, NULL, NULL,
_m.getString().c_str() );
m_window = FindWindowEx( top, NULL, NULL, NULL );
break;
}
#endif
case IdVstSetTempo:
setBPM( _m.getInt() );
break;
@@ -2084,21 +2074,27 @@ int main( int _argc, char * * _argv )
if ( embedMethod == "none" )
{
cerr << "Starting detached." << endl;
EMBED = EMBED_X11 = false;
EMBED = EMBED_X11 = EMBED_WIN32 = false;
}
else if ( embedMethod == "win32" )
{
cerr << "Starting using Win32-native embedding." << endl;
EMBED = EMBED_WIN32 = true; EMBED_X11= false;
}
else if ( embedMethod == "qt" )
{
cerr << "Starting using Qt-native embedding." << endl;
EMBED = true; EMBED_X11 = false;
EMBED = true; EMBED_X11 = EMBED_WIN32 = false;
}
else if ( embedMethod == "xembed" )
{
cerr << "Starting using X11Embed protocol." << endl;
EMBED = true; EMBED_X11 = true;
EMBED = EMBED_X11 = true; EMBED_WIN32 = false;
}
else
{
cerr << "Unknown embed method " << embedMethod << ". Starting detached instead." << endl;
EMBED = EMBED_X11 = EMBED_WIN32 = false;
}
}

View File

@@ -51,6 +51,7 @@
#ifdef LMMS_BUILD_WIN32
# include <windows.h>
# include <QLayout>
#endif
#include "ConfigManager.h"
@@ -668,19 +669,49 @@ void VstPlugin::createUI( QWidget * parent, bool isEffect )
// TODO: Synchronize show
// Tell remote that it is embedded
// Wait for remote reply
}
} else
#endif
#ifdef LMMS_BUILD_WIN32
if (m_embedMethod == "win32" )
{
QWidget * helper = new QWidget;
QHBoxLayout * l = new QHBoxLayout( helper );
QWidget * target = new QWidget( helper );
l->setSpacing( 0 );
l->setMargin( 0 );
l->addWidget( target );
// we've to call that for making sure, Qt created the windows
helper->winId();
HWND targetHandle = (HWND)target->winId();
HWND pluginHandle = (HWND)(intptr_t)m_pluginWindowID;
DWORD style = GetWindowLong(pluginHandle, GWL_STYLE);
style = style & ~(WS_POPUP);
style = style | WS_CHILD;
SetWindowLong(pluginHandle, GWL_STYLE, style);
SetParent(pluginHandle, targetHandle);
DWORD threadId = GetWindowThreadProcessId(pluginHandle, NULL);
DWORD currentThreadId = GetCurrentThreadId();
AttachThreadInput(currentThreadId, threadId, true);
container = helper;
RemotePlugin::showUI();
} else
#endif
#ifdef LMMS_BUILD_LINUX
else if (m_embedMethod == "xembed" )
if (m_embedMethod == "xembed" )
{
QX11EmbedContainer * embedContainer = new QX11EmbedContainer( sw );
connect(embedContainer, SIGNAL(clientIsEmbedded()), this, SLOT(handleClientEmbed()));
embedContainer->embedClient( m_pluginWindowID );
container = embedContainer;
}
} else
#endif
else
{
qCritical() << "Unknown embed method" << m_embedMethod;
delete m_pluginSubWindow;

View File

@@ -57,8 +57,6 @@ enum VstRemoteMessageIDs
{
// vstPlugin -> remoteVstPlugin
IdVstLoadPlugin = IdUserBase,
// TODO: Drop IdVstPluginWindowInformation, Windows hack for Qt 4
IdVstPluginWindowInformation,
IdVstClosePlugin,
IdVstSetTempo,
IdVstSetLanguage,

View File

@@ -199,6 +199,10 @@ QString ConfigManager::vstEmbedMethod() const
}
#endif
#ifdef LMMS_BUILD_WIN32
defaultMethod = "win32";
#endif
return value( "ui", "vstembedmethod", defaultMethod );
}

View File

@@ -347,6 +347,10 @@ SetupDialog::SetupDialog( ConfigTabs _tab_to_open ) :
m_vstEmbedComboBox->addItem( tr( "Embed using Qt API" ), "qt" );
#endif
#ifdef LMMS_BUILD_WIN32
m_vstEmbedComboBox->addItem( tr( "Embed using native Win32 API" ), "win32" );
#endif
#ifdef LMMS_BUILD_LINUX
if ( QX11Info::isPlatformX11() ) {
m_vstEmbedComboBox->addItem( tr( "Embed using XEmbed protocol" ), "xembed" );