diff --git a/Common/System/Request.h b/Common/System/Request.h index 745f4eb555..5c925184a4 100644 --- a/Common/System/Request.h +++ b/Common/System/Request.h @@ -121,3 +121,7 @@ inline void System_ShareText(const std::string &text) { inline void System_NotifyUIState(const std::string &state) { g_requestManager.MakeSystemRequest(SystemRequestType::NOTIFY_UI_STATE, nullptr, state, "", 0); } + +inline void System_SetWindowTitle(const std::string ¶m) { + g_requestManager.MakeSystemRequest(SystemRequestType::SET_WINDOW_TITLE, nullptr, param, "", 0); +} diff --git a/Common/System/System.h b/Common/System/System.h index 71bcb1cb71..f364ec45d4 100644 --- a/Common/System/System.h +++ b/Common/System/System.h @@ -64,16 +64,17 @@ enum class SystemRequestType { EXIT_APP, RESTART_APP, // For graphics backend changes COPY_TO_CLIPBOARD, + SHARE_TEXT, + SET_WINDOW_TITLE, TOGGLE_FULLSCREEN_STATE, GRAPHICS_BACKEND_FAILED_ALERT, + NOTIFY_UI_STATE, // Used on Android only. Not a SystemNotification since it takes a parameter. + // High-level hardware control CAMERA_COMMAND, GPS_COMMAND, MICROPHONE_COMMAND, - - SHARE_TEXT, - NOTIFY_UI_STATE, // Used on Android only. Not a SystemNotification since it takes a parameter. }; // Implementations are supposed to process the request, and post the response to the g_RequestManager (see Message.h). diff --git a/Core/Host.h b/Core/Host.h index 0fc4746710..34267e9652 100644 --- a/Core/Host.h +++ b/Core/Host.h @@ -33,7 +33,6 @@ public: virtual bool AttemptLoadSymbolMap(); virtual void SaveSymbolMap() {} - virtual void SetWindowTitle(const char *message) {} virtual bool CreateDesktopShortcut(std::string argumentPath, std::string title) {return false;} diff --git a/Core/PSPLoaders.cpp b/Core/PSPLoaders.cpp index ab060eb27b..ccf9a349dc 100644 --- a/Core/PSPLoaders.cpp +++ b/Core/PSPLoaders.cpp @@ -19,6 +19,7 @@ #include "Common/Data/Encoding/Utf8.h" #include "Common/Thread/ThreadUtil.h" +#include "Common/System/Request.h" #include "Common/File/FileUtil.h" #include "Common/StringUtils.h" @@ -248,7 +249,7 @@ bool Load_PSP_ISO(FileLoader *fileLoader, std::string *error_string) { if (g_paramSFO.ReadSFO(paramsfo)) { std::string title = StringFromFormat("%s : %s", g_paramSFO.GetValueString("DISC_ID").c_str(), g_paramSFO.GetValueString("TITLE").c_str()); INFO_LOG(LOADER, "%s", title.c_str()); - host->SetWindowTitle(title.c_str()); + System_SetWindowTitle(title); } } @@ -430,7 +431,7 @@ bool Load_PSP_ELF_PBP(FileLoader *fileLoader, std::string *error_string) { std::string title = StringFromFormat("%s : %s", discID.c_str(), homebrewTitle.c_str()); INFO_LOG(LOADER, "%s", title.c_str()); - host->SetWindowTitle(title.c_str()); + System_SetWindowTitle(title); // Migrate old save states from old versions of fake game IDs. const Path savestateDir = GetSysDirectory(DIRECTORY_SAVESTATE); diff --git a/Core/System.cpp b/Core/System.cpp index 5a1c26b338..bd02850911 100644 --- a/Core/System.cpp +++ b/Core/System.cpp @@ -522,7 +522,7 @@ void PSP_Shutdown() { CPU_Shutdown(); GPU_Shutdown(); g_paramSFO.Clear(); - host->SetWindowTitle(0); + System_SetWindowTitle(""); currentMIPS = 0; pspIsInited = false; pspIsIniting = false; diff --git a/Qt/QtHost.h b/Qt/QtHost.h index 71278529e5..275a99bcb8 100644 --- a/Qt/QtHost.h +++ b/Qt/QtHost.h @@ -23,7 +23,6 @@ #include "Qt/mainwindow.h" #include "Core/Debugger/SymbolMap.h" - class QtHost : public Host { public: QtHost(MainWindow *mainWindow_) @@ -42,15 +41,6 @@ public: auto fn = SymbolMapFilename(PSP_CoreParameter().fileToStart); g_symbolMap->SaveSymbolMap(fn); } - void SetWindowTitle(const char *message) override { - std::string title = std::string("PPSSPP ") + PPSSPP_GIT_VERSION; - if (message) - title += std::string(" - ") + message; -#ifdef _DEBUG - title += " (debug)"; -#endif - mainWindow->SetWindowTitleAsync(title); - } void NotifyUserMessage(const std::string &message, float duration = 1.0f, u32 color = 0x00FFFFFF, const char *id = nullptr) override { osm.Show(message, duration, color, -1, true, id); diff --git a/Qt/QtMain.cpp b/Qt/QtMain.cpp index 36a15643dc..86b4caf5d2 100644 --- a/Qt/QtMain.cpp +++ b/Qt/QtMain.cpp @@ -355,6 +355,17 @@ bool System_MakeRequest(SystemRequestType type, int requestId, const std::string case SystemRequestType::COPY_TO_CLIPBOARD: QApplication::clipboard()->setText(param1.c_str()); return true; + case SystemRequestType::SET_WINDOW_TITLE: + { + std::string title = std::string("PPSSPP ") + PPSSPP_GIT_VERSION; + if (!param1.empty()) + title += std::string(" - ") + param1; +#ifdef _DEBUG + title += " (debug)"; +#endif + g_mainWindow->SetWindowTitleAsync(title); + return true; + } case SystemRequestType::INPUT_TEXT_MODAL: { g_requestId = requestId; diff --git a/UI/HostTypes.h b/UI/HostTypes.h index ede4580f52..0ee6325d9a 100644 --- a/UI/HostTypes.h +++ b/UI/HostTypes.h @@ -27,7 +27,6 @@ public: void UpdateSound() override {} bool AttemptLoadSymbolMap() override {return false;} - void SetWindowTitle(const char *message) override {} void NotifyUserMessage(const std::string &message, float duration = 1.0f, u32 color = 0x00FFFFFF, const char *id = nullptr) override { osm.Show(message, duration, color, -1, true, id); diff --git a/UWP/UWPHost.cpp b/UWP/UWPHost.cpp index d620046e82..5048a95868 100644 --- a/UWP/UWPHost.cpp +++ b/UWP/UWPHost.cpp @@ -54,9 +54,6 @@ void UWPHost::SetConsolePosition() { void UWPHost::UpdateConsolePosition() { } -void UWPHost::SetWindowTitle(const char *message) { -} - void UWPHost::UpdateSound() { } diff --git a/UWP/UWPHost.h b/UWP/UWPHost.h index 8e13f6af2a..244a6af3f0 100644 --- a/UWP/UWPHost.h +++ b/UWP/UWPHost.h @@ -18,7 +18,6 @@ public: bool AttemptLoadSymbolMap() override; void SaveSymbolMap() override; - void SetWindowTitle(const char *message) override; void ToggleDebugConsoleVisibility() override; diff --git a/Windows/EmuThread.cpp b/Windows/EmuThread.cpp index 4748557d18..898a0f5d09 100644 --- a/Windows/EmuThread.cpp +++ b/Windows/EmuThread.cpp @@ -4,6 +4,7 @@ #include "Common/System/NativeApp.h" #include "Common/System/System.h" +#include "Common/System/Request.h" #include "Common/Data/Text/I18n.h" #include "Common/Input/InputState.h" #include "Common/Data/Encoding/Utf8.h" @@ -160,7 +161,7 @@ void MainThreadFunc() { } host = new WindowsHost(MainWindow::GetHInstance(), MainWindow::GetHWND(), MainWindow::GetDisplayHWND()); - host->SetWindowTitle(nullptr); + System_SetWindowTitle(""); // We convert command line arguments to UTF-8 immediately. std::vector wideArgs = GetWideCmdLine(); diff --git a/Windows/WindowsHost.cpp b/Windows/WindowsHost.cpp index 5217a01463..1783eab47f 100644 --- a/Windows/WindowsHost.cpp +++ b/Windows/WindowsHost.cpp @@ -109,26 +109,6 @@ void WindowsHost::UpdateConsolePosition() { } } -void WindowsHost::SetWindowTitle(const char *message) { -#ifdef GOLD - const char *name = "PPSSPP Gold "; -#else - const char *name = "PPSSPP "; -#endif - std::wstring winTitle = ConvertUTF8ToWString(std::string(name) + PPSSPP_GIT_VERSION); - if (message != nullptr) { - winTitle.append(ConvertUTF8ToWString(" - ")); - winTitle.append(ConvertUTF8ToWString(message)); - } -#ifdef _DEBUG - winTitle.append(L" (debug)"); -#endif - lastTitle_ = winTitle; - - MainWindow::SetWindowTitle(winTitle.c_str()); - PostMessage(mainWindow_, MainWindow::WM_USER_WINDOW_TITLE_CHANGED, 0, 0); -} - // UGLY! extern WindowsAudioBackend *winAudioBackend; diff --git a/Windows/WindowsHost.h b/Windows/WindowsHost.h index b13032b799..2aeba43996 100644 --- a/Windows/WindowsHost.h +++ b/Windows/WindowsHost.h @@ -36,7 +36,6 @@ public: bool AttemptLoadSymbolMap() override; void SaveSymbolMap() override; - void SetWindowTitle(const char *message) override; void ToggleDebugConsoleVisibility() override; @@ -53,7 +52,6 @@ private: HWND displayWindow_; HWND mainWindow_; size_t numDinputDevices_ = 0; - std::wstring lastTitle_; std::list> input; }; diff --git a/Windows/main.cpp b/Windows/main.cpp index 929abafdc8..561e374dc1 100644 --- a/Windows/main.cpp +++ b/Windows/main.cpp @@ -467,6 +467,24 @@ bool System_MakeRequest(SystemRequestType type, int requestId, const std::string W32Util::CopyTextToClipboard(MainWindow::GetDisplayHWND(), data); return true; } + case SystemRequestType::SET_WINDOW_TITLE: + { +#ifdef GOLD + const char *name = "PPSSPP Gold "; +#else + const char *name = "PPSSPP "; +#endif + std::wstring winTitle = ConvertUTF8ToWString(std::string(name) + PPSSPP_GIT_VERSION); + if (!param1.empty()) { + winTitle.append(ConvertUTF8ToWString(" - " + param1)); + } +#ifdef _DEBUG + winTitle.append(L" (debug)"); +#endif + MainWindow::SetWindowTitle(winTitle.c_str()); + PostMessage(MainWindow::GetHWND(), MainWindow::WM_USER_WINDOW_TITLE_CHANGED, 0, 0); + return true; + } case SystemRequestType::INPUT_TEXT_MODAL: if (g_dialogRunning) { g_dialogThread.join();