From 63b246baa417fc35bcfcf0e30365dc803b208e91 Mon Sep 17 00:00:00 2001 From: Cleroth Date: Fri, 9 Oct 2026 00:54:16 +0800 Subject: [PATCH] feat(window): exclusive fullscreen option GameSystem.Window.ExclusiveFullscreen requests ExclusiveFullScreen instead of FullScreenWindow when not windowed. With the game rendering on the GPU that drives the display and Windows fullscreen optimizations disabled for Sinmai.exe, frames are presented by legacy flip instead of desktop composition: on a measured setup this removed about 1.6 F of visual lag and its whole-frame variation. Without those two Windows settings, Windows emulates the request as a composed flip window, which is slower than the default. The game minimizes when it loses focus. --- AquaMai.Mods/GameSystem/Window.cs | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/AquaMai.Mods/GameSystem/Window.cs b/AquaMai.Mods/GameSystem/Window.cs index cda069c6..069e381b 100644 --- a/AquaMai.Mods/GameSystem/Window.cs +++ b/AquaMai.Mods/GameSystem/Window.cs @@ -44,6 +44,22 @@ 如果设为 0,窗口化将记住用户设定的大小,全屏时将使用当 en: "Height, as above.")] private static readonly int height = 0; + [ConfigEntry( + name: "独占全屏", + en: """ + Exclusive fullscreen instead of a fullscreen window (fullscreen mode only). + Skips desktop composition, which lowers and steadies display latency. The game minimizes when it loses focus. + Needs the game to render on the GPU that drives the display, and Windows "fullscreen optimizations" disabled for Sinmai.exe + (compatibility settings); otherwise Windows emulates it as a composed window, which is slower than the default. + """, + zh: """ + 使用独占全屏而不是全屏窗口(仅全屏模式) + 跳过桌面合成,显示延迟更低更稳定。游戏失去焦点时会最小化 + 需要游戏在驱动该显示器的 GPU 上渲染,并为 Sinmai.exe 禁用 Windows 的“全屏优化”(兼容性设置), + 否则 Windows 会用合成窗口模拟独占全屏,延迟反而比默认更高 + """)] + private static readonly bool exclusiveFullscreen = false; + private const int GWL_STYLE = -16; private const uint WS_WHATEVER = 0x14CF0000; private const uint WS_VISIBLE = 0x10000000; @@ -85,7 +101,7 @@ public static void OnBeforePatch() { var width = Window.width == 0 ? Display.main.systemWidth : Window.width; var height = Window.height == 0 ? Display.main.systemHeight : Window.height; - Screen.SetResolution(width, height, FullScreenMode.FullScreenWindow); + Screen.SetResolution(width, height, exclusiveFullscreen ? FullScreenMode.ExclusiveFullScreen : FullScreenMode.FullScreenWindow); } }