From 1baba074e93f8f9edbd7a87df506f3a73713bddc Mon Sep 17 00:00:00 2001 From: lars-berger Date: Mon, 2 Dec 2024 16:53:08 +0800 Subject: [PATCH] feat: cleanup --- packages/wm/src/cleanup.rs | 1 + .../wm/src/common/commands/platform_sync.rs | 22 ++++++++++--------- .../wm/src/common/commands/reload_config.rs | 13 ++++++++++- resources/assets/sample-config.yaml | 3 ++- 4 files changed, 27 insertions(+), 12 deletions(-) diff --git a/packages/wm/src/cleanup.rs b/packages/wm/src/cleanup.rs index bbfee2fa3..d9e056f51 100644 --- a/packages/wm/src/cleanup.rs +++ b/packages/wm/src/cleanup.rs @@ -10,6 +10,7 @@ pub fn run_cleanup(managed_windows: Vec) { warn!("Failed to show window: {:?}", err); } + _ = window.set_taskbar_visibility(true); _ = window.set_border_color(None); } } diff --git a/packages/wm/src/common/commands/platform_sync.rs b/packages/wm/src/common/commands/platform_sync.rs index ba41b26f2..68346b8ea 100644 --- a/packages/wm/src/common/commands/platform_sync.rs +++ b/packages/wm/src/common/commands/platform_sync.rs @@ -11,7 +11,8 @@ use crate::{ Container, WindowContainer, }, user_config::{ - CornerStyle, CursorJumpTrigger, UserConfig, WindowEffectConfig, + CornerStyle, CursorJumpTrigger, HideMethod, UserConfig, + WindowEffectConfig, }, windows::traits::WindowGetters, wm_event::WmEvent, @@ -154,16 +155,17 @@ fn redraw_containers( warn!("Failed to set window position: {}", err); } - let taskbar_visibility = if config.value.general.show_all_in_taskbar { - true - } else { - is_visible - }; - - if let Err(err) = - window.native().set_taskbar_visibility(taskbar_visibility) + // Skip setting taskbar visibility if the window is hidden (has no + // effect). Since cloaked windows are normally always visible in the + // taskbar, we only need to set visibility if `show_all_in_taskbar` is + // `false`. + if config.value.general.hide_method == HideMethod::Cloak + && !config.value.general.show_all_in_taskbar { - warn!("Failed to set taskbar visibility: {}", err); + if let Err(err) = window.native().set_taskbar_visibility(is_visible) + { + warn!("Failed to set taskbar visibility: {}", err); + } } } diff --git a/packages/wm/src/common/commands/reload_config.rs b/packages/wm/src/common/commands/reload_config.rs index 47648ebf2..c44b6781d 100644 --- a/packages/wm/src/common/commands/reload_config.rs +++ b/packages/wm/src/common/commands/reload_config.rs @@ -37,13 +37,24 @@ pub fn reload_config( // Ensure all windows are shown when hide method is changed. if old_config.general.hide_method != config.value.general.hide_method - && old_config.general.hide_method == HideMethod::Hide + && config.value.general.hide_method == HideMethod::Cloak { for window in state.windows() { let _ = window.native().show(); } } + // Ensure all windows are shown in taskbar when `show_all_in_taskbar` is + // changed. + if old_config.general.show_all_in_taskbar + != config.value.general.show_all_in_taskbar + && config.value.general.show_all_in_taskbar + { + for window in state.windows() { + let _ = window.native().set_taskbar_visibility(true); + } + } + // Clear active binding modes. state.binding_modes = Vec::new(); diff --git a/resources/assets/sample-config.yaml b/resources/assets/sample-config.yaml index ea3de60d8..9e07a8e89 100644 --- a/resources/assets/sample-config.yaml +++ b/resources/assets/sample-config.yaml @@ -33,7 +33,8 @@ general: # but has stability issues with some apps. hide_method: 'cloak' - # Affects which windows get shown in the native Windows taskbar. + # Affects which windows get shown in the native Windows taskbar. Has no + # effect if `hide_method: 'hide'`. # - 'true': Show all windows (regardless of workspace). # - 'false': Only show windows from the currently shown workspaces. show_all_in_taskbar: false