Skip to content

视频全屏时自动隐藏原生标题栏 - #2591

Open
OliverArcher wants to merge 3 commits into
Predidit:mainfrom
OliverArcher:titlebar-auto-hide
Open

OliverArcher wants to merge 3 commits into
Predidit:mainfrom
OliverArcher:titlebar-auto-hide

Conversation

@OliverArcher

Copy link
Copy Markdown

TL;DR

Windows 与 Linux 上,原生标题栏会在窗口进入全屏时压在画面顶部、退出全屏后行为又跟用户偏好对不上。这个 PR 让标题栏在进入全屏前自动隐藏、退出全屏后按用户偏好恢复。macOS 上原生标题栏本就永远隐藏,所以这两个调用是 no-op,行为不变。

改动

三处文件改动,最小化补丁:

  • lib/services/platform/display_mode_service.dart:在 applyVideoFullscreen(true) 之前调 setTitleBarStyle(hidden),在 applyVideoFullscreen(false) 之后按 showWindowButton 偏好恢复(macOS 走 defaultTargetPlatform == macOS 的旁路,永远 hidden)。新拆出的两个私有方法 _hideTitleBarForFullscreen() / _restoreTitleBarAfterFullscreen() 跟现有 _attempt() 错误处理一致。2.3.6 把 enter/exitFullScreen 重写成了单参数的 applyVideoFullscreen(bool),本补丁跟着这套新签名走,并切到 defaultTargetPlatform 而不是 Platform.isXxx,跟同文件其他判断风格一致。
  • lib/services/storage/settings_keys.dart:showWindowButton 的默认值从 false 改成 true,让全新安装的用户默认显示标题栏(也就是说不打开全屏时看得见标题栏、进入全屏时自动隐藏)。
  • lib/pages/settings/theme_settings_page.dart:删掉"外观 → 使用系统标题栏"那一段设置入口,连同 showWindowButton 字段和 initState 读取都删掉。代码仍然读 showWindowButton,所以已经手动设过 false 的旧用户继续保留隐藏。

为什么不留在设置里

showWindowButton 这个开关之前只是用来选要不要显示原生标题栏,对全屏行为没有影响。把它从设置里挪走、把默认值反过来、并把全屏前后逻辑写进代码之后,全屏体验是统一的,没有用户能选错。showWindowButton 这个 setting key 保留,所有现有用户数据不受影响。

验证

  • Windows 11 + Flutter 3.47.5 + MSVC 19.44 (VS 2022 17.14) 上 flutter build windows --release 干净通过。
  • 启动后默认显示标题栏;进入全屏标题栏立即消失、贴合视频顶部不留黑条;按 Esc 退出全屏,标题栏按原偏好恢复。
  • macOS / Linux 上 setTitleBarStyle 是 no-op,行为不变。

适用范围

补丁基线是 2.3.6。如果 display_mode_service.dart 或 settings_keys.dart 后续重构,本补丁需要相应迁移。

Added methods to hide and restore the title bar during fullscreen mode for Windows and Linux.
Removed the showWindowButton variable and its related settings section for desktop.
static const showWindowButton = SettingKey<bool>(
_SettingBoxKey.showWindowButton,
false,
true,

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.

WARNING: Flipping this default changes behavior for existing users too — including macOS — and there is no longer a way to change it back

GStorage.getSetting returns the default whenever nothing is stored, so this isn't only a new-install change. Any existing user who never touched the toggle goes from false to true after upgrading:

  • Windows/Linux: the native title bar comes back, and the in-app CloseButton in SysAppBar (lib/bean/appbar/sys_app_bar.dart:36) and popular_page.dart:250 disappears.
  • macOS: main.dart:84 now passes windowButtonVisibility: true, so the native traffic-light buttons show up. SysAppBar.preferredSize / info_page.dart:366-374 also add a 22px top offset. That goes against the PR description's claim that macOS behavior is unchanged.

theme_settings_page.dart also removes the "使用系统标题栏" toggle. So neither these upgraded users nor anyone who set it manually can change the preference in the UI anymore; the key is only reachable through settings import/export. Options: keep the toggle, only apply the new default to fresh installs (e.g. a migration that stores false for existing installs), or keep macOS on its old behavior.


Reply with @kilocode-bot fix it to have Kilo Code address this issue.

@kilo-code-bot

kilo-code-bot Bot commented Sep 27, 2026 •

Copy link
Copy Markdown
Contributor

Code Review Summary

Status: 1 Issue Found | Recommendation: Address before merge

Overview

Severity Count
CRITICAL 0
WARNING 1
SUGGESTION 0
Issue Details (click to expand)

WARNING

File Line Issue
lib/services/storage/settings_keys.dart 339 Changing the showWindowButton default to true also affects existing users who never set it, including on macOS (traffic lights plus a 22px offset). Because the settings toggle is removed in theme_settings_page.dart, users can no longer change it back.
Files Reviewed (3 files)
  • lib/services/platform/display_mode_service.dart - 0 issues
  • lib/services/storage/settings_keys.dart - 1 issue
  • lib/pages/settings/theme_settings_page.dart - 0 issues (toggle removal covered in the settings_keys finding)

Fix these issues in Kilo Cloud


Reviewed by claude-opus-5.5 · Input: 0 · Output: 0 · Cached: 0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant