diff --git a/source/backend/CarlaHost.h b/source/backend/CarlaHost.h index 0cf070d32..0ab30d6c0 100644 --- a/source/backend/CarlaHost.h +++ b/source/backend/CarlaHost.h @@ -1079,6 +1079,7 @@ CARLA_EXPORT const char* carla_get_host_osc_url_udp(); /*! * Implemented in standalone. */ +extern ulong carla_standalone_get_transient_win_id(); extern const char* carla_standalone_file_callback(FileCallbackOpcode action, bool isDir, const char* title, const char* filter); #endif /* CARLA_HOST_H_INCLUDED */ diff --git a/source/backend/plugin/CarlaPluginUi.cpp b/source/backend/plugin/CarlaPluginUi.cpp index 19c9a9c69..899088d30 100644 --- a/source/backend/plugin/CarlaPluginUi.cpp +++ b/source/backend/plugin/CarlaPluginUi.cpp @@ -149,6 +149,14 @@ public: XStoreName(fDisplay, fWindow, title); } + void setTransientWinId(const uintptr_t winId) override + { + CARLA_SAFE_ASSERT_RETURN(fDisplay != nullptr,); + CARLA_SAFE_ASSERT_RETURN(fWindow != 0,); + + XSetTransientForHint(fDisplay, fWindow, (Window)winId); + } + void* getPtr() const noexcept { return (void*)fWindow; diff --git a/source/backend/plugin/CarlaPluginUi.hpp b/source/backend/plugin/CarlaPluginUi.hpp index b20c8cd28..48d516d9f 100644 --- a/source/backend/plugin/CarlaPluginUi.hpp +++ b/source/backend/plugin/CarlaPluginUi.hpp @@ -38,6 +38,7 @@ public: virtual void idle() = 0; virtual void setSize(const uint with, const uint height, const bool forceUpdate) = 0; virtual void setTitle(const char* const title) = 0; + virtual void setTransientWinId(const uintptr_t winId) = 0; virtual void* getPtr() const noexcept = 0; #ifdef CARLA_OS_MAC diff --git a/source/backend/plugin/Lv2Plugin.cpp b/source/backend/plugin/Lv2Plugin.cpp index f79887290..2e2c5c006 100644 --- a/source/backend/plugin/Lv2Plugin.cpp +++ b/source/backend/plugin/Lv2Plugin.cpp @@ -24,6 +24,8 @@ #include "CarlaMathUtils.hpp" #include "CarlaLv2Utils.hpp" + +#include "CarlaHost.h" #include "CarlaPluginUi.hpp" #include "Lv2AtomQueue.hpp" @@ -1158,6 +1160,9 @@ public: if (fUi.window == nullptr) return pData->engine->callback(ENGINE_CALLBACK_UI_STATE_CHANGED, pData->id, -1, 0, 0.0f, msg); + if (const uintptr_t transientId = carla_standalone_get_transient_win_id()) + fUi.window->setTransientWinId(transientId); + fUi.window->setTitle(fUi.title); #if 0 diff --git a/source/backend/plugin/Makefile b/source/backend/plugin/Makefile index a178765c2..e3d9bef5d 100644 --- a/source/backend/plugin/Makefile +++ b/source/backend/plugin/Makefile @@ -78,7 +78,7 @@ LadspaPlugin.cpp.o: LadspaPlugin.cpp $(CARLA_PLUGIN_INTERNAL_HPP) $(CARLA_ENGINE DssiPlugin.cpp.o: DssiPlugin.cpp $(CARLA_PLUGIN_INTERNAL_HPP) $(CARLA_ENGINE_HPP) $(CARLA_DSSI_UTILS_HPP) $(CARLA_MATH_UTILS_HPP) $(CXX) $< $(BUILD_CXX_FLAGS) $(QTCORE_FLAGS) -c -o $@ -Lv2Plugin.cpp.o: Lv2Plugin.cpp $(CARLA_PLUGIN_INTERNAL_HPP) $(CARLA_ENGINE_HPP) $(CARLA_MATH_UTILS_HPP) $(CARLA_LV2_UTILS_HPP) $(CARLA_PLUGIN_UI_HPP) $(LV2_ATOM_QUEUE_HPP) $(CARLA_ENGINE_OSC_HPP) +Lv2Plugin.cpp.o: Lv2Plugin.cpp $(CARLA_PLUGIN_INTERNAL_HPP) $(CARLA_ENGINE_HPP) $(CARLA_MATH_UTILS_HPP) $(CARLA_LV2_UTILS_HPP) $(CARLA_HOST_H) $(CARLA_PLUGIN_UI_HPP) $(LV2_ATOM_QUEUE_HPP) $(CARLA_ENGINE_OSC_HPP) $(CXX) $< $(BUILD_CXX_FLAGS) $(QTCORE_FLAGS) -c -o $@ VstPlugin.cpp.o: VstPlugin.cpp $(CARLA_PLUGIN_INTERNAL_HPP) $(CARLA_ENGINE_HPP) $(CARLA_VST_UTILS_HPP) $(CARLA_MATH_UTILS_HPP) diff --git a/source/backend/standalone/CarlaStandalone.cpp b/source/backend/standalone/CarlaStandalone.cpp index 6ace815cb..568d3055b 100644 --- a/source/backend/standalone/CarlaStandalone.cpp +++ b/source/backend/standalone/CarlaStandalone.cpp @@ -113,6 +113,15 @@ struct CarlaBackendStandalone { static CarlaBackendStandalone gStandalone; +// ------------------------------------------------------------------------------------------------------------------- + +static ulong gTransientWinId = 0; + +ulong carla_standalone_get_transient_win_id() +{ + return gTransientWinId; +} + // ------------------------------------------------------------------------------------------------------------------- // API @@ -571,6 +580,13 @@ void carla_set_engine_option(EngineOption option, int value, const char* valueSt switch (option) { case CB::ENGINE_OPTION_DEBUG: + if (value == -1729) + { + CARLA_SAFE_ASSERT_BREAK(valueStr != nullptr && valueStr[0] != '\0'); + const long winId(std::atol(valueStr)); + CARLA_SAFE_ASSERT_BREAK(winId != 0); + gTransientWinId = static_cast(winId); + } break; case CB::ENGINE_OPTION_PROCESS_MODE: diff --git a/source/carla b/source/carla index 383b5a21e..f597b2325 100755 --- a/source/carla +++ b/source/carla @@ -303,11 +303,8 @@ if __name__ == '__main__': Carla.gui = CarlaHostW() - # test - win = Carla.gui.winId() - - if win: - os.environ["CARLA_TRANSIENT_WINDOW"] = str(win) + # set our gui as transient for all plugins UIs + Carla.host.set_engine_option(ENGINE_OPTION_DEBUG, -1729, str(Carla.gui.winId())) # ------------------------------------------------------------- # Load project file if set diff --git a/source/carla-patchbay b/source/carla-patchbay index b80bc8620..37d48c6a6 100755 --- a/source/carla-patchbay +++ b/source/carla-patchbay @@ -87,6 +87,9 @@ if __name__ == '__main__': Carla.gui = CarlaHostW() + # set our gui as transient for all plugins UIs + Carla.host.set_engine_option(ENGINE_OPTION_DEBUG, -1729, str(Carla.gui.winId())) + # ------------------------------------------------------------- # Load project file if set diff --git a/source/carla-rack b/source/carla-rack index eef6ea29e..bc72a7f7e 100755 --- a/source/carla-rack +++ b/source/carla-rack @@ -87,6 +87,9 @@ if __name__ == '__main__': Carla.gui = CarlaHostW() + # set our gui as transient for all plugins UIs + Carla.host.set_engine_option(ENGINE_OPTION_DEBUG, -1729, str(Carla.gui.winId())) + # ------------------------------------------------------------- # Load project file if set diff --git a/source/plugin/carla-native-base.cpp b/source/plugin/carla-native-base.cpp index de5e4ecd6..63ce1c6be 100644 --- a/source/plugin/carla-native-base.cpp +++ b/source/plugin/carla-native-base.cpp @@ -29,7 +29,12 @@ // ----------------------------------------------------------------------- -const char* carla_file_callback(FileCallbackOpcode action, bool isDir, const char* title, const char* filter) +ulong carla_standalone_get_transient_win_id() +{ + return 0; +} + +const char* carla_standalone_file_callback(FileCallbackOpcode action, bool isDir, const char* title, const char* filter) { CARLA_SAFE_ASSERT_RETURN(title != nullptr && title[0] != '\0', nullptr); CARLA_SAFE_ASSERT_RETURN(filter != nullptr && filter[0] != '\0', nullptr);