1
0
Fork 0
forked from wry/wry

config: add Window

This commit is contained in:
Julian Orth 2025-04-29 15:29:39 +02:00
parent ab095b89cf
commit 9977f9dfdf
19 changed files with 1172 additions and 203 deletions

View file

@ -79,7 +79,8 @@ use {
state::{DeviceHandlerData, State},
tree::{
ContainerNode, ContainerSplit, Direction, FoundNode, Node, OutputNode, ToplevelNode,
WorkspaceNode, generic_node_visitor,
WorkspaceNode, generic_node_visitor, toplevel_create_split, toplevel_parent_container,
toplevel_set_floating, toplevel_set_workspace,
},
utils::{
asyncevent::AsyncEvent, bindings::PerClientBindings, clonecell::CloneCell,
@ -401,6 +402,10 @@ impl WlSeatGlobal {
self.cursor_user_group.latest_output()
}
pub fn get_keyboard_node(&self) -> Rc<dyn Node> {
self.keyboard_node.get()
}
pub fn get_keyboard_output(&self) -> Option<Rc<OutputNode>> {
self.keyboard_node.get().node_output()
}
@ -410,38 +415,7 @@ impl WlSeatGlobal {
Some(tl) => tl,
_ => return,
};
if tl.tl_data().is_fullscreen.get() {
return;
}
let old_ws = match tl.tl_data().workspace.get() {
Some(ws) => ws,
_ => return,
};
if old_ws.id == ws.id {
return;
}
let cn = match tl.tl_data().parent.get() {
Some(cn) => cn,
_ => return,
};
let kb_foci = collect_kb_foci(tl.clone());
cn.cnode_remove_child2(&*tl, true);
if !ws.visible.get() {
for focus in kb_foci {
old_ws.clone().node_do_focus(&focus, Direction::Unspecified);
}
}
if tl.tl_data().is_floating.get() {
self.state.map_floating(
tl.clone(),
tl.tl_data().float_width.get(),
tl.tl_data().float_height.get(),
ws,
None,
);
} else {
self.state.map_tiled_on(tl, ws);
}
toplevel_set_workspace(&self.state, tl, ws);
}
pub fn mark_last_active(self: &Rc<Self>) {
@ -556,11 +530,7 @@ impl WlSeatGlobal {
pub fn kb_parent_container(&self) -> Option<Rc<ContainerNode>> {
if let Some(tl) = self.keyboard_node.get().node_toplevel() {
if let Some(parent) = tl.tl_data().parent.get() {
if let Some(container) = parent.node_into_container() {
return Some(container);
}
}
return toplevel_parent_container(&*tl);
}
None
}
@ -595,21 +565,7 @@ impl WlSeatGlobal {
Some(tl) => tl,
_ => return,
};
if tl.tl_data().is_fullscreen.get() {
return;
}
let ws = match tl.tl_data().workspace.get() {
Some(ws) => ws,
_ => return,
};
let pn = match tl.tl_data().parent.get() {
Some(pn) => pn,
_ => return,
};
if let Some(pn) = pn.node_into_containing_node() {
let cn = ContainerNode::new(&self.state, &ws, tl.clone(), axis);
pn.cnode_replace_child(&*tl, cn);
}
toplevel_create_split(&self.state, tl, axis);
}
pub fn focus_parent(self: &Rc<Self>) {
@ -634,29 +590,7 @@ impl WlSeatGlobal {
Some(tl) => tl,
_ => return,
};
self.set_tl_floating(tl, floating);
}
pub fn set_tl_floating(self: &Rc<Self>, tl: Rc<dyn ToplevelNode>, floating: bool) {
let data = tl.tl_data();
if data.is_fullscreen.get() {
return;
}
if data.is_floating.get() == floating {
return;
}
let parent = match data.parent.get() {
Some(p) => p,
_ => return,
};
if !floating {
parent.cnode_remove_child2(&*tl, true);
self.state.map_tiled(tl);
} else if let Some(ws) = data.workspace.get() {
parent.cnode_remove_child2(&*tl, true);
let (width, height) = data.float_size(&ws);
self.state.map_floating(tl, width, height, &ws, None);
}
toplevel_set_floating(&self.state, tl, floating);
}
pub fn get_rate(&self) -> (i32, i32) {

View file

@ -13,7 +13,7 @@ use {
tree::{
ContainerSplit, Direction, FindTreeResult, FindTreeUsecase, FoundNode, Node, NodeId,
NodeVisitor, OutputNode, StackedNode, TileDragDestination, ToplevelData, ToplevelNode,
ToplevelNodeBase, WorkspaceNode, default_tile_drag_destination,
ToplevelNodeBase, ToplevelType, WorkspaceNode, default_tile_drag_destination,
},
utils::{clonecell::CloneCell, copyhashmap::CopyHashMap, linkedlist::LinkedNode},
wire::WlSurfaceId,
@ -205,16 +205,19 @@ impl Xwindow {
if xsurface.xwindow.is_some() {
return Err(XWindowError::AlreadyAttached);
}
let id = data.state.node_ids.next();
let slf = Rc::new_cyclic(|weak| {
let tld = ToplevelData::new(
&data.state,
data.info.title.borrow_mut().clone().unwrap_or_default(),
Some(surface.client.clone()),
ToplevelType::XWindow,
id,
weak,
);
tld.pos.set(surface.extents.get());
Self {
id: data.state.node_ids.next(),
id,
data: data.clone(),
display_link: Default::default(),
toplevel_data: tld,

View file

@ -27,7 +27,8 @@ use {
tree::{
ContainerSplit, Direction, FindTreeResult, FindTreeUsecase, FoundNode, Node, NodeId,
NodeVisitor, OutputNode, TileDragDestination, ToplevelData, ToplevelNode,
ToplevelNodeBase, ToplevelNodeId, WorkspaceNode, default_tile_drag_destination,
ToplevelNodeBase, ToplevelNodeId, ToplevelType, WorkspaceNode,
default_tile_drag_destination,
},
utils::{clonecell::CloneCell, hash_map_ext::HashMapExt},
wire::{XdgToplevelId, xdg_toplevel::*},
@ -133,11 +134,12 @@ impl XdgToplevel {
states.insert(STATE_CONSTRAINED_BOTTOM);
}
let state = &surface.surface.client.state;
let node_id = state.node_ids.next();
Self {
id,
state: state.clone(),
xdg: surface.clone(),
node_id: state.node_ids.next(),
node_id,
parent: Default::default(),
children: RefCell::new(Default::default()),
states: RefCell::new(states),
@ -152,6 +154,8 @@ impl XdgToplevel {
state,
String::new(),
Some(surface.surface.client.clone()),
ToplevelType::XdgToplevel,
node_id,
slf,
),
drag: Default::default(),