Skip to content

Commit

Permalink
feat(wm): add window based work area offset overrides
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
LGUG2Z committed Jul 4, 2024
1 parent cc7dbde commit 128db85
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
4 changes: 4 additions & 0 deletions komorebi/src/static_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,9 @@ pub struct WorkspaceConfig {
/// Permanent workspace application rules
#[serde(skip_serializing_if = "Option::is_none")]
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 {
Expand Down Expand Up @@ -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()),
}
}
}
Expand Down
11 changes: 10 additions & 1 deletion komorebi/src/workspace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ pub struct Workspace {
resize_dimensions: Vec<Option<Rect>>,
#[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);
Expand All @@ -103,6 +105,7 @@ impl Default for Workspace {
latest_layout: vec![],
resize_dimensions: vec![],
tile: true,
apply_window_based_work_area_offset: true,
}
}
}
Expand Down Expand Up @@ -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(())
}

Expand Down Expand Up @@ -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| {
Expand Down

0 comments on commit 128db85

Please sign in to comment.