| @@ -2210,8 +2210,12 @@ void CarlaPlugin::uiIdle() | |||||
| CarlaString uiTitle(pData->name); | CarlaString uiTitle(pData->name); | ||||
| uiTitle += " (GUI)"; | uiTitle += " (GUI)"; | ||||
| if (CarlaPluginUI::tryTransientWinIdMatch(getUiBridgeProcessId(), uiTitle, pData->engine->getOptions().frontendWinId, true)) | |||||
| if (CarlaPluginUI::tryTransientWinIdMatch(getUiBridgeProcessId(), uiTitle, | |||||
| pData->engine->getOptions().frontendWinId, pData->transientFirstTry)) | |||||
| { | |||||
| pData->transientTryCounter = 0; | pData->transientTryCounter = 0; | ||||
| pData->transientFirstTry = false; | |||||
| } | |||||
| } | } | ||||
| void CarlaPlugin::uiParameterChange(const uint32_t index, const float value) noexcept | void CarlaPlugin::uiParameterChange(const uint32_t index, const float value) noexcept | ||||
| @@ -592,6 +592,7 @@ CarlaPlugin::ProtectedData::ProtectedData(CarlaEngine* const eng, const uint idx | |||||
| ctrlChannel(0), | ctrlChannel(0), | ||||
| extraHints(0x0), | extraHints(0x0), | ||||
| transientTryCounter(0), | transientTryCounter(0), | ||||
| transientFirstTry(true), | |||||
| name(nullptr), | name(nullptr), | ||||
| filename(nullptr), | filename(nullptr), | ||||
| iconName(nullptr), | iconName(nullptr), | ||||
| @@ -228,6 +228,7 @@ struct CarlaPlugin::ProtectedData { | |||||
| int8_t ctrlChannel; | int8_t ctrlChannel; | ||||
| uint extraHints; | uint extraHints; | ||||
| uint transientTryCounter; | uint transientTryCounter; | ||||
| bool transientFirstTry; | |||||
| // data 1 | // data 1 | ||||
| const char* name; | const char* name; | ||||
| @@ -68,8 +68,7 @@ public: | |||||
| fHostUI->setTitle(options.windowTitle.buffer()); | fHostUI->setTitle(options.windowTitle.buffer()); | ||||
| #ifdef HAVE_X11 | |||||
| // Out-of-process reparenting only possible on X11 | |||||
| #if (defined(CARLA_OS_WIN) && defined(BRIDGE_HWND)) || (defined(HAVE_X11) && defined(BRIDGE_X11)) | |||||
| if (options.transientWindowId != 0) | if (options.transientWindowId != 0) | ||||
| { | { | ||||
| fHostUI->setTransientWinId(options.transientWindowId); | fHostUI->setTransientWinId(options.transientWindowId); | ||||
| @@ -346,22 +346,6 @@ struct Window::PrivateData { | |||||
| fModal.enabled = true; | fModal.enabled = true; | ||||
| fModal.parent->fModal.childFocus = this; | fModal.parent->fModal.childFocus = this; | ||||
| #ifdef DISTRHO_OS_WINDOWS | |||||
| // Center this window | |||||
| PuglInternals* const parentImpl = fModal.parent->fView->impl; | |||||
| RECT curRect; | |||||
| RECT parentRect; | |||||
| GetWindowRect(hwnd, &curRect); | |||||
| GetWindowRect(parentImpl->hwnd, &parentRect); | |||||
| int x = parentRect.left+(parentRect.right-curRect.right)/2; | |||||
| int y = parentRect.top +(parentRect.bottom-curRect.bottom)/2; | |||||
| SetWindowPos(hwnd, 0, x, y, 0, 0, SWP_NOACTIVATE|SWP_NOOWNERZORDER|SWP_NOSIZE|SWP_NOZORDER); | |||||
| UpdateWindow(hwnd); | |||||
| #endif | |||||
| fModal.parent->setVisible(true); | fModal.parent->setVisible(true); | ||||
| setVisible(true); | setVisible(true); | ||||
| @@ -1046,10 +1046,41 @@ bool CarlaPluginUI::tryTransientWinIdMatch(const uintptr_t pid, const char* cons | |||||
| XFlush(sd.display); | XFlush(sd.display); | ||||
| return true; | return true; | ||||
| #else | |||||
| #endif | |||||
| #ifdef CARLA_OS_MAC | |||||
| // TODO | |||||
| #endif | |||||
| #ifdef CARLA_OS_WIN | |||||
| if (HWND const childWindow = FindWindowA(nullptr, uiTitle)) | |||||
| { | |||||
| HWND const parentWindow = (HWND)winId; | |||||
| SetWindowLongPtr(childWindow, GWLP_HWNDPARENT, (LONG_PTR)parentWindow); | |||||
| if (centerUI) | |||||
| { | |||||
| RECT rectChild, rectParent; | |||||
| if (GetWindowRect(childWindow, &rectChild) && GetWindowRect(parentWindow, &rectParent)) | |||||
| { | |||||
| SetWindowPos(childWindow, parentWindow, | |||||
| rectParent.left + (rectChild.right-rectChild.left)/2, | |||||
| rectParent.top + (rectChild.bottom-rectChild.top)/2, | |||||
| 0, 0, SWP_NOSIZE); | |||||
| } | |||||
| } | |||||
| carla_stdout("Match found using window name"); | |||||
| return true; | |||||
| } | |||||
| return false; | |||||
| #endif | |||||
| // fallback, may be unused | |||||
| return true; | return true; | ||||
| (void)pid; (void)centerUI; | (void)pid; (void)centerUI; | ||||
| #endif | |||||
| } | } | ||||
| // ----------------------------------------------------- | // ----------------------------------------------------- | ||||