From c989a941c575c496bffe2dde245e28dd7f79b321 Mon Sep 17 00:00:00 2001 From: Benjamin Schubert Date: Fri, 12 May 2023 18:16:36 -0400 Subject: [PATCH] Requests: Add CloseMainWindow Adds a new request called CloseMainWindow which closes the main window and cleanly shuts down OBS. --- src/requesthandler/RequestHandler.cpp | 1 + src/requesthandler/RequestHandler.h | 1 + src/requesthandler/RequestHandler_Ui.cpp | 16 ++++++++++++++++ 3 files changed, 18 insertions(+) diff --git a/src/requesthandler/RequestHandler.cpp b/src/requesthandler/RequestHandler.cpp index 785b00384..f1aeb71b4 100644 --- a/src/requesthandler/RequestHandler.cpp +++ b/src/requesthandler/RequestHandler.cpp @@ -182,6 +182,7 @@ const std::unordered_map RequestHandler::_han {"TriggerMediaInputAction", &RequestHandler::TriggerMediaInputAction}, // Ui + {"CloseMainWindow", &RequestHandler::CloseMainWindow}, {"GetStudioModeEnabled", &RequestHandler::GetStudioModeEnabled}, {"SetStudioModeEnabled", &RequestHandler::SetStudioModeEnabled}, {"OpenInputPropertiesDialog", &RequestHandler::OpenInputPropertiesDialog}, diff --git a/src/requesthandler/RequestHandler.h b/src/requesthandler/RequestHandler.h index cfd100ad0..914ba9088 100644 --- a/src/requesthandler/RequestHandler.h +++ b/src/requesthandler/RequestHandler.h @@ -201,6 +201,7 @@ class RequestHandler { RequestResult TriggerMediaInputAction(const Request &); // Ui + RequestResult CloseMainWindow(const Request &); RequestResult GetStudioModeEnabled(const Request &); RequestResult SetStudioModeEnabled(const Request &); RequestResult OpenInputPropertiesDialog(const Request &); diff --git a/src/requesthandler/RequestHandler_Ui.cpp b/src/requesthandler/RequestHandler_Ui.cpp index aa3d0f1ee..e3e26a012 100644 --- a/src/requesthandler/RequestHandler_Ui.cpp +++ b/src/requesthandler/RequestHandler_Ui.cpp @@ -24,6 +24,22 @@ with this program. If not, see #include "RequestHandler.h" +/** + * Closes the main window. + * + * @requestType CloseMainWindow + * @complexity 1 + * @rpcVersion -1 + * @initialVersion 5.0.0 + * @category ui + * @api requests + */ +RequestResult RequestHandler::CloseMainWindow(const Request &) +{ + obs_frontend_close_main_window(); + return RequestResult::Success(); +} + /** * Gets whether studio is enabled. *