feat: Windows system title bar theme follows the theme#1961
Conversation
|
这个问题很麻烦,因为 windows 实际上并不只一个深色模式 windows 可以为系统和应用独立设置深色和浅色模式 并且很多 OEM 厂商的默认主题是系统为深色模式,应用为浅色模式以提供高级感 总之一团糟,我不知道这里怎么做才是对的 |
|
直觉上这个PR的切入点不是很好,我们应该考虑在 window_manager 包中或者 main.cpp 中做一些修改,为我们的窗体设定特定的属性,让其跟随默认应用模式,这样应该改动最小且可靠 当前的方案像是某种 hack ,并且看上去当我们在系统设置中调整应用模式时,应用的行为存在不确定性 |
This comment was marked as resolved.
This comment was marked as resolved.
…se and using SetTitleBarDarkMode
…nd adding isEffectiveDark method
|
关于在 main.cpp 中的窗体属性中添加特定值来简单适配的做法有可行性吗 如果没有的话,我注意到我们本身在使用的 window_manager 包已经提供了设定窗体深色模式的API,也就是 |
|
感谢你的贡献,在我看来已经没有问题了 但是我个人现在对 glm5 的输出现在有些缺乏信任,我需要去查看一下文档,看看 WM_DWMCOLORIZATIONCOLORCHANGED 的修改是否合理与准确 我尽量在明天晚上之前合并这个pr |
https://learn.microsoft.com/zh-cn/windows/win32/dwm/wm-dwmcolorizationcolorchanged 搜集了一下,希望有用 |
|
此实现仍然有问题,让人头痛的同步问题 当应用中强制设置为浅色模式时,系统更改色彩模式为深色仍然会改变标题栏,不会改变应用内容 |
* feat: add Windows title bar theme support based on app theme * feat: refine Windows title bar theme handling based on system settings * feat: update Windows title bar theme handling and method channel setup * feat: simplify theme update handling by removing redundant message case and using SetTitleBarDarkMode * feat: enhance Windows title bar theme handling by simplifying logic and adding isEffectiveDark method * ref: use windowManager.setBrightness method * fix: remove unnecessary newline * imp by review * revert * fix: update theme handling in MessageHandler to use correct window handle * feat: update title bar theme handling based on platform brightness changes * imp by review * remove llm slop (cherry picked from commit d7a1648)





What's Changed:
close #1757
由 LLM 修改
Copilot's Summary
This pull request adds support for synchronizing the Windows title bar theme (light/dark mode) with the app's selected theme. It introduces a platform channel to communicate theme changes from Flutter to native Windows code, and updates the window frame appearance accordingly. The changes ensure that when users toggle the app's theme, the Windows title bar updates in real time, provided the system title bar is used.Windows Title Bar Theme Sync:
setWindowTitleBarDarkModemethod inUtils(lib/utils/utils.dart) to invoke a native platform channel and update the Windows title bar theme based on the app's theme.setWindowTitleBarDarkModein both app initialization (lib/app_widget.dart) and theme settings changes (lib/pages/settings/theme_settings_page.dart), so the title bar theme updates whenever the app theme changes. [1] [2]Platform Channel and Native Windows Implementation:
windows/runner/flutter_window.cppandwindows/runner/flutter_window.h) to handle requests from Flutter for updating the title bar theme. [1] [2] [3]Win32Window::UpdateThememethod (windows/runner/win32_window.cppandwindows/runner/win32_window.h) to accept an optional dark mode parameter, allowing explicit control or fallback to system theme. [1] [2] [3] [4]These changes provide a seamless, platform-consistent look for Windows users when toggling between light and dark themes in the app.