autocommit 2022-04-23 00:55:20 CEST
This commit is contained in:
parent
436f383cd6
commit
e3b3d848c3
32 changed files with 1773 additions and 2451 deletions
|
|
@ -32,7 +32,10 @@ use {
|
|||
leaks::Tracker,
|
||||
object::{Object, ObjectId},
|
||||
state::State,
|
||||
tree::{generic_node_visitor, ContainerSplit, FloatNode, FoundNode, Node, OutputNode},
|
||||
tree::{
|
||||
generic_node_visitor, ContainerNode, ContainerSplit, FloatNode, FoundNode, Node,
|
||||
OutputNode, WorkspaceNode,
|
||||
},
|
||||
utils::{
|
||||
asyncevent::AsyncEvent,
|
||||
buffd::{MsgParser, MsgParserError},
|
||||
|
|
@ -56,7 +59,7 @@ use {
|
|||
cell::{Cell, RefCell},
|
||||
collections::hash_map::Entry,
|
||||
mem,
|
||||
ops::DerefMut,
|
||||
ops::{Deref, DerefMut},
|
||||
rc::Rc,
|
||||
},
|
||||
thiserror::Error,
|
||||
|
|
@ -196,17 +199,24 @@ impl WlSeatGlobal {
|
|||
self.output.get()
|
||||
}
|
||||
|
||||
pub fn set_workspace(&self, _ws: &Rc<WorkspaceNode>) {}
|
||||
|
||||
pub fn mark_last_active(self: &Rc<Self>) {
|
||||
self.queue_link
|
||||
.set(Some(self.state.seat_queue.add_last(self.clone())));
|
||||
}
|
||||
|
||||
pub fn set_fullscreen(&self, fullscreen: bool) {
|
||||
self.keyboard_node.get().node_set_fullscreen(fullscreen);
|
||||
if let Some(tl) = self.keyboard_node.get().node_toplevel() {
|
||||
tl.tl_set_fullscreen(fullscreen);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_fullscreen(&self) -> bool {
|
||||
self.keyboard_node.get().node_fullscreen()
|
||||
if let Some(tl) = self.keyboard_node.get().node_toplevel() {
|
||||
return tl.tl_data().is_fullscreen.get();
|
||||
}
|
||||
false
|
||||
}
|
||||
|
||||
pub fn set_keymap(&self, keymap: &Rc<XkbKeymap>) {
|
||||
|
|
@ -254,32 +264,96 @@ 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
None
|
||||
}
|
||||
|
||||
pub fn get_mono(&self) -> Option<bool> {
|
||||
self.keyboard_node.get().node_get_parent_mono()
|
||||
self.kb_parent_container()
|
||||
.map(|c| c.mono_child.get().is_some())
|
||||
}
|
||||
|
||||
pub fn get_split(&self) -> Option<ContainerSplit> {
|
||||
self.keyboard_node.get().node_get_parent_split()
|
||||
self.kb_parent_container().map(|c| c.split.get())
|
||||
}
|
||||
|
||||
pub fn set_mono(&self, mono: bool) {
|
||||
self.keyboard_node.get().node_set_parent_mono(mono)
|
||||
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() {
|
||||
let node = if mono { Some(tl.deref()) } else { None };
|
||||
container.set_mono(node);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn set_split(&self, axis: ContainerSplit) {
|
||||
self.keyboard_node.get().node_set_parent_split(axis)
|
||||
if let Some(c) = self.kb_parent_container() {
|
||||
c.set_split(axis);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn create_split(&self, axis: ContainerSplit) {
|
||||
self.keyboard_node.get().node_create_split(axis)
|
||||
let tl = match self.keyboard_node.get().node_toplevel() {
|
||||
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, pn.clone(), tl.clone(), axis);
|
||||
pn.cnode_replace_child(tl.tl_as_node(), cn);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn focus_parent(self: &Rc<Self>) {
|
||||
self.keyboard_node.get().node_focus_parent(self);
|
||||
if let Some(tl) = self.keyboard_node.get().node_toplevel() {
|
||||
if let Some(parent) = tl.tl_data().parent.get() {
|
||||
self.focus_node(parent.cnode_into_node());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn toggle_floating(self: &Rc<Self>) {
|
||||
self.keyboard_node.get().node_toggle_floating(self);
|
||||
let tl = match self.keyboard_node.get().node_toplevel() {
|
||||
Some(tl) => tl,
|
||||
_ => return,
|
||||
};
|
||||
let data = tl.tl_data();
|
||||
if data.is_fullscreen.get() {
|
||||
return;
|
||||
}
|
||||
let parent = match data.parent.get() {
|
||||
Some(p) => p,
|
||||
_ => return,
|
||||
};
|
||||
if let Some(cn) = parent.clone().node_into_containing_node() {
|
||||
if parent.node_is_float() {
|
||||
cn.cnode_remove_child2(tl.tl_as_node(), true);
|
||||
self.state.map_tiled(tl);
|
||||
} else if let Some(ws) = data.workspace.get() {
|
||||
cn.cnode_remove_child2(tl.tl_as_node(), true);
|
||||
let (width, height) = data.float_size(&ws);
|
||||
self.state.map_floating(tl, width, height, &ws);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_rate(&self) -> (i32, i32) {
|
||||
|
|
@ -303,17 +377,34 @@ impl WlSeatGlobal {
|
|||
|
||||
pub fn close(self: &Rc<Self>) {
|
||||
let kb_node = self.keyboard_node.get();
|
||||
kb_node.node_close();
|
||||
if let Some(tl) = kb_node.node_toplevel() {
|
||||
tl.tl_close();
|
||||
}
|
||||
}
|
||||
|
||||
pub fn move_focus(self: &Rc<Self>, direction: Direction) {
|
||||
let kb_node = self.keyboard_node.get();
|
||||
kb_node.node_move_focus(self, direction);
|
||||
let tl = match self.keyboard_node.get().node_toplevel() {
|
||||
Some(tl) => tl,
|
||||
_ => return,
|
||||
};
|
||||
if direction == Direction::Down && tl.node_is_container() {
|
||||
tl.node_do_focus(self, direction);
|
||||
} else if let Some(p) = tl.tl_data().parent.get() {
|
||||
if let Some(c) = p.node_into_container() {
|
||||
c.move_focus_from_child(self, tl.deref(), direction);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn move_focused(self: &Rc<Self>, direction: Direction) {
|
||||
let kb_node = self.keyboard_node.get();
|
||||
kb_node.node_move_self(direction);
|
||||
if let Some(tl) = kb_node.node_toplevel() {
|
||||
if let Some(parent) = tl.tl_data().parent.get() {
|
||||
if let Some(c) = parent.node_into_container() {
|
||||
c.move_child(tl, direction);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn set_selection_<T: ipc::Vtable>(
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ use {
|
|||
wl_surface::{xdg_surface::xdg_popup::XdgPopup, WlSurface},
|
||||
},
|
||||
object::ObjectId,
|
||||
tree::{FloatNode, Node, SizedNode, ToplevelNode},
|
||||
tree::{FloatNode, Node, ToplevelNode},
|
||||
utils::{bitflags::BitflagsExt, clonecell::CloneCell, smallmap::SmallMap},
|
||||
wire::WlDataOfferId,
|
||||
xkbcommon::{ModifierState, XKB_KEY_DOWN, XKB_KEY_UP},
|
||||
|
|
@ -97,7 +97,9 @@ impl NodeSeatState {
|
|||
seat.keyboard_node.set(seat.state.root.clone());
|
||||
// log::info!("keyboard_node = root");
|
||||
if focus_last {
|
||||
seat.output.get().do_focus(&seat, Direction::Unspecified);
|
||||
seat.output
|
||||
.get()
|
||||
.node_do_focus(&seat, Direction::Unspecified);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -131,7 +133,7 @@ impl NodeSeatState {
|
|||
break;
|
||||
}
|
||||
last.node_seat_state().leave(&seat);
|
||||
last.node_leave(&seat);
|
||||
last.node_on_leave(&seat);
|
||||
}
|
||||
seat.state.tree_changed();
|
||||
}
|
||||
|
|
@ -253,14 +255,14 @@ impl WlSeatGlobal {
|
|||
}
|
||||
let node = self.keyboard_node.get();
|
||||
if shortcuts.is_empty() {
|
||||
node.node_key(self, key, state);
|
||||
node.node_on_key(self, key, state);
|
||||
} else if let Some(config) = self.state.config.get() {
|
||||
for shortcut in shortcuts {
|
||||
config.invoke_shortcut(self.id(), &shortcut);
|
||||
}
|
||||
}
|
||||
if let Some(mods) = new_mods {
|
||||
node.node_mods(self, mods);
|
||||
node.node_on_mods(self, mods);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -278,9 +280,9 @@ impl WlSeatGlobal {
|
|||
}
|
||||
|
||||
pub fn focus_toplevel(self: &Rc<Self>, n: Rc<dyn ToplevelNode>) {
|
||||
let node = match n.focus_surface(self.id) {
|
||||
let node = match n.tl_focus_child(self.id) {
|
||||
Some(n) => n,
|
||||
_ => n.into_node(),
|
||||
_ => n.tl_into_node(),
|
||||
};
|
||||
self.focus_node(node);
|
||||
}
|
||||
|
|
@ -491,7 +493,7 @@ impl WlSeatGlobal {
|
|||
// Enter callbacks
|
||||
impl WlSeatGlobal {
|
||||
pub fn enter_toplevel(self: &Rc<Self>, n: Rc<dyn ToplevelNode>) {
|
||||
if n.accepts_keyboard_focus() && self.changes.get().contains(CHANGE_CURSOR_MOVED) {
|
||||
if n.tl_accepts_keyboard_focus() && self.changes.get().contains(CHANGE_CURSOR_MOVED) {
|
||||
self.focus_toplevel(n);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ impl KbOwner for DefaultKbOwner {
|
|||
if old.node_is_xwayland_surface() && !node.node_is_xwayland_surface() {
|
||||
seat.state.xwayland.queue.push(XWaylandEvent::ActivateRoot);
|
||||
}
|
||||
old.node_unfocus(seat);
|
||||
old.node_on_unfocus(seat);
|
||||
if old.node_seat_state().unfocus(seat) {
|
||||
old.node_active_changed(false);
|
||||
}
|
||||
|
|
@ -73,7 +73,7 @@ impl KbOwner for DefaultKbOwner {
|
|||
node.node_active_changed(true);
|
||||
}
|
||||
// log::info!("focus {}", node.node_id());
|
||||
node.clone().node_focus(seat);
|
||||
node.clone().node_on_focus(seat);
|
||||
seat.keyboard_node.set(node.clone());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ use {
|
|||
wl_seat::{wl_pointer::PendingScroll, Dnd, DroppedDnd, WlSeatError, WlSeatGlobal},
|
||||
wl_surface::WlSurface,
|
||||
},
|
||||
tree::{FoundNode, Node, SizedNode},
|
||||
tree::{FoundNode, Node},
|
||||
utils::{clonecell::CloneCell, smallmap::SmallMap},
|
||||
},
|
||||
std::{cell::Cell, rc::Rc},
|
||||
|
|
@ -54,7 +54,7 @@ impl PointerOwnerHolder {
|
|||
pub fn frame(&self, seat: &Rc<WlSeatGlobal>) {
|
||||
let pending = self.pending_scroll.take();
|
||||
if let Some(node) = self.owner.get().axis_node(seat) {
|
||||
node.node_axis_event(seat, &pending);
|
||||
node.node_on_axis_event(seat, &pending);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -148,7 +148,7 @@ impl PointerOwner for DefaultPointerOwner {
|
|||
serial,
|
||||
}));
|
||||
pn.node_seat_state().add_pointer_grab(seat);
|
||||
pn.node_button(seat, button, state, serial);
|
||||
pn.node_on_button(seat, button, state, serial);
|
||||
}
|
||||
|
||||
fn axis_node(&self, seat: &Rc<WlSeatGlobal>) -> Option<Rc<dyn Node>> {
|
||||
|
|
@ -178,7 +178,7 @@ impl PointerOwner for DefaultPointerOwner {
|
|||
}
|
||||
if (stack.len(), found_tree.len()) == (divergence, divergence) {
|
||||
if let Some(node) = found_tree.last() {
|
||||
node.node.clone().node_pointer_motion(
|
||||
node.node.clone().node_on_pointer_motion(
|
||||
seat,
|
||||
x.apply_fract(node.x),
|
||||
y.apply_fract(node.y),
|
||||
|
|
@ -186,15 +186,15 @@ impl PointerOwner for DefaultPointerOwner {
|
|||
}
|
||||
} else {
|
||||
if let Some(last) = stack.last() {
|
||||
last.node_pointer_unfocus(seat);
|
||||
last.node_on_pointer_unfocus(seat);
|
||||
}
|
||||
for old in stack.drain(divergence..).rev() {
|
||||
old.node_leave(seat);
|
||||
old.node_on_leave(seat);
|
||||
old.node_seat_state().leave(seat);
|
||||
}
|
||||
if found_tree.len() == divergence {
|
||||
if let Some(node) = found_tree.last() {
|
||||
node.node.clone().node_pointer_motion(
|
||||
node.node.clone().node_on_pointer_motion(
|
||||
seat,
|
||||
x.apply_fract(node.x),
|
||||
y.apply_fract(node.y),
|
||||
|
|
@ -203,7 +203,7 @@ impl PointerOwner for DefaultPointerOwner {
|
|||
} else {
|
||||
for new in found_tree.drain(divergence..) {
|
||||
new.node.node_seat_state().enter(seat);
|
||||
new.node.clone().node_pointer_enter(
|
||||
new.node.clone().node_on_pointer_enter(
|
||||
seat,
|
||||
x.apply_fract(new.x),
|
||||
y.apply_fract(new.y),
|
||||
|
|
@ -212,7 +212,7 @@ impl PointerOwner for DefaultPointerOwner {
|
|||
}
|
||||
}
|
||||
if let Some(node) = stack.last() {
|
||||
node.node_pointer_focus(seat);
|
||||
node.node_on_pointer_focus(seat);
|
||||
}
|
||||
}
|
||||
found_tree.clear();
|
||||
|
|
@ -271,7 +271,9 @@ impl PointerOwner for GrabPointerOwner {
|
|||
}
|
||||
}
|
||||
let serial = seat.state.next_serial(self.node.node_client().as_deref());
|
||||
self.node.clone().node_button(seat, button, state, serial);
|
||||
self.node
|
||||
.clone()
|
||||
.node_on_button(seat, button, state, serial);
|
||||
}
|
||||
|
||||
fn axis_node(&self, _seat: &Rc<WlSeatGlobal>) -> Option<Rc<dyn Node>> {
|
||||
|
|
@ -284,7 +286,7 @@ impl PointerOwner for GrabPointerOwner {
|
|||
let (x_int, y_int) = pos.translate(x.round_down(), y.round_down());
|
||||
self.node
|
||||
.clone()
|
||||
.node_pointer_motion(seat, x.apply_fract(x_int), y.apply_fract(y_int));
|
||||
.node_on_pointer_motion(seat, x.apply_fract(x_int), y.apply_fract(y_int));
|
||||
}
|
||||
|
||||
fn start_drag(
|
||||
|
|
@ -330,7 +332,7 @@ impl PointerOwner for GrabPointerOwner {
|
|||
{
|
||||
let mut stack = seat.pointer_stack.borrow_mut();
|
||||
for node in stack.drain(1..).rev() {
|
||||
node.node_leave(seat);
|
||||
node.node_on_leave(seat);
|
||||
node.node_seat_state().leave(seat);
|
||||
}
|
||||
}
|
||||
|
|
@ -380,12 +382,12 @@ impl PointerOwner for DndPointerOwner {
|
|||
};
|
||||
let target = self.target.get();
|
||||
if should_drop {
|
||||
self.target.get().node_dnd_drop(&self.dnd);
|
||||
self.target.get().node_on_dnd_drop(&self.dnd);
|
||||
*seat.dropped_dnd.borrow_mut() = Some(DroppedDnd {
|
||||
dnd: self.dnd.clone(),
|
||||
});
|
||||
}
|
||||
target.node_dnd_leave(&self.dnd);
|
||||
target.node_on_dnd_leave(&self.dnd);
|
||||
target.node_seat_state().remove_dnd_target(seat);
|
||||
if !should_drop {
|
||||
if let Some(src) = &self.dnd.src {
|
||||
|
|
@ -415,7 +417,9 @@ impl PointerOwner for DndPointerOwner {
|
|||
x: x_int,
|
||||
y: y_int,
|
||||
});
|
||||
seat.state.root.find_tree_at(x_int, y_int, &mut found_tree);
|
||||
seat.state
|
||||
.root
|
||||
.node_find_tree_at(x_int, y_int, &mut found_tree);
|
||||
let FoundNode { node, x, y } = found_tree.pop().unwrap();
|
||||
found_tree.clear();
|
||||
(node, x, y)
|
||||
|
|
@ -423,10 +427,10 @@ impl PointerOwner for DndPointerOwner {
|
|||
let (x, y) = (x.apply_fract(x_int), y.apply_fract(y_int));
|
||||
let mut target = self.target.get();
|
||||
if node.node_id() != target.node_id() {
|
||||
target.node_dnd_leave(&self.dnd);
|
||||
target.node_on_dnd_leave(&self.dnd);
|
||||
target.node_seat_state().remove_dnd_target(seat);
|
||||
target = node;
|
||||
target.node_dnd_enter(
|
||||
target.node_on_dnd_enter(
|
||||
&self.dnd,
|
||||
x,
|
||||
y,
|
||||
|
|
@ -435,7 +439,7 @@ impl PointerOwner for DndPointerOwner {
|
|||
target.node_seat_state().add_dnd_target(seat);
|
||||
self.target.set(target);
|
||||
} else if (self.pos_x.get(), self.pos_y.get()) != (x, y) {
|
||||
node.node_dnd_motion(&self.dnd, x, y);
|
||||
node.node_on_dnd_motion(&self.dnd, x, y);
|
||||
}
|
||||
self.pos_x.set(x);
|
||||
self.pos_y.set(y);
|
||||
|
|
@ -457,7 +461,7 @@ impl PointerOwner for DndPointerOwner {
|
|||
|
||||
fn cancel_dnd(&self, seat: &Rc<WlSeatGlobal>) {
|
||||
let target = self.target.get();
|
||||
target.node_dnd_leave(&self.dnd);
|
||||
target.node_on_dnd_leave(&self.dnd);
|
||||
target.node_seat_state().remove_dnd_target(seat);
|
||||
if let Some(src) = &self.dnd.src {
|
||||
ipc::detach_seat::<WlDataDevice>(src);
|
||||
|
|
@ -476,7 +480,7 @@ impl PointerOwner for DndPointerOwner {
|
|||
}
|
||||
|
||||
fn dnd_target_removed(&self, seat: &Rc<WlSeatGlobal>) {
|
||||
self.target.get().node_dnd_leave(&self.dnd);
|
||||
self.target.get().node_on_dnd_leave(&self.dnd);
|
||||
self.target.set(seat.state.root.clone());
|
||||
seat.state.tree_changed();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,10 +23,7 @@ use {
|
|||
object::Object,
|
||||
rect::{Rect, Region},
|
||||
render::Renderer,
|
||||
tree::{
|
||||
ContainerNode, ContainerSplit, FindTreeResult, FoundNode, Node, NodeId, NodeVisitor,
|
||||
SizedNode, ToplevelNode, WorkspaceNode,
|
||||
},
|
||||
tree::{FindTreeResult, FoundNode, Node, NodeId, NodeVisitor, ToplevelNode},
|
||||
utils::{
|
||||
buffd::{MsgParser, MsgParserError},
|
||||
clonecell::CloneCell,
|
||||
|
|
@ -39,7 +36,6 @@ use {
|
|||
xkbcommon::ModifierState,
|
||||
},
|
||||
ahash::AHashMap,
|
||||
jay_config::Direction,
|
||||
std::{
|
||||
cell::{Cell, RefCell},
|
||||
fmt::{Debug, Formatter},
|
||||
|
|
@ -260,7 +256,7 @@ impl WlSurface {
|
|||
|
||||
pub fn accepts_kb_focus(&self) -> bool {
|
||||
match self.toplevel.get() {
|
||||
Some(tl) => tl.accepts_keyboard_focus(),
|
||||
Some(tl) => tl.tl_accepts_keyboard_focus(),
|
||||
_ => self.ext.get().accepts_kb_focus(),
|
||||
}
|
||||
}
|
||||
|
|
@ -281,7 +277,7 @@ impl WlSurface {
|
|||
}
|
||||
if self.seat_state.is_active() {
|
||||
if let Some(tl) = &tl {
|
||||
tl.surface_active_changed(true);
|
||||
tl.tl_surface_active_changed(true);
|
||||
}
|
||||
}
|
||||
self.toplevel.set(tl);
|
||||
|
|
@ -372,7 +368,7 @@ impl WlSurface {
|
|||
self.unset_dnd_icons();
|
||||
self.unset_cursors();
|
||||
self.ext.get().on_surface_destroy()?;
|
||||
self.destroy_node(true);
|
||||
self.destroy_node();
|
||||
{
|
||||
let mut children = self.children.borrow_mut();
|
||||
if let Some(children) = &mut *children {
|
||||
|
|
@ -597,6 +593,56 @@ impl WlSurface {
|
|||
self.seat_state
|
||||
.for_each_kb_focus(|s| s.unfocus_surface(self));
|
||||
}
|
||||
|
||||
pub fn set_visible(&self, visible: bool) {
|
||||
self.visible.set(visible);
|
||||
for inhibitor in self.idle_inhibitors.lock().values() {
|
||||
if visible {
|
||||
inhibitor.activate();
|
||||
} else {
|
||||
inhibitor.deactivate();
|
||||
}
|
||||
}
|
||||
let children = self.children.borrow_mut();
|
||||
if let Some(children) = children.deref() {
|
||||
for child in children.subsurfaces.values() {
|
||||
child.surface.set_visible(visible);
|
||||
}
|
||||
}
|
||||
if !visible {
|
||||
self.send_seat_release_events();
|
||||
}
|
||||
self.seat_state.set_visible(self, visible);
|
||||
}
|
||||
|
||||
pub fn destroy_node(&self) {
|
||||
for (_, inhibitor) in self.idle_inhibitors.lock().drain() {
|
||||
inhibitor.deactivate();
|
||||
}
|
||||
let children = self.children.borrow();
|
||||
if let Some(ch) = children.deref() {
|
||||
for ss in ch.subsurfaces.values() {
|
||||
ss.surface.destroy_node();
|
||||
}
|
||||
}
|
||||
if let Some(tl) = self.toplevel.get() {
|
||||
let data = tl.tl_data();
|
||||
let mut remove = vec![];
|
||||
for (seat, s) in data.focus_node.iter() {
|
||||
if s.node_id() == self.node_id() {
|
||||
remove.push(seat);
|
||||
}
|
||||
}
|
||||
for seat in remove {
|
||||
data.focus_node.remove(&seat);
|
||||
}
|
||||
if self.seat_state.is_active() {
|
||||
tl.tl_surface_active_changed(false);
|
||||
}
|
||||
}
|
||||
self.send_seat_release_events();
|
||||
self.seat_state.destroy_node(self);
|
||||
}
|
||||
}
|
||||
|
||||
object_base! {
|
||||
|
|
@ -622,7 +668,7 @@ impl Object for WlSurface {
|
|||
fn break_loops(&self) {
|
||||
self.unset_dnd_icons();
|
||||
self.unset_cursors();
|
||||
self.node_destroy(true);
|
||||
self.destroy_node();
|
||||
*self.children.borrow_mut() = None;
|
||||
self.unset_ext();
|
||||
mem::take(self.frame_requests.borrow_mut().deref_mut());
|
||||
|
|
@ -635,49 +681,20 @@ impl Object for WlSurface {
|
|||
dedicated_add_obj!(WlSurface, WlSurfaceId, surfaces);
|
||||
|
||||
tree_id!(SurfaceNodeId);
|
||||
impl SizedNode for WlSurface {
|
||||
fn id(&self) -> NodeId {
|
||||
impl Node for WlSurface {
|
||||
fn node_id(&self) -> NodeId {
|
||||
self.node_id.into()
|
||||
}
|
||||
|
||||
fn seat_state(&self) -> &NodeSeatState {
|
||||
fn node_seat_state(&self) -> &NodeSeatState {
|
||||
&self.seat_state
|
||||
}
|
||||
|
||||
fn destroy_node(&self, _detach: bool) {
|
||||
for (_, inhibitor) in self.idle_inhibitors.lock().drain() {
|
||||
inhibitor.deactivate();
|
||||
}
|
||||
let children = self.children.borrow();
|
||||
if let Some(ch) = children.deref() {
|
||||
for ss in ch.subsurfaces.values() {
|
||||
ss.surface.node_destroy(false);
|
||||
}
|
||||
}
|
||||
if let Some(tl) = self.toplevel.get() {
|
||||
let data = tl.data();
|
||||
let mut remove = vec![];
|
||||
for (seat, s) in data.focus_surface.iter() {
|
||||
if s.id == self.id {
|
||||
remove.push(seat);
|
||||
}
|
||||
}
|
||||
for seat in remove {
|
||||
data.focus_surface.remove(&seat);
|
||||
}
|
||||
if self.seat_state.is_active() {
|
||||
tl.surface_active_changed(false);
|
||||
}
|
||||
}
|
||||
self.send_seat_release_events();
|
||||
self.seat_state.destroy_node(self);
|
||||
fn node_visit(self: Rc<Self>, visitor: &mut dyn NodeVisitor) {
|
||||
visitor.visit_surface(&self);
|
||||
}
|
||||
|
||||
fn visit(self: &Rc<Self>, visitor: &mut dyn NodeVisitor) {
|
||||
visitor.visit_surface(self);
|
||||
}
|
||||
|
||||
fn visit_children(&self, visitor: &mut dyn NodeVisitor) {
|
||||
fn node_visit_children(&self, visitor: &mut dyn NodeVisitor) {
|
||||
let children = self.children.borrow_mut();
|
||||
if let Some(c) = children.deref() {
|
||||
for child in c.subsurfaces.values() {
|
||||
|
|
@ -686,224 +703,101 @@ impl SizedNode for WlSurface {
|
|||
}
|
||||
}
|
||||
|
||||
fn visible(&self) -> bool {
|
||||
fn node_visible(&self) -> bool {
|
||||
self.visible.get()
|
||||
}
|
||||
|
||||
fn parent(&self) -> Option<Rc<dyn Node>> {
|
||||
self.toplevel.get().map(|tl| tl.into_node())
|
||||
}
|
||||
|
||||
fn set_visible(&self, visible: bool) {
|
||||
self.visible.set(visible);
|
||||
for inhibitor in self.idle_inhibitors.lock().values() {
|
||||
if visible {
|
||||
inhibitor.activate();
|
||||
} else {
|
||||
inhibitor.deactivate();
|
||||
}
|
||||
}
|
||||
let children = self.children.borrow_mut();
|
||||
if let Some(children) = children.deref() {
|
||||
for child in children.subsurfaces.values() {
|
||||
child.surface.node_set_visible(visible);
|
||||
}
|
||||
}
|
||||
if !visible {
|
||||
self.send_seat_release_events();
|
||||
}
|
||||
self.seat_state.set_visible(self, visible);
|
||||
}
|
||||
|
||||
fn get_workspace(&self) -> Option<Rc<WorkspaceNode>> {
|
||||
if let Some(tl) = self.toplevel.get() {
|
||||
return tl.as_node().node_get_workspace();
|
||||
}
|
||||
None
|
||||
}
|
||||
|
||||
fn get_parent_mono(&self) -> Option<bool> {
|
||||
self.toplevel
|
||||
.get()
|
||||
.and_then(|t| t.parent())
|
||||
.and_then(|p| p.node_get_mono())
|
||||
}
|
||||
|
||||
fn get_parent_split(&self) -> Option<ContainerSplit> {
|
||||
self.toplevel
|
||||
.get()
|
||||
.and_then(|t| t.parent())
|
||||
.and_then(|p| p.node_get_split())
|
||||
}
|
||||
|
||||
fn set_parent_mono(&self, mono: bool) {
|
||||
if let Some(tl) = self.toplevel.get() {
|
||||
if let Some(pn) = tl.parent() {
|
||||
let node = if mono { Some(tl.as_node()) } else { None };
|
||||
pn.node_set_mono(node)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn set_parent_split(&self, split: ContainerSplit) {
|
||||
if let Some(tl) = self.toplevel.get() {
|
||||
if let Some(pn) = tl.parent() {
|
||||
pn.node_set_split(split);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn create_split(self: &Rc<Self>, split: ContainerSplit) {
|
||||
let tl = match self.toplevel.get() {
|
||||
Some(tl) => tl,
|
||||
_ => return,
|
||||
};
|
||||
let ws = match tl.as_node().node_get_workspace() {
|
||||
Some(ws) => ws,
|
||||
_ => return,
|
||||
};
|
||||
let pn = match tl.parent() {
|
||||
Some(pn) => pn,
|
||||
_ => return,
|
||||
};
|
||||
let cn = ContainerNode::new(
|
||||
&self.client.state,
|
||||
&ws,
|
||||
pn.clone(),
|
||||
tl.clone().into_node(),
|
||||
split,
|
||||
);
|
||||
pn.node_replace_child(tl.as_node(), cn);
|
||||
}
|
||||
|
||||
fn close(self: &Rc<Self>) {
|
||||
if let Some(tl) = self.toplevel.get() {
|
||||
tl.into_node().node_close();
|
||||
}
|
||||
}
|
||||
|
||||
fn move_focus(self: &Rc<Self>, seat: &Rc<WlSeatGlobal>, direction: Direction) {
|
||||
if let Some(tl) = self.toplevel.get() {
|
||||
if let Some(pn) = tl.parent() {
|
||||
pn.node_move_focus_from_child(seat, tl.as_node(), direction);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn move_self(self: &Rc<Self>, direction: Direction) {
|
||||
if let Some(tl) = self.toplevel.get() {
|
||||
if let Some(pn) = tl.parent() {
|
||||
pn.node_move_child(tl.into_node(), direction);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn absolute_position(&self) -> Rect {
|
||||
fn node_absolute_position(&self) -> Rect {
|
||||
self.buffer_abs_pos.get()
|
||||
}
|
||||
|
||||
fn active_changed(&self, active: bool) {
|
||||
fn node_active_changed(&self, active: bool) {
|
||||
if let Some(tl) = self.toplevel.get() {
|
||||
tl.surface_active_changed(active);
|
||||
tl.tl_surface_active_changed(active);
|
||||
}
|
||||
}
|
||||
|
||||
fn key(&self, seat: &WlSeatGlobal, key: u32, state: u32) {
|
||||
fn node_render(&self, renderer: &mut Renderer, x: i32, y: i32) {
|
||||
renderer.render_surface(self, x, y);
|
||||
}
|
||||
|
||||
fn node_client(&self) -> Option<Rc<Client>> {
|
||||
Some(self.client.clone())
|
||||
}
|
||||
|
||||
fn node_toplevel(self: Rc<Self>) -> Option<Rc<dyn ToplevelNode>> {
|
||||
self.toplevel.get()
|
||||
}
|
||||
|
||||
fn node_on_key(&self, seat: &WlSeatGlobal, key: u32, state: u32) {
|
||||
seat.key_surface(self, key, state);
|
||||
}
|
||||
|
||||
fn mods(&self, seat: &WlSeatGlobal, mods: ModifierState) {
|
||||
fn node_on_mods(&self, seat: &WlSeatGlobal, mods: ModifierState) {
|
||||
seat.mods_surface(self, mods);
|
||||
}
|
||||
|
||||
fn button(self: &Rc<Self>, seat: &Rc<WlSeatGlobal>, button: u32, state: KeyState, serial: u32) {
|
||||
fn node_on_button(
|
||||
self: Rc<Self>,
|
||||
seat: &Rc<WlSeatGlobal>,
|
||||
button: u32,
|
||||
state: KeyState,
|
||||
serial: u32,
|
||||
) {
|
||||
seat.button_surface(&self, button, state, serial);
|
||||
}
|
||||
|
||||
fn axis_event(self: &Rc<Self>, seat: &WlSeatGlobal, event: &PendingScroll) {
|
||||
fn node_on_axis_event(self: Rc<Self>, seat: &WlSeatGlobal, event: &PendingScroll) {
|
||||
seat.scroll_surface(&*self, event);
|
||||
}
|
||||
|
||||
fn focus(self: &Rc<Self>, seat: &Rc<WlSeatGlobal>) {
|
||||
fn node_on_focus(self: Rc<Self>, seat: &Rc<WlSeatGlobal>) {
|
||||
if let Some(tl) = self.toplevel.get() {
|
||||
tl.data().focus_surface.insert(seat.id(), self.clone());
|
||||
tl.activate();
|
||||
tl.tl_data().focus_node.insert(seat.id(), self.clone());
|
||||
tl.tl_on_activate();
|
||||
}
|
||||
seat.focus_surface(&self);
|
||||
}
|
||||
|
||||
fn focus_parent(&self, seat: &Rc<WlSeatGlobal>) {
|
||||
if let Some(tl) = self.toplevel.get() {
|
||||
tl.parent().map(|p| p.node_focus_self(seat));
|
||||
}
|
||||
}
|
||||
|
||||
fn toggle_floating(self: &Rc<Self>, seat: &Rc<WlSeatGlobal>) {
|
||||
if let Some(tl) = self.toplevel.get() {
|
||||
tl.into_node().node_toggle_floating(seat);
|
||||
}
|
||||
}
|
||||
|
||||
fn unfocus(&self, seat: &WlSeatGlobal) {
|
||||
fn node_on_unfocus(&self, seat: &WlSeatGlobal) {
|
||||
seat.unfocus_surface(self);
|
||||
}
|
||||
|
||||
fn leave(&self, seat: &WlSeatGlobal) {
|
||||
fn node_on_leave(&self, seat: &WlSeatGlobal) {
|
||||
seat.leave_surface(self);
|
||||
}
|
||||
|
||||
fn pointer_enter(self: &Rc<Self>, seat: &Rc<WlSeatGlobal>, x: Fixed, y: Fixed) {
|
||||
fn node_on_pointer_enter(self: Rc<Self>, seat: &Rc<WlSeatGlobal>, x: Fixed, y: Fixed) {
|
||||
seat.enter_surface(&self, x, y)
|
||||
}
|
||||
|
||||
fn pointer_motion(self: &Rc<Self>, seat: &Rc<WlSeatGlobal>, x: Fixed, y: Fixed) {
|
||||
fn node_on_pointer_motion(self: Rc<Self>, seat: &Rc<WlSeatGlobal>, x: Fixed, y: Fixed) {
|
||||
seat.motion_surface(&*self, x, y)
|
||||
}
|
||||
|
||||
fn render(&self, renderer: &mut Renderer, x: i32, y: i32) {
|
||||
renderer.render_surface(self, x, y);
|
||||
}
|
||||
|
||||
fn client(&self) -> Option<Rc<Client>> {
|
||||
Some(self.client.clone())
|
||||
}
|
||||
|
||||
fn into_surface(self: &Rc<Self>) -> Option<Rc<WlSurface>> {
|
||||
Some(self.clone())
|
||||
}
|
||||
|
||||
fn dnd_drop(&self, dnd: &Dnd) {
|
||||
fn node_on_dnd_drop(&self, dnd: &Dnd) {
|
||||
dnd.seat.dnd_surface_drop(self, dnd);
|
||||
}
|
||||
|
||||
fn dnd_leave(&self, dnd: &Dnd) {
|
||||
fn node_on_dnd_leave(&self, dnd: &Dnd) {
|
||||
dnd.seat.dnd_surface_leave(self, dnd);
|
||||
}
|
||||
|
||||
fn dnd_enter(&self, dnd: &Dnd, x: Fixed, y: Fixed, serial: u32) {
|
||||
fn node_on_dnd_enter(&self, dnd: &Dnd, x: Fixed, y: Fixed, serial: u32) {
|
||||
dnd.seat.dnd_surface_enter(self, dnd, x, y, serial);
|
||||
}
|
||||
|
||||
fn dnd_motion(&self, dnd: &Dnd, x: Fixed, y: Fixed) {
|
||||
fn node_on_dnd_motion(&self, dnd: &Dnd, x: Fixed, y: Fixed) {
|
||||
dnd.seat.dnd_surface_motion(self, dnd, x, y);
|
||||
}
|
||||
|
||||
fn is_xwayland_surface(&self) -> bool {
|
||||
fn node_into_surface(self: Rc<Self>) -> Option<Rc<WlSurface>> {
|
||||
Some(self.clone())
|
||||
}
|
||||
|
||||
fn node_is_xwayland_surface(&self) -> bool {
|
||||
self.client.is_xwayland
|
||||
}
|
||||
|
||||
fn set_fullscreen(self: &Rc<Self>, fullscreen: bool) {
|
||||
if let Some(tl) = self.toplevel.get() {
|
||||
tl.set_fullscreen(fullscreen);
|
||||
}
|
||||
}
|
||||
|
||||
fn fullscreen(&self) -> bool {
|
||||
self.toplevel
|
||||
.get()
|
||||
.map(|tl| tl.fullscreen())
|
||||
.unwrap_or(false)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@ use {
|
|||
crate::{
|
||||
client::ClientError,
|
||||
ifs::{
|
||||
wl_seat::NodeSeatState,
|
||||
wl_surface::{
|
||||
xdg_surface::{
|
||||
xdg_popup::{XdgPopup, XdgPopupError},
|
||||
|
|
@ -18,7 +17,7 @@ use {
|
|||
leaks::Tracker,
|
||||
object::Object,
|
||||
rect::Rect,
|
||||
tree::{FindTreeResult, FoundNode, Node, SizedNode, WorkspaceNode},
|
||||
tree::{FindTreeResult, FoundNode, WorkspaceNode},
|
||||
utils::{
|
||||
buffd::{MsgParser, MsgParserError},
|
||||
clonecell::CloneCell,
|
||||
|
|
@ -67,7 +66,6 @@ pub struct XdgSurface {
|
|||
ext: CloneCell<Option<Rc<dyn XdgSurfaceExt>>>,
|
||||
popups: CopyHashMap<XdgPopupId, Rc<XdgPopup>>,
|
||||
pending: PendingXdgSurfaceData,
|
||||
seat_state: NodeSeatState,
|
||||
pub workspace: CloneCell<Option<Rc<WorkspaceNode>>>,
|
||||
pub tracker: Tracker<Self>,
|
||||
}
|
||||
|
|
@ -106,7 +104,6 @@ impl XdgSurface {
|
|||
ext: Default::default(),
|
||||
popups: Default::default(),
|
||||
pending: Default::default(),
|
||||
seat_state: Default::default(),
|
||||
workspace: Default::default(),
|
||||
tracker: Default::default(),
|
||||
}
|
||||
|
|
@ -152,10 +149,10 @@ impl XdgSurface {
|
|||
|
||||
fn destroy_node(&self) {
|
||||
self.workspace.set(None);
|
||||
self.surface.destroy_node(false);
|
||||
self.surface.destroy_node();
|
||||
let popups = self.popups.lock();
|
||||
for popup in popups.values() {
|
||||
popup.destroy_node(true);
|
||||
popup.destroy_node();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -301,7 +298,7 @@ impl XdgSurface {
|
|||
}
|
||||
|
||||
fn set_visible(&self, visible: bool) {
|
||||
self.surface.node_set_visible(visible);
|
||||
self.surface.set_visible(visible);
|
||||
for popup in self.popups.lock().values() {
|
||||
popup.set_visible(visible);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ use {
|
|||
object::Object,
|
||||
rect::Rect,
|
||||
render::Renderer,
|
||||
tree::{FindTreeResult, FoundNode, Node, NodeId, NodeVisitor, SizedNode, WorkspaceNode},
|
||||
tree::{FindTreeResult, FoundNode, Node, NodeId, NodeVisitor, StackedNode, WorkspaceNode},
|
||||
utils::{
|
||||
buffd::{MsgParser, MsgParserError},
|
||||
clonecell::CloneCell,
|
||||
|
|
@ -39,10 +39,11 @@ pub struct XdgPopup {
|
|||
pub xdg: Rc<XdgSurface>,
|
||||
pub(super) parent: CloneCell<Option<Rc<XdgSurface>>>,
|
||||
relative_position: Cell<Rect>,
|
||||
display_link: RefCell<Option<LinkedNode<Rc<dyn Node>>>>,
|
||||
workspace_link: RefCell<Option<LinkedNode<Rc<dyn Node>>>>,
|
||||
display_link: RefCell<Option<LinkedNode<Rc<dyn StackedNode>>>>,
|
||||
workspace_link: RefCell<Option<LinkedNode<Rc<dyn StackedNode>>>>,
|
||||
pos: RefCell<XdgPositioned>,
|
||||
pub tracker: Tracker<Self>,
|
||||
seat_state: NodeSeatState,
|
||||
}
|
||||
|
||||
impl Debug for XdgPopup {
|
||||
|
|
@ -72,6 +73,7 @@ impl XdgPopup {
|
|||
workspace_link: RefCell::new(None),
|
||||
pos: RefCell::new(pos),
|
||||
tracker: Default::default(),
|
||||
seat_state: Default::default(),
|
||||
})
|
||||
}
|
||||
|
||||
|
|
@ -201,7 +203,7 @@ impl XdgPopup {
|
|||
|
||||
fn destroy(&self, parser: MsgParser<'_, '_>) -> Result<(), DestroyError> {
|
||||
let _req: Destroy = self.xdg.surface.client.parse(self, parser)?;
|
||||
self.node_destroy(true);
|
||||
self.destroy_node();
|
||||
{
|
||||
if let Some(parent) = self.parent.take() {
|
||||
parent.popups.remove(&self.id);
|
||||
|
|
@ -235,6 +237,19 @@ impl XdgPopup {
|
|||
fn get_parent_workspace(&self) -> Option<Rc<WorkspaceNode>> {
|
||||
self.parent.get()?.workspace.get()
|
||||
}
|
||||
|
||||
pub fn set_visible(&self, visible: bool) {
|
||||
// log::info!("set visible = {}", visible);
|
||||
self.xdg.set_visible(visible);
|
||||
self.seat_state.set_visible(self, visible);
|
||||
}
|
||||
|
||||
pub fn destroy_node(&self) {
|
||||
let _v = self.display_link.borrow_mut().take();
|
||||
let _v = self.workspace_link.borrow_mut().take();
|
||||
self.xdg.destroy_node();
|
||||
self.seat_state.destroy_node(self);
|
||||
}
|
||||
}
|
||||
|
||||
object_base! {
|
||||
|
|
@ -255,7 +270,7 @@ impl Object for XdgPopup {
|
|||
}
|
||||
|
||||
fn break_loops(&self) {
|
||||
self.node_destroy(true);
|
||||
self.destroy_node();
|
||||
self.parent.set(None);
|
||||
*self.display_link.borrow_mut() = None;
|
||||
*self.workspace_link.borrow_mut() = None;
|
||||
|
|
@ -264,80 +279,57 @@ impl Object for XdgPopup {
|
|||
|
||||
simple_add_obj!(XdgPopup);
|
||||
|
||||
impl SizedNode for XdgPopup {
|
||||
fn id(&self) -> NodeId {
|
||||
impl Node for XdgPopup {
|
||||
fn node_id(&self) -> NodeId {
|
||||
self.node_id.into()
|
||||
}
|
||||
|
||||
fn seat_state(&self) -> &NodeSeatState {
|
||||
&self.xdg.seat_state
|
||||
fn node_seat_state(&self) -> &NodeSeatState {
|
||||
&self.seat_state
|
||||
}
|
||||
|
||||
fn destroy_node(&self, _detach: bool) {
|
||||
let _v = self.display_link.borrow_mut().take();
|
||||
let _v = self.workspace_link.borrow_mut().take();
|
||||
self.xdg.destroy_node();
|
||||
self.xdg.seat_state.destroy_node(self);
|
||||
fn node_visit(self: Rc<Self>, visitor: &mut dyn NodeVisitor) {
|
||||
visitor.visit_popup(&self);
|
||||
}
|
||||
|
||||
fn visit(self: &Rc<Self>, visitor: &mut dyn NodeVisitor) {
|
||||
visitor.visit_popup(self);
|
||||
}
|
||||
|
||||
fn visit_children(&self, visitor: &mut dyn NodeVisitor) {
|
||||
fn node_visit_children(&self, visitor: &mut dyn NodeVisitor) {
|
||||
visitor.visit_surface(&self.xdg.surface);
|
||||
}
|
||||
|
||||
fn visible(&self) -> bool {
|
||||
fn node_visible(&self) -> bool {
|
||||
self.xdg.surface.visible.get()
|
||||
}
|
||||
|
||||
fn parent(&self) -> Option<Rc<dyn Node>> {
|
||||
self.parent
|
||||
.get()
|
||||
.and_then(|x| x.workspace.get().map(|w| w as Rc<dyn Node>))
|
||||
}
|
||||
|
||||
fn set_visible(&self, visible: bool) {
|
||||
// log::info!("set visible = {}", visible);
|
||||
self.xdg.set_visible(visible);
|
||||
self.xdg.seat_state.set_visible(self, visible);
|
||||
}
|
||||
|
||||
fn get_workspace(&self) -> Option<Rc<WorkspaceNode>> {
|
||||
self.xdg.workspace.get()
|
||||
}
|
||||
|
||||
fn absolute_position(&self) -> Rect {
|
||||
fn node_absolute_position(&self) -> Rect {
|
||||
self.xdg.absolute_desired_extents.get()
|
||||
}
|
||||
|
||||
fn absolute_position_constrains_input(&self) -> bool {
|
||||
false
|
||||
}
|
||||
|
||||
fn find_tree_at(&self, x: i32, y: i32, tree: &mut Vec<FoundNode>) -> FindTreeResult {
|
||||
fn node_find_tree_at(&self, x: i32, y: i32, tree: &mut Vec<FoundNode>) -> FindTreeResult {
|
||||
self.xdg.find_tree_at(x, y, tree)
|
||||
}
|
||||
|
||||
fn pointer_enter(self: &Rc<Self>, seat: &Rc<WlSeatGlobal>, _x: Fixed, _y: Fixed) {
|
||||
seat.enter_popup(&self);
|
||||
}
|
||||
|
||||
fn pointer_focus(&self, seat: &Rc<WlSeatGlobal>) {
|
||||
seat.set_known_cursor(KnownCursor::Default);
|
||||
}
|
||||
|
||||
fn render(&self, renderer: &mut Renderer, x: i32, y: i32) {
|
||||
fn node_render(&self, renderer: &mut Renderer, x: i32, y: i32) {
|
||||
renderer.render_xdg_surface(&self.xdg, x, y)
|
||||
}
|
||||
|
||||
fn set_workspace(self: &Rc<Self>, ws: &Rc<WorkspaceNode>) {
|
||||
self.xdg.set_workspace(ws);
|
||||
fn node_client(&self) -> Option<Rc<Client>> {
|
||||
Some(self.xdg.surface.client.clone())
|
||||
}
|
||||
|
||||
fn client(&self) -> Option<Rc<Client>> {
|
||||
Some(self.xdg.surface.client.clone())
|
||||
fn node_on_pointer_enter(self: Rc<Self>, seat: &Rc<WlSeatGlobal>, _x: Fixed, _y: Fixed) {
|
||||
seat.enter_popup(&self);
|
||||
}
|
||||
|
||||
fn node_on_pointer_focus(&self, seat: &Rc<WlSeatGlobal>) {
|
||||
seat.set_known_cursor(KnownCursor::Default);
|
||||
}
|
||||
}
|
||||
|
||||
impl StackedNode for XdgPopup {
|
||||
stacked_node_impl!();
|
||||
|
||||
fn stacked_absolute_position_constrains_input(&self) -> bool {
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -381,7 +373,7 @@ impl XdgSurfaceExt for XdgPopup {
|
|||
drop(wl);
|
||||
drop(dl);
|
||||
self.set_visible(false);
|
||||
self.destroy_node(true);
|
||||
self.destroy_node();
|
||||
self.send_popup_done();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,10 +7,7 @@ use {
|
|||
fixed::Fixed,
|
||||
ifs::{
|
||||
wl_seat::{NodeSeatState, WlSeatGlobal},
|
||||
wl_surface::{
|
||||
xdg_surface::{XdgSurface, XdgSurfaceError, XdgSurfaceExt},
|
||||
WlSurface,
|
||||
},
|
||||
wl_surface::xdg_surface::{XdgSurface, XdgSurfaceError, XdgSurfaceExt},
|
||||
},
|
||||
leaks::Tracker,
|
||||
object::Object,
|
||||
|
|
@ -18,9 +15,8 @@ use {
|
|||
render::Renderer,
|
||||
state::State,
|
||||
tree::{
|
||||
FindTreeResult, FoundNode, FullscreenData, Node, NodeId, NodeVisitor,
|
||||
SizedFullscreenNode, SizedNode, SizedToplevelNode, ToplevelData, ToplevelNodeId,
|
||||
WorkspaceNode,
|
||||
FindTreeResult, FoundNode, Node, NodeId, NodeVisitor, ToplevelData, ToplevelNode,
|
||||
ToplevelNodeId, WorkspaceNode,
|
||||
},
|
||||
utils::{
|
||||
buffd::{MsgParser, MsgParserError},
|
||||
|
|
@ -78,7 +74,6 @@ pub struct XdgToplevel {
|
|||
pub state: Rc<State>,
|
||||
pub xdg: Rc<XdgSurface>,
|
||||
pub node_id: ToplevelNodeId,
|
||||
pub parent_node: CloneCell<Option<Rc<dyn Node>>>,
|
||||
pub parent: CloneCell<Option<Rc<XdgToplevel>>>,
|
||||
pub children: RefCell<AHashMap<XdgToplevelId, Rc<XdgToplevel>>>,
|
||||
states: RefCell<AHashSet<u32>>,
|
||||
|
|
@ -88,10 +83,8 @@ pub struct XdgToplevel {
|
|||
min_height: Cell<Option<i32>>,
|
||||
max_width: Cell<Option<i32>>,
|
||||
max_height: Cell<Option<i32>>,
|
||||
title: RefCell<String>,
|
||||
pub tracker: Tracker<Self>,
|
||||
toplevel_data: ToplevelData,
|
||||
fullscreen_data: FullscreenData,
|
||||
}
|
||||
|
||||
impl Debug for XdgToplevel {
|
||||
|
|
@ -107,12 +100,12 @@ impl XdgToplevel {
|
|||
states.insert(STATE_TILED_RIGHT);
|
||||
states.insert(STATE_TILED_TOP);
|
||||
states.insert(STATE_TILED_BOTTOM);
|
||||
let state = &surface.surface.client.state;
|
||||
Self {
|
||||
id,
|
||||
state: surface.surface.client.state.clone(),
|
||||
state: state.clone(),
|
||||
xdg: surface.clone(),
|
||||
node_id: surface.surface.client.state.node_ids.next(),
|
||||
parent_node: Default::default(),
|
||||
node_id: state.node_ids.next(),
|
||||
parent: Default::default(),
|
||||
children: RefCell::new(Default::default()),
|
||||
states: RefCell::new(states),
|
||||
|
|
@ -122,10 +115,12 @@ impl XdgToplevel {
|
|||
min_height: Cell::new(None),
|
||||
max_width: Cell::new(None),
|
||||
max_height: Cell::new(None),
|
||||
title: RefCell::new("".to_string()),
|
||||
tracker: Default::default(),
|
||||
toplevel_data: Default::default(),
|
||||
fullscreen_data: Default::default(),
|
||||
toplevel_data: ToplevelData::new(
|
||||
state,
|
||||
String::new(),
|
||||
Some(surface.surface.client.clone()),
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -172,7 +167,7 @@ impl XdgToplevel {
|
|||
|
||||
fn destroy(self: &Rc<Self>, parser: MsgParser<'_, '_>) -> Result<(), DestroyError> {
|
||||
let _req: Destroy = self.xdg.surface.client.parse(self.deref(), parser)?;
|
||||
self.node_destroy(true);
|
||||
self.tl_destroy();
|
||||
self.xdg.ext.set(None);
|
||||
{
|
||||
let mut children = self.children.borrow_mut();
|
||||
|
|
@ -210,13 +205,8 @@ impl XdgToplevel {
|
|||
|
||||
fn set_title(&self, parser: MsgParser<'_, '_>) -> Result<(), SetTitleError> {
|
||||
let req: SetTitle = self.xdg.surface.client.parse(self, parser)?;
|
||||
let mut title = self.title.borrow_mut();
|
||||
title.clear();
|
||||
title.push_str(req.title);
|
||||
if let Some(parent) = self.parent_node.get() {
|
||||
parent.node_child_title_changed(self, &title);
|
||||
}
|
||||
self.fullscreen_data.set_title(&title);
|
||||
*self.toplevel_data.title.borrow_mut() = req.title.to_string();
|
||||
self.tl_title_changed();
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
|
@ -234,7 +224,7 @@ impl XdgToplevel {
|
|||
fn move_(&self, parser: MsgParser<'_, '_>) -> Result<(), MoveError> {
|
||||
let req: Move = self.xdg.surface.client.parse(self, parser)?;
|
||||
let seat = self.xdg.surface.client.lookup(req.seat)?;
|
||||
if let Some(parent) = self.parent_node.get() {
|
||||
if let Some(parent) = self.toplevel_data.parent.get() {
|
||||
if let Some(float) = parent.node_into_float() {
|
||||
seat.move_(&float);
|
||||
}
|
||||
|
|
@ -314,7 +304,7 @@ impl XdgToplevel {
|
|||
} else {
|
||||
break 'set_fullscreen;
|
||||
};
|
||||
self.fullscreen_data
|
||||
self.toplevel_data
|
||||
.set_fullscreen(&client.state, self.clone(), &output);
|
||||
}
|
||||
self.send_current_configure();
|
||||
|
|
@ -327,7 +317,7 @@ impl XdgToplevel {
|
|||
) -> Result<(), UnsetFullscreenError> {
|
||||
let _req: UnsetFullscreen = self.xdg.surface.client.parse(self.deref(), parser)?;
|
||||
self.states.borrow_mut().remove(&STATE_FULLSCREEN);
|
||||
self.fullscreen_data
|
||||
self.toplevel_data
|
||||
.unset_fullscreen(&self.state, self.clone());
|
||||
self.send_current_configure();
|
||||
Ok(())
|
||||
|
|
@ -339,18 +329,18 @@ impl XdgToplevel {
|
|||
}
|
||||
|
||||
fn notify_parent(&self) {
|
||||
let parent = match self.parent_node.get() {
|
||||
let parent = match self.toplevel_data.parent.get() {
|
||||
Some(p) => p,
|
||||
_ => return,
|
||||
};
|
||||
let extents = self.xdg.extents.get();
|
||||
parent.clone().node_child_active_changed(
|
||||
self,
|
||||
self.toplevel_data.active_surfaces.get() > 0,
|
||||
self.toplevel_data.active_children.get() > 0,
|
||||
1,
|
||||
);
|
||||
parent.node_child_size_changed(self, extents.width(), extents.height());
|
||||
parent.node_child_title_changed(self, self.title.borrow_mut().deref());
|
||||
parent.node_child_title_changed(self, self.toplevel_data.title.borrow_mut().deref());
|
||||
}
|
||||
|
||||
fn map_floating(self: &Rc<Self>, workspace: &Rc<WorkspaceNode>) {
|
||||
|
|
@ -396,7 +386,7 @@ impl Object for XdgToplevel {
|
|||
}
|
||||
|
||||
fn break_loops(&self) {
|
||||
self.node_destroy(true);
|
||||
self.tl_destroy();
|
||||
self.parent.set(None);
|
||||
let _children = mem::take(&mut *self.children.borrow_mut());
|
||||
}
|
||||
|
|
@ -404,145 +394,73 @@ impl Object for XdgToplevel {
|
|||
|
||||
dedicated_add_obj!(XdgToplevel, XdgToplevelId, xdg_toplevel);
|
||||
|
||||
impl SizedNode for XdgToplevel {
|
||||
fn id(&self) -> NodeId {
|
||||
impl Node for XdgToplevel {
|
||||
fn node_id(&self) -> NodeId {
|
||||
self.node_id.into()
|
||||
}
|
||||
|
||||
fn seat_state(&self) -> &NodeSeatState {
|
||||
&self.xdg.seat_state
|
||||
fn node_seat_state(&self) -> &NodeSeatState {
|
||||
&self.toplevel_data.seat_state
|
||||
}
|
||||
|
||||
fn destroy_node(&self, detach: bool) {
|
||||
self.fullscreen_data.destroy_node();
|
||||
if let Some(parent) = self.parent_node.take() {
|
||||
if detach {
|
||||
parent.node_remove_child(self);
|
||||
self.state.tree_changed();
|
||||
}
|
||||
}
|
||||
self.toplevel_data.clear();
|
||||
self.xdg.destroy_node();
|
||||
self.xdg.seat_state.destroy_node(self)
|
||||
fn node_visit(self: Rc<Self>, visitor: &mut dyn NodeVisitor) {
|
||||
visitor.visit_toplevel(&self);
|
||||
}
|
||||
|
||||
fn visit(self: &Rc<Self>, visitor: &mut dyn NodeVisitor) {
|
||||
visitor.visit_toplevel(self);
|
||||
}
|
||||
|
||||
fn visit_children(&self, visitor: &mut dyn NodeVisitor) {
|
||||
fn node_visit_children(&self, visitor: &mut dyn NodeVisitor) {
|
||||
visitor.visit_surface(&self.xdg.surface);
|
||||
}
|
||||
|
||||
fn visible(&self) -> bool {
|
||||
fn node_visible(&self) -> bool {
|
||||
self.xdg.surface.visible.get()
|
||||
}
|
||||
|
||||
fn parent(&self) -> Option<Rc<dyn Node>> {
|
||||
self.parent_node.get()
|
||||
}
|
||||
|
||||
fn set_visible(&self, visible: bool) {
|
||||
// log::info!("set_visible {}", visible);
|
||||
// if !visible {
|
||||
// log::info!("\n{:?}", Backtrace::new());
|
||||
// }
|
||||
self.xdg.set_visible(visible);
|
||||
self.xdg.seat_state.set_visible(self, visible);
|
||||
}
|
||||
|
||||
fn get_workspace(&self) -> Option<Rc<WorkspaceNode>> {
|
||||
self.xdg.workspace.get()
|
||||
}
|
||||
|
||||
fn do_focus(self: &Rc<Self>, seat: &Rc<WlSeatGlobal>, _direction: Direction) {
|
||||
seat.focus_toplevel(self.clone());
|
||||
}
|
||||
|
||||
fn close(self: &Rc<Self>) {
|
||||
self.send_close();
|
||||
}
|
||||
|
||||
fn absolute_position(&self) -> Rect {
|
||||
fn node_absolute_position(&self) -> Rect {
|
||||
self.xdg.absolute_desired_extents.get()
|
||||
}
|
||||
|
||||
fn toggle_floating(self: &Rc<Self>, _seat: &Rc<WlSeatGlobal>) {
|
||||
let parent = match self.parent_node.get() {
|
||||
Some(p) => p,
|
||||
_ => return,
|
||||
};
|
||||
if parent.node_is_float() {
|
||||
parent.node_remove_child2(self.deref(), true);
|
||||
self.map_tiled();
|
||||
} else if let Some(ws) = self.xdg.workspace.get() {
|
||||
parent.node_remove_child2(self.deref(), true);
|
||||
self.map_floating(&ws);
|
||||
}
|
||||
fn node_do_focus(self: Rc<Self>, seat: &Rc<WlSeatGlobal>, _direction: Direction) {
|
||||
seat.focus_toplevel(self.clone());
|
||||
}
|
||||
|
||||
fn find_tree_at(&self, x: i32, y: i32, tree: &mut Vec<FoundNode>) -> FindTreeResult {
|
||||
fn node_find_tree_at(&self, x: i32, y: i32, tree: &mut Vec<FoundNode>) -> FindTreeResult {
|
||||
self.xdg.find_tree_at(x, y, tree)
|
||||
}
|
||||
|
||||
fn pointer_enter(self: &Rc<Self>, seat: &Rc<WlSeatGlobal>, _x: Fixed, _y: Fixed) {
|
||||
seat.enter_toplevel(self.clone());
|
||||
}
|
||||
|
||||
fn pointer_focus(&self, seat: &Rc<WlSeatGlobal>) {
|
||||
seat.set_known_cursor(KnownCursor::Default);
|
||||
}
|
||||
|
||||
fn render(&self, renderer: &mut Renderer, x: i32, y: i32) {
|
||||
fn node_render(&self, renderer: &mut Renderer, x: i32, y: i32) {
|
||||
renderer.render_xdg_surface(&self.xdg, x, y)
|
||||
}
|
||||
|
||||
fn change_extents(self: &Rc<Self>, rect: &Rect) {
|
||||
let nw = rect.width();
|
||||
let nh = rect.height();
|
||||
let de = self.xdg.absolute_desired_extents.get();
|
||||
if de.width() != nw || de.height() != nh {
|
||||
if self.toplevel_data.is_floating.get() {
|
||||
self.toplevel_data.float_width.set(rect.width());
|
||||
self.toplevel_data.float_height.set(rect.height());
|
||||
}
|
||||
self.send_configure_checked(nw, nh);
|
||||
self.xdg.do_send_configure();
|
||||
self.xdg.surface.client.flush();
|
||||
}
|
||||
self.xdg.set_absolute_desired_extents(rect);
|
||||
}
|
||||
|
||||
fn set_workspace(self: &Rc<Self>, ws: &Rc<WorkspaceNode>) {
|
||||
self.xdg.set_workspace(ws);
|
||||
}
|
||||
|
||||
fn set_parent(self: &Rc<Self>, parent: Rc<dyn Node>) {
|
||||
self.toplevel_data.is_floating.set(parent.node_is_float());
|
||||
self.parent_node.set(Some(parent));
|
||||
self.notify_parent();
|
||||
}
|
||||
|
||||
fn client(&self) -> Option<Rc<Client>> {
|
||||
fn node_client(&self) -> Option<Rc<Client>> {
|
||||
Some(self.xdg.surface.client.clone())
|
||||
}
|
||||
|
||||
fn node_toplevel(self: Rc<Self>) -> Option<Rc<dyn crate::tree::ToplevelNode>> {
|
||||
Some(self)
|
||||
}
|
||||
|
||||
fn node_on_pointer_enter(self: Rc<Self>, seat: &Rc<WlSeatGlobal>, _x: Fixed, _y: Fixed) {
|
||||
seat.enter_toplevel(self.clone());
|
||||
}
|
||||
|
||||
fn node_on_pointer_focus(&self, seat: &Rc<WlSeatGlobal>) {
|
||||
seat.set_known_cursor(KnownCursor::Default);
|
||||
}
|
||||
}
|
||||
|
||||
impl SizedToplevelNode for XdgToplevel {
|
||||
fn data(&self) -> &ToplevelData {
|
||||
impl ToplevelNode for XdgToplevel {
|
||||
tl_node_impl!();
|
||||
|
||||
fn tl_data(&self) -> &ToplevelData {
|
||||
&self.toplevel_data
|
||||
}
|
||||
|
||||
fn accepts_keyboard_focus(&self) -> bool {
|
||||
true
|
||||
}
|
||||
|
||||
fn default_surface(&self) -> Option<Rc<WlSurface>> {
|
||||
fn tl_default_focus_child(&self) -> Option<Rc<dyn Node>> {
|
||||
Some(self.xdg.surface.clone())
|
||||
}
|
||||
|
||||
fn set_active(&self, active: bool) {
|
||||
if let Some(parent) = self.parent_node.get() {
|
||||
fn tl_set_active(&self, active: bool) {
|
||||
if let Some(parent) = self.toplevel_data.parent.get() {
|
||||
parent.node_child_active_changed(self, active, 1);
|
||||
}
|
||||
let changed = {
|
||||
|
|
@ -559,26 +477,67 @@ impl SizedToplevelNode for XdgToplevel {
|
|||
}
|
||||
}
|
||||
|
||||
fn activate(&self) {
|
||||
// nothing
|
||||
fn tl_set_workspace(self: Rc<Self>, ws: &Rc<WorkspaceNode>) {
|
||||
self.toplevel_data.workspace.set(Some(ws.clone()));
|
||||
self.xdg.set_workspace(ws);
|
||||
}
|
||||
|
||||
fn set_fullscreen(self: &Rc<Self>, fullscreen: bool) {
|
||||
let state = &self.state;
|
||||
if fullscreen {
|
||||
if let Some(ws) = self.xdg.workspace.get() {
|
||||
self.fullscreen_data
|
||||
.set_fullscreen(state, self.clone(), &ws.output.get());
|
||||
fn tl_change_extents(self: Rc<Self>, rect: &Rect) {
|
||||
let nw = rect.width();
|
||||
let nh = rect.height();
|
||||
let de = self.xdg.absolute_desired_extents.get();
|
||||
if de.width() != nw || de.height() != nh {
|
||||
if self.toplevel_data.is_floating.get() {
|
||||
self.toplevel_data.float_width.set(rect.width());
|
||||
self.toplevel_data.float_height.set(rect.height());
|
||||
}
|
||||
} else {
|
||||
self.fullscreen_data.unset_fullscreen(state, self.clone());
|
||||
self.send_configure_checked(nw, nh);
|
||||
self.xdg.do_send_configure();
|
||||
self.xdg.surface.client.flush();
|
||||
}
|
||||
self.send_current_configure();
|
||||
self.xdg.set_absolute_desired_extents(rect);
|
||||
}
|
||||
|
||||
fn fullscreen(&self) -> bool {
|
||||
self.fullscreen_data.is_fullscreen.get()
|
||||
fn tl_close(self: Rc<Self>) {
|
||||
self.send_close();
|
||||
}
|
||||
|
||||
fn tl_set_visible(&self, visible: bool) {
|
||||
// log::info!("set_visible {}", visible);
|
||||
// if !visible {
|
||||
// log::info!("\n{:?}", Backtrace::new());
|
||||
// }
|
||||
self.xdg.set_visible(visible);
|
||||
self.toplevel_data.set_visible(self, visible);
|
||||
}
|
||||
|
||||
fn tl_destroy(&self) {
|
||||
self.toplevel_data.destroy_node(self);
|
||||
self.xdg.destroy_node();
|
||||
}
|
||||
|
||||
// fn move_to_workspace(self: &Rc<Self>, workspace: &Rc<WorkspaceNode>) {
|
||||
// let parent = match self.parent_node.get() {
|
||||
// Some(p) => p,
|
||||
// _ => return,
|
||||
// };
|
||||
// if self.fullscreen_data.is_fullscreen.get() {
|
||||
// if workspace.fullscreen.get().is_some() {
|
||||
// log::info!("Not moving fullscreen node to workspace {} because that workspace already contains a fullscreen node", workspace.name);
|
||||
// return;
|
||||
// }
|
||||
// parent.node_remove_child2(self.deref(), workspace.visible());
|
||||
// workspace.fullscreen.set(Some(self.clone()));
|
||||
// self.state.tree_changed();
|
||||
// return;
|
||||
// }
|
||||
// parent.node_remove_child2(self.deref(), workspace.visible());
|
||||
// if self.toplevel_data.is_floating.get() {
|
||||
// self.map_floating(workspace);
|
||||
// } else {
|
||||
// self.map_tiled()
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
impl XdgSurfaceExt for XdgToplevel {
|
||||
|
|
@ -589,9 +548,9 @@ impl XdgSurfaceExt for XdgToplevel {
|
|||
|
||||
fn post_commit(self: Rc<Self>) {
|
||||
let surface = &self.xdg.surface;
|
||||
if let Some(parent) = self.parent_node.get() {
|
||||
if self.toplevel_data.parent.get().is_some() {
|
||||
if surface.buffer.get().is_none() {
|
||||
parent.node_remove_child(&*self);
|
||||
self.tl_destroy();
|
||||
{
|
||||
let new_parent = self.parent.get();
|
||||
let mut children = self.children.borrow_mut();
|
||||
|
|
@ -629,26 +588,12 @@ impl XdgSurfaceExt for XdgToplevel {
|
|||
|
||||
fn extents_changed(&self) {
|
||||
self.notify_parent();
|
||||
if self.parent_node.get().is_some() {
|
||||
if self.toplevel_data.parent.get().is_some() {
|
||||
self.state.tree_changed();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl SizedFullscreenNode for XdgToplevel {
|
||||
fn on_set_fullscreen(&self, _workspace: &Rc<WorkspaceNode>) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
fn on_unset_fullscreen(&self) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
fn title(&self) -> String {
|
||||
self.title.borrow_mut().clone()
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum XdgToplevelError {
|
||||
#[error("Could not process `destroy` request")]
|
||||
|
|
|
|||
|
|
@ -4,21 +4,17 @@ use {
|
|||
cursor::KnownCursor,
|
||||
fixed::Fixed,
|
||||
ifs::{
|
||||
wl_seat::{NodeSeatState, SeatId, WlSeatGlobal},
|
||||
wl_seat::{NodeSeatState, WlSeatGlobal},
|
||||
wl_surface::{SurfaceExt, SurfaceRole, WlSurface, WlSurfaceError},
|
||||
},
|
||||
rect::Rect,
|
||||
render::Renderer,
|
||||
state::State,
|
||||
tree::{
|
||||
FindTreeResult, FoundNode, FullscreenData, Node, NodeId, NodeVisitor,
|
||||
SizedFullscreenNode, SizedNode, SizedToplevelNode, ToplevelData, ToplevelNode,
|
||||
WorkspaceNode,
|
||||
},
|
||||
utils::{
|
||||
clonecell::CloneCell, copyhashmap::CopyHashMap, linkedlist::LinkedNode,
|
||||
smallmap::SmallMap,
|
||||
FindTreeResult, FoundNode, Node, NodeId, NodeVisitor, StackedNode, ToplevelData,
|
||||
ToplevelNode,
|
||||
},
|
||||
utils::{clonecell::CloneCell, copyhashmap::CopyHashMap, linkedlist::LinkedNode},
|
||||
wire::WlSurfaceId,
|
||||
wire_xcon::CreateNotify,
|
||||
xwayland::XWaylandEvent,
|
||||
|
|
@ -139,11 +135,8 @@ pub struct Xwindow {
|
|||
pub data: Rc<XwindowData>,
|
||||
pub surface: Rc<WlSurface>,
|
||||
pub parent_node: CloneCell<Option<Rc<dyn Node>>>,
|
||||
pub focus_history: SmallMap<SeatId, LinkedNode<Rc<dyn ToplevelNode>>, 1>,
|
||||
pub workspace: CloneCell<Option<Rc<WorkspaceNode>>>,
|
||||
pub display_link: RefCell<Option<LinkedNode<Rc<dyn Node>>>>,
|
||||
pub display_link: RefCell<Option<LinkedNode<Rc<dyn StackedNode>>>>,
|
||||
pub toplevel_data: ToplevelData,
|
||||
pub fullscreen_data: FullscreenData,
|
||||
}
|
||||
|
||||
impl XwindowData {
|
||||
|
|
@ -212,11 +205,12 @@ impl Xwindow {
|
|||
data: data.clone(),
|
||||
surface: surface.clone(),
|
||||
parent_node: Default::default(),
|
||||
focus_history: Default::default(),
|
||||
workspace: Default::default(),
|
||||
display_link: Default::default(),
|
||||
toplevel_data: Default::default(),
|
||||
fullscreen_data: Default::default(),
|
||||
toplevel_data: ToplevelData::new(
|
||||
&data.state,
|
||||
data.info.title.borrow_mut().clone().unwrap_or_default(),
|
||||
Some(surface.client.clone()),
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -226,7 +220,7 @@ impl Xwindow {
|
|||
}
|
||||
|
||||
pub fn break_loops(&self) {
|
||||
self.node_destroy(true);
|
||||
self.tl_destroy();
|
||||
self.surface.set_toplevel(None);
|
||||
}
|
||||
|
||||
|
|
@ -248,7 +242,7 @@ impl Xwindow {
|
|||
let extents = self.surface.extents.get();
|
||||
parent.clone().node_child_active_changed(
|
||||
self,
|
||||
self.toplevel_data.active_surfaces.get() > 0,
|
||||
self.toplevel_data.active_children.get() > 0,
|
||||
1,
|
||||
);
|
||||
parent.node_child_size_changed(self, extents.width(), extents.height());
|
||||
|
|
@ -283,10 +277,11 @@ impl Xwindow {
|
|||
.info
|
||||
.pending_extents
|
||||
.set(self.data.info.extents.take());
|
||||
self.node_destroy(true);
|
||||
self.tl_destroy();
|
||||
}
|
||||
Change::Map if self.data.info.override_redirect.get() => {
|
||||
self.change_extents(&self.data.info.pending_extents.get());
|
||||
self.clone()
|
||||
.tl_change_extents(&self.data.info.pending_extents.get());
|
||||
*self.display_link.borrow_mut() =
|
||||
Some(self.data.state.root.stacked.add_last(self.clone()));
|
||||
self.data.state.tree_changed();
|
||||
|
|
@ -305,8 +300,8 @@ impl Xwindow {
|
|||
}
|
||||
}
|
||||
match map_change {
|
||||
Change::Unmap => self.node_set_visible(false),
|
||||
Change::Map => self.node_set_visible(true),
|
||||
Change::Unmap => self.tl_set_visible(false),
|
||||
Change::Map => self.tl_set_visible(true),
|
||||
Change::None => {}
|
||||
}
|
||||
self.data.state.tree_changed();
|
||||
|
|
@ -319,7 +314,7 @@ impl SurfaceExt for Xwindow {
|
|||
}
|
||||
|
||||
fn on_surface_destroy(&self) -> Result<(), WlSurfaceError> {
|
||||
self.node_destroy(true);
|
||||
self.tl_destroy();
|
||||
self.surface.unset_ext();
|
||||
self.data.window.set(None);
|
||||
self.data.surface_id.set(None);
|
||||
|
|
@ -336,69 +331,36 @@ impl SurfaceExt for Xwindow {
|
|||
}
|
||||
}
|
||||
|
||||
impl SizedNode for Xwindow {
|
||||
fn id(&self) -> NodeId {
|
||||
impl Node for Xwindow {
|
||||
fn node_id(&self) -> NodeId {
|
||||
self.id.into()
|
||||
}
|
||||
|
||||
fn seat_state(&self) -> &NodeSeatState {
|
||||
fn node_seat_state(&self) -> &NodeSeatState {
|
||||
&self.seat_state
|
||||
}
|
||||
|
||||
fn destroy_node(&self, _detach: bool) {
|
||||
self.toplevel_data.clear();
|
||||
self.display_link.borrow_mut().take();
|
||||
self.workspace.take();
|
||||
self.focus_history.clear();
|
||||
if let Some(parent) = self.parent_node.take() {
|
||||
parent.node_remove_child(self);
|
||||
}
|
||||
self.surface.node_destroy(false);
|
||||
self.seat_state.destroy_node(self);
|
||||
fn node_visit(self: Rc<Self>, visitor: &mut dyn NodeVisitor) {
|
||||
visitor.visit_xwindow(&self);
|
||||
}
|
||||
|
||||
fn visit(self: &Rc<Self>, visitor: &mut dyn NodeVisitor) {
|
||||
visitor.visit_xwindow(self);
|
||||
}
|
||||
|
||||
fn visit_children(&self, visitor: &mut dyn NodeVisitor) {
|
||||
fn node_visit_children(&self, visitor: &mut dyn NodeVisitor) {
|
||||
visitor.visit_surface(&self.surface);
|
||||
}
|
||||
|
||||
fn visible(&self) -> bool {
|
||||
fn node_visible(&self) -> bool {
|
||||
self.surface.visible.get()
|
||||
}
|
||||
|
||||
fn parent(&self) -> Option<Rc<dyn Node>> {
|
||||
self.parent_node.get()
|
||||
}
|
||||
|
||||
fn set_visible(&self, visible: bool) {
|
||||
self.surface.node_set_visible(visible);
|
||||
self.seat_state.set_visible(self, visible);
|
||||
}
|
||||
|
||||
fn get_workspace(&self) -> Option<Rc<WorkspaceNode>> {
|
||||
self.workspace.get()
|
||||
}
|
||||
|
||||
fn do_focus(self: &Rc<Self>, seat: &Rc<WlSeatGlobal>, _direction: Direction) {
|
||||
seat.focus_toplevel(self.clone());
|
||||
}
|
||||
|
||||
fn close(self: &Rc<Self>) {
|
||||
self.data
|
||||
.state
|
||||
.xwayland
|
||||
.queue
|
||||
.push(XWaylandEvent::Close(self.data.clone()));
|
||||
}
|
||||
|
||||
fn absolute_position(&self) -> Rect {
|
||||
fn node_absolute_position(&self) -> Rect {
|
||||
self.data.info.extents.get()
|
||||
}
|
||||
|
||||
fn find_tree_at(&self, x: i32, y: i32, tree: &mut Vec<FoundNode>) -> FindTreeResult {
|
||||
fn node_do_focus(self: Rc<Self>, seat: &Rc<WlSeatGlobal>, _direction: Direction) {
|
||||
seat.focus_toplevel(self.clone());
|
||||
}
|
||||
|
||||
fn node_find_tree_at(&self, x: i32, y: i32, tree: &mut Vec<FoundNode>) -> FindTreeResult {
|
||||
if let Some(buffer) = self.surface.buffer.get() {
|
||||
if x < buffer.rect.width() && y < buffer.rect.height() {
|
||||
tree.push(FoundNode {
|
||||
|
|
@ -412,19 +374,58 @@ impl SizedNode for Xwindow {
|
|||
FindTreeResult::Other
|
||||
}
|
||||
|
||||
fn pointer_enter(self: &Rc<Self>, seat: &Rc<WlSeatGlobal>, _x: Fixed, _y: Fixed) {
|
||||
seat.enter_toplevel(self.clone());
|
||||
}
|
||||
|
||||
fn pointer_focus(&self, seat: &Rc<WlSeatGlobal>) {
|
||||
seat.set_known_cursor(KnownCursor::Default);
|
||||
}
|
||||
|
||||
fn render(&self, renderer: &mut Renderer, x: i32, y: i32) {
|
||||
fn node_render(&self, renderer: &mut Renderer, x: i32, y: i32) {
|
||||
renderer.render_surface(&self.surface, x, y)
|
||||
}
|
||||
|
||||
fn change_extents(self: &Rc<Self>, rect: &Rect) {
|
||||
fn node_client(&self) -> Option<Rc<Client>> {
|
||||
Some(self.data.client.clone())
|
||||
}
|
||||
|
||||
fn node_toplevel(self: Rc<Self>) -> Option<Rc<dyn ToplevelNode>> {
|
||||
Some(self)
|
||||
}
|
||||
|
||||
fn node_on_pointer_enter(self: Rc<Self>, seat: &Rc<WlSeatGlobal>, _x: Fixed, _y: Fixed) {
|
||||
seat.enter_toplevel(self.clone());
|
||||
}
|
||||
|
||||
fn node_on_pointer_focus(&self, seat: &Rc<WlSeatGlobal>) {
|
||||
seat.set_known_cursor(KnownCursor::Default);
|
||||
}
|
||||
}
|
||||
|
||||
impl ToplevelNode for Xwindow {
|
||||
tl_node_impl!();
|
||||
|
||||
fn tl_data(&self) -> &ToplevelData {
|
||||
&self.toplevel_data
|
||||
}
|
||||
|
||||
fn tl_default_focus_child(&self) -> Option<Rc<dyn Node>> {
|
||||
Some(self.surface.clone())
|
||||
}
|
||||
|
||||
fn tl_accepts_keyboard_focus(&self) -> bool {
|
||||
self.data.info.never_focus.get().not()
|
||||
&& self.data.info.input_model.get() != XInputModel::None
|
||||
}
|
||||
|
||||
fn tl_set_active(&self, active: bool) {
|
||||
if let Some(pn) = self.parent_node.get() {
|
||||
pn.node_child_active_changed(self, active, 1);
|
||||
}
|
||||
}
|
||||
|
||||
fn tl_on_activate(&self) {
|
||||
self.data
|
||||
.state
|
||||
.xwayland
|
||||
.queue
|
||||
.push(XWaylandEvent::Activate(self.data.clone()));
|
||||
}
|
||||
|
||||
fn tl_change_extents(self: Rc<Self>, rect: &Rect) {
|
||||
// log::info!("xwin {} change_extents {:?}", self.data.window_id, rect);
|
||||
let old = self.data.info.extents.replace(*rect);
|
||||
if old != *rect {
|
||||
|
|
@ -445,111 +446,28 @@ impl SizedNode for Xwindow {
|
|||
}
|
||||
}
|
||||
|
||||
fn set_workspace(self: &Rc<Self>, ws: &Rc<WorkspaceNode>) {
|
||||
self.workspace.set(Some(ws.clone()));
|
||||
fn tl_close(self: Rc<Self>) {
|
||||
self.data
|
||||
.state
|
||||
.xwayland
|
||||
.queue
|
||||
.push(XWaylandEvent::Close(self.data.clone()));
|
||||
}
|
||||
|
||||
fn set_parent(self: &Rc<Self>, parent: Rc<dyn Node>) {
|
||||
self.toplevel_data.is_floating.set(parent.node_is_float());
|
||||
self.parent_node.set(Some(parent));
|
||||
self.notify_parent();
|
||||
fn tl_set_visible(&self, visible: bool) {
|
||||
self.surface.set_visible(visible);
|
||||
self.seat_state.set_visible(self, visible);
|
||||
}
|
||||
|
||||
fn client(&self) -> Option<Rc<Client>> {
|
||||
Some(self.data.client.clone())
|
||||
}
|
||||
|
||||
fn toggle_floating(self: &Rc<Self>, _seat: &Rc<WlSeatGlobal>) {
|
||||
let parent = match self.parent_node.get() {
|
||||
Some(p) => p,
|
||||
_ => return,
|
||||
};
|
||||
if parent.node_is_float() {
|
||||
parent.node_remove_child2(self.deref(), true);
|
||||
self.data.state.map_tiled(self.clone());
|
||||
} else if let Some(ws) = self.workspace.get() {
|
||||
parent.node_remove_child2(self.deref(), true);
|
||||
let (width, height) = self.toplevel_data.float_size(&ws);
|
||||
self.data
|
||||
.state
|
||||
.map_floating(self.clone(), width, height, &ws);
|
||||
}
|
||||
fn tl_destroy(&self) {
|
||||
self.toplevel_data.destroy_node(self);
|
||||
self.display_link.borrow_mut().take();
|
||||
self.surface.destroy_node();
|
||||
}
|
||||
}
|
||||
|
||||
impl SizedToplevelNode for Xwindow {
|
||||
fn data(&self) -> &ToplevelData {
|
||||
&self.toplevel_data
|
||||
}
|
||||
|
||||
fn accepts_keyboard_focus(&self) -> bool {
|
||||
self.data.info.never_focus.get().not()
|
||||
&& self.data.info.input_model.get() != XInputModel::None
|
||||
}
|
||||
|
||||
fn default_surface(&self) -> Option<Rc<WlSurface>> {
|
||||
Some(self.surface.clone())
|
||||
}
|
||||
|
||||
fn set_active(&self, active: bool) {
|
||||
if let Some(pn) = self.parent_node.get() {
|
||||
pn.node_child_active_changed(self, active, 1);
|
||||
}
|
||||
}
|
||||
|
||||
fn activate(&self) {
|
||||
self.data
|
||||
.state
|
||||
.xwayland
|
||||
.queue
|
||||
.push(XWaylandEvent::Activate(self.data.clone()));
|
||||
}
|
||||
|
||||
fn set_fullscreen(self: &Rc<Self>, fullscreen: bool) {
|
||||
if fullscreen {
|
||||
if let Some(ws) = self.workspace.get() {
|
||||
self.fullscreen_data.set_fullscreen(
|
||||
&self.data.state,
|
||||
self.clone(),
|
||||
&ws.output.get(),
|
||||
);
|
||||
}
|
||||
} else {
|
||||
self.fullscreen_data
|
||||
.unset_fullscreen(&self.data.state, self.clone());
|
||||
}
|
||||
}
|
||||
|
||||
fn fullscreen(&self) -> bool {
|
||||
self.fullscreen_data.is_fullscreen.get()
|
||||
}
|
||||
}
|
||||
|
||||
impl SizedFullscreenNode for Xwindow {
|
||||
fn on_set_fullscreen(&self, _workspace: &Rc<WorkspaceNode>) {
|
||||
self.data
|
||||
.state
|
||||
.xwayland
|
||||
.queue
|
||||
.push(XWaylandEvent::SetFullscreen(self.data.clone(), true));
|
||||
}
|
||||
|
||||
fn on_unset_fullscreen(&self) {
|
||||
self.data
|
||||
.state
|
||||
.xwayland
|
||||
.queue
|
||||
.push(XWaylandEvent::SetFullscreen(self.data.clone(), false));
|
||||
}
|
||||
|
||||
fn title(&self) -> String {
|
||||
self.data
|
||||
.info
|
||||
.title
|
||||
.borrow_mut()
|
||||
.clone()
|
||||
.unwrap_or_default()
|
||||
}
|
||||
impl StackedNode for Xwindow {
|
||||
stacked_node_impl!();
|
||||
}
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ use {
|
|||
object::Object,
|
||||
rect::Rect,
|
||||
render::Renderer,
|
||||
tree::{FindTreeResult, FoundNode, Node, NodeId, NodeVisitor, OutputNode, SizedNode},
|
||||
tree::{FindTreeResult, FoundNode, Node, NodeId, NodeVisitor, OutputNode},
|
||||
utils::{
|
||||
bitflags::BitflagsExt,
|
||||
buffd::{MsgParser, MsgParserError},
|
||||
|
|
@ -198,7 +198,7 @@ impl ZwlrLayerSurfaceV1 {
|
|||
|
||||
fn destroy(&self, parser: MsgParser<'_, '_>) -> Result<(), DestroyError> {
|
||||
let _req: Destroy = self.client.parse(self, parser)?;
|
||||
self.node_destroy(true);
|
||||
self.destroy_node();
|
||||
self.client.remove_obj(self)?;
|
||||
self.surface.unset_ext();
|
||||
Ok(())
|
||||
|
|
@ -272,7 +272,7 @@ impl ZwlrLayerSurfaceV1 {
|
|||
self.pos.get()
|
||||
}
|
||||
|
||||
fn compute_position(&self) {
|
||||
pub fn compute_position(&self) {
|
||||
let (width, height) = self.size.get();
|
||||
let mut anchor = self.anchor.get();
|
||||
if anchor == 0 {
|
||||
|
|
@ -301,6 +301,13 @@ impl ZwlrLayerSurfaceV1 {
|
|||
self.surface.set_absolute_position(x1, y1);
|
||||
self.client.state.tree_changed();
|
||||
}
|
||||
|
||||
pub fn destroy_node(&self) {
|
||||
self.link.set(None);
|
||||
self.mapped.set(false);
|
||||
self.surface.destroy_node();
|
||||
self.seat_state.destroy_node(self);
|
||||
}
|
||||
}
|
||||
|
||||
impl SurfaceExt for ZwlrLayerSurfaceV1 {
|
||||
|
|
@ -313,7 +320,7 @@ impl SurfaceExt for ZwlrLayerSurfaceV1 {
|
|||
let buffer = self.surface.buffer.get();
|
||||
if self.mapped.get() {
|
||||
if buffer.is_none() {
|
||||
self.node_destroy(true);
|
||||
self.destroy_node();
|
||||
} else {
|
||||
let pos = self.pos.get();
|
||||
let (width, height) = self.size.get();
|
||||
|
|
@ -353,53 +360,38 @@ impl SurfaceExt for ZwlrLayerSurfaceV1 {
|
|||
}
|
||||
}
|
||||
|
||||
impl SizedNode for ZwlrLayerSurfaceV1 {
|
||||
fn id(&self) -> NodeId {
|
||||
impl Node for ZwlrLayerSurfaceV1 {
|
||||
fn node_id(&self) -> NodeId {
|
||||
self.node_id.into()
|
||||
}
|
||||
|
||||
fn seat_state(&self) -> &NodeSeatState {
|
||||
fn node_seat_state(&self) -> &NodeSeatState {
|
||||
&self.seat_state
|
||||
}
|
||||
|
||||
fn destroy_node(&self, _detach: bool) {
|
||||
self.link.set(None);
|
||||
self.mapped.set(false);
|
||||
self.surface.node_destroy(false);
|
||||
self.seat_state.destroy_node(self);
|
||||
fn node_visit(self: Rc<Self>, visitor: &mut dyn NodeVisitor) {
|
||||
visitor.visit_layer_surface(&self);
|
||||
}
|
||||
|
||||
fn visit(self: &Rc<Self>, visitor: &mut dyn NodeVisitor) {
|
||||
visitor.visit_layer_surface(self);
|
||||
fn node_visit_children(&self, visitor: &mut dyn NodeVisitor) {
|
||||
visitor.visit_surface(&self.surface);
|
||||
}
|
||||
|
||||
fn visit_children(&self, visitor: &mut dyn NodeVisitor) {
|
||||
self.surface.visit(visitor);
|
||||
}
|
||||
|
||||
fn visible(&self) -> bool {
|
||||
fn node_visible(&self) -> bool {
|
||||
true
|
||||
}
|
||||
|
||||
fn parent(&self) -> Option<Rc<dyn Node>> {
|
||||
Some(self.output.clone())
|
||||
}
|
||||
|
||||
fn absolute_position(&self) -> Rect {
|
||||
fn node_absolute_position(&self) -> Rect {
|
||||
self.pos.get()
|
||||
}
|
||||
|
||||
fn find_tree_at(&self, x: i32, y: i32, tree: &mut Vec<FoundNode>) -> FindTreeResult {
|
||||
fn node_find_tree_at(&self, x: i32, y: i32, tree: &mut Vec<FoundNode>) -> FindTreeResult {
|
||||
self.surface.find_tree_at_(x, y, tree)
|
||||
}
|
||||
|
||||
fn render(&self, renderer: &mut Renderer, x: i32, y: i32) {
|
||||
fn node_render(&self, renderer: &mut Renderer, x: i32, y: i32) {
|
||||
renderer.render_layer_surface(self, x, y);
|
||||
}
|
||||
|
||||
fn change_extents(self: &Rc<Self>, _rect: &Rect) {
|
||||
self.compute_position();
|
||||
}
|
||||
}
|
||||
|
||||
object_base! {
|
||||
|
|
@ -426,7 +418,7 @@ impl Object for ZwlrLayerSurfaceV1 {
|
|||
}
|
||||
|
||||
fn break_loops(&self) {
|
||||
self.node_destroy(true);
|
||||
self.destroy_node();
|
||||
self.link.set(None);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue