diff --git a/source/backend/CarlaStandaloneNSM.cpp b/source/backend/CarlaStandaloneNSM.cpp index e74d7cade..ad51e6bf6 100644 --- a/source/backend/CarlaStandaloneNSM.cpp +++ b/source/backend/CarlaStandaloneNSM.cpp @@ -232,11 +232,12 @@ protected: fHasOptionalGui = std::strstr(features, ":optional-gui:") != nullptr; fHasServerControl = std::strstr(features, ":server_control:") != nullptr; -#if 0 - // UI starts visible + // UI starts hidden if (fHasOptionalGui) - lo_send_from(fReplyAddress, fServer, LO_TT_IMMEDIATE, "/nsm/client/gui_is_shown", ""); -#endif + { + // NOTE: lo_send_from is a macro that creates local variables + lo_send_from(fReplyAddress, fServer, LO_TT_IMMEDIATE, "/nsm/client/gui_is_hidden", ""); + } carla_stdout("Carla started via '%s', message: %s", smName, message); @@ -298,6 +299,7 @@ protected: if (carla_is_engine_running(handle)) carla_engine_close(handle); + // TODO send error if engine failed to initialize carla_engine_init(handle, "JACK", clientNameId); fProjectPath = projectPath; diff --git a/source/frontend/carla b/source/frontend/carla index 7f47f7341..6239d996f 100755 --- a/source/frontend/carla +++ b/source/frontend/carla @@ -54,7 +54,7 @@ if __name__ == '__main__': # ------------------------------------------------------------------------------------------------------------------ # Show GUI - gui.show() + gui.showIfNeeded() # ------------------------------------------------------------------------------------------------------------------ # App-Loop diff --git a/source/frontend/carla-jack-multi b/source/frontend/carla-jack-multi index 3a44c1441..1d1623227 100755 --- a/source/frontend/carla-jack-multi +++ b/source/frontend/carla-jack-multi @@ -60,7 +60,7 @@ if __name__ == '__main__': # ------------------------------------------------------------------------------------------------------------------ # Show GUI - gui.show() + gui.showIfNeeded() # ------------------------------------------------------------------------------------------------------------------ # App-Loop diff --git a/source/frontend/carla-jack-single b/source/frontend/carla-jack-single index 7a7b4a65d..c14151d1c 100755 --- a/source/frontend/carla-jack-single +++ b/source/frontend/carla-jack-single @@ -60,7 +60,7 @@ if __name__ == '__main__': # ------------------------------------------------------------------------------------------------------------------ # Show GUI - gui.show() + gui.showIfNeeded() # ------------------------------------------------------------------------------------------------------------------ # App-Loop diff --git a/source/frontend/carla-patchbay b/source/frontend/carla-patchbay index 05861b54f..0b0e63451 100755 --- a/source/frontend/carla-patchbay +++ b/source/frontend/carla-patchbay @@ -58,7 +58,7 @@ if __name__ == '__main__': # ------------------------------------------------------------------------------------------------------------------ # Show GUI - gui.show() + gui.showIfNeeded() # ------------------------------------------------------------------------------------------------------------------ # App-Loop diff --git a/source/frontend/carla_host.py b/source/frontend/carla_host.py index 3987e78db..0e4c61c8e 100644 --- a/source/frontend/carla_host.py +++ b/source/frontend/carla_host.py @@ -610,6 +610,23 @@ class HostWindow(QMainWindow): if not host.isControl: QTimer.singleShot(0, self.slot_engineStart) + # -------------------------------------------------------------------------------------------------------- + # Manage visibility state, needed for NSM + + def hideForNSM(self): + for pitem in reversed(self.fPluginList): + if pitem is None: + continue + widget = pitem.getWidget().hideCustomUI() + self.hide() + + def showIfNeeded(self): + if self.host.nsmOK: + self.ui.act_file_quit.setText(self.tr("Hide")) + QApplication.instance().setQuitOnLastWindowClosed(False) + else: + self.show() + # -------------------------------------------------------------------------------------------------------- # Setup @@ -2404,11 +2421,7 @@ class HostWindow(QMainWindow): # Hide Optional Gui elif opcode == NSM_CALLBACK_HIDE_OPTIONAL_GUI: - for pitem in reversed(self.fPluginList): - if pitem is None: - continue - widget = pitem.getWidget().hideCustomUI() - self.hide() + self.hideForNSM() self.host.nsm_ready(opcode) @@ -2453,7 +2466,7 @@ class HostWindow(QMainWindow): def slot_handleSIGTERM(self): print("Got SIGTERM -> Closing now") self.fCustomStopAction = self.CUSTOM_ACTION_APP_CLOSE - self.slot_engineStop(True) + self.close() # -------------------------------------------------------------------------------------------------------- # Internal stuff @@ -2749,6 +2762,11 @@ class HostWindow(QMainWindow): event.ignore() return + if self.host.nsmOK and self.fCustomStopAction != self.CUSTOM_ACTION_APP_CLOSE: + self.hideForNSM() + self.host.nsm_ready(NSM_CALLBACK_HIDE_OPTIONAL_GUI) + return + patchcanvas.handleAllPluginsRemoved() if MACOS and self.fMacClosingHelper and not (self.host.isControl or self.host.isPlugin): @@ -2773,6 +2791,9 @@ class HostWindow(QMainWindow): QMainWindow.closeEvent(self, event) + # if we reach this point, fully close ourselves + QApplication.instance().quit() + # ------------------------------------------------------------------------------------------------ # Canvas callback