mirror of
https://github.com/LGUG2Z/komorebi.git
synced 2026-03-21 08:59:11 +01:00
feat(config): add floating ws layer behaviour opt
This commit adds a new option to the WorkspaceConfig object, floating_layer_behaviour, which allows the user to either set FloatingLayerBehaviour::Tile or FloatingLayerBehaviour::Float. Although I prefer Float as a default, there was a good enough argument to make Tile the default based on the fact that the Floating layer is automatically engaged based on the focused window, and previously when the focused window was a floating window, new windows would be tiled unless they matched floating rules.
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -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<Axis>,
|
||||
/// 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<FloatingLayerBehaviour>,
|
||||
}
|
||||
|
||||
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()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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<usize>,
|
||||
#[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()));
|
||||
|
||||
|
||||
@@ -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",
|
||||
|
||||
21
schema.json
21
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",
|
||||
|
||||
Reference in New Issue
Block a user