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.
This commit is contained in:
LGUG2Z
2024-07-04 11:52:51 -07:00
parent cc7dbde049
commit 128db85054
2 changed files with 14 additions and 1 deletions
+4
View File
@@ -114,6 +114,9 @@ pub struct WorkspaceConfig {
/// Permanent workspace application rules /// Permanent workspace application rules
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
pub workspace_rules: Option<Vec<IdWithIdentifier>>, pub workspace_rules: Option<Vec<IdWithIdentifier>>,
/// 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<bool>,
} }
impl From<&Workspace> for WorkspaceConfig { impl From<&Workspace> for WorkspaceConfig {
@@ -196,6 +199,7 @@ impl From<&Workspace> for WorkspaceConfig {
workspace_padding, workspace_padding,
initial_workspace_rules: initial_ws_rules, initial_workspace_rules: initial_ws_rules,
workspace_rules: ws_rules, workspace_rules: ws_rules,
apply_window_based_work_area_offset: Some(value.apply_window_based_work_area_offset()),
} }
} }
} }
+10 -1
View File
@@ -81,6 +81,8 @@ pub struct Workspace {
resize_dimensions: Vec<Option<Rect>>, resize_dimensions: Vec<Option<Rect>>,
#[getset(get = "pub", set = "pub")] #[getset(get = "pub", set = "pub")]
tile: bool, tile: bool,
#[getset(get_copy = "pub", set = "pub")]
apply_window_based_work_area_offset: bool,
} }
impl_ring_elements!(Workspace, Container); impl_ring_elements!(Workspace, Container);
@@ -103,6 +105,7 @@ impl Default for Workspace {
latest_layout: vec![], latest_layout: vec![],
resize_dimensions: vec![], resize_dimensions: vec![],
tile: true, tile: true,
apply_window_based_work_area_offset: true,
} }
} }
} }
@@ -155,6 +158,10 @@ impl Workspace {
self.tile = true; self.tile = true;
} }
self.set_apply_window_based_work_area_offset(
config.apply_window_based_work_area_offset.unwrap_or(true),
);
Ok(()) 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 = window_based_work_area_offset.map_or_else(
|| adjusted_work_area, || adjusted_work_area,
|offset| { |offset| {