diff --git a/source/bridges-ui/CarlaBridgeToolkitGtk.cpp b/source/bridges-ui/CarlaBridgeToolkitGtk.cpp index 676771743..459f3dfea 100644 --- a/source/bridges-ui/CarlaBridgeToolkitGtk.cpp +++ b/source/bridges-ui/CarlaBridgeToolkitGtk.cpp @@ -85,7 +85,7 @@ public: gtk_container_add(GTK_CONTAINER(fWindow), widget); gtk_window_set_resizable(gtkWindow, options.isResizable); - gtk_window_set_title(gtkWindow, options.windowTitle); + gtk_window_set_title(gtkWindow, options.windowTitle.buffer()); if (showUI || fNeedsShow) { @@ -195,14 +195,10 @@ protected: gtk_window_get_size(GTK_WINDOW(fWindow), &fLastWidth, &fLastHeight); } - ui->idlePipe(); - ui->idleUI(); + if (ui->isPipeRunning()) + ui->idlePipe(); -// if (! fUi) -// { -// gtk_main_quit_if_needed(); -// return false; -// } + ui->idleUI(); return true; } diff --git a/source/bridges-ui/CarlaBridgeToolkitPlugin.cpp b/source/bridges-ui/CarlaBridgeToolkitPlugin.cpp index d02e4a896..ed47f5e58 100644 --- a/source/bridges-ui/CarlaBridgeToolkitPlugin.cpp +++ b/source/bridges-ui/CarlaBridgeToolkitPlugin.cpp @@ -65,7 +65,7 @@ public: #endif CARLA_SAFE_ASSERT_RETURN(fUI != nullptr, false); - fUI->setTitle(options.windowTitle); + fUI->setTitle(options.windowTitle.buffer()); fUI->setTransientWinId(options.transientWindowId); return true; @@ -90,12 +90,12 @@ public: for (; fIdling;) { - fUI->idle(); - ui->idlePipe(); + if (ui->isPipeRunning()) + ui->idlePipe(); + ui->idleUI(); - //if (! kClient->oscIdle()) - // break; + fUI->idle(); #if defined(CARLA_OS_WIN) || defined(CARLA_OS_MAC) if (MessageManager* const msgMgr = MessageManager::getInstance()) @@ -108,13 +108,16 @@ public: void quit() override { - CARLA_SAFE_ASSERT_RETURN(fUI != nullptr,); carla_debug("CarlaBridgeToolkitPlugin::quit()"); fIdling = false; - delete fUI; - fUI = nullptr; + if (fUI != nullptr) + { + fUI->hide(); + delete fUI; + fUI = nullptr; + } } void show() override diff --git a/source/bridges-ui/CarlaBridgeToolkitQt.cpp b/source/bridges-ui/CarlaBridgeToolkitQt.cpp index 387894ada..7b8fb481f 100644 --- a/source/bridges-ui/CarlaBridgeToolkitQt.cpp +++ b/source/bridges-ui/CarlaBridgeToolkitQt.cpp @@ -112,7 +112,7 @@ public: } fWindow->setWindowIcon(QIcon::fromTheme("carla", QIcon(":/scalable/carla.svg"))); - fWindow->setWindowTitle(options.windowTitle); + fWindow->setWindowTitle(options.windowTitle.buffer()); if (options.transientWindowId != 0) { @@ -226,15 +226,10 @@ protected: { CARLA_SAFE_ASSERT_RETURN(ui != nullptr,); - ui->idlePipe(); - ui->idleUI(); + if (ui->isPipeRunning()) + ui->idlePipe(); -// if (! kClient->oscIdle()) -// { -// killTimer(fMsgTimer); -// fMsgTimer = 0; -// fApp->quit(); -// } + ui->idleUI(); } private: diff --git a/source/bridges-ui/CarlaBridgeUI-LV2.cpp b/source/bridges-ui/CarlaBridgeUI-LV2.cpp index 8d74b84fc..467c871fd 100644 --- a/source/bridges-ui/CarlaBridgeUI-LV2.cpp +++ b/source/bridges-ui/CarlaBridgeUI-LV2.cpp @@ -377,12 +377,6 @@ public: bool init(const int argc, const char* argv[]) override { - // ----------------------------------------------------------------- - // init UI - - if (! CarlaBridgeUI::init(argc, argv)) - return false; - const char* pluginURI = argv[1]; const char* uiURI = argv[2]; @@ -422,6 +416,45 @@ public: CARLA_SAFE_ASSERT_RETURN(fRdfUiDescriptor != nullptr, false); + // ----------------------------------------------------------- + // check if not resizable + +#if defined(BRIDGE_COCOA) || defined(BRIDGE_HWND) || defined(BRIDGE_X11) + // embed UIs can only be resizable if they provide resize extension + fUiOptions.isResizable = false; + + for (uint32_t i=0; i < fRdfUiDescriptor->ExtensionCount; ++i) + { + carla_stdout("Test UI extension %s", fRdfUiDescriptor->Extensions[i]); + + if (std::strcmp(fRdfUiDescriptor->Extensions[i], LV2_UI__resize) == 0) + { + fUiOptions.isResizable = true; + break; + } + } +#endif + + for (uint32_t i=0; i < fRdfUiDescriptor->FeatureCount; ++i) + { + carla_stdout("Test UI feature %s", fRdfUiDescriptor->Features[i].URI); + + if (std::strcmp(fRdfUiDescriptor->Features[i].URI, LV2_UI__fixedSize ) == 0 || + std::strcmp(fRdfUiDescriptor->Features[i].URI, LV2_UI__noUserResize) == 0) + { + fUiOptions.isResizable = false; + break; + } + } + + carla_stdout("Is resizable => %s", bool2str(fUiOptions.isResizable)); + + // ----------------------------------------------------------------- + // init UI + + if (! CarlaBridgeUI::init(argc, argv)) + return false; + // ----------------------------------------------------------------- // open DLL @@ -465,19 +498,6 @@ public: fHandle = fDescriptor->instantiate(fDescriptor, fRdfDescriptor->URI, fRdfUiDescriptor->Bundle, carla_lv2_ui_write_function, this, &fWidget, fFeatures); CARLA_SAFE_ASSERT_RETURN(fHandle != nullptr, false); - // ----------------------------------------------------------- - // check if not resizable - - for (uint32_t j=0; j < fRdfUiDescriptor->FeatureCount; ++j) - { - if (std::strcmp(fRdfUiDescriptor->Features[j].URI, LV2_UI__fixedSize ) == 0 || - std::strcmp(fRdfUiDescriptor->Features[j].URI, LV2_UI__noUserResize) == 0) - { - fUiOptions.isResizable = false; - break; - } - } - // ----------------------------------------------------------- // check for known extensions @@ -568,7 +588,7 @@ public: void dspAtomReceived(const uint32_t portIndex, const LV2_Atom* const atom) override { - CARLA_SAFE_ASSERT_RETURN(fHandle != nullptr,) + CARLA_SAFE_ASSERT_RETURN(fHandle != nullptr,); CARLA_SAFE_ASSERT_RETURN(fDescriptor != nullptr,); CARLA_SAFE_ASSERT_RETURN(atom != nullptr,); diff --git a/source/bridges-ui/CarlaBridgeUI.cpp b/source/bridges-ui/CarlaBridgeUI.cpp index bc28d10db..6dcf21315 100644 --- a/source/bridges-ui/CarlaBridgeUI.cpp +++ b/source/bridges-ui/CarlaBridgeUI.cpp @@ -245,6 +245,8 @@ bool CarlaBridgeUI::msgReceived(const char* const msg) noexcept { fQuitReceived = true; fToolkit->quit(); + delete fToolkit; + fToolkit = nullptr; return true; } @@ -300,6 +302,11 @@ bool CarlaBridgeUI::init(const int argc, const char* argv[]) } #endif } + else + { + // no mapping needed + fUridMapComplete = true; + } return true; } diff --git a/source/bridges-ui/CarlaBridgeUI.hpp b/source/bridges-ui/CarlaBridgeUI.hpp index fde8e3bd9..ca5dcba04 100644 --- a/source/bridges-ui/CarlaBridgeUI.hpp +++ b/source/bridges-ui/CarlaBridgeUI.hpp @@ -21,6 +21,7 @@ #include "CarlaBridgeToolkit.hpp" #include "CarlaLibUtils.hpp" #include "CarlaPipeUtils.hpp" +#include "CarlaString.hpp" #ifdef BRIDGE_LV2 # include "lv2/atom.h" @@ -115,7 +116,7 @@ public: /*! * Window title. */ - const char* windowTitle; + CarlaString windowTitle; /*! * Transient window id (parent), null if zero. @@ -129,7 +130,7 @@ public: : isResizable(true), useTheme(true), useThemeColors(true), - windowTitle(nullptr), + windowTitle("TestUI"), transientWindowId(0) {} };