From d43ded20602e2ebb9e06cb880c6bea3cb1523fe9 Mon Sep 17 00:00:00 2001 From: somewhatlurker <52014015+somewhatlurker@users.noreply.github.com> Date: Sat, 14 Sep 2019 15:07:58 +1000 Subject: [PATCH] make borderless popup windows style optional --- source-code/data/plugins/config.ini | 2 ++ source-code/source/plugins/Launcher/framework.h | 1 + source-code/source/plugins/Render/dllmain.cpp | 7 ++++++- source-code/source/plugins/Render/framework.h | 2 ++ 4 files changed, 11 insertions(+), 1 deletion(-) diff --git a/source-code/data/plugins/config.ini b/source-code/data/plugins/config.ini index 93925c1..b5386bd 100644 --- a/source-code/data/plugins/config.ini +++ b/source-code/data/plugins/config.ini @@ -63,6 +63,8 @@ FRM.Motion.Rate=300 Display=1 Width=1280 Height=720 +# Make borderless mode use a popup window (better performance/lower latency, but can cause screenshot issues) +Borderless.Popup=1 # Fullscreen only options BitDepth=32 RefreshRate=60 diff --git a/source-code/source/plugins/Launcher/framework.h b/source-code/source/plugins/Launcher/framework.h index c23adaa..8d1c507 100644 --- a/source-code/source/plugins/Launcher/framework.h +++ b/source-code/source/plugins/Launcher/framework.h @@ -172,6 +172,7 @@ ConfigOptionBase* optionsArray[] = { new BooleanOption(L"TAA", GRAPHICS_SECTION, CONFIG_FILE, L"TAA", L"Temporal Anti-Aliasing", true, false), new BooleanOption(L"MLAA", GRAPHICS_SECTION, CONFIG_FILE, L"MLAA", L"Morphological Anti-Aliasing", true, false), + new BooleanOption(L"borderless.popup", RESOLUTION_SECTION, CONFIG_FILE, L"Popup Borderless Mode", L"Makes borderless mode use a popup window.\nPerformance may increase and latency should decrease, but screenshots may not work as expected.", true, false), new BooleanOption(L"FPS.Limit.LightMode", GRAPHICS_SECTION, CONFIG_FILE, L"Use Lightweight Limiter", L"Makes the FPS limiter use less CPU.\nMay have less consistent performance.", true, false), new NumericOption(L"FPS.Limit", GRAPHICS_SECTION, CONFIG_FILE, L"FPS Limit:", L"Allows you to set a frame rate cap. Set to -1 to unlock the frame rate.", 60, -1, INT_MAX), new NumericOption(L"frm.motion.rate", GRAPHICS_SECTION, CONFIG_FILE, L"FRM Motion Rate:", L"Sets the motion rate (fps) for the Frame Rate Manager component.\nLarger values should be smoother, but more CPU intensive and possibly buggier.", 300, 1, INT_MAX), diff --git a/source-code/source/plugins/Render/dllmain.cpp b/source-code/source/plugins/Render/dllmain.cpp index 6c43ff3..6c0809a 100644 --- a/source-code/source/plugins/Render/dllmain.cpp +++ b/source-code/source/plugins/Render/dllmain.cpp @@ -74,7 +74,12 @@ int hookedCreateWindow(const char* title, void(__cdecl* exit_function)(int)) HDC hDev = wglGetCurrentDC(); // get handle to current opengl device context HWND hWnd = WindowFromDC(hDev); // convert it to a window handle - SetWindowLongPtr(hWnd, GWL_STYLE, WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN); // set no border (visible to ensure something is shown immediately) + LONG_PTR wndStyle = WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN; // set no border (visible to ensure something is shown immediately) + + if (nPopupBorderless) + wndStyle |= WS_POPUP; + + SetWindowLongPtr(hWnd, GWL_STYLE, wndStyle); SetWindowPos(hWnd, HWND_TOP, wndX, wndY, nWidth, nHeight, SWP_FRAMECHANGED); // adjust position to apply new style printf("[Render Manager] Borderless mode.\n"); diff --git a/source-code/source/plugins/Render/framework.h b/source-code/source/plugins/Render/framework.h index 9bc848f..696d17d 100644 --- a/source-code/source/plugins/Render/framework.h +++ b/source-code/source/plugins/Render/framework.h @@ -35,6 +35,8 @@ int nIntResHeight = GetPrivateProfileIntW(L"resolution", L"r.height", 720, CONFI int nBitDepth = GetPrivateProfileIntW(L"resolution", L"bitdepth", 32, CONFIG_FILE); int nRefreshRate = GetPrivateProfileIntW(L"resolution", L"refreshrate", 60, CONFIG_FILE); +int nPopupBorderless = GetPrivateProfileIntW(L"resolution", L"borderless.popup", TRUE, CONFIG_FILE); + int nFpsLimit = GetPrivateProfileIntW(L"graphics", L"fps.limit", 60, CONFIG_FILE); int nUseLightLimiter = GetPrivateProfileIntW(L"graphics", L"fps.limit.lightmode", TRUE, CONFIG_FILE); int nVerboseLimiter = GetPrivateProfileIntW(L"graphics", L"fps.limit.verbose", FALSE, CONFIG_FILE);