Browse Source

Cleanup

Signed-off-by: falkTX <falktx@falktx.com>
main
falkTX 1 year ago
parent
commit
2521899d37
Signed by: falkTX <falktx@falktx.com> GPG Key ID: CDBAA37ABC74FBA0
3 changed files with 18 additions and 22 deletions
  1. +5
    -2
      plugins/Common/IldaeilUI.cpp
  2. +11
    -18
      plugins/Common/PluginHostWindow.cpp
  3. +2
    -2
      plugins/Common/PluginHostWindow.hpp

+ 5
- 2
plugins/Common/IldaeilUI.cpp View File

@@ -162,6 +162,7 @@ class IldaeilUI : public UI,
} fIdleState = kIdleInit; } fIdleState = kIdleInit;


IldaeilBasePlugin* const fPlugin; IldaeilBasePlugin* const fPlugin;
void* const fNativeWindowHandle;
PluginHostWindow fPluginHostWindow; PluginHostWindow fPluginHostWindow;


BinaryType fBinaryType; BinaryType fBinaryType;
@@ -218,7 +219,8 @@ public:
fDrawingState(kDrawingLoading), fDrawingState(kDrawingLoading),
fIdleState(kIdleInit), fIdleState(kIdleInit),
fPlugin((IldaeilBasePlugin*)getPluginInstancePointer()), fPlugin((IldaeilBasePlugin*)getPluginInstancePointer()),
fPluginHostWindow(getWindow(), this),
fNativeWindowHandle(reinterpret_cast<void*>(getWindow().getNativeWindowHandle())),
fPluginHostWindow(fNativeWindowHandle, this),
fBinaryType(BINARY_NATIVE), fBinaryType(BINARY_NATIVE),
fPluginType(PLUGIN_LV2), fPluginType(PLUGIN_LV2),
fNextPluginType(fPluginType), fNextPluginType(fPluginType),
@@ -412,7 +414,8 @@ public:
fIgnoreNextHostWindowResize = false; fIgnoreNextHostWindowResize = false;
fShowingHostWindow = true; fShowingHostWindow = true;


carla_embed_custom_ui(handle, fPluginId, fPluginHostWindow.attachAndGetWindowHandle());
fPluginHostWindow.restart();
carla_embed_custom_ui(handle, fPluginId, fNativeWindowHandle);
} }
else else
#endif #endif


+ 11
- 18
plugins/Common/PluginHostWindow.cpp View File

@@ -51,8 +51,7 @@ static int ildaeilErrorHandler(Display*, XErrorEvent*)


struct PluginHostWindow::PrivateData struct PluginHostWindow::PrivateData
{ {
Window& parentWindow;
const uintptr_t parentWindowId;
void* const windowHandle;
Callbacks* const pluginWindowCallbacks; Callbacks* const pluginWindowCallbacks;


#if defined(DISTRHO_OS_HAIKU) #if defined(DISTRHO_OS_HAIKU)
@@ -69,9 +68,8 @@ struct PluginHostWindow::PrivateData


bool lookingForChildren; bool lookingForChildren;


PrivateData(Window& pw, Callbacks* const cbs)
: parentWindow(pw),
parentWindowId(pw.getNativeWindowHandle()),
PrivateData(void* const wh, Callbacks* const cbs)
: windowHandle(wh),
pluginWindowCallbacks(cbs), pluginWindowCallbacks(cbs),
#if defined(DISTRHO_OS_HAIKU) #if defined(DISTRHO_OS_HAIKU)
#elif defined(DISTRHO_OS_MAC) #elif defined(DISTRHO_OS_MAC)
@@ -109,22 +107,17 @@ struct PluginHostWindow::PrivateData
#endif #endif
} }


void* attachAndGetWindowHandle()
void restart()
{ {
lookingForChildren = true; lookingForChildren = true;
#if defined(DISTRHO_OS_HAIKU) #if defined(DISTRHO_OS_HAIKU)
return nullptr;
#elif defined(DISTRHO_OS_MAC) #elif defined(DISTRHO_OS_MAC)
pluginView = nullptr; pluginView = nullptr;
return (void*)parentWindowId;
#elif defined(DISTRHO_OS_WASM) #elif defined(DISTRHO_OS_WASM)
return nullptr;
#elif defined(DISTRHO_OS_WINDOWS) #elif defined(DISTRHO_OS_WINDOWS)
pluginWindow = nullptr; pluginWindow = nullptr;
return (void*)parentWindowId;
#else #else
pluginWindow = 0; pluginWindow = 0;
return (void*)parentWindowId;
#endif #endif
} }


@@ -168,7 +161,7 @@ struct PluginHostWindow::PrivateData
if (pluginView == nullptr) if (pluginView == nullptr)
{ {
bool first = true; bool first = true;
for (NSView* view in [(NSView*)parentWindowId subviews])
for (NSView* view in [(NSView*)windowHandle subviews])
{ {
if (first) if (first)
{ {
@@ -182,7 +175,7 @@ struct PluginHostWindow::PrivateData
#elif defined(DISTRHO_OS_WASM) #elif defined(DISTRHO_OS_WASM)
#elif defined(DISTRHO_OS_WINDOWS) #elif defined(DISTRHO_OS_WINDOWS)
if (pluginWindow == nullptr) if (pluginWindow == nullptr)
pluginWindow = FindWindowExA((::HWND)parentWindowId, nullptr, nullptr, nullptr);
pluginWindow = FindWindowExA((::HWND)windowHandle, nullptr, nullptr, nullptr);
#else #else
if (display == nullptr) if (display == nullptr)
return; return;
@@ -193,7 +186,7 @@ struct PluginHostWindow::PrivateData
::Window* childWindows = nullptr; ::Window* childWindows = nullptr;
uint numChildren = 0; uint numChildren = 0;


XQueryTree(display, parentWindowId, &rootWindow, &parentWindow, &childWindows, &numChildren);
XQueryTree(display, (::Window)windowHandle, &rootWindow, &parentWindow, &childWindows, &numChildren);


if (numChildren > 0 && childWindows != nullptr) if (numChildren > 0 && childWindows != nullptr)
{ {
@@ -334,17 +327,17 @@ struct PluginHostWindow::PrivateData
} }
}; };


PluginHostWindow::PluginHostWindow(Window& parentWindow, Callbacks* const cbs)
: pData(new PrivateData(parentWindow, cbs)) {}
PluginHostWindow::PluginHostWindow(void* const windowHandle, Callbacks* const cbs)
: pData(new PrivateData(windowHandle, cbs)) {}


PluginHostWindow::~PluginHostWindow() PluginHostWindow::~PluginHostWindow()
{ {
delete pData; delete pData;
} }


void* PluginHostWindow::attachAndGetWindowHandle()
void PluginHostWindow::restart()
{ {
return pData->attachAndGetWindowHandle();
pData->restart();
} }


bool PluginHostWindow::hide() bool PluginHostWindow::hide()


+ 2
- 2
plugins/Common/PluginHostWindow.hpp View File

@@ -32,10 +32,10 @@ public:
virtual void pluginWindowResized(uint width, uint height) = 0; virtual void pluginWindowResized(uint width, uint height) = 0;
}; };


explicit PluginHostWindow(Window& parentWindow, Callbacks* cbs);
explicit PluginHostWindow(void* windowHandle, Callbacks* cbs);
~PluginHostWindow(); ~PluginHostWindow();


void* attachAndGetWindowHandle();
void restart();
bool hide(); bool hide();
void idle(); void idle();
void setOffset(uint x, uint y); void setOffset(uint x, uint y);


Loading…
Cancel
Save