mirror of
https://github.com/farion1231/cc-switch.git
synced 2026-07-24 12:44:18 +08:00
添加应用级别窗口按钮,以改善linux wayland下系统窗口按钮失效的问题 (#1119)
* feat(window): add app-level window controls with settings toggle Add a persistent settings toggle to enable app-level minimize/maximize/close controls and hide system decorations when enabled, providing a Wayland-friendly fallback for broken native titlebar interactions. Co-authored-by: Cursor <cursoragent@cursor.com> * fix(window): restrict app-level window controls to Linux only and fix startup flicker - Guard useAppWindowControls with isLinux() in App.tsx so it's always false on macOS/Windows even if persisted as true - Wrap set_decorations call in lib.rs with #[cfg(target_os = "linux")] - Only show the toggle in WindowSettings on Linux - Skip setDecorations effect while settingsData is still loading to prevent the Rust-side decoration state from being overridden by the undefined->false fallback, which caused a brief title bar flicker --------- Co-authored-by: wzk <wx13571681304@outlook.com> Co-authored-by: Cursor <cursoragent@cursor.com> Co-authored-by: Jason <farion1231@gmail.com>
This commit is contained in:
@@ -11,6 +11,11 @@
|
||||
"updater:default",
|
||||
"core:window:allow-set-skip-taskbar",
|
||||
"core:window:allow-start-dragging",
|
||||
"core:window:allow-minimize",
|
||||
"core:window:allow-toggle-maximize",
|
||||
"core:window:allow-is-maximized",
|
||||
"core:window:allow-close",
|
||||
"core:window:allow-set-decorations",
|
||||
"process:allow-restart",
|
||||
"dialog:default"
|
||||
]
|
||||
|
||||
@@ -971,6 +971,10 @@ pub fn run() {
|
||||
// 静默启动:根据设置决定是否显示主窗口
|
||||
let settings = crate::settings::get_settings();
|
||||
if let Some(window) = app.get_webview_window("main") {
|
||||
// 在窗口首次显示前同步装饰状态,避免前端加载后再切换导致标题栏闪烁
|
||||
// 仅 Linux 生效:解决 Wayland 下系统窗口按钮不可用的问题
|
||||
#[cfg(target_os = "linux")]
|
||||
let _ = window.set_decorations(!settings.use_app_window_controls);
|
||||
if settings.silent_startup {
|
||||
// 静默启动模式:保持窗口隐藏
|
||||
let _ = window.hide();
|
||||
|
||||
@@ -175,6 +175,8 @@ pub struct AppSettings {
|
||||
pub show_in_tray: bool,
|
||||
#[serde(default = "default_minimize_to_tray_on_close")]
|
||||
pub minimize_to_tray_on_close: bool,
|
||||
#[serde(default)]
|
||||
pub use_app_window_controls: bool,
|
||||
/// 是否启用 Claude 插件联动
|
||||
#[serde(default)]
|
||||
pub enable_claude_plugin_integration: bool,
|
||||
@@ -293,6 +295,7 @@ impl Default for AppSettings {
|
||||
Self {
|
||||
show_in_tray: true,
|
||||
minimize_to_tray_on_close: true,
|
||||
use_app_window_controls: false,
|
||||
enable_claude_plugin_integration: false,
|
||||
skip_claude_onboarding: false,
|
||||
launch_on_startup: false,
|
||||
|
||||
Reference in New Issue
Block a user