diff --git a/komorebi/src/core/mod.rs b/komorebi/src/core/mod.rs index 9da94bcb..131b9ef4 100644 --- a/komorebi/src/core/mod.rs +++ b/komorebi/src/core/mod.rs @@ -378,6 +378,18 @@ pub enum WindowContainerBehaviour { Append, } +#[derive( + Clone, Copy, Debug, Default, Serialize, Deserialize, Display, EnumString, ValueEnum, PartialEq, +)] +#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] +pub enum FloatingLayerBehaviour { + /// Tile new windows (unless they match a float rule) + #[default] + Tile, + /// Float new windows + Float, +} + #[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize, Display, EnumString, ValueEnum)] #[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] pub enum MoveBehaviour { diff --git a/komorebi/src/static_config.rs b/komorebi/src/static_config.rs index ff53a559..d2331739 100644 --- a/komorebi/src/static_config.rs +++ b/komorebi/src/static_config.rs @@ -60,6 +60,7 @@ use crate::workspace::Workspace; use crate::AspectRatio; use crate::Axis; use crate::CrossBoundaryBehaviour; +use crate::FloatingLayerBehaviour; use crate::PredefinedAspectRatio; use crate::DATA_DIR; use crate::DEFAULT_CONTAINER_PADDING; @@ -164,6 +165,9 @@ pub struct WorkspaceConfig { /// Specify an axis on which to flip the selected layout (default: None) #[serde(skip_serializing_if = "Option::is_none")] pub layout_flip: Option, + /// Determine what happens to a new window when the Floating workspace layer is active (default: Tile) + #[serde(skip_serializing_if = "Option::is_none")] + pub floating_layer_behaviour: Option, } impl From<&Workspace> for WorkspaceConfig { @@ -239,6 +243,7 @@ impl From<&Workspace> for WorkspaceConfig { window_container_behaviour_rules: Option::from(window_container_behaviour_rules), float_override: *value.float_override(), layout_flip: value.layout_flip(), + floating_layer_behaviour: Option::from(*value.floating_layer_behaviour()), } } } diff --git a/komorebi/src/window_manager.rs b/komorebi/src/window_manager.rs index 23e860ea..678fa62e 100644 --- a/komorebi/src/window_manager.rs +++ b/komorebi/src/window_manager.rs @@ -80,6 +80,7 @@ use crate::workspace::WorkspaceLayer; use crate::BorderColours; use crate::Colour; use crate::CrossBoundaryBehaviour; +use crate::FloatingLayerBehaviour; use crate::Rgb; use crate::CUSTOM_FFM; use crate::DATA_DIR; @@ -341,6 +342,7 @@ impl From<&WindowManager> for State { .clone(), float_override: workspace.float_override, layer: workspace.layer, + floating_layer_behaviour: workspace.floating_layer_behaviour, globals: workspace.globals, locked_containers: workspace.locked_containers.clone(), workspace_config: None, @@ -644,10 +646,14 @@ impl WindowManager { self.window_management_behaviour.float_override }; - // If the workspace layer is `Floating`, then consider it as if it had float - // override so that new windows spawn as floating - float_override = - float_override || matches!(workspace.layer, WorkspaceLayer::Floating); + // If the workspace layer is `Floating` and the floating layer behaviour is `Float`, + // then consider it as if it had float override so that new windows spawn as floating + float_override = float_override + || (matches!(workspace.layer, WorkspaceLayer::Floating) + && matches!( + workspace.floating_layer_behaviour, + FloatingLayerBehaviour::Float + )); return WindowManagementBehaviour { current_behaviour, diff --git a/komorebi/src/workspace.rs b/komorebi/src/workspace.rs index 93da3b32..b3f5a80e 100644 --- a/komorebi/src/workspace.rs +++ b/komorebi/src/workspace.rs @@ -22,6 +22,7 @@ use crate::core::DefaultLayout; use crate::core::Layout; use crate::core::OperationDirection; use crate::core::Rect; +use crate::FloatingLayerBehaviour; use crate::border_manager::BORDER_OFFSET; use crate::border_manager::BORDER_WIDTH; @@ -92,6 +93,8 @@ pub struct Workspace { #[getset(get = "pub", get_mut = "pub", set = "pub")] pub layer: WorkspaceLayer, #[getset(get = "pub", get_mut = "pub", set = "pub")] + pub floating_layer_behaviour: FloatingLayerBehaviour, + #[getset(get = "pub", get_mut = "pub", set = "pub")] pub locked_containers: BTreeSet, #[serde(skip_serializing_if = "Option::is_none")] #[getset(get = "pub", set = "pub")] @@ -141,6 +144,7 @@ impl Default for Workspace { window_container_behaviour_rules: None, float_override: None, layer: Default::default(), + floating_layer_behaviour: Default::default(), globals: Default::default(), workspace_config: None, locked_containers: Default::default(), @@ -250,6 +254,7 @@ impl Workspace { self.set_float_override(config.float_override); self.set_layout_flip(config.layout_flip); + self.set_floating_layer_behaviour(config.floating_layer_behaviour.unwrap_or_default()); self.set_workspace_config(Some(config.clone())); diff --git a/schema.bar.json b/schema.bar.json index 530304a8..7b693884 100644 --- a/schema.bar.json +++ b/schema.bar.json @@ -1,7 +1,7 @@ { "$schema": "http://json-schema.org/draft-07/schema#", "title": "KomobarConfig", - "description": "The `komorebi.bar.json` configuration file reference for `v0.1.35`", + "description": "The `komorebi.bar.json` configuration file reference for `v0.1.36`", "type": "object", "required": [ "left_widgets", diff --git a/schema.json b/schema.json index f981dc9d..38ff1a79 100644 --- a/schema.json +++ b/schema.json @@ -1,7 +1,7 @@ { "$schema": "http://json-schema.org/draft-07/schema#", "title": "StaticConfig", - "description": "The `komorebi.json` static configuration file reference for `v0.1.35`", + "description": "The `komorebi.json` static configuration file reference for `v0.1.36`", "type": "object", "properties": { "animation": { @@ -1199,6 +1199,25 @@ "description": "Enable or disable float override, which makes it so every new window opens in floating mode (default: false)", "type": "boolean" }, + "floating_layer_behaviour": { + "description": "Determine what happens to a new window when the Floating workspace layer is active (default: Tile)", + "oneOf": [ + { + "description": "Tile new windows (unless they match a float rule)", + "type": "string", + "enum": [ + "Tile" + ] + }, + { + "description": "Float new windows", + "type": "string", + "enum": [ + "Float" + ] + } + ] + }, "initial_workspace_rules": { "description": "Initial workspace application rules", "type": "array",