From c4e9011714354d36ab64151f970ab8af35ddde50 Mon Sep 17 00:00:00 2001 From: kossLAN Date: Fri, 29 May 2026 21:51:40 -0400 Subject: [PATCH] wl-seat: split window management --- src/ifs/wl_seat.rs | 106 +------------------------- src/ifs/wl_seat/window_management.rs | 108 +++++++++++++++++++++++++++ 2 files changed, 112 insertions(+), 102 deletions(-) create mode 100644 src/ifs/wl_seat/window_management.rs diff --git a/src/ifs/wl_seat.rs b/src/ifs/wl_seat.rs index 62211638..3fcdcffb 100644 --- a/src/ifs/wl_seat.rs +++ b/src/ifs/wl_seat.rs @@ -14,6 +14,7 @@ mod touch_owner; pub mod wl_keyboard; pub mod wl_pointer; pub mod wl_touch; +mod window_management; pub mod wp_pointer_warp_v1; pub mod zwp_pointer_constraints_v1; pub mod zwp_pointer_gesture_hold_v1; @@ -83,10 +84,9 @@ use { rect::Rect, state::{DeviceHandlerData, State}, tree::{ - ChangeGroupAction, ContainerNode, ContainerSplit, Direction, FoundNode, Node, NodeId, - NodeLayer, NodeLayerLink, NodeLocation, OutputNode, StackedNode, ToplevelNode, - WorkspaceNode, generic_node_visitor, toplevel_create_split, toplevel_parent_container, - toplevel_set_floating, toplevel_set_workspace, + Direction, FoundNode, Node, NodeId, NodeLayer, NodeLayerLink, NodeLocation, OutputNode, + StackedNode, ToplevelNode, WorkspaceNode, generic_node_visitor, + toplevel_set_workspace, }, utils::{ asyncevent::AsyncEvent, @@ -710,104 +710,6 @@ impl WlSeatGlobal { self.kb_owner.ungrab(self); } - pub fn kb_parent_container(&self) -> Option> { - if let Some(tl) = self.keyboard_node.get().node_toplevel() { - return toplevel_parent_container(&*tl); - } - None - } - - pub fn get_mono(&self) -> Option { - self.kb_parent_container().map(|c| c.mono_child.is_some()) - } - - pub fn get_split(&self) -> Option { - self.kb_parent_container().map(|c| c.split.get()) - } - - pub fn set_mono(&self, mono: bool) { - if let Some(tl) = self.keyboard_node.get().node_toplevel() - && let Some(parent) = tl.tl_data().parent.get() - && let Some(container) = parent.node_into_container() - { - let node = if mono { Some(tl.deref()) } else { None }; - container.set_mono(node); - } - } - - pub fn set_split(&self, axis: ContainerSplit) { - if let Some(c) = self.kb_parent_container() { - c.set_split(axis); - } - } - - pub fn create_split(&self, axis: ContainerSplit) { - let tl = match self.keyboard_node.get().node_toplevel() { - Some(tl) => tl, - _ => return, - }; - toplevel_create_split(&self.state, tl, axis); - } - - pub fn toggle_tab(&self) { - if let Some(c) = self.kb_parent_container() { - c.change_group(ChangeGroupAction::ToggleTab); - } - } - - pub fn make_group(&self, axis: ContainerSplit, ephemeral: bool) { - if let Some(c) = self.kb_parent_container() { - c.make_group(axis, ephemeral); - } - } - - pub fn change_group_opposite(&self) { - if let Some(c) = self.kb_parent_container() { - c.change_group(ChangeGroupAction::Opposite); - } - } - - pub fn equalize(&self, recursive: bool) { - if let Some(c) = self.kb_parent_container() { - if recursive { - c.equalize_recursive(); - } else { - c.equalize(); - } - } - } - - pub fn move_tab(&self, right: bool) { - if let Some(c) = self.kb_parent_container() { - c.move_tab(right); - } - } - - pub fn focus_parent(self: &Rc) { - if let Some(tl) = self.keyboard_node.get().node_toplevel() - && let Some(parent) = tl.tl_data().parent.get() - && let Some(tl) = parent.node_toplevel() - { - self.focus_node(tl); - self.maybe_schedule_warp_mouse_to_focus(); - } - } - - pub fn get_floating(self: &Rc) -> Option { - match self.keyboard_node.get().node_toplevel() { - Some(tl) => Some(tl.tl_data().parent_is_float.get()), - _ => None, - } - } - - pub fn set_floating(self: &Rc, floating: bool) { - let tl = match self.keyboard_node.get().node_toplevel() { - Some(tl) => tl, - _ => return, - }; - toplevel_set_floating(&self.state, tl, floating); - } - pub fn get_rate(&self) -> (i32, i32) { self.repeat_rate.get() } diff --git a/src/ifs/wl_seat/window_management.rs b/src/ifs/wl_seat/window_management.rs new file mode 100644 index 00000000..0163a15a --- /dev/null +++ b/src/ifs/wl_seat/window_management.rs @@ -0,0 +1,108 @@ +use { + super::WlSeatGlobal, + crate::tree::{ + ChangeGroupAction, ContainerNode, ContainerSplit, toplevel_create_split, + toplevel_parent_container, toplevel_set_floating, + }, + std::{ops::Deref, rc::Rc}, +}; + +impl WlSeatGlobal { + pub fn kb_parent_container(&self) -> Option> { + if let Some(tl) = self.keyboard_node.get().node_toplevel() { + return toplevel_parent_container(&*tl); + } + None + } + + pub fn get_mono(&self) -> Option { + self.kb_parent_container().map(|c| c.mono_child.is_some()) + } + + pub fn get_split(&self) -> Option { + self.kb_parent_container().map(|c| c.split.get()) + } + + pub fn set_mono(&self, mono: bool) { + if let Some(tl) = self.keyboard_node.get().node_toplevel() + && let Some(parent) = tl.tl_data().parent.get() + && let Some(container) = parent.node_into_container() + { + let node = if mono { Some(tl.deref()) } else { None }; + container.set_mono(node); + } + } + + pub fn set_split(&self, axis: ContainerSplit) { + if let Some(c) = self.kb_parent_container() { + c.set_split(axis); + } + } + + pub fn create_split(&self, axis: ContainerSplit) { + let tl = match self.keyboard_node.get().node_toplevel() { + Some(tl) => tl, + _ => return, + }; + toplevel_create_split(&self.state, tl, axis); + } + + pub fn toggle_tab(&self) { + if let Some(c) = self.kb_parent_container() { + c.change_group(ChangeGroupAction::ToggleTab); + } + } + + pub fn make_group(&self, axis: ContainerSplit, ephemeral: bool) { + if let Some(c) = self.kb_parent_container() { + c.make_group(axis, ephemeral); + } + } + + pub fn change_group_opposite(&self) { + if let Some(c) = self.kb_parent_container() { + c.change_group(ChangeGroupAction::Opposite); + } + } + + pub fn equalize(&self, recursive: bool) { + if let Some(c) = self.kb_parent_container() { + if recursive { + c.equalize_recursive(); + } else { + c.equalize(); + } + } + } + + pub fn move_tab(&self, right: bool) { + if let Some(c) = self.kb_parent_container() { + c.move_tab(right); + } + } + + pub fn focus_parent(self: &Rc) { + if let Some(tl) = self.keyboard_node.get().node_toplevel() + && let Some(parent) = tl.tl_data().parent.get() + && let Some(tl) = parent.node_toplevel() + { + self.focus_node(tl); + self.maybe_schedule_warp_mouse_to_focus(); + } + } + + pub fn get_floating(self: &Rc) -> Option { + match self.keyboard_node.get().node_toplevel() { + Some(tl) => Some(tl.tl_data().parent_is_float.get()), + _ => None, + } + } + + pub fn set_floating(self: &Rc, floating: bool) { + let tl = match self.keyboard_node.get().node_toplevel() { + Some(tl) => tl, + _ => return, + }; + toplevel_set_floating(&self.state, tl, floating); + } +}