diff --git a/komorebi/src/core/mod.rs b/komorebi/src/core/mod.rs index 394864b5..7eed5dcb 100644 --- a/komorebi/src/core/mod.rs +++ b/komorebi/src/core/mod.rs @@ -202,6 +202,7 @@ pub enum SocketMessage { StackbarFontFamily(Option), WorkAreaOffset(Rect), MonitorWorkAreaOffset(usize, Rect), + WorkspaceWorkAreaOffset(usize, usize, Rect), ToggleWindowBasedWorkAreaOffset, ResizeDelta(i32), InitialWorkspaceRule(ApplicationIdentifier, String, usize, usize), diff --git a/komorebi/src/process_command.rs b/komorebi/src/process_command.rs index b01be330..747c0f3e 100644 --- a/komorebi/src/process_command.rs +++ b/komorebi/src/process_command.rs @@ -1886,6 +1886,14 @@ if (!(Get-Process komorebi-bar -ErrorAction SilentlyContinue)) self.retile_all(false)?; } } + SocketMessage::WorkspaceWorkAreaOffset(monitor_idx, workspace_idx, rect) => { + if let Some(monitor) = self.monitors_mut().get_mut(monitor_idx) { + if let Some(workspace) = monitor.workspaces_mut().get_mut(workspace_idx) { + workspace.set_work_area_offset(Option::from(rect)); + self.retile_all(false)? + } + } + } SocketMessage::ToggleWindowBasedWorkAreaOffset => { let workspace = self.focused_workspace_mut()?; workspace.set_apply_window_based_work_area_offset( diff --git a/komorebi/src/static_config.rs b/komorebi/src/static_config.rs index 737103c1..0101383b 100644 --- a/komorebi/src/static_config.rs +++ b/komorebi/src/static_config.rs @@ -218,6 +218,9 @@ pub struct WorkspaceConfig { /// Permanent workspace application rules #[serde(skip_serializing_if = "Option::is_none")] pub workspace_rules: Option>, + /// Workspace specific work area offset (default: None) + #[serde(skip_serializing_if = "Option::is_none")] + pub work_area_offset: 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, @@ -310,6 +313,7 @@ impl From<&Workspace> for WorkspaceConfig { .workspace_config() .as_ref() .and_then(|c| c.workspace_rules.clone()), + 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(), window_container_behaviour_rules: Option::from(window_container_behaviour_rules), diff --git a/komorebi/src/window_manager.rs b/komorebi/src/window_manager.rs index 5aba0499..2dffc259 100644 --- a/komorebi/src/window_manager.rs +++ b/komorebi/src/window_manager.rs @@ -337,6 +337,7 @@ impl From<&WindowManager> for State { latest_layout: workspace.latest_layout.clone(), resize_dimensions: workspace.resize_dimensions.clone(), tile: workspace.tile, + work_area_offset: workspace.work_area_offset, apply_window_based_work_area_offset: workspace .apply_window_based_work_area_offset, window_container_behaviour: workspace.window_container_behaviour, diff --git a/komorebi/src/workspace.rs b/komorebi/src/workspace.rs index de7f5e3c..5781e6dc 100644 --- a/komorebi/src/workspace.rs +++ b/komorebi/src/workspace.rs @@ -87,6 +87,8 @@ pub struct Workspace { #[getset(get = "pub", set = "pub")] pub tile: bool, #[getset(get_copy = "pub", set = "pub")] + pub work_area_offset: Option, + #[getset(get_copy = "pub", set = "pub")] pub apply_window_based_work_area_offset: bool, #[getset(get = "pub", get_mut = "pub", set = "pub")] pub window_container_behaviour: Option, @@ -147,6 +149,7 @@ impl Default for Workspace { latest_layout: vec![], resize_dimensions: vec![], tile: true, + work_area_offset: None, apply_window_based_work_area_offset: true, window_container_behaviour: None, window_container_behaviour_rules: None, @@ -241,6 +244,8 @@ impl Workspace { self.set_layout_rules(all_layout_rules); } + self.set_work_area_offset(config.work_area_offset); + self.set_apply_window_based_work_area_offset( config.apply_window_based_work_area_offset.unwrap_or(true), ); @@ -496,7 +501,7 @@ 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.globals().work_area_offset; + let work_area_offset = 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; diff --git a/komorebic.lib.ahk b/komorebic.lib.ahk index 29a5ff0c..cb64349f 100644 --- a/komorebic.lib.ahk +++ b/komorebic.lib.ahk @@ -184,6 +184,10 @@ MonitorWorkAreaOffset(monitor, left, top, right, bottom) { RunWait("komorebic.exe monitor-work-area-offset " monitor " " left " " top " " right " " bottom, , "Hide") } +WorkspaceWorkAreaOffset(monitor, workspace, left, top, right, bottom) { + RunWait("komorebic.exe workspace-work-area-offset " monitor " "workspace" " left " " top " " right " " bottom, , "Hide") +} + AdjustContainerPadding(sizing, adjustment) { RunWait("komorebic.exe adjust-container-padding " sizing " " adjustment, , "Hide") } diff --git a/komorebic/src/main.rs b/komorebic/src/main.rs index d0167c12..af7ee66e 100644 --- a/komorebic/src/main.rs +++ b/komorebic/src/main.rs @@ -428,6 +428,22 @@ struct MonitorWorkAreaOffset { bottom: i32, } +#[derive(Parser)] +struct WorkspaceWorkAreaOffset { + /// Monitor index (zero-indexed) + monitor: usize, + /// Workspace index (zero-indexed) + workspace: usize, + /// Size of the left work area offset (set right to left * 2 to maintain right padding) + left: i32, + /// Size of the top work area offset (set bottom to the same value to maintain bottom padding) + top: i32, + /// Size of the right work area offset + right: i32, + /// Size of the bottom work area offset + bottom: i32, +} + #[derive(Parser)] struct MonitorIndexPreference { /// Preferred monitor index (zero-indexed) @@ -1188,6 +1204,9 @@ enum SubCommand { /// Set offsets for a monitor to exclude parts of the work area from tiling #[clap(arg_required_else_help = true)] MonitorWorkAreaOffset(MonitorWorkAreaOffset), + /// Set offsets for a workspace to exclude parts of the work area from tiling + #[clap(arg_required_else_help = true)] + WorkspaceWorkAreaOffset(WorkspaceWorkAreaOffset), /// Toggle application of the window-based work area offset for the focused workspace ToggleWindowBasedWorkAreaOffset, /// Set container padding on the focused workspace @@ -1938,6 +1957,20 @@ fn main() -> Result<()> { bottom: arg.bottom, }))?; } + + SubCommand::WorkspaceWorkAreaOffset(arg) => { + send_message(&SocketMessage::WorkspaceWorkAreaOffset( + arg.monitor, + arg.workspace, + Rect { + left: arg.left, + top: arg.top, + right: arg.right, + bottom: arg.bottom, + }, + ))?; + } + SubCommand::ToggleWindowBasedWorkAreaOffset => { send_message(&SocketMessage::ToggleWindowBasedWorkAreaOffset)?; } diff --git a/schema.bar.json b/schema.bar.json index b9dc8197..8a7b5d69 100644 --- a/schema.bar.json +++ b/schema.bar.json @@ -8217,6 +8217,69 @@ } } }, + { + "type": "object", + "required": [ + "content", + "type" + ], + "properties": { + "content": { + "type": "array", + "items": [ + { + "type": "integer", + "format": "uint", + "minimum": 0.0 + }, + { + "type": "integer", + "format": "uint", + "minimum": 0.0 + }, + { + "type": "object", + "required": [ + "bottom", + "left", + "right", + "top" + ], + "properties": { + "bottom": { + "description": "The bottom point in a Win32 Rect", + "type": "integer", + "format": "int32" + }, + "left": { + "description": "The left point in a Win32 Rect", + "type": "integer", + "format": "int32" + }, + "right": { + "description": "The right point in a Win32 Rect", + "type": "integer", + "format": "int32" + }, + "top": { + "description": "The top point in a Win32 Rect", + "type": "integer", + "format": "int32" + } + } + } + ], + "maxItems": 3, + "minItems": 3 + }, + "type": { + "type": "string", + "enum": [ + "WorkspaceWorkAreaOffset" + ] + } + } + }, { "type": "object", "required": [ @@ -14295,6 +14358,69 @@ } } }, + { + "type": "object", + "required": [ + "content", + "type" + ], + "properties": { + "content": { + "type": "array", + "items": [ + { + "type": "integer", + "format": "uint", + "minimum": 0.0 + }, + { + "type": "integer", + "format": "uint", + "minimum": 0.0 + }, + { + "type": "object", + "required": [ + "bottom", + "left", + "right", + "top" + ], + "properties": { + "bottom": { + "description": "The bottom point in a Win32 Rect", + "type": "integer", + "format": "int32" + }, + "left": { + "description": "The left point in a Win32 Rect", + "type": "integer", + "format": "int32" + }, + "right": { + "description": "The right point in a Win32 Rect", + "type": "integer", + "format": "int32" + }, + "top": { + "description": "The top point in a Win32 Rect", + "type": "integer", + "format": "int32" + } + } + } + ], + "maxItems": 3, + "minItems": 3 + }, + "type": { + "type": "string", + "enum": [ + "WorkspaceWorkAreaOffset" + ] + } + } + }, { "type": "object", "required": [ @@ -20373,6 +20499,69 @@ } } }, + { + "type": "object", + "required": [ + "content", + "type" + ], + "properties": { + "content": { + "type": "array", + "items": [ + { + "type": "integer", + "format": "uint", + "minimum": 0.0 + }, + { + "type": "integer", + "format": "uint", + "minimum": 0.0 + }, + { + "type": "object", + "required": [ + "bottom", + "left", + "right", + "top" + ], + "properties": { + "bottom": { + "description": "The bottom point in a Win32 Rect", + "type": "integer", + "format": "int32" + }, + "left": { + "description": "The left point in a Win32 Rect", + "type": "integer", + "format": "int32" + }, + "right": { + "description": "The right point in a Win32 Rect", + "type": "integer", + "format": "int32" + }, + "top": { + "description": "The top point in a Win32 Rect", + "type": "integer", + "format": "int32" + } + } + } + ], + "maxItems": 3, + "minItems": 3 + }, + "type": { + "type": "string", + "enum": [ + "WorkspaceWorkAreaOffset" + ] + } + } + }, { "type": "object", "required": [ @@ -26451,6 +26640,69 @@ } } }, + { + "type": "object", + "required": [ + "content", + "type" + ], + "properties": { + "content": { + "type": "array", + "items": [ + { + "type": "integer", + "format": "uint", + "minimum": 0.0 + }, + { + "type": "integer", + "format": "uint", + "minimum": 0.0 + }, + { + "type": "object", + "required": [ + "bottom", + "left", + "right", + "top" + ], + "properties": { + "bottom": { + "description": "The bottom point in a Win32 Rect", + "type": "integer", + "format": "int32" + }, + "left": { + "description": "The left point in a Win32 Rect", + "type": "integer", + "format": "int32" + }, + "right": { + "description": "The right point in a Win32 Rect", + "type": "integer", + "format": "int32" + }, + "top": { + "description": "The top point in a Win32 Rect", + "type": "integer", + "format": "int32" + } + } + } + ], + "maxItems": 3, + "minItems": 3 + }, + "type": { + "type": "string", + "enum": [ + "WorkspaceWorkAreaOffset" + ] + } + } + }, { "type": "object", "required": [ @@ -32529,6 +32781,69 @@ } } }, + { + "type": "object", + "required": [ + "content", + "type" + ], + "properties": { + "content": { + "type": "array", + "items": [ + { + "type": "integer", + "format": "uint", + "minimum": 0.0 + }, + { + "type": "integer", + "format": "uint", + "minimum": 0.0 + }, + { + "type": "object", + "required": [ + "bottom", + "left", + "right", + "top" + ], + "properties": { + "bottom": { + "description": "The bottom point in a Win32 Rect", + "type": "integer", + "format": "int32" + }, + "left": { + "description": "The left point in a Win32 Rect", + "type": "integer", + "format": "int32" + }, + "right": { + "description": "The right point in a Win32 Rect", + "type": "integer", + "format": "int32" + }, + "top": { + "description": "The top point in a Win32 Rect", + "type": "integer", + "format": "int32" + } + } + } + ], + "maxItems": 3, + "minItems": 3 + }, + "type": { + "type": "string", + "enum": [ + "WorkspaceWorkAreaOffset" + ] + } + } + }, { "type": "object", "required": [ @@ -38607,6 +38922,69 @@ } } }, + { + "type": "object", + "required": [ + "content", + "type" + ], + "properties": { + "content": { + "type": "array", + "items": [ + { + "type": "integer", + "format": "uint", + "minimum": 0.0 + }, + { + "type": "integer", + "format": "uint", + "minimum": 0.0 + }, + { + "type": "object", + "required": [ + "bottom", + "left", + "right", + "top" + ], + "properties": { + "bottom": { + "description": "The bottom point in a Win32 Rect", + "type": "integer", + "format": "int32" + }, + "left": { + "description": "The left point in a Win32 Rect", + "type": "integer", + "format": "int32" + }, + "right": { + "description": "The right point in a Win32 Rect", + "type": "integer", + "format": "int32" + }, + "top": { + "description": "The top point in a Win32 Rect", + "type": "integer", + "format": "int32" + } + } + } + ], + "maxItems": 3, + "minItems": 3 + }, + "type": { + "type": "string", + "enum": [ + "WorkspaceWorkAreaOffset" + ] + } + } + }, { "type": "object", "required": [ @@ -44685,6 +45063,69 @@ } } }, + { + "type": "object", + "required": [ + "content", + "type" + ], + "properties": { + "content": { + "type": "array", + "items": [ + { + "type": "integer", + "format": "uint", + "minimum": 0.0 + }, + { + "type": "integer", + "format": "uint", + "minimum": 0.0 + }, + { + "type": "object", + "required": [ + "bottom", + "left", + "right", + "top" + ], + "properties": { + "bottom": { + "description": "The bottom point in a Win32 Rect", + "type": "integer", + "format": "int32" + }, + "left": { + "description": "The left point in a Win32 Rect", + "type": "integer", + "format": "int32" + }, + "right": { + "description": "The right point in a Win32 Rect", + "type": "integer", + "format": "int32" + }, + "top": { + "description": "The top point in a Win32 Rect", + "type": "integer", + "format": "int32" + } + } + } + ], + "maxItems": 3, + "minItems": 3 + }, + "type": { + "type": "string", + "enum": [ + "WorkspaceWorkAreaOffset" + ] + } + } + }, { "type": "object", "required": [ @@ -50763,6 +51204,69 @@ } } }, + { + "type": "object", + "required": [ + "content", + "type" + ], + "properties": { + "content": { + "type": "array", + "items": [ + { + "type": "integer", + "format": "uint", + "minimum": 0.0 + }, + { + "type": "integer", + "format": "uint", + "minimum": 0.0 + }, + { + "type": "object", + "required": [ + "bottom", + "left", + "right", + "top" + ], + "properties": { + "bottom": { + "description": "The bottom point in a Win32 Rect", + "type": "integer", + "format": "int32" + }, + "left": { + "description": "The left point in a Win32 Rect", + "type": "integer", + "format": "int32" + }, + "right": { + "description": "The right point in a Win32 Rect", + "type": "integer", + "format": "int32" + }, + "top": { + "description": "The top point in a Win32 Rect", + "type": "integer", + "format": "int32" + } + } + } + ], + "maxItems": 3, + "minItems": 3 + }, + "type": { + "type": "string", + "enum": [ + "WorkspaceWorkAreaOffset" + ] + } + } + }, { "type": "object", "required": [ @@ -56841,6 +57345,69 @@ } } }, + { + "type": "object", + "required": [ + "content", + "type" + ], + "properties": { + "content": { + "type": "array", + "items": [ + { + "type": "integer", + "format": "uint", + "minimum": 0.0 + }, + { + "type": "integer", + "format": "uint", + "minimum": 0.0 + }, + { + "type": "object", + "required": [ + "bottom", + "left", + "right", + "top" + ], + "properties": { + "bottom": { + "description": "The bottom point in a Win32 Rect", + "type": "integer", + "format": "int32" + }, + "left": { + "description": "The left point in a Win32 Rect", + "type": "integer", + "format": "int32" + }, + "right": { + "description": "The right point in a Win32 Rect", + "type": "integer", + "format": "int32" + }, + "top": { + "description": "The top point in a Win32 Rect", + "type": "integer", + "format": "int32" + } + } + } + ], + "maxItems": 3, + "minItems": 3 + }, + "type": { + "type": "string", + "enum": [ + "WorkspaceWorkAreaOffset" + ] + } + } + }, { "type": "object", "required": [ diff --git a/schema.json b/schema.json index 83c44896..fa3c2d1a 100644 --- a/schema.json +++ b/schema.json @@ -2138,6 +2138,38 @@ ] } }, + "work_area_offset": { + "description": "Workspace specific work area offset (default: None)", + "type": "object", + "required": [ + "bottom", + "left", + "right", + "top" + ], + "properties": { + "bottom": { + "description": "The bottom point in a Win32 Rect", + "type": "integer", + "format": "int32" + }, + "left": { + "description": "The left point in a Win32 Rect", + "type": "integer", + "format": "int32" + }, + "right": { + "description": "The right point in a Win32 Rect", + "type": "integer", + "format": "int32" + }, + "top": { + "description": "The top point in a Win32 Rect", + "type": "integer", + "format": "int32" + } + } + }, "workspace_padding": { "description": "Workspace padding (default: global)", "type": "integer",