mirror of
https://github.com/LGUG2Z/komorebi.git
synced 2026-07-08 14:05:10 +02:00
feat(wm): add window_container_behaviour and float_override to workspaces
This commit adds the `window_management_behaviour` and the `float_override` options to the workspace, so that these can be changed per-workspace. It allows setting this options directly on the config.
This commit is contained in:
@@ -131,6 +131,13 @@ pub struct WorkspaceConfig {
|
|||||||
/// Apply this monitor's window-based work area offset (default: true)
|
/// Apply this monitor's window-based work area offset (default: true)
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub apply_window_based_work_area_offset: Option<bool>,
|
pub apply_window_based_work_area_offset: Option<bool>,
|
||||||
|
/// Determine what happens when a new window is opened (default: Create)
|
||||||
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
|
pub window_container_behaviour: Option<WindowContainerBehaviour>,
|
||||||
|
/// Enable or disable float override, which makes it so every new window opens in floating mode
|
||||||
|
/// (default: false)
|
||||||
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
|
pub float_override: Option<bool>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<&Workspace> for WorkspaceConfig {
|
impl From<&Workspace> for WorkspaceConfig {
|
||||||
@@ -183,6 +190,8 @@ impl From<&Workspace> for WorkspaceConfig {
|
|||||||
initial_workspace_rules: None,
|
initial_workspace_rules: None,
|
||||||
workspace_rules: None,
|
workspace_rules: None,
|
||||||
apply_window_based_work_area_offset: Some(value.apply_window_based_work_area_offset()),
|
apply_window_based_work_area_offset: Some(value.apply_window_based_work_area_offset()),
|
||||||
|
window_container_behaviour: *value.window_container_behaviour(),
|
||||||
|
float_override: *value.float_override(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -318,16 +318,29 @@ impl WindowManager {
|
|||||||
) -> WindowManagementBehaviour {
|
) -> WindowManagementBehaviour {
|
||||||
if let Some(monitor) = self.monitors().get(monitor_idx) {
|
if let Some(monitor) = self.monitors().get(monitor_idx) {
|
||||||
if let Some(workspace) = monitor.workspaces().get(workspace_idx) {
|
if let Some(workspace) = monitor.workspaces().get(workspace_idx) {
|
||||||
let current_behaviour = if workspace.containers().is_empty() && matches!(self.window_management_behaviour.current_behaviour, WindowContainerBehaviour::Append) {
|
let current_behaviour = if let Some(behaviour) = workspace.window_container_behaviour() {
|
||||||
|
if workspace.containers().is_empty() && matches!(behaviour, WindowContainerBehaviour::Append) {
|
||||||
|
// You can't append to an empty workspace
|
||||||
|
WindowContainerBehaviour::Create
|
||||||
|
} else {
|
||||||
|
*behaviour
|
||||||
|
}
|
||||||
|
} else if workspace.containers().is_empty() && matches!(self.window_management_behaviour.current_behaviour, WindowContainerBehaviour::Append) {
|
||||||
// You can't append to an empty workspace
|
// You can't append to an empty workspace
|
||||||
WindowContainerBehaviour::Create
|
WindowContainerBehaviour::Create
|
||||||
} else {
|
} else {
|
||||||
self.window_management_behaviour.current_behaviour
|
self.window_management_behaviour.current_behaviour
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let float_override = if let Some(float_override) = workspace.float_override() {
|
||||||
|
*float_override
|
||||||
|
} else {
|
||||||
|
self.window_management_behaviour.float_override
|
||||||
|
};
|
||||||
|
|
||||||
return WindowManagementBehaviour {
|
return WindowManagementBehaviour {
|
||||||
current_behaviour,
|
current_behaviour,
|
||||||
float_override: self.window_management_behaviour.float_override,
|
float_override
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ use crate::static_config::WorkspaceConfig;
|
|||||||
use crate::window::Window;
|
use crate::window::Window;
|
||||||
use crate::window::WindowDetails;
|
use crate::window::WindowDetails;
|
||||||
use crate::windows_api::WindowsApi;
|
use crate::windows_api::WindowsApi;
|
||||||
|
use crate::WindowContainerBehaviour;
|
||||||
use crate::DEFAULT_CONTAINER_PADDING;
|
use crate::DEFAULT_CONTAINER_PADDING;
|
||||||
use crate::DEFAULT_WORKSPACE_PADDING;
|
use crate::DEFAULT_WORKSPACE_PADDING;
|
||||||
use crate::INITIAL_CONFIGURATION_LOADED;
|
use crate::INITIAL_CONFIGURATION_LOADED;
|
||||||
@@ -83,6 +84,10 @@ pub struct Workspace {
|
|||||||
tile: bool,
|
tile: bool,
|
||||||
#[getset(get_copy = "pub", set = "pub")]
|
#[getset(get_copy = "pub", set = "pub")]
|
||||||
apply_window_based_work_area_offset: bool,
|
apply_window_based_work_area_offset: bool,
|
||||||
|
#[getset(get = "pub", get_mut = "pub", set = "pub")]
|
||||||
|
window_container_behaviour: Option<WindowContainerBehaviour>,
|
||||||
|
#[getset(get = "pub", get_mut = "pub", set = "pub")]
|
||||||
|
float_override: Option<bool>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl_ring_elements!(Workspace, Container);
|
impl_ring_elements!(Workspace, Container);
|
||||||
@@ -106,6 +111,8 @@ impl Default for Workspace {
|
|||||||
resize_dimensions: vec![],
|
resize_dimensions: vec![],
|
||||||
tile: true,
|
tile: true,
|
||||||
apply_window_based_work_area_offset: true,
|
apply_window_based_work_area_offset: true,
|
||||||
|
window_container_behaviour: None,
|
||||||
|
float_override: None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -162,6 +169,14 @@ impl Workspace {
|
|||||||
config.apply_window_based_work_area_offset.unwrap_or(true),
|
config.apply_window_based_work_area_offset.unwrap_or(true),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if config.window_container_behaviour.is_some() {
|
||||||
|
self.set_window_container_behaviour(config.window_container_behaviour);
|
||||||
|
}
|
||||||
|
|
||||||
|
if config.float_override.is_some() {
|
||||||
|
self.set_float_override(config.float_override);
|
||||||
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user