Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion AquaMai.Mods/GameSystem/Window.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: Vulkan 图形 API 不支持 FullScreenMode.ExclusiveFullScreen,Unity 会静默回退为 FullScreenMode.FullScreenWindow,因此启用该选项时并不一定得到独占全屏。请检测 SystemInfo.graphicsDeviceType,在 Vulkan 下明确回退并记录警告,或在配置说明中注明该限制。

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At AquaMai.Mods/GameSystem/Window.cs, line 104:

<comment>Vulkan 图形 API 不支持 `FullScreenMode.ExclusiveFullScreen`,Unity 会静默回退为 `FullScreenMode.FullScreenWindow`,因此启用该选项时并不一定得到独占全屏。请检测 `SystemInfo.graphicsDeviceType`,在 Vulkan 下明确回退并记录警告,或在配置说明中注明该限制。</comment>

<file context>
@@ -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);
         }
     }
</file context>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sinmai 应该是编译给dx的

}
}

Expand Down
Loading