Skip to content

Commit

Permalink
Add an option to strip window of it's borders to improve multi with 1…
Browse files Browse the repository at this point in the history
… display.
  • Loading branch information
LunaMoo committed May 5, 2019
1 parent df1e967 commit 9b0b239
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 1 deletion.
1 change: 1 addition & 0 deletions Core/Config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
1 change: 1 addition & 0 deletions Core/Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,7 @@ struct Config {
#if defined(USING_WIN_UI)
bool bBypassOSKWithKeyboard;
bool bDisableWinMenu;
bool bDisableWinBorders;
#endif

// Debugger
Expand Down
28 changes: 27 additions & 1 deletion UI/GameSettingsScreen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
1 change: 1 addition & 0 deletions UI/GameSettingsScreen.h
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ class OtherSettingsScreen : public UIDialogScreenWithBackground {
void CreateViews() override;

private:
UI::EventReturn OnDisableWinBorders(UI::EventParams& e);
bool QualityDepth_;
};

Expand Down
30 changes: 30 additions & 0 deletions Windows/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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();
Expand Down
1 change: 1 addition & 0 deletions Windows/MainWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ namespace MainWindow
void ToggleDebugConsoleVisibility();
void SetInternalResolution(int res = -1);
void SetWindowSize(int zoom);
void SetWindowXXYY();
}

#endif

0 comments on commit 9b0b239

Please sign in to comment.