diff --git a/Core/Config.cpp b/Core/Config.cpp index bfc8806751..a4ea72eb6a 100644 --- a/Core/Config.cpp +++ b/Core/Config.cpp @@ -849,6 +849,7 @@ static ConfigSetting systemParamSettings[] = { #if defined(USING_WIN_UI) ConfigSetting("BypassOSKWithKeyboard", &g_Config.bBypassOSKWithKeyboard, false, true, true), ConfigSetting("DisableWinMenu", &g_Config.bDisableWinMenu, false, true, true), + ConfigSetting("DisableWinBorders", &g_Config.bDisableWinBorders, false, true, true), #endif ConfigSetting("WlanPowerSave", &g_Config.bWlanPowerSave, (bool) PSP_SYSTEMPARAM_WLAN_POWERSAVE_OFF, true, true), ReportedConfigSetting("EncryptSave", &g_Config.bEncryptSave, true, true, true), diff --git a/Core/Config.h b/Core/Config.h index 918cdefc95..a2429a90d3 100644 --- a/Core/Config.h +++ b/Core/Config.h @@ -380,6 +380,7 @@ public: #if defined(USING_WIN_UI) bool bBypassOSKWithKeyboard; bool bDisableWinMenu; + bool bDisableWinBorders; #endif // Debugger diff --git a/UI/GameSettingsScreen.cpp b/UI/GameSettingsScreen.cpp index 43f75bb716..9539e635ec 100644 --- a/UI/GameSettingsScreen.cpp +++ b/UI/GameSettingsScreen.cpp @@ -1503,13 +1503,39 @@ void OtherSettingsScreen::CreateViews() { list->Add(new CheckBox(&g_Config.bSimpleFrameStats, gr->T("Display simple frame stats(heavy!)"))); list->Add(new CheckBox(&g_Config.bSavestateScreenshotResLimit, gr->T("Limit resolution of savestates screenshots"))); list->Add(new CheckBox(&g_Config.bDiscordPresence, n->T("Send Discord(3rd party software) Presence information"))); - list->Add(new CheckBox(&g_Config.bDisableWinMenu, n->T("Disable Windows menu bar"))); +#if defined(USING_WIN_UI) + list->Add(new CheckBox(&g_Config.bDisableWinMenu, n->T("Disable Windows menu bar")))->OnClick.Handle(this, &OtherSettingsScreen::OnDisableWinBorders); + list->Add(new CheckBox(&g_Config.bDisableWinBorders, n->T("Disable Windows borders")))->OnClick.Handle(this, &OtherSettingsScreen::OnDisableWinBorders); + if (g_Config.bDisableWinBorders) { + const int currentScreenWidth = GetSystemMetrics(SM_CXSCREEN); + const int currentScreenHeight = GetSystemMetrics(SM_CYSCREEN); + PopupSliderChoice* pWindowPosX = list->Add(new PopupSliderChoice(&g_Config.iWindowX, 0, currentScreenWidth, gr->T("X Coordinate of the window"), 1, screenManager(), gr->T("X"))); + pWindowPosX->SetFormat("%i X"); + pWindowPosX->OnChange.Handle(this, &OtherSettingsScreen::OnDisableWinBorders); + PopupSliderChoice* pWindowPosY = list->Add(new PopupSliderChoice(&g_Config.iWindowY, 0, currentScreenHeight, gr->T("Y Coordinate of the window"), 1, screenManager(), gr->T("Y"))); + pWindowPosY->SetFormat("%i Y"); + pWindowPosY->OnChange.Handle(this, &OtherSettingsScreen::OnDisableWinBorders); + PopupSliderChoice* pWindowWidth = list->Add(new PopupSliderChoice(&g_Config.iWindowWidth, 480, currentScreenWidth, gr->T("X Size of the window"), 1, screenManager(), gr->T("X"))); + pWindowWidth->SetFormat("%i X"); + pWindowWidth->OnChange.Handle(this, &OtherSettingsScreen::OnDisableWinBorders); + PopupSliderChoice* pWindowHeight = list->Add(new PopupSliderChoice(&g_Config.iWindowHeight, 272, currentScreenHeight, gr->T("Y Size of the window"), 1, screenManager(), gr->T("Y"))); + pWindowHeight->SetFormat("%i Y"); + pWindowHeight->OnChange.Handle(this, &OtherSettingsScreen::OnDisableWinBorders); + } +#endif } void OtherSettingsScreen::onFinish(DialogResult result) { g_Config.Save("GameSettingsScreen::onFinish"); } +UI::EventReturn OtherSettingsScreen::OnDisableWinBorders(UI::EventParams& e) { + MainWindow::SetWindowXXYY(); + MainWindow::SendToggleFullscreen(g_Config.bFullScreen = false); + RecreateViews(); + return UI::EVENT_DONE; +} + void GameSettingsScreen::CallbackRestoreDefaults(bool yes) { if (yes) g_Config.RestoreDefaults(); diff --git a/UI/GameSettingsScreen.h b/UI/GameSettingsScreen.h index 1a4a40841b..b78bc0ad64 100644 --- a/UI/GameSettingsScreen.h +++ b/UI/GameSettingsScreen.h @@ -185,6 +185,7 @@ protected: void CreateViews() override; private: + UI::EventReturn OnDisableWinBorders(UI::EventParams& e); bool QualityDepth_; }; diff --git a/Windows/MainWindow.cpp b/Windows/MainWindow.cpp index 3005f28139..7451431853 100644 --- a/Windows/MainWindow.cpp +++ b/Windows/MainWindow.cpp @@ -381,6 +381,17 @@ namespace MainWindow if (g_Config.bDisableWinMenu) SetMenu(hwndMain, NULL); + if (g_Config.bDisableWinBorders) { + LONG lStyle = GetWindowLongPtr(hwndMain, GWL_STYLE); + lStyle &= ~(WS_CAPTION | WS_THICKFRAME | WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_SYSMENU); + SetWindowLongPtr(hwndMain, GWL_STYLE, lStyle); + + LONG lExStyle = GetWindowLongPtr(hwndMain, GWL_EXSTYLE); + lExStyle &= ~(WS_EX_DLGMODALFRAME | WS_EX_CLIENTEDGE | WS_EX_STATICEDGE); + SetWindowLongPtr(hwndMain, GWL_EXSTYLE, lExStyle); + + SetWindowPos(hwndMain, NULL, g_Config.iWindowX, g_Config.iWindowY, g_Config.iWindowWidth, g_Config.iWindowHeight, SWP_NOZORDER); + } } void Minimize() { @@ -460,6 +471,25 @@ namespace MainWindow windowTitle = title; } + void SetWindowXXYY() { + const int currentScreenWidth = GetSystemMetrics(SM_CXSCREEN); + const int currentScreenHeight = GetSystemMetrics(SM_CYSCREEN); + if (g_Config.iWindowWidth > currentScreenWidth) + g_Config.iWindowWidth = currentScreenWidth; + if (g_Config.iWindowHeight > currentScreenHeight) + g_Config.iWindowHeight = currentScreenHeight; + if (g_Config.iWindowX > (currentScreenWidth - g_Config.iWindowWidth)) + g_Config.iWindowX = currentScreenWidth - g_Config.iWindowWidth; + if (g_Config.iWindowY > (currentScreenHeight - g_Config.iWindowHeight)) + g_Config.iWindowY = currentScreenHeight - g_Config.iWindowHeight; + if (g_Config.iWindowX < 0) + g_Config.iWindowX = 0; + if (g_Config.iWindowY < 0) + g_Config.iWindowY = 0; + MoveWindow(hwndMain, g_Config.iWindowX, g_Config.iWindowY, g_Config.iWindowWidth, g_Config.iWindowHeight, TRUE); + g_Config.Save("SetWindowXXYY"); + } + BOOL Show(HINSTANCE hInstance) { hInst = hInstance; // Store instance handle in our global variable. RECT rc = DetermineWindowRectangle(); diff --git a/Windows/MainWindow.h b/Windows/MainWindow.h index b10c0468f4..ec90100a68 100644 --- a/Windows/MainWindow.h +++ b/Windows/MainWindow.h @@ -77,6 +77,7 @@ namespace MainWindow void ToggleDebugConsoleVisibility(); void SetInternalResolution(int res = -1); void SetWindowSize(int zoom); + void SetWindowXXYY(); } #endif