Let Wine handle the window interface
This commit is contained in:
committed by
Lukas W
parent
d04fd9f542
commit
7a9396d6ea
@@ -428,6 +428,7 @@ enum RemoteMessageIDs
|
||||
IdShowUI,
|
||||
IdHideUI,
|
||||
IdToggleUI,
|
||||
IdIsUIVisible,
|
||||
IdSaveSettingsToString,
|
||||
IdSaveSettingsToFile,
|
||||
IdLoadSettingsFromString,
|
||||
@@ -816,6 +817,15 @@ public:
|
||||
unlock();
|
||||
}
|
||||
|
||||
int isUIVisible()
|
||||
{
|
||||
lock();
|
||||
sendMessage( IdIsUIVisible );
|
||||
unlock();
|
||||
message m = waitForMessage( IdIsUIVisible );
|
||||
return m.id != IdIsUIVisible ? -1 : m.getInt() ? 1 : 0;
|
||||
}
|
||||
|
||||
inline bool failed() const
|
||||
{
|
||||
return m_failed;
|
||||
|
||||
@@ -43,7 +43,9 @@
|
||||
|
||||
VstEffectControlDialog::VstEffectControlDialog( VstEffectControls * _ctl ) :
|
||||
EffectControlDialog( _ctl ),
|
||||
#ifdef LMMS_EMBED_VST
|
||||
m_pluginWidget( NULL ),
|
||||
#endif
|
||||
m_plugin( NULL ),
|
||||
tbLabel( NULL )
|
||||
{
|
||||
@@ -56,6 +58,7 @@ VstEffectControlDialog::VstEffectControlDialog( VstEffectControls * _ctl ) :
|
||||
_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();
|
||||
|
||||
@@ -66,18 +69,31 @@ VstEffectControlDialog::VstEffectControlDialog( VstEffectControls * _ctl ) :
|
||||
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
|
||||
{
|
||||
setWindowTitle( m_pluginWidget->windowTitle() );
|
||||
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
|
||||
|
||||
btn->setMinimumWidth( 78 );
|
||||
btn->setMaximumWidth( 78 );
|
||||
@@ -206,8 +222,12 @@ 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
|
||||
QWidget* resize = new QWidget(this);
|
||||
resize->resize( newSize, 10 );
|
||||
QWidget* space0 = new QWidget(this);
|
||||
@@ -219,8 +239,10 @@ 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
|
||||
#if QT_VERSION < 0x050000
|
||||
l->addWidget( m_pluginWidget, 3, 0, 1, 1, Qt::AlignCenter );
|
||||
#endif
|
||||
#endif
|
||||
l->setRowStretch( 5, 1 );
|
||||
l->setColumnStretch( 1, 1 );
|
||||
@@ -273,6 +295,7 @@ void VstEffectControlDialog::togglePluginUI( bool checked )
|
||||
{
|
||||
if( m_plugin )
|
||||
{
|
||||
#ifdef LMMS_EMBED_VST
|
||||
if( checked )
|
||||
{
|
||||
m_plugin->showEditor( NULL, true );
|
||||
@@ -281,6 +304,9 @@ void VstEffectControlDialog::togglePluginUI( bool checked )
|
||||
{
|
||||
m_plugin->hideEditor();
|
||||
}
|
||||
#else
|
||||
m_plugin->toggleUI();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -51,7 +51,9 @@ protected:
|
||||
virtual void paintEvent( QPaintEvent * _pe );
|
||||
|
||||
private:
|
||||
#ifdef LMMS_EMBED_VST
|
||||
QWidget * m_pluginWidget;
|
||||
#endif
|
||||
|
||||
PixmapButton * m_openPresetButton;
|
||||
PixmapButton * m_rolLPresetButton;
|
||||
|
||||
@@ -261,7 +261,11 @@ 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 )
|
||||
{
|
||||
@@ -735,7 +739,11 @@ void VestigeInstrumentView::toggleGUI( void )
|
||||
{
|
||||
return;
|
||||
}
|
||||
#ifdef LMMS_EMBED_VST
|
||||
m_vi->m_plugin->toggleEditor();
|
||||
#else
|
||||
m_vi->m_plugin->toggleUI();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -59,13 +59,6 @@
|
||||
#define USE_WS_PREFIX
|
||||
#include <windows.h>
|
||||
|
||||
#if defined(LMMS_BUILD_WIN32) || defined(LMMS_BUILD_WIN64)
|
||||
#include "basename.c"
|
||||
#else
|
||||
#include <libgen.h>
|
||||
#endif
|
||||
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
@@ -100,7 +93,6 @@ struct ERect
|
||||
#ifndef USE_QT_SHMEM
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/ipc.h>
|
||||
#include <sys/shm.h>
|
||||
@@ -341,7 +333,6 @@ RemoteVstPlugin::RemoteVstPlugin( key_t _shm_in, key_t _shm_out ) :
|
||||
RemoteVstPlugin::RemoteVstPlugin( const char * socketPath ) :
|
||||
RemotePluginClient( socketPath ),
|
||||
#endif
|
||||
m_shortName( "" ),
|
||||
m_libInst( NULL ),
|
||||
m_plugin( NULL ),
|
||||
m_window( NULL ),
|
||||
@@ -482,6 +473,11 @@ bool RemoteVstPlugin::processMessage( const message & _m )
|
||||
}
|
||||
break;
|
||||
|
||||
case IdIsUIVisible:
|
||||
sendMessage( message( IdIsUIVisible )
|
||||
.addInt( m_window ? 1 : 0 ) );
|
||||
break;
|
||||
|
||||
case IdVstLoadPlugin:
|
||||
init( _m.getString() );
|
||||
break;
|
||||
@@ -682,8 +678,12 @@ void RemoteVstPlugin::initEditor()
|
||||
m_registeredWindowClass = true;
|
||||
}
|
||||
|
||||
m_window = CreateWindowEx( 0, "LVSL", m_shortName.c_str(),
|
||||
m_window = CreateWindowEx( 0, "LVSL", pluginName(),
|
||||
#ifdef LMMS_EMBED_VST
|
||||
WS_POPUP | WS_SYSMENU | WS_BORDER,
|
||||
#else
|
||||
WS_OVERLAPPEDWINDOW & ~WS_MAXIMIZEBOX,
|
||||
#endif
|
||||
0, 0, 10, 10, NULL, NULL, hInst, NULL );
|
||||
if( m_window == NULL )
|
||||
{
|
||||
@@ -708,7 +708,6 @@ void RemoteVstPlugin::initEditor()
|
||||
ShowWindow( m_window, SW_SHOWNORMAL );
|
||||
#ifdef LMMS_BUILD_LINUX
|
||||
m_windowID = (intptr_t) GetProp( m_window, "__wine_x11_whole_window" );
|
||||
fprintf(stderr, "m_windowID %x\n", m_windowID);
|
||||
#else
|
||||
// 64-bit versions of Windows use 32-bit handles for interoperability
|
||||
m_windowID = (intptr_t) m_window;
|
||||
@@ -746,10 +745,6 @@ bool RemoteVstPlugin::load( const std::string & _plugin_file )
|
||||
return false;
|
||||
}
|
||||
|
||||
char * tmp = strdup( _plugin_file.c_str() );
|
||||
m_shortName = basename( tmp );
|
||||
free( tmp );
|
||||
|
||||
typedef AEffect * ( __stdcall * mainEntryPointer )
|
||||
( audioMasterCallback );
|
||||
mainEntryPointer mainEntry = (mainEntryPointer)
|
||||
@@ -1843,6 +1838,13 @@ DWORD WINAPI RemoteVstPlugin::guiEventLoop( LPVOID _param )
|
||||
while( quit == false && GetMessage( &msg, NULL, 0, 0 ) )
|
||||
{
|
||||
TranslateMessage( &msg );
|
||||
|
||||
if( msg.message == WM_SYSCOMMAND && msg.wParam == SC_CLOSE )
|
||||
{
|
||||
_this->destroyEditor();
|
||||
continue;
|
||||
}
|
||||
|
||||
DispatchMessage( &msg );
|
||||
|
||||
if( msg.message == WM_TIMER && _this->isInitialized() )
|
||||
|
||||
@@ -177,6 +177,7 @@ void VstPlugin::tryLoad( const QString &remoteVstPluginExecutable )
|
||||
|
||||
|
||||
|
||||
#ifdef LMMS_EMBED_VST
|
||||
void VstPlugin::showEditor( QWidget * _parent, bool isEffect )
|
||||
{
|
||||
QWidget * w = pluginWidget();
|
||||
@@ -237,8 +238,6 @@ void VstPlugin::showEditor( QWidget * _parent, bool isEffect )
|
||||
}
|
||||
#else
|
||||
QWindow * window = QWindow::fromWinId( m_pluginWindowID );
|
||||
fprintf(stderr, "m_pluginWindowID %x\n", m_pluginWindowID);
|
||||
fprintf(stderr, "window %p\n", window);
|
||||
m_pluginWidget = QWidget::createWindowContainer( window, _parent,
|
||||
Qt::Window );
|
||||
m_pluginWidget->setFixedSize( m_pluginGeometry );
|
||||
@@ -275,12 +274,14 @@ 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() )
|
||||
@@ -292,6 +293,16 @@ void VstPlugin::loadSettings( const QDomElement & _this )
|
||||
hideEditor();
|
||||
}
|
||||
}
|
||||
#else
|
||||
if( _this.attribute( "guivisible" ).toInt() )
|
||||
{
|
||||
showUI();
|
||||
}
|
||||
else
|
||||
{
|
||||
hideUI();
|
||||
}
|
||||
#endif
|
||||
|
||||
const int num_params = _this.attribute( "numparams" ).toInt();
|
||||
// if it exists try to load settings chunk
|
||||
@@ -324,10 +335,18 @@ void VstPlugin::loadSettings( const QDomElement & _this )
|
||||
|
||||
void VstPlugin::saveSettings( QDomDocument & _doc, QDomElement & _this )
|
||||
{
|
||||
#ifdef LMMS_EMBED_VST
|
||||
if( pluginWidget() != NULL )
|
||||
{
|
||||
_this.setAttribute( "guivisible", pluginWidget()->isVisible() );
|
||||
}
|
||||
#else
|
||||
int visible = isUIVisible();
|
||||
if ( visible != -1 )
|
||||
{
|
||||
_this.setAttribute( "guivisible", visible );
|
||||
}
|
||||
#endif
|
||||
|
||||
// try to save all settings in a chunk
|
||||
QByteArray chunk = saveChunk();
|
||||
|
||||
@@ -52,9 +52,11 @@ 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
|
||||
{
|
||||
|
||||
@@ -1,166 +0,0 @@
|
||||
/* basename.c
|
||||
*
|
||||
* $Id: basename.c,v 1.2 2007/03/08 23:15:58 keithmarshall Exp $
|
||||
*
|
||||
* Provides an implementation of the "basename" function, conforming
|
||||
* to SUSv3, with extensions to accommodate Win32 drive designators,
|
||||
* and suitable for use on native Microsoft(R) Win32 platforms.
|
||||
*
|
||||
* Written by Keith Marshall <keithmarshall@users.sourceforge.net>
|
||||
*
|
||||
* This is free software. You may redistribute and/or modify it as you
|
||||
* see fit, without restriction of copyright.
|
||||
*
|
||||
* This software is provided "as is", in the hope that it may be useful,
|
||||
* but WITHOUT WARRANTY OF ANY KIND, not even any implied warranty of
|
||||
* MERCHANTABILITY, nor of FITNESS FOR ANY PARTICULAR PURPOSE. At no
|
||||
* time will the author accept any form of liability for any damages,
|
||||
* however caused, resulting from the use of this software.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <locale.h>
|
||||
|
||||
#ifndef __cdecl /* If compiling on any non-Win32 platform ... */
|
||||
#define __cdecl /* this may not be defined. */
|
||||
#endif
|
||||
|
||||
__cdecl char *basename( char *path )
|
||||
{
|
||||
size_t len;
|
||||
static char *retfail = NULL;
|
||||
|
||||
/* to handle path names for files in multibyte character locales,
|
||||
* we need to set up LC_CTYPE to match the host file system locale
|
||||
*/
|
||||
|
||||
char *locale = setlocale( LC_CTYPE, NULL );
|
||||
if( locale != NULL ) locale = strdup( locale );
|
||||
setlocale( LC_CTYPE, "" );
|
||||
|
||||
if( path && *path )
|
||||
{
|
||||
/* allocate sufficient local storage space,
|
||||
* in which to create a wide character reference copy of path
|
||||
*/
|
||||
|
||||
wchar_t refcopy[1 + (len = mbstowcs( NULL, path, 0 ))];
|
||||
|
||||
/* create the wide character reference copy of path,
|
||||
* and step over the drive designator, if present ...
|
||||
*/
|
||||
|
||||
wchar_t *refpath = refcopy;
|
||||
if( ((len = mbstowcs( refpath, path, len )) > 1) && (refpath[1] == L':') )
|
||||
{
|
||||
/* FIXME: maybe should confirm *refpath is a valid drive designator */
|
||||
|
||||
refpath += 2;
|
||||
}
|
||||
|
||||
/* ensure that our wide character reference path is NUL terminated */
|
||||
|
||||
refcopy[ len ] = L'\0';
|
||||
|
||||
/* check again, just to ensure we still have a non-empty path name ... */
|
||||
|
||||
if( *refpath )
|
||||
{
|
||||
/* and, when we do, process it in the wide character domain ...
|
||||
* scanning from left to right, to the char after the final dir separator
|
||||
*/
|
||||
|
||||
wchar_t *refname;
|
||||
for( refname = refpath ; *refpath ; ++refpath )
|
||||
{
|
||||
if( (*refpath == L'/') || (*refpath == L'\\') )
|
||||
{
|
||||
/* we found a dir separator ...
|
||||
* step over it, and any others which immediately follow it
|
||||
*/
|
||||
|
||||
while( (*refpath == L'/') || (*refpath == L'\\') )
|
||||
++refpath;
|
||||
|
||||
/* if we didn't reach the end of the path string ... */
|
||||
|
||||
if( *refpath )
|
||||
|
||||
/* then we have a new candidate for the base name */
|
||||
|
||||
refname = refpath;
|
||||
|
||||
/* otherwise ...
|
||||
* strip off any trailing dir separators which we found
|
||||
*/
|
||||
|
||||
else while( (refpath > refname)
|
||||
&& ((*--refpath == L'/') || (*refpath == L'\\')) )
|
||||
*refpath = L'\0';
|
||||
}
|
||||
}
|
||||
|
||||
/* in the wide character domain ...
|
||||
* refname now points at the resolved base name ...
|
||||
*/
|
||||
|
||||
if( *refname )
|
||||
{
|
||||
/* if it's not empty,
|
||||
* then we transform the full normalised path back into
|
||||
* the multibyte character domain, and skip over the dirname,
|
||||
* to return the resolved basename.
|
||||
*/
|
||||
|
||||
if( (len = wcstombs( path, refcopy, len )) != (size_t)(-1) )
|
||||
path[ len ] = '\0';
|
||||
*refname = L'\0';
|
||||
if( (len = wcstombs( NULL, refcopy, 0 )) != (size_t)(-1) )
|
||||
path += len;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
/* the basename is empty, so return the default value of "/",
|
||||
* transforming from wide char to multibyte char domain, and
|
||||
* returning it in our own buffer.
|
||||
*/
|
||||
|
||||
retfail = (char *) realloc( retfail, len = 1 + wcstombs( NULL, L"/", 0 ));
|
||||
wcstombs( path = retfail, L"/", len );
|
||||
}
|
||||
|
||||
/* restore the caller's locale, clean up, and return the result */
|
||||
|
||||
setlocale( LC_CTYPE, locale );
|
||||
free( locale );
|
||||
return( path );
|
||||
}
|
||||
|
||||
/* or we had an empty residual path name, after the drive designator,
|
||||
* in which case we simply fall through ...
|
||||
*/
|
||||
}
|
||||
|
||||
/* and, if we get to here ...
|
||||
* the path name is either NULL, or it decomposes to an empty string;
|
||||
* in either case, we return the default value of "." in our own buffer,
|
||||
* reloading it with the correct value, transformed from the wide char
|
||||
* to the multibyte char domain, just in case the caller trashed it
|
||||
* after a previous call.
|
||||
*/
|
||||
|
||||
retfail = (char *) realloc( retfail, len = 1 + wcstombs( NULL, L".", 0 ));
|
||||
wcstombs( retfail, L".", len );
|
||||
|
||||
/* restore the caller's locale, clean up, and return the result */
|
||||
|
||||
setlocale( LC_CTYPE, locale );
|
||||
free( locale );
|
||||
return( retfail );
|
||||
}
|
||||
|
||||
/* $RCSfile: basename.c,v $$Revision: 1.2 $: end of file */
|
||||
@@ -30,6 +30,9 @@
|
||||
#include "RemotePlugin.h"
|
||||
|
||||
|
||||
//#define LMMS_EMBED_VST
|
||||
|
||||
|
||||
struct VstParameterDumpItem
|
||||
{
|
||||
int32_t index;
|
||||
|
||||
Reference in New Issue
Block a user