diff --git a/source/backend/CarlaPlugin.hpp b/source/backend/CarlaPlugin.hpp index 722503863..0bc2ed047 100644 --- a/source/backend/CarlaPlugin.hpp +++ b/source/backend/CarlaPlugin.hpp @@ -423,7 +423,7 @@ public: * * @see getId() */ - void setId(const uint newId) noexcept; + virtual void setId(const uint newId) noexcept; /*! * Set the plugin's name to @a newName. @@ -838,6 +838,13 @@ public: */ virtual const void* getNativeDescriptor() const noexcept; + /*! + * Get the plugin UI bridge process Id. + */ + virtual uintptr_t getUiBridgeProcessId() const noexcept; + + // ------------------------------------------------------------------- + /*! * Get the plugin's patchbay nodeId. * @see setPatchbayNodeId() diff --git a/source/backend/plugin/CarlaPlugin.cpp b/source/backend/plugin/CarlaPlugin.cpp index 5444d26dd..ddc016a49 100644 --- a/source/backend/plugin/CarlaPlugin.cpp +++ b/source/backend/plugin/CarlaPlugin.cpp @@ -1351,13 +1351,7 @@ void CarlaPlugin::idle() CarlaString uiTitle(pData->name); uiTitle += " (GUI)"; - uint32_t pid = 0; -#ifndef BUILD_BRIDGE - if (pData->oscData.target != nullptr && pData->childProcess != nullptr) - pid = pData->childProcess->getPID(); -#endif - - if (CarlaPluginUI::tryTransientWinIdMatch(pid, uiTitle, pData->engine->getOptions().frontendWinId, true)) + if (CarlaPluginUI::tryTransientWinIdMatch(getUiBridgeProcessId(), uiTitle, pData->engine->getOptions().frontendWinId, true)) pData->transientTryCounter = 0; } @@ -1891,6 +1885,13 @@ const void* CarlaPlugin::getNativeDescriptor() const noexcept return nullptr; } +uintptr_t CarlaPlugin::getUiBridgeProcessId() const noexcept +{ + return 0; +} + +// ------------------------------------------------------------------- + uint32_t CarlaPlugin::getPatchbayNodeId() const noexcept { return pData->nodeId; diff --git a/source/backend/plugin/CarlaPluginDSSI.cpp b/source/backend/plugin/CarlaPluginDSSI.cpp index 942bd3eb0..5b5ae17a1 100644 --- a/source/backend/plugin/CarlaPluginDSSI.cpp +++ b/source/backend/plugin/CarlaPluginDSSI.cpp @@ -350,7 +350,13 @@ public: // ------------------------------------------------------------------- // Set data (internal stuff) - // nothing + void setId(const uint newId) noexcept + { + CarlaPlugin::setId(newId); + + // UI osc-url uses Id, so we need to close it when it changes + showCustomUI(false); + } // ------------------------------------------------------------------- // Set data (plugin-specific stuff) @@ -2026,6 +2032,11 @@ public: return fDssiDescriptor; } + uintptr_t getUiBridgeProcessId() const noexcept override + { + return (pData->oscData.target != nullptr && pData->childProcess != nullptr) ? pData->childProcess->getPID() : 0; + } + const void* getExtraStuff() const noexcept override { return fUiFilename; diff --git a/source/backend/plugin/CarlaPluginLV2.cpp b/source/backend/plugin/CarlaPluginLV2.cpp index c207da8c4..57beafed0 100644 --- a/source/backend/plugin/CarlaPluginLV2.cpp +++ b/source/backend/plugin/CarlaPluginLV2.cpp @@ -4621,6 +4621,11 @@ public: return fDescriptor; } + uintptr_t getUiBridgeProcessId() const noexcept override + { + return fPipeServer.isPipeRunning() ? fPipeServer.getPID() : 0; + } + // ------------------------------------------------------------------- public: diff --git a/source/utils/CarlaPipeUtils.cpp b/source/utils/CarlaPipeUtils.cpp index 2e39e35f4..47df5acf2 100644 --- a/source/utils/CarlaPipeUtils.cpp +++ b/source/utils/CarlaPipeUtils.cpp @@ -1050,6 +1050,15 @@ CarlaPipeServer::~CarlaPipeServer() /*noexcept*/ stopPipeServer(5*1000); } +uintptr_t CarlaPipeServer::getPID() const noexcept +{ +#ifndef CARLA_OS_WIN + return pData->pid; +#else + return 0; +#endif +} + // ----------------------------------------------------------------------- bool CarlaPipeServer::startPipeServer(const char* const filename, const char* const arg1, const char* const arg2) noexcept diff --git a/source/utils/CarlaPipeUtils.hpp b/source/utils/CarlaPipeUtils.hpp index 67734b8c9..fb9ffce6f 100644 --- a/source/utils/CarlaPipeUtils.hpp +++ b/source/utils/CarlaPipeUtils.hpp @@ -244,6 +244,13 @@ public: */ ~CarlaPipeServer() /*noexcept*/ override; + /*! + * Get the process ID of this pipe's matching client. + * Will return 0 if client is not running. + * @note: Unsupported on Windows + */ + uintptr_t getPID() const noexcept; + /*! * Start the pipe server using @a filename with 2 arguments. * @see fail()