mirror of
https://github.com/LGUG2Z/komorebi.git
synced 2026-11-19 15:18:40 +01:00
feat(wm): add dynamic work area offsets
This commit migrates this features as it was implemented in LGUG2Z/komorebi@d3779e5a74 and LGUG2Z/komorebi@53c81c4596.
This commit is contained in:
1 parent
a17a39ea3b
commit
742543188d
6 files changed
+225
-164
No files matched your search
@@ -128,6 +128,7 @@ impl From<&WindowManager> for State {
|
||||
resize_dimensions: workspace.resize_dimensions.clone(),
|
||||
tile: workspace.tile,
|
||||
work_area_offset: workspace.work_area_offset,
|
||||
work_area_offset_rules: workspace.work_area_offset_rules.clone(),
|
||||
apply_window_based_work_area_offset: workspace
|
||||
.apply_window_based_work_area_offset,
|
||||
window_container_behaviour: workspace.window_container_behaviour,
|
||||
|
||||
@@ -201,6 +201,9 @@ pub struct WorkspaceConfig {
|
||||
/// Permanent workspace application rules
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub workspace_rules: Option<Vec<MatchingRule>>,
|
||||
/// Work area offset rules in the format of threshold => Rect (default: None)
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub work_area_offset_rules: Option<HashMap<usize, Rect>>,
|
||||
/// Workspace specific work area offset
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub work_area_offset: Option<Rect>,
|
||||
@@ -247,6 +250,13 @@ impl From<&Workspace> for WorkspaceConfig {
|
||||
}
|
||||
let layout_rules = (!layout_rules.is_empty()).then_some(layout_rules);
|
||||
|
||||
let mut work_area_offset_rules = HashMap::new();
|
||||
for (threshold, rect) in &value.work_area_offset_rules {
|
||||
work_area_offset_rules.insert(*threshold, *rect);
|
||||
}
|
||||
let work_area_offset_rules =
|
||||
(!work_area_offset_rules.is_empty()).then_some(work_area_offset_rules);
|
||||
|
||||
let mut window_container_behaviour_rules = HashMap::new();
|
||||
for (threshold, behaviour) in value.window_container_behaviour_rules.iter().flatten() {
|
||||
window_container_behaviour_rules.insert(*threshold, *behaviour);
|
||||
@@ -306,6 +316,7 @@ impl From<&Workspace> for WorkspaceConfig {
|
||||
.workspace_config
|
||||
.as_ref()
|
||||
.and_then(|c| c.workspace_rules.clone()),
|
||||
work_area_offset_rules,
|
||||
work_area_offset: value.work_area_offset,
|
||||
apply_window_based_work_area_offset: Some(value.apply_window_based_work_area_offset),
|
||||
window_container_behaviour: value.window_container_behaviour,
|
||||
|
||||
@@ -58,6 +58,7 @@ pub struct Workspace {
|
||||
pub resize_dimensions: Vec<Option<Rect>>,
|
||||
pub tile: bool,
|
||||
pub work_area_offset: Option<Rect>,
|
||||
pub work_area_offset_rules: Vec<(usize, Rect)>,
|
||||
pub apply_window_based_work_area_offset: bool,
|
||||
pub window_container_behaviour: Option<WindowContainerBehaviour>,
|
||||
pub window_container_behaviour_rules: Option<Vec<(usize, WindowContainerBehaviour)>>,
|
||||
@@ -109,6 +110,7 @@ impl Default for Workspace {
|
||||
resize_dimensions: vec![],
|
||||
layout: Layout::Default(DefaultLayout::BSP),
|
||||
work_area_offset: None,
|
||||
work_area_offset_rules: vec![],
|
||||
latest_layout: vec![],
|
||||
layout_flip: None,
|
||||
layout_options: None,
|
||||
@@ -182,6 +184,17 @@ impl Workspace {
|
||||
|
||||
self.work_area_offset = config.work_area_offset;
|
||||
|
||||
let mut all_work_area_offset_rules = vec![];
|
||||
if let Some(work_area_offset_rules) = &config.work_area_offset_rules {
|
||||
for (count, rect) in work_area_offset_rules {
|
||||
all_work_area_offset_rules.push((*count, *rect));
|
||||
}
|
||||
|
||||
all_work_area_offset_rules.sort_by_key(|(i, _)| *i);
|
||||
}
|
||||
|
||||
self.work_area_offset_rules = all_work_area_offset_rules;
|
||||
|
||||
self.apply_window_based_work_area_offset =
|
||||
config.apply_window_based_work_area_offset.unwrap_or(true);
|
||||
|
||||
@@ -1155,7 +1168,25 @@ impl Workspace {
|
||||
let border_width = self.globals.border_width;
|
||||
let border_offset = self.globals.border_offset;
|
||||
let work_area = self.globals.work_area;
|
||||
let work_area_offset = self.work_area_offset.or(self.globals.work_area_offset);
|
||||
let mut rules_work_area_offset = None;
|
||||
|
||||
if !self.work_area_offset_rules.is_empty() {
|
||||
let count = if self.monocle_container.is_some() {
|
||||
1
|
||||
} else {
|
||||
self.containers().len()
|
||||
};
|
||||
|
||||
for (threshold, work_area_offset_rule) in &self.work_area_offset_rules {
|
||||
if count >= *threshold {
|
||||
rules_work_area_offset = Some(*work_area_offset_rule);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
let work_area_offset = rules_work_area_offset
|
||||
.or(self.work_area_offset)
|
||||
.or(self.globals.work_area_offset);
|
||||
let window_based_work_area_offset = self.globals.window_based_work_area_offset;
|
||||
let window_based_work_area_offset_limit = self.globals.window_based_work_area_offset_limit;
|
||||
|
||||
|
||||
@@ -979,6 +979,103 @@ in
|
||||
]
|
||||
);
|
||||
};
|
||||
colours = lib.mkOption {
|
||||
type = (
|
||||
lib.types.nullOr (
|
||||
lib.types.submodule {
|
||||
options = {
|
||||
base_00 = lib.mkOption {
|
||||
type = colour;
|
||||
description = "Base00";
|
||||
};
|
||||
base_01 = lib.mkOption {
|
||||
type = colour;
|
||||
description = "Base01";
|
||||
};
|
||||
base_02 = lib.mkOption {
|
||||
type = colour;
|
||||
description = "Base02";
|
||||
};
|
||||
base_03 = lib.mkOption {
|
||||
type = colour;
|
||||
description = "Base03";
|
||||
};
|
||||
base_04 = lib.mkOption {
|
||||
type = colour;
|
||||
description = "Base04";
|
||||
};
|
||||
base_05 = lib.mkOption {
|
||||
type = colour;
|
||||
description = "Base05";
|
||||
};
|
||||
base_06 = lib.mkOption {
|
||||
type = colour;
|
||||
description = "Base06";
|
||||
};
|
||||
base_07 = lib.mkOption {
|
||||
type = colour;
|
||||
description = "Base07";
|
||||
};
|
||||
base_08 = lib.mkOption {
|
||||
type = colour;
|
||||
description = "Base08";
|
||||
};
|
||||
base_09 = lib.mkOption {
|
||||
type = colour;
|
||||
description = "Base09";
|
||||
};
|
||||
base_0a = lib.mkOption {
|
||||
type = colour;
|
||||
description = "Base0A";
|
||||
};
|
||||
base_0b = lib.mkOption {
|
||||
type = colour;
|
||||
description = "Base0B";
|
||||
};
|
||||
base_0c = lib.mkOption {
|
||||
type = colour;
|
||||
description = "Base0C";
|
||||
};
|
||||
base_0d = lib.mkOption {
|
||||
type = colour;
|
||||
description = "Base0D";
|
||||
};
|
||||
base_0e = lib.mkOption {
|
||||
type = colour;
|
||||
description = "Base0E";
|
||||
};
|
||||
base_0f = lib.mkOption {
|
||||
type = colour;
|
||||
description = "Base0F";
|
||||
};
|
||||
};
|
||||
}
|
||||
)
|
||||
);
|
||||
default = null;
|
||||
};
|
||||
accent = lib.mkOption {
|
||||
type = (
|
||||
lib.types.nullOr (
|
||||
lib.types.oneOf [
|
||||
(lib.types.nullOr catppuccinValue)
|
||||
(lib.types.nullOr base16Value)
|
||||
]
|
||||
)
|
||||
);
|
||||
default = null;
|
||||
};
|
||||
auto_select_fill = lib.mkOption {
|
||||
type = (
|
||||
lib.types.nullOr (
|
||||
lib.types.oneOf [
|
||||
(lib.types.nullOr catppuccinValue)
|
||||
(lib.types.nullOr base16Value)
|
||||
]
|
||||
)
|
||||
);
|
||||
default = null;
|
||||
};
|
||||
name = lib.mkOption {
|
||||
type = (
|
||||
lib.types.nullOr (
|
||||
@@ -1276,103 +1373,6 @@ in
|
||||
);
|
||||
default = null;
|
||||
};
|
||||
auto_select_fill = lib.mkOption {
|
||||
type = (
|
||||
lib.types.nullOr (
|
||||
lib.types.oneOf [
|
||||
(lib.types.nullOr catppuccinValue)
|
||||
(lib.types.nullOr base16Value)
|
||||
]
|
||||
)
|
||||
);
|
||||
default = null;
|
||||
};
|
||||
colours = lib.mkOption {
|
||||
type = (
|
||||
lib.types.nullOr (
|
||||
lib.types.submodule {
|
||||
options = {
|
||||
base_00 = lib.mkOption {
|
||||
type = colour;
|
||||
description = "Base00";
|
||||
};
|
||||
base_01 = lib.mkOption {
|
||||
type = colour;
|
||||
description = "Base01";
|
||||
};
|
||||
base_02 = lib.mkOption {
|
||||
type = colour;
|
||||
description = "Base02";
|
||||
};
|
||||
base_03 = lib.mkOption {
|
||||
type = colour;
|
||||
description = "Base03";
|
||||
};
|
||||
base_04 = lib.mkOption {
|
||||
type = colour;
|
||||
description = "Base04";
|
||||
};
|
||||
base_05 = lib.mkOption {
|
||||
type = colour;
|
||||
description = "Base05";
|
||||
};
|
||||
base_06 = lib.mkOption {
|
||||
type = colour;
|
||||
description = "Base06";
|
||||
};
|
||||
base_07 = lib.mkOption {
|
||||
type = colour;
|
||||
description = "Base07";
|
||||
};
|
||||
base_08 = lib.mkOption {
|
||||
type = colour;
|
||||
description = "Base08";
|
||||
};
|
||||
base_09 = lib.mkOption {
|
||||
type = colour;
|
||||
description = "Base09";
|
||||
};
|
||||
base_0a = lib.mkOption {
|
||||
type = colour;
|
||||
description = "Base0A";
|
||||
};
|
||||
base_0b = lib.mkOption {
|
||||
type = colour;
|
||||
description = "Base0B";
|
||||
};
|
||||
base_0c = lib.mkOption {
|
||||
type = colour;
|
||||
description = "Base0C";
|
||||
};
|
||||
base_0d = lib.mkOption {
|
||||
type = colour;
|
||||
description = "Base0D";
|
||||
};
|
||||
base_0e = lib.mkOption {
|
||||
type = colour;
|
||||
description = "Base0E";
|
||||
};
|
||||
base_0f = lib.mkOption {
|
||||
type = colour;
|
||||
description = "Base0F";
|
||||
};
|
||||
};
|
||||
}
|
||||
)
|
||||
);
|
||||
default = null;
|
||||
};
|
||||
accent = lib.mkOption {
|
||||
type = (
|
||||
lib.types.nullOr (
|
||||
lib.types.oneOf [
|
||||
(lib.types.nullOr catppuccinValue)
|
||||
(lib.types.nullOr base16Value)
|
||||
]
|
||||
)
|
||||
);
|
||||
default = null;
|
||||
};
|
||||
};
|
||||
}
|
||||
)
|
||||
|
||||
+71
-66
@@ -735,6 +735,11 @@ in
|
||||
default = null;
|
||||
description = "Workspace specific work area offset";
|
||||
};
|
||||
work_area_offset_rules = lib.mkOption {
|
||||
type = (lib.types.nullOr (lib.types.attrsOf rect));
|
||||
default = null;
|
||||
description = "Work area offset rules in the format of threshold => Rect (default: None)";
|
||||
};
|
||||
workspace_padding = lib.mkOption {
|
||||
type = (lib.types.nullOr lib.types.int);
|
||||
default = null;
|
||||
@@ -788,6 +793,17 @@ in
|
||||
]
|
||||
);
|
||||
};
|
||||
floating_border = lib.mkOption {
|
||||
type = (
|
||||
lib.types.nullOr (
|
||||
lib.types.oneOf [
|
||||
(lib.types.nullOr catppuccinValue)
|
||||
(lib.types.nullOr base16Value)
|
||||
]
|
||||
)
|
||||
);
|
||||
default = null;
|
||||
};
|
||||
colours = lib.mkOption {
|
||||
type = (
|
||||
lib.types.nullOr (
|
||||
@@ -863,72 +879,6 @@ in
|
||||
);
|
||||
default = null;
|
||||
};
|
||||
unfocused_locked_border = lib.mkOption {
|
||||
type = (
|
||||
lib.types.nullOr (
|
||||
lib.types.oneOf [
|
||||
(lib.types.nullOr catppuccinValue)
|
||||
(lib.types.nullOr base16Value)
|
||||
]
|
||||
)
|
||||
);
|
||||
default = null;
|
||||
};
|
||||
bar_accent = lib.mkOption {
|
||||
type = (
|
||||
lib.types.nullOr (
|
||||
lib.types.oneOf [
|
||||
(lib.types.nullOr catppuccinValue)
|
||||
(lib.types.nullOr base16Value)
|
||||
]
|
||||
)
|
||||
);
|
||||
default = null;
|
||||
};
|
||||
monocle_border = lib.mkOption {
|
||||
type = (
|
||||
lib.types.nullOr (
|
||||
lib.types.oneOf [
|
||||
(lib.types.nullOr catppuccinValue)
|
||||
(lib.types.nullOr base16Value)
|
||||
]
|
||||
)
|
||||
);
|
||||
default = null;
|
||||
};
|
||||
stack_border = lib.mkOption {
|
||||
type = (
|
||||
lib.types.nullOr (
|
||||
lib.types.oneOf [
|
||||
(lib.types.nullOr catppuccinValue)
|
||||
(lib.types.nullOr base16Value)
|
||||
]
|
||||
)
|
||||
);
|
||||
default = null;
|
||||
};
|
||||
floating_border = lib.mkOption {
|
||||
type = (
|
||||
lib.types.nullOr (
|
||||
lib.types.oneOf [
|
||||
(lib.types.nullOr catppuccinValue)
|
||||
(lib.types.nullOr base16Value)
|
||||
]
|
||||
)
|
||||
);
|
||||
default = null;
|
||||
};
|
||||
unfocused_border = lib.mkOption {
|
||||
type = (
|
||||
lib.types.nullOr (
|
||||
lib.types.oneOf [
|
||||
(lib.types.nullOr catppuccinValue)
|
||||
(lib.types.nullOr base16Value)
|
||||
]
|
||||
)
|
||||
);
|
||||
default = null;
|
||||
};
|
||||
name = lib.mkOption {
|
||||
type = (
|
||||
lib.types.nullOr (
|
||||
@@ -1215,6 +1165,50 @@ in
|
||||
);
|
||||
default = null;
|
||||
};
|
||||
monocle_border = lib.mkOption {
|
||||
type = (
|
||||
lib.types.nullOr (
|
||||
lib.types.oneOf [
|
||||
(lib.types.nullOr catppuccinValue)
|
||||
(lib.types.nullOr base16Value)
|
||||
]
|
||||
)
|
||||
);
|
||||
default = null;
|
||||
};
|
||||
unfocused_border = lib.mkOption {
|
||||
type = (
|
||||
lib.types.nullOr (
|
||||
lib.types.oneOf [
|
||||
(lib.types.nullOr catppuccinValue)
|
||||
(lib.types.nullOr base16Value)
|
||||
]
|
||||
)
|
||||
);
|
||||
default = null;
|
||||
};
|
||||
stack_border = lib.mkOption {
|
||||
type = (
|
||||
lib.types.nullOr (
|
||||
lib.types.oneOf [
|
||||
(lib.types.nullOr catppuccinValue)
|
||||
(lib.types.nullOr base16Value)
|
||||
]
|
||||
)
|
||||
);
|
||||
default = null;
|
||||
};
|
||||
bar_accent = lib.mkOption {
|
||||
type = (
|
||||
lib.types.nullOr (
|
||||
lib.types.oneOf [
|
||||
(lib.types.nullOr catppuccinValue)
|
||||
(lib.types.nullOr base16Value)
|
||||
]
|
||||
)
|
||||
);
|
||||
default = null;
|
||||
};
|
||||
single_border = lib.mkOption {
|
||||
type = (
|
||||
lib.types.nullOr (
|
||||
@@ -1226,6 +1220,17 @@ in
|
||||
);
|
||||
default = null;
|
||||
};
|
||||
unfocused_locked_border = lib.mkOption {
|
||||
type = (
|
||||
lib.types.nullOr (
|
||||
lib.types.oneOf [
|
||||
(lib.types.nullOr catppuccinValue)
|
||||
(lib.types.nullOr base16Value)
|
||||
]
|
||||
)
|
||||
);
|
||||
default = null;
|
||||
};
|
||||
};
|
||||
}
|
||||
)
|
||||
|
||||
+13
@@ -3685,6 +3685,19 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
"work_area_offset_rules": {
|
||||
"description": "Work area offset rules in the format of threshold => Rect (default: None)",
|
||||
"type": [
|
||||
"object",
|
||||
"null"
|
||||
],
|
||||
"additionalProperties": false,
|
||||
"patternProperties": {
|
||||
"^\\d+$": {
|
||||
"$ref": "#/$defs/Rect"
|
||||
}
|
||||
}
|
||||
},
|
||||
"workspace_padding": {
|
||||
"description": "Workspace padding (default: global)",
|
||||
"type": [
|
||||
|
||||
Reference in new issue
Block a user