feat(wm): toggle float override with floating layer

This commit ensures that a workspace float override will also be applied
when the user switches to the floating layer, and removed when the user
switches to the tiling layer. This results in a workflow which makes it
easier to spawn floating windows on the fly.
This commit is contained in:
LGUG2Z
2025-03-16 13:32:16 -07:00
parent 42c12d5ec3
commit ff2aa5e51a

View File

@@ -88,7 +88,7 @@ pub struct Workspace {
pub float_override: Option<bool>,
#[getset(get = "pub", get_mut = "pub", set = "pub")]
pub globals: WorkspaceGlobals,
#[getset(get = "pub", get_mut = "pub", set = "pub")]
#[getset(get = "pub", get_mut = "pub")]
pub layer: WorkspaceLayer,
#[serde(skip_serializing_if = "Option::is_none")]
#[getset(get = "pub", set = "pub")]
@@ -593,6 +593,19 @@ impl Workspace {
Ok((hwnds.len() + floating_hwnds.len(), container_ids.len()))
}
pub fn set_layer(&mut self, layer: WorkspaceLayer) {
self.layer = layer;
match layer {
WorkspaceLayer::Tiling => {
self.float_override = None;
}
WorkspaceLayer::Floating => {
self.float_override = Some(true);
}
}
}
pub fn container_for_window(&self, hwnd: isize) -> Option<&Container> {
self.containers().get(self.container_idx_for_window(hwnd)?)
}