Signed-off-by: falkTX <falktx@falktx.com>pull/1689/head
@@ -3145,6 +3145,7 @@ bool CarlaEngine::loadProjectInternal(water::XmlDocument& xmlDoc, const bool alw | |||||
case PLUGIN_LV2: | case PLUGIN_LV2: | ||||
case PLUGIN_VST2: | case PLUGIN_VST2: | ||||
case PLUGIN_VST3: | case PLUGIN_VST3: | ||||
case PLUGIN_CLAP: | |||||
btype = getBinaryTypeFromFile(stateSave.binary); | btype = getBinaryTypeFromFile(stateSave.binary); | ||||
break; | break; | ||||
default: | default: | ||||
@@ -1101,7 +1101,12 @@ public: | |||||
uint32_t width, height; | uint32_t width, height; | ||||
if (fExtensions.gui->get_size(fPlugin, &width, &height)) | if (fExtensions.gui->get_size(fPlugin, &width, &height)) | ||||
fUI.window->setSize(width, height, false); | |||||
{ | |||||
fUI.isResizingFromInit = true; | |||||
fUI.width = width; | |||||
fUI.height = height; | |||||
fUI.window->setSize(width, height, true, true); | |||||
} | |||||
fExtensions.gui->show(fPlugin); | fExtensions.gui->show(fPlugin); | ||||
fUI.window->show(); | fUI.window->show(); | ||||
@@ -1162,7 +1167,48 @@ public: | |||||
void uiIdle() override | void uiIdle() override | ||||
{ | { | ||||
#ifdef CLAP_WINDOW_API_NATIVE | |||||
if (fUI.shouldClose) | |||||
{ | |||||
fUI.shouldClose = false; | |||||
fUI.isResizingFromHost = fUI.isResizingFromInit = false; | |||||
fUI.isResizingFromPlugin = 0; | |||||
showCustomUI(false); | |||||
pData->engine->callback(true, true, | |||||
ENGINE_CALLBACK_UI_STATE_CHANGED, | |||||
pData->id, | |||||
0, | |||||
0, 0, 0.0f, nullptr); | |||||
} | |||||
if (fUI.isResizingFromHost) | |||||
{ | |||||
fUI.isResizingFromHost = false; | |||||
if (fUI.isResizingFromPlugin == 0 && !fUI.isResizingFromInit == false) | |||||
{ | |||||
carla_stdout("Host resize restarted"); | |||||
fExtensions.gui->set_size(fPlugin, fUI.width, fUI.height); | |||||
} | |||||
} | |||||
if (fUI.window != nullptr) | |||||
fUI.window->idle(); | |||||
if (fUI.isResizingFromPlugin == 2) | |||||
{ | |||||
fUI.isResizingFromPlugin = 1; | |||||
} | |||||
else if (fUI.isResizingFromPlugin == 1) | |||||
{ | |||||
fUI.isResizingFromPlugin = 0; | |||||
carla_stdout("Plugin resize stopped"); | |||||
} | |||||
#endif | |||||
runIdleCallbacksAsNeeded(); | runIdleCallbacksAsNeeded(); | ||||
CarlaPlugin::uiIdle(); | CarlaPlugin::uiIdle(); | ||||
} | } | ||||
@@ -2451,23 +2497,66 @@ protected: | |||||
void handlePluginUIClosed() override | void handlePluginUIClosed() override | ||||
{ | { | ||||
CARLA_SAFE_ASSERT_RETURN(fUI.window != nullptr,); | CARLA_SAFE_ASSERT_RETURN(fUI.window != nullptr,); | ||||
carla_debug("CarlaPluginCLAP::handlePluginUIClosed()"); | |||||
carla_stdout("CarlaPluginCLAP::handlePluginUIClosed()"); | |||||
showCustomUI(false); | |||||
pData->engine->callback(true, true, | |||||
ENGINE_CALLBACK_UI_STATE_CHANGED, | |||||
pData->id, | |||||
0, | |||||
0, 0, 0.0f, nullptr); | |||||
fUI.shouldClose = true; | |||||
} | } | ||||
void handlePluginUIResized(const uint width, const uint height) override | void handlePluginUIResized(const uint width, const uint height) override | ||||
{ | { | ||||
CARLA_SAFE_ASSERT_RETURN(fUI.window != nullptr,); | CARLA_SAFE_ASSERT_RETURN(fUI.window != nullptr,); | ||||
carla_debug("CarlaPluginCLAP::handlePluginUIResized(%u, %u)", width, height); | |||||
carla_stdout("CarlaPluginCLAP::handlePluginUIResized(%u, %u | vs %u %u) %d %s %s", | |||||
width, height, | |||||
fUI.width, fUI.height, | |||||
fUI.isResizingFromPlugin, bool2str(fUI.isResizingFromInit), bool2str(fUI.isResizingFromHost)); | |||||
if (fExtensions.gui == nullptr) | |||||
return; | |||||
if (fUI.isResizingFromPlugin != 0) | |||||
{ | |||||
CARLA_SAFE_ASSERT_UINT2_RETURN(fUI.width == width, fUI.width, width,); | |||||
CARLA_SAFE_ASSERT_UINT2_RETURN(fUI.height == height, fUI.height, height,); | |||||
fUI.isResizingFromPlugin = 2; | |||||
return; | |||||
} | |||||
if (fExtensions.gui != nullptr) | |||||
fExtensions.gui->set_size(fPlugin, width, height); | |||||
if (fUI.isResizingFromInit) | |||||
{ | |||||
CARLA_SAFE_ASSERT_UINT2_RETURN(fUI.width == width, fUI.width, width,); | |||||
CARLA_SAFE_ASSERT_UINT2_RETURN(fUI.height == height, fUI.height, height,); | |||||
fUI.isResizingFromInit = false; | |||||
return; | |||||
} | |||||
if (fUI.isResizingFromHost) | |||||
{ | |||||
CARLA_SAFE_ASSERT_UINT2_RETURN(fUI.width == width, fUI.width, width,); | |||||
CARLA_SAFE_ASSERT_UINT2_RETURN(fUI.height == height, fUI.height, height,); | |||||
fUI.isResizingFromHost = false; | |||||
return; | |||||
} | |||||
if (fUI.width != width || fUI.height != height) | |||||
{ | |||||
uint width2 = width; | |||||
uint height2 = height; | |||||
if (fExtensions.gui->adjust_size(fPlugin, &width2, &height2)) | |||||
{ | |||||
if (width2 != width || height2 != height) | |||||
{ | |||||
fUI.isResizingFromHost = true; | |||||
fUI.width = width2; | |||||
fUI.height = height2; | |||||
fUI.window->setSize(width2, height2, false, false); | |||||
} | |||||
else | |||||
{ | |||||
fExtensions.gui->set_size(fPlugin, width2, height2); | |||||
} | |||||
} | |||||
} | |||||
} | } | ||||
#endif | #endif | ||||
@@ -2511,7 +2600,10 @@ protected: | |||||
CARLA_SAFE_ASSERT_RETURN(fUI.window != nullptr, false); | CARLA_SAFE_ASSERT_RETURN(fUI.window != nullptr, false); | ||||
carla_stdout("CarlaPluginCLAP::hostRequestResize(%u, %u)", width, height); | carla_stdout("CarlaPluginCLAP::hostRequestResize(%u, %u)", width, height); | ||||
fUI.window->setSize(width, height, true); | |||||
fUI.isResizingFromPlugin = 3; | |||||
fUI.width = width; | |||||
fUI.height = height; | |||||
fUI.window->setSize(width, height, true, false); | |||||
return true; | return true; | ||||
} | } | ||||
@@ -2964,6 +3056,11 @@ private: | |||||
bool isCreated; | bool isCreated; | ||||
bool isEmbed; | bool isEmbed; | ||||
bool isVisible; | bool isVisible; | ||||
bool isResizingFromHost; | |||||
bool isResizingFromInit; | |||||
int isResizingFromPlugin; | |||||
bool shouldClose; | |||||
uint32_t width, height; | |||||
CarlaPluginUI* window; | CarlaPluginUI* window; | ||||
UI() | UI() | ||||
@@ -2971,6 +3068,12 @@ private: | |||||
isCreated(false), | isCreated(false), | ||||
isEmbed(false), | isEmbed(false), | ||||
isVisible(false), | isVisible(false), | ||||
isResizingFromHost(false), | |||||
isResizingFromInit(false), | |||||
isResizingFromPlugin(0), | |||||
shouldClose(false), | |||||
width(0), | |||||
height(0), | |||||
window(nullptr) {} | window(nullptr) {} | ||||
~UI() | ~UI() | ||||
@@ -6181,7 +6181,7 @@ public: | |||||
else | else | ||||
{ | { | ||||
CARLA_SAFE_ASSERT_RETURN(fUI.window != nullptr, 1); | CARLA_SAFE_ASSERT_RETURN(fUI.window != nullptr, 1); | ||||
fUI.window->setSize(static_cast<uint>(width), static_cast<uint>(height), true); | |||||
fUI.window->setSize(static_cast<uint>(width), static_cast<uint>(height), true, true); | |||||
} | } | ||||
return 0; | return 0; | ||||
@@ -589,7 +589,7 @@ public: | |||||
CARLA_SAFE_ASSERT_INT2(width > 1 && height > 1, width, height); | CARLA_SAFE_ASSERT_INT2(width > 1 && height > 1, width, height); | ||||
if (width > 1 && height > 1) | if (width > 1 && height > 1) | ||||
fUI.window->setSize(static_cast<uint>(width), static_cast<uint>(height), true); | |||||
fUI.window->setSize(static_cast<uint>(width), static_cast<uint>(height), true, true); | |||||
} | } | ||||
} | } | ||||
else | else | ||||
@@ -2213,7 +2213,7 @@ protected: | |||||
else | else | ||||
{ | { | ||||
CARLA_SAFE_ASSERT_BREAK(fUI.window != nullptr); | CARLA_SAFE_ASSERT_BREAK(fUI.window != nullptr); | ||||
fUI.window->setSize(static_cast<uint>(index), static_cast<uint>(value), true); | |||||
fUI.window->setSize(static_cast<uint>(index), static_cast<uint>(value), true, false); | |||||
} | } | ||||
ret = 1; | ret = 1; | ||||
break; | break; | ||||
@@ -799,7 +799,7 @@ public: | |||||
CARLA_SAFE_ASSERT_INT2(width > 1 && height > 1, width, height); | CARLA_SAFE_ASSERT_INT2(width > 1 && height > 1, width, height); | ||||
if (width > 1 && height > 1) | if (width > 1 && height > 1) | ||||
fUI.window->setSize(static_cast<uint>(width), static_cast<uint>(height), true); | |||||
fUI.window->setSize(static_cast<uint>(width), static_cast<uint>(height), true, true); | |||||
} | } | ||||
} | } | ||||
else | else | ||||
@@ -178,7 +178,7 @@ public: | |||||
CARLA_SAFE_ASSERT_RETURN(height > 0,); | CARLA_SAFE_ASSERT_RETURN(height > 0,); | ||||
carla_debug("CarlaBridgeToolkitNative::resize(%i, %i)", width, height); | carla_debug("CarlaBridgeToolkitNative::resize(%i, %i)", width, height); | ||||
fHostUI->setSize(width, height, false); | |||||
fHostUI->setSize(width, height, false, false); | |||||
} | } | ||||
void setTitle(const char* const title) override | void setTitle(const char* const title) override | ||||
@@ -202,7 +202,7 @@ public: | |||||
} | } | ||||
if (width > 1 && height > 1) | if (width > 1 && height > 1) | ||||
setSize(static_cast<uint>(width), static_cast<uint>(height), false); | |||||
setSize(static_cast<uint>(width), static_cast<uint>(height), false, false); | |||||
} | } | ||||
const Atom _xevp = XInternAtom(fDisplay, "_XEventProc", False); | const Atom _xevp = XInternAtom(fDisplay, "_XEventProc", False); | ||||
@@ -391,7 +391,7 @@ public: | |||||
} | } | ||||
} | } | ||||
void setSize(const uint width, const uint height, const bool forceUpdate) override | |||||
void setSize(const uint width, const uint height, const bool forceUpdate, const bool resizeChild) override | |||||
{ | { | ||||
CARLA_SAFE_ASSERT_RETURN(fDisplay != nullptr,); | CARLA_SAFE_ASSERT_RETURN(fDisplay != nullptr,); | ||||
CARLA_SAFE_ASSERT_RETURN(fHostWindow != 0,); | CARLA_SAFE_ASSERT_RETURN(fHostWindow != 0,); | ||||
@@ -399,7 +399,7 @@ public: | |||||
fSetSizeCalledAtLeastOnce = true; | fSetSizeCalledAtLeastOnce = true; | ||||
XResizeWindow(fDisplay, fHostWindow, width, height); | XResizeWindow(fDisplay, fHostWindow, width, height); | ||||
if (fChildWindow != 0) | |||||
if (fChildWindow != 0 && resizeChild) | |||||
XResizeWindow(fDisplay, fChildWindow, width, height); | XResizeWindow(fDisplay, fChildWindow, width, height); | ||||
if (! fIsResizable) | if (! fIsResizable) | ||||
@@ -763,7 +763,7 @@ public: | |||||
[NSApp activateIgnoringOtherApps:YES]; | [NSApp activateIgnoringOtherApps:YES]; | ||||
} | } | ||||
void setSize(const uint width, const uint height, const bool forceUpdate) override | |||||
void setSize(const uint width, const uint height, const bool forceUpdate, const bool resizeChild) override | |||||
{ | { | ||||
carla_debug("CocoaPluginUI::setSize(%u, %u, %s)", width, height, bool2str(forceUpdate)); | carla_debug("CocoaPluginUI::setSize(%u, %u, %s)", width, height, bool2str(forceUpdate)); | ||||
CARLA_SAFE_ASSERT_RETURN(fWindow != nullptr,); | CARLA_SAFE_ASSERT_RETURN(fWindow != nullptr,); | ||||
@@ -775,7 +775,7 @@ public: | |||||
[fWindow setContentSize:size]; | [fWindow setContentSize:size]; | ||||
// this is needed for a few plugins | // this is needed for a few plugins | ||||
if (forceUpdate) | |||||
if (forceUpdate && resizeChild) | |||||
{ | { | ||||
for (NSView* subview in [fView subviews]) | for (NSView* subview in [fView subviews]) | ||||
{ | { | ||||
@@ -978,7 +978,7 @@ public: | |||||
RECT rectChild, rectParent; | RECT rectChild, rectParent; | ||||
if (fChildWindow != nullptr && GetWindowRect(fChildWindow, &rectChild)) | if (fChildWindow != nullptr && GetWindowRect(fChildWindow, &rectChild)) | ||||
setSize(rectChild.right - rectChild.left, rectChild.bottom - rectChild.top, false); | |||||
setSize(rectChild.right - rectChild.left, rectChild.bottom - rectChild.top, false, false); | |||||
if (fParentWindow != nullptr && | if (fParentWindow != nullptr && | ||||
GetWindowRect(fWindow, &rectChild) && | GetWindowRect(fWindow, &rectChild) && | ||||
@@ -1074,7 +1074,7 @@ public: | |||||
SetFocus(fWindow); | SetFocus(fWindow); | ||||
} | } | ||||
void setSize(const uint width, const uint height, const bool forceUpdate) override | |||||
void setSize(const uint width, const uint height, const bool forceUpdate, bool) override | |||||
{ | { | ||||
CARLA_SAFE_ASSERT_RETURN(fWindow != nullptr,); | CARLA_SAFE_ASSERT_RETURN(fWindow != nullptr,); | ||||
@@ -37,7 +37,7 @@ public: | |||||
virtual void hide() = 0; | virtual void hide() = 0; | ||||
virtual void focus() = 0; | virtual void focus() = 0; | ||||
virtual void idle() = 0; | virtual void idle() = 0; | ||||
virtual void setSize(uint with, uint height, bool forceUpdate) = 0; | |||||
virtual void setSize(uint with, uint height, bool forceUpdate, bool resizeChild) = 0; | |||||
virtual void setTitle(const char* title) = 0; | virtual void setTitle(const char* title) = 0; | ||||
virtual void setChildWindow(void* ptr) = 0; | virtual void setChildWindow(void* ptr) = 0; | ||||
virtual void setTransientWinId(uintptr_t winId) = 0; | virtual void setTransientWinId(uintptr_t winId) = 0; | ||||