Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
Signed-off-by: falkTX <falktx@falktx.com>
  • Loading branch information
falkTX committed Apr 18, 2024
1 parent 444849d commit 2521899
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 22 deletions.
7 changes: 5 additions & 2 deletions plugins/Common/IldaeilUI.cpp
Expand Up @@ -162,6 +162,7 @@ class IldaeilUI : public UI,
} fIdleState = kIdleInit;

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

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

carla_embed_custom_ui(handle, fPluginId, fPluginHostWindow.attachAndGetWindowHandle());
fPluginHostWindow.restart();
carla_embed_custom_ui(handle, fPluginId, fNativeWindowHandle);
}
else
#endif
Expand Down
29 changes: 11 additions & 18 deletions plugins/Common/PluginHostWindow.cpp
Expand Up @@ -51,8 +51,7 @@ static int ildaeilErrorHandler(Display*, XErrorEvent*)

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

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

bool lookingForChildren;

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

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

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

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

if (numChildren > 0 && childWindows != nullptr)
{
Expand Down Expand Up @@ -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()
{
delete pData;
}

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

bool PluginHostWindow::hide()
Expand Down
4 changes: 2 additions & 2 deletions plugins/Common/PluginHostWindow.hpp
Expand Up @@ -32,10 +32,10 @@ class PluginHostWindow
virtual void pluginWindowResized(uint width, uint height) = 0;
};

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

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

0 comments on commit 2521899

Please sign in to comment.