config: add Window
This commit is contained in:
parent
ab095b89cf
commit
9977f9dfdf
19 changed files with 1172 additions and 203 deletions
|
|
@ -19,7 +19,8 @@ use {
|
|||
tree::{
|
||||
ContainingNode, Direction, FindTreeResult, FindTreeUsecase, FoundNode, Node, NodeId,
|
||||
OutputNode, TddType, TileDragDestination, ToplevelData, ToplevelNode, ToplevelNodeBase,
|
||||
WorkspaceNode, default_tile_drag_bounds, walker::NodeVisitor,
|
||||
ToplevelType, WorkspaceNode, default_tile_drag_bounds, toplevel_set_floating,
|
||||
walker::NodeVisitor,
|
||||
},
|
||||
utils::{
|
||||
asyncevent::AsyncEvent,
|
||||
|
|
@ -212,8 +213,9 @@ impl ContainerNode {
|
|||
let child_node_ref = child_node.clone();
|
||||
let mut child_nodes = AHashMap::new();
|
||||
child_nodes.insert(child.node_id(), child_node);
|
||||
let id = state.node_ids.next();
|
||||
let slf = Rc::new_cyclic(|weak| Self {
|
||||
id: state.node_ids.next(),
|
||||
id,
|
||||
split: Cell::new(split),
|
||||
mono_child: CloneCell::new(None),
|
||||
mono_body: Cell::new(Default::default()),
|
||||
|
|
@ -237,7 +239,14 @@ impl ContainerNode {
|
|||
state: state.clone(),
|
||||
render_data: Default::default(),
|
||||
scroller: Default::default(),
|
||||
toplevel_data: ToplevelData::new(state, Default::default(), None, weak),
|
||||
toplevel_data: ToplevelData::new(
|
||||
state,
|
||||
Default::default(),
|
||||
None,
|
||||
ToplevelType::Container,
|
||||
id,
|
||||
weak,
|
||||
),
|
||||
attention_requests: Default::default(),
|
||||
});
|
||||
child.tl_set_parent(slf.clone());
|
||||
|
|
@ -1239,7 +1248,7 @@ impl ContainerNode {
|
|||
&& kind == SeatOpKind::Move
|
||||
{
|
||||
drop(seat_datas);
|
||||
seat.set_tl_floating(child.node.clone(), true);
|
||||
toplevel_set_floating(&self.state, child.node.clone(), true);
|
||||
return;
|
||||
}
|
||||
seat_data.op = Some(SeatOp {
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ use {
|
|||
tree::{
|
||||
ContainingNode, Direction, FindTreeResult, FindTreeUsecase, FoundNode, Node, NodeId,
|
||||
OutputNode, PinnedNode, StackedNode, TileDragDestination, ToplevelNode, WorkspaceNode,
|
||||
walker::NodeVisitor,
|
||||
toplevel_set_floating, walker::NodeVisitor,
|
||||
},
|
||||
utils::{
|
||||
asyncevent::AsyncEvent, clonecell::CloneCell, double_click_state::DoubleClickState,
|
||||
|
|
@ -603,7 +603,7 @@ impl FloatNode {
|
|||
{
|
||||
if let Some(tl) = self.child.get() {
|
||||
drop(cursors);
|
||||
seat.set_tl_floating(tl, false);
|
||||
toplevel_set_floating(&self.state, tl, false);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ use {
|
|||
tree::{
|
||||
ContainerSplit, Direction, FindTreeResult, FindTreeUsecase, FoundNode, Node, NodeId,
|
||||
NodeVisitor, OutputNode, TileDragDestination, ToplevelData, ToplevelNode,
|
||||
ToplevelNodeBase, default_tile_drag_destination,
|
||||
ToplevelNodeBase, ToplevelType, default_tile_drag_destination,
|
||||
},
|
||||
utils::{
|
||||
asyncevent::AsyncEvent, errorfmt::ErrorFmt, on_drop_event::OnDropEvent,
|
||||
|
|
@ -49,12 +49,15 @@ pub async fn placeholder_render_textures(state: Rc<State>) {
|
|||
|
||||
impl PlaceholderNode {
|
||||
pub fn new_for(state: &Rc<State>, node: Rc<dyn ToplevelNode>, slf: &Weak<Self>) -> Self {
|
||||
let id = state.node_ids.next();
|
||||
Self {
|
||||
id: state.node_ids.next(),
|
||||
id,
|
||||
toplevel: ToplevelData::new(
|
||||
state,
|
||||
node.tl_data().title.borrow().clone(),
|
||||
node.node_client(),
|
||||
ToplevelType::Placeholder,
|
||||
id,
|
||||
slf,
|
||||
),
|
||||
destroyed: Default::default(),
|
||||
|
|
@ -65,9 +68,17 @@ impl PlaceholderNode {
|
|||
}
|
||||
|
||||
pub fn new_empty(state: &Rc<State>, slf: &Weak<Self>) -> Self {
|
||||
let id = state.node_ids.next();
|
||||
Self {
|
||||
id: state.node_ids.next(),
|
||||
toplevel: ToplevelData::new(state, String::new(), None, slf),
|
||||
id,
|
||||
toplevel: ToplevelData::new(
|
||||
state,
|
||||
String::new(),
|
||||
None,
|
||||
ToplevelType::Placeholder,
|
||||
id,
|
||||
slf,
|
||||
),
|
||||
destroyed: Default::default(),
|
||||
update_textures_scheduled: Default::default(),
|
||||
state: state.clone(),
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ use {
|
|||
JayToplevelId,
|
||||
},
|
||||
},
|
||||
jay_config::{window, window::WindowType},
|
||||
std::{
|
||||
cell::{Cell, RefCell},
|
||||
ops::Deref,
|
||||
|
|
@ -254,7 +255,29 @@ impl ToplevelOpt {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub enum ToplevelType {
|
||||
Container,
|
||||
Placeholder,
|
||||
XdgToplevel,
|
||||
XWindow,
|
||||
}
|
||||
|
||||
impl ToplevelType {
|
||||
pub fn to_window_type(&self) -> WindowType {
|
||||
match self {
|
||||
ToplevelType::Container => window::CONTAINER,
|
||||
ToplevelType::Placeholder => window::PLACEHOLDER,
|
||||
ToplevelType::XdgToplevel => window::XDG_TOPLEVEL,
|
||||
ToplevelType::XWindow => window::X_WINDOW,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub struct ToplevelData {
|
||||
#[expect(dead_code)]
|
||||
pub node_id: NodeId,
|
||||
pub kind: ToplevelType,
|
||||
pub self_active: Cell<bool>,
|
||||
pub client: Option<Rc<Client>>,
|
||||
pub state: Rc<State>,
|
||||
|
|
@ -291,11 +314,16 @@ impl ToplevelData {
|
|||
state: &Rc<State>,
|
||||
title: String,
|
||||
client: Option<Rc<Client>>,
|
||||
kind: ToplevelType,
|
||||
node_id: impl Into<NodeId>,
|
||||
slf: &Weak<T>,
|
||||
) -> Self {
|
||||
let node_id = node_id.into();
|
||||
let id = toplevel_identifier();
|
||||
state.toplevels.set(id, slf.clone());
|
||||
Self {
|
||||
node_id,
|
||||
kind,
|
||||
self_active: Cell::new(false),
|
||||
client,
|
||||
state: state.clone(),
|
||||
|
|
@ -372,7 +400,7 @@ impl ToplevelData {
|
|||
{
|
||||
let id = toplevel_identifier();
|
||||
let prev = self.identifier.replace(id);
|
||||
self.state.toplevels.remove(&prev);
|
||||
self.state.remove_toplevel_id(prev);
|
||||
self.state.toplevels.set(id, self.slf.clone());
|
||||
}
|
||||
{
|
||||
|
|
@ -620,7 +648,7 @@ impl ToplevelData {
|
|||
|
||||
impl Drop for ToplevelData {
|
||||
fn drop(&mut self) {
|
||||
self.state.toplevels.remove(&self.identifier.get());
|
||||
self.state.remove_toplevel_id(self.identifier.get());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -662,3 +690,82 @@ pub fn default_tile_drag_bounds<T: ToplevelNodeBase + ?Sized>(t: &T, split: Cont
|
|||
ContainerSplit::Vertical => t.node_absolute_position().height() / FACTOR,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn toplevel_parent_container(tl: &dyn ToplevelNode) -> Option<Rc<ContainerNode>> {
|
||||
if let Some(parent) = tl.tl_data().parent.get() {
|
||||
if let Some(container) = parent.node_into_container() {
|
||||
return Some(container);
|
||||
}
|
||||
}
|
||||
None
|
||||
}
|
||||
|
||||
pub fn toplevel_create_split(state: &Rc<State>, tl: Rc<dyn ToplevelNode>, axis: ContainerSplit) {
|
||||
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(state, &ws, tl.clone(), axis);
|
||||
pn.cnode_replace_child(&*tl, cn);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn toplevel_set_floating(state: &Rc<State>, 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);
|
||||
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);
|
||||
state.map_floating(tl, width, height, &ws, None);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn toplevel_set_workspace(state: &Rc<State>, tl: Rc<dyn ToplevelNode>, ws: &Rc<WorkspaceNode>) {
|
||||
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() {
|
||||
let (width, height) = tl.tl_data().float_size(ws);
|
||||
state.map_floating(tl.clone(), width, height, ws, None);
|
||||
} else {
|
||||
state.map_tiled_on(tl, ws);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue