diff --git a/komorebi/src/lib.rs b/komorebi/src/lib.rs index 28423ee8..f3d7473d 100644 --- a/komorebi/src/lib.rs +++ b/komorebi/src/lib.rs @@ -147,6 +147,7 @@ lazy_static! { "komorebi".to_string(), "komorebic".to_string() ])); + static ref TITLELESS_APPLICATIONS: Arc>> = Arc::new(Mutex::new(Vec::new())); static ref UNMANAGED_WINDOW_IDS: Arc>> = Arc::new(Mutex::new(vec![])); } diff --git a/komorebi/src/process_event.rs b/komorebi/src/process_event.rs index a09e7f41..b68b6f8b 100644 --- a/komorebi/src/process_event.rs +++ b/komorebi/src/process_event.rs @@ -252,26 +252,23 @@ impl WindowManager { Err(error) => return Err(error.into()), }; - if tab_rect == main_rect { - if window.id != window_id { - // Tab changed - update stored element - container_idx_to_update = Some(container_idx); - tabbed_window = true; - } - // If window.id == window_id, proceed with normal focus handling + if tab_rect == main_rect && window.id != window_id { + // Tab changed - update stored element + container_idx_to_update = Some(container_idx); + tabbed_window = true; } + // If window.id == window_id, proceed with normal focus handling } } // Update the window element outside the immutable borrow - if let Some(container_idx) = container_idx_to_update { - if let Some(container) = + if let Some(container_idx) = container_idx_to_update + && let Some(container) = workspace.containers_mut().get_mut(container_idx) - && let Some(window) = container.focused_window_mut() - { - window.id = window_id; - window.element = AccessibilityUiElement(element.clone()); - } + && let Some(window) = container.focused_window_mut() + { + window.id = window_id; + window.element = AccessibilityUiElement(element.clone()); } // check monocle_container for tabbed applications @@ -299,13 +296,12 @@ impl WindowManager { } } - if update_monocle { - if let Some(monocle) = workspace.monocle_container.as_mut() - && let Some(window) = monocle.focused_window_mut() - { - window.id = window_id; - window.element = AccessibilityUiElement(element.clone()); - } + if update_monocle + && let Some(monocle) = workspace.monocle_container.as_mut() + && let Some(window) = monocle.focused_window_mut() + { + window.id = window_id; + window.element = AccessibilityUiElement(element.clone()); } if first_tab_destroyed { diff --git a/komorebi/src/static_config.rs b/komorebi/src/static_config.rs index dade8cc5..3f59b830 100644 --- a/komorebi/src/static_config.rs +++ b/komorebi/src/static_config.rs @@ -10,6 +10,8 @@ use crate::FLOATING_WINDOW_TOGGLE_ASPECT_RATIO; use crate::IGNORE_IDENTIFIERS; use crate::MANAGE_IDENTIFIERS; use crate::REGEX_IDENTIFIERS; +use crate::TABBED_APPLICATIONS; +use crate::TITLELESS_APPLICATIONS; use crate::WORKSPACE_MATCHING_RULES; use crate::animation::ANIMATION_DURATION_GLOBAL; use crate::animation::ANIMATION_DURATION_PER_ANIMATION; @@ -530,6 +532,12 @@ pub struct StaticConfig { /// Identify applications which should be managed as floating windows #[serde(skip_serializing_if = "Option::is_none")] pub floating_applications: Option>, + /// Identify applications which should be managed despite not reporting titles to the system + #[serde(skip_serializing_if = "Option::is_none")] + pub titleless_applications: Option>, + /// Identify applications which use native tabs for special handling + #[serde(skip_serializing_if = "Option::is_none")] + pub tabbed_applications: Option>, // /// Identify border overflow applications // #[serde(skip_serializing_if = "Option::is_none")] // pub border_overflow_applications: Option>, @@ -730,6 +738,7 @@ impl From<&WindowManager> for StaticConfig { global_work_area_offset: value.work_area_offset, ignore_rules: None, floating_applications: None, + titleless_applications: None, manage_rules: None, // border_overflow_applications: None, // tray_and_multi_window_applications: None, @@ -749,6 +758,7 @@ impl From<&WindowManager> for StaticConfig { // remove_titlebar_applications: Option::from(NO_TITLEBAR.lock().clone()), floating_window_aspect_ratio: Option::from(*FLOATING_WINDOW_TOGGLE_ASPECT_RATIO.lock()), // window_handling_behaviour: Option::from(WINDOW_HANDLING_BEHAVIOUR.load()), + tabbed_applications: None, } } } @@ -916,6 +926,8 @@ impl StaticConfig { // let mut slow_application_identifiers = SLOW_APPLICATION_IDENTIFIERS.lock(); let mut floating_applications = FLOATING_APPLICATIONS.lock(); // let mut no_titlebar_applications = NO_TITLEBAR.lock(); + let mut titleless_applications = TITLELESS_APPLICATIONS.lock(); + let mut tabbed_applications = TABBED_APPLICATIONS.lock(); if let Some(rules) = &mut self.ignore_rules { populate_rules(rules, &mut ignore_identifiers, &mut regex_identifiers)?; @@ -929,6 +941,22 @@ impl StaticConfig { populate_rules(rules, &mut manage_identifiers, &mut regex_identifiers)?; } + if let Some(rules) = &mut self.tabbed_applications { + for r in rules { + if !tabbed_applications.contains(r) { + tabbed_applications.push(r.to_string()); + } + } + } + + if let Some(rules) = &mut self.titleless_applications { + for r in rules { + if !titleless_applications.contains(r) { + titleless_applications.push(r.to_string()); + } + } + } + // if let Some(rules) = &mut self.object_name_change_applications { // populate_rules( // rules, diff --git a/komorebi/src/window.rs b/komorebi/src/window.rs index a2451c7f..0a98a400 100644 --- a/komorebi/src/window.rs +++ b/komorebi/src/window.rs @@ -8,6 +8,7 @@ use crate::MANAGE_IDENTIFIERS; use crate::PERMAIGNORE_CLASSES; use crate::REGEX_IDENTIFIERS; use crate::TABBED_APPLICATIONS; +use crate::TITLELESS_APPLICATIONS; use crate::WINDOW_RESTORE_POSITIONS; use crate::accessibility::AccessibilityApi; use crate::accessibility::action_constants::kAXPressAction; @@ -933,12 +934,22 @@ impl Window { // // debug.has_minimum_height = true; - if self.title().is_none() { - return Ok(false); + match self.title() { + None => { + if TITLELESS_APPLICATIONS + .lock() + .contains(&self.exe().unwrap_or_default()) + { + debug.matches_titleless_applications = self.exe(); + } else { + return Ok(false); + } + } + Some(_) => { + debug.has_title = true; + } } - debug.has_title = true; - // let is_cloaked = self.is_cloaked().unwrap_or_default(); // // debug.is_cloaked = is_cloaked; @@ -961,13 +972,15 @@ impl Window { // (true, _) | // // If not allowing cloaked windows, we need to ensure the window is not cloaked // (false, false) => { - if let (Some(title), Some(exe_name), Some(role), Some(subrole), Some(path)) = ( - self.title(), - self.exe(), - self.role(), - self.subrole(), - self.path(), - ) { + let title = if debug.matches_titleless_applications.is_some() { + self.exe() + } else { + self.title() + }; + + if let (Some(title), Some(exe_name), Some(role), Some(subrole), Some(path)) = + (title, self.exe(), self.role(), self.subrole(), self.path()) + { debug.title = Some(title.clone()); debug.exe_name = Some(exe_name.clone()); debug.role = Some(role.clone()); @@ -1270,6 +1283,7 @@ pub struct RuleDebug { pub matches_managed_override: Option, // pub matches_layered_whitelist: Option, pub matches_floating_applications: Option, + pub matches_titleless_applications: Option, // pub matches_wsl2_gui: Option, // pub matches_no_titlebar: Option, } diff --git a/nix/komorebi-bar-options.nix b/nix/komorebi-bar-options.nix index f47eab01..69a10842 100644 --- a/nix/komorebi-bar-options.nix +++ b/nix/komorebi-bar-options.nix @@ -962,6 +962,17 @@ in ] ); }; + auto_select_text = 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 ( @@ -1248,6 +1259,17 @@ in ); default = null; }; + accent = 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 ( @@ -1323,17 +1345,6 @@ in ); 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 ( @@ -1345,17 +1356,6 @@ in ); default = null; }; - auto_select_text = lib.mkOption { - type = ( - lib.types.nullOr ( - lib.types.oneOf [ - (lib.types.nullOr catppuccinValue) - (lib.types.nullOr base16Value) - ] - ) - ); - default = null; - }; }; } ) diff --git a/nix/komorebi-options.nix b/nix/komorebi-options.nix index ae1236fd..2afd533a 100644 --- a/nix/komorebi-options.nix +++ b/nix/komorebi-options.nix @@ -306,7 +306,13 @@ in type = ( lib.types.nullOr ( lib.types.oneOf [ - (lib.types.attrsOf lib.types.int) + (lib.types.submodule { + options = { + movement = lib.mkOption { + type = lib.types.int; + }; + }; + }) lib.types.int ] ) @@ -317,7 +323,13 @@ in enabled = lib.mkOption { type = ( lib.types.oneOf [ - (lib.types.attrsOf lib.types.bool) + (lib.types.submodule { + options = { + movement = lib.mkOption { + type = lib.types.bool; + }; + }; + }) lib.types.bool ] ); @@ -333,7 +345,13 @@ in type = ( lib.types.nullOr ( lib.types.oneOf [ - (lib.types.attrsOf animationStyle) + (lib.types.submodule { + options = { + movement = lib.mkOption { + type = animationStyle; + }; + }; + }) animationStyle ] ) @@ -741,6 +759,11 @@ in default = 50; description = "Delta to resize windows by"; }; + tabbed_applications = lib.mkOption { + type = (lib.types.nullOr (lib.types.listOf lib.types.str)); + default = null; + description = "Identify applications which use native tabs for special handling"; + }; theme = lib.mkOption { type = ( lib.types.nullOr ( @@ -755,6 +778,28 @@ in ] ); }; + floating_border = 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; + }; unfocused_locked_border = lib.mkOption { type = ( lib.types.nullOr ( @@ -766,6 +811,17 @@ in ); default = null; }; + stack_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 ( @@ -841,28 +897,6 @@ in ); default = null; }; - monocle_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; - }; name = lib.mkOption { type = ( lib.types.nullOr ( @@ -1149,28 +1183,6 @@ in ); 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; - }; single_border = lib.mkOption { type = ( lib.types.nullOr ( @@ -1182,7 +1194,18 @@ in ); default = null; }; - floating_border = lib.mkOption { + bar_accent = 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 [ @@ -1200,6 +1223,11 @@ in default = null; description = "Theme configuration options\n\nIf a theme is specified, `border_colours` will have no effect"; }; + titleless_applications = lib.mkOption { + type = (lib.types.nullOr (lib.types.listOf lib.types.str)); + default = null; + description = "Identify applications which should be managed despite not reporting titles to the system"; + }; toggle_float_placement = lib.mkOption { type = (lib.types.nullOr placement); default = "CenterAndResize"; diff --git a/schema.json b/schema.json index 417c9815..c167e0d2 100644 --- a/schema.json +++ b/schema.json @@ -260,6 +260,16 @@ "format": "int32", "default": 50 }, + "tabbed_applications": { + "description": "Identify applications which use native tabs for special handling", + "type": [ + "array", + "null" + ], + "items": { + "type": "string" + } + }, "theme": { "description": "Theme configuration options\n\nIf a theme is specified, `border_colours` will have no effect", "anyOf": [ @@ -271,6 +281,16 @@ } ] }, + "titleless_applications": { + "description": "Identify applications which should be managed despite not reporting titles to the system", + "type": [ + "array", + "null" + ], + "items": { + "type": "string" + } + }, "toggle_float_placement": { "description": "Determines the placement of a new window when toggling to float", "anyOf": [ @@ -3119,9 +3139,12 @@ { "description": "Animation configuration prefixed for a specific animation kind", "type": "object", - "additionalProperties": { - "type": "boolean" - } + "properties": { + "movement": { + "type": "boolean" + } + }, + "additionalProperties": false }, { "description": "Animation configuration for all animation kinds", @@ -3135,11 +3158,14 @@ { "description": "Animation configuration prefixed for a specific animation kind", "type": "object", - "additionalProperties": { - "type": "integer", - "format": "uint64", - "minimum": 0 - } + "properties": { + "movement": { + "type": "integer", + "format": "uint64", + "minimum": 0 + } + }, + "additionalProperties": false }, { "description": "Animation configuration for all animation kinds", @@ -3155,9 +3181,12 @@ { "description": "Animation configuration prefixed for a specific animation kind", "type": "object", - "additionalProperties": { - "$ref": "#/$defs/AnimationStyle" - } + "properties": { + "movement": { + "$ref": "#/$defs/AnimationStyle" + } + }, + "additionalProperties": false }, { "description": "Animation configuration for all animation kinds",