wl-seat: split window management
This commit is contained in:
parent
8f7997e270
commit
c4e9011714
2 changed files with 112 additions and 102 deletions
|
|
@ -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<Rc<ContainerNode>> {
|
||||
if let Some(tl) = self.keyboard_node.get().node_toplevel() {
|
||||
return toplevel_parent_container(&*tl);
|
||||
}
|
||||
None
|
||||
}
|
||||
|
||||
pub fn get_mono(&self) -> Option<bool> {
|
||||
self.kb_parent_container().map(|c| c.mono_child.is_some())
|
||||
}
|
||||
|
||||
pub fn get_split(&self) -> Option<ContainerSplit> {
|
||||
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<Self>) {
|
||||
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<Self>) -> Option<bool> {
|
||||
match self.keyboard_node.get().node_toplevel() {
|
||||
Some(tl) => Some(tl.tl_data().parent_is_float.get()),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn set_floating(self: &Rc<Self>, 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()
|
||||
}
|
||||
|
|
|
|||
108
src/ifs/wl_seat/window_management.rs
Normal file
108
src/ifs/wl_seat/window_management.rs
Normal file
|
|
@ -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<Rc<ContainerNode>> {
|
||||
if let Some(tl) = self.keyboard_node.get().node_toplevel() {
|
||||
return toplevel_parent_container(&*tl);
|
||||
}
|
||||
None
|
||||
}
|
||||
|
||||
pub fn get_mono(&self) -> Option<bool> {
|
||||
self.kb_parent_container().map(|c| c.mono_child.is_some())
|
||||
}
|
||||
|
||||
pub fn get_split(&self) -> Option<ContainerSplit> {
|
||||
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<Self>) {
|
||||
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<Self>) -> Option<bool> {
|
||||
match self.keyboard_node.get().node_toplevel() {
|
||||
Some(tl) => Some(tl.tl_data().parent_is_float.get()),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn set_floating(self: &Rc<Self>, floating: bool) {
|
||||
let tl = match self.keyboard_node.get().node_toplevel() {
|
||||
Some(tl) => tl,
|
||||
_ => return,
|
||||
};
|
||||
toplevel_set_floating(&self.state, tl, floating);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue