From 128db85054a34b3733364dc193b13e41f2082621 Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Thu, 4 Jul 2024 11:52:51 -0700 Subject: [PATCH] feat(wm): add window based work area offset overrides This commit adds an override option "apply_window_based_work_area_offset" to the Workspace configuration object in the static config. This option defaults to true to preserve existing behaviour, and can be set to false for workspaces where the monitor-level offset changes are undesirable. --- komorebi/src/static_config.rs | 4 ++++ komorebi/src/workspace.rs | 11 ++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/komorebi/src/static_config.rs b/komorebi/src/static_config.rs index a34a10d8..a74e7306 100644 --- a/komorebi/src/static_config.rs +++ b/komorebi/src/static_config.rs @@ -114,6 +114,9 @@ pub struct WorkspaceConfig { /// Permanent workspace application rules #[serde(skip_serializing_if = "Option::is_none")] pub workspace_rules: Option>, + /// Apply this monitor's window-based work area offset (default: true) + #[serde(skip_serializing_if = "Option::is_none")] + pub apply_window_based_work_area_offset: Option, } impl From<&Workspace> for WorkspaceConfig { @@ -196,6 +199,7 @@ impl From<&Workspace> for WorkspaceConfig { workspace_padding, initial_workspace_rules: initial_ws_rules, workspace_rules: ws_rules, + apply_window_based_work_area_offset: Some(value.apply_window_based_work_area_offset()), } } } diff --git a/komorebi/src/workspace.rs b/komorebi/src/workspace.rs index 672bd61f..d543700a 100644 --- a/komorebi/src/workspace.rs +++ b/komorebi/src/workspace.rs @@ -81,6 +81,8 @@ pub struct Workspace { resize_dimensions: Vec>, #[getset(get = "pub", set = "pub")] tile: bool, + #[getset(get_copy = "pub", set = "pub")] + apply_window_based_work_area_offset: bool, } impl_ring_elements!(Workspace, Container); @@ -103,6 +105,7 @@ impl Default for Workspace { latest_layout: vec![], resize_dimensions: vec![], tile: true, + apply_window_based_work_area_offset: true, } } } @@ -155,6 +158,10 @@ impl Workspace { self.tile = true; } + self.set_apply_window_based_work_area_offset( + config.apply_window_based_work_area_offset.unwrap_or(true), + ); + Ok(()) } @@ -260,7 +267,9 @@ impl Workspace { }, ); - if self.containers().len() <= window_based_work_area_offset_limit as usize { + if self.containers().len() <= window_based_work_area_offset_limit as usize + && self.apply_window_based_work_area_offset + { adjusted_work_area = window_based_work_area_offset.map_or_else( || adjusted_work_area, |offset| {