autocommit 2022-04-12 17:26:33 CEST
This commit is contained in:
parent
d9d1addbf5
commit
8924936079
26 changed files with 896 additions and 543 deletions
|
|
@ -127,10 +127,7 @@ pub fn configure() {
|
|||
{
|
||||
let time_format: Vec<_> = StrftimeItems::new("%Y-%m-%d %H:%M:%S").collect();
|
||||
let update_status = move || {
|
||||
let status = format!(
|
||||
"{}",
|
||||
Local::now().format_with_items(time_format.iter()),
|
||||
);
|
||||
let status = format!("{}", Local::now().format_with_items(time_format.iter()),);
|
||||
set_status(&status);
|
||||
};
|
||||
update_status();
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ use {
|
|||
xdg_wm_base::XdgWmBase,
|
||||
},
|
||||
object::{Object, ObjectId},
|
||||
tree::Node,
|
||||
tree::SizedNode,
|
||||
utils::{
|
||||
clonecell::CloneCell,
|
||||
copyhashmap::{CopyHashMap, Locked},
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
use uapi::c;
|
||||
use {
|
||||
crate::{
|
||||
acceptor::{Acceptor, AcceptorError},
|
||||
|
|
@ -25,8 +24,8 @@ use {
|
|||
NodeIds, OutputNode, WorkspaceNode,
|
||||
},
|
||||
utils::{
|
||||
clonecell::CloneCell, errorfmt::ErrorFmt, fdcloser::FdCloser, queue::AsyncQueue,
|
||||
run_toplevel::RunToplevel,
|
||||
clonecell::CloneCell, errorfmt::ErrorFmt, fdcloser::FdCloser, oserror::OsError,
|
||||
queue::AsyncQueue, run_toplevel::RunToplevel, tri::Try,
|
||||
},
|
||||
wheel::{Wheel, WheelError},
|
||||
xkbcommon::XkbContext,
|
||||
|
|
@ -35,9 +34,8 @@ use {
|
|||
forker::ForkerProxy,
|
||||
std::{cell::Cell, ops::Deref, rc::Rc, sync::Arc},
|
||||
thiserror::Error,
|
||||
uapi::c,
|
||||
};
|
||||
use crate::utils::oserror::OsError;
|
||||
use crate::utils::tri::Try;
|
||||
|
||||
pub const MAX_EXTENTS: i32 = (1 << 24) - 1;
|
||||
|
||||
|
|
@ -177,8 +175,6 @@ fn main_(forker: Rc<ForkerProxy>, logger: Arc<Logger>, _args: &RunArgs) -> Resul
|
|||
state.dummy_output.set(Some(dummy_output));
|
||||
}
|
||||
forker.install(&state);
|
||||
let config = ConfigProxy::default(&state);
|
||||
state.config.set(Some(Rc::new(config)));
|
||||
let _global_event_handler = engine.spawn(tasks::handle_backend_events(state.clone()));
|
||||
let _slow_client_handler = engine.spawn(tasks::handle_slow_clients(state.clone()));
|
||||
let _container_do_layout = engine.spawn2(Phase::Layout, container_layout(state.clone()));
|
||||
|
|
@ -191,6 +187,8 @@ fn main_(forker: Rc<ForkerProxy>, logger: Arc<Logger>, _args: &RunArgs) -> Resul
|
|||
forker.setenv(b"_JAVA_AWT_WM_NONREPARENTING", b"1");
|
||||
let _xwayland = engine.spawn(xwayland::manage(state.clone()));
|
||||
let _backend = engine.spawn(tasks::start_backend(state.clone()));
|
||||
let config = ConfigProxy::default(&state);
|
||||
state.config.set(Some(Rc::new(config)));
|
||||
el.run()?;
|
||||
drop(_xwayland);
|
||||
state.clients.clear();
|
||||
|
|
@ -205,7 +203,11 @@ fn init_fd_limit() {
|
|||
let res = OsError::tri(|| {
|
||||
let mut cur = uapi::getrlimit(c::RLIMIT_NOFILE as _)?;
|
||||
if cur.rlim_cur < cur.rlim_max {
|
||||
log::info!("Increasing file descriptor limit from {} to {}", cur.rlim_cur, cur.rlim_max);
|
||||
log::info!(
|
||||
"Increasing file descriptor limit from {} to {}",
|
||||
cur.rlim_cur,
|
||||
cur.rlim_max
|
||||
);
|
||||
cur.rlim_cur = cur.rlim_max;
|
||||
uapi::setrlimit(c::RLIMIT_NOFILE as _, &cur)?;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ use {
|
|||
compositor::MAX_EXTENTS,
|
||||
ifs::wl_seat::{SeatId, WlSeatGlobal},
|
||||
state::{ConnectorData, DeviceHandlerData, OutputData, State},
|
||||
tree::{ContainerNode, ContainerSplit, FloatNode, Node, NodeVisitorBase},
|
||||
tree::{ContainerNode, ContainerSplit, FloatNode, NodeVisitorBase, SizedNode},
|
||||
utils::{
|
||||
copyhashmap::CopyHashMap, debug_fn::debug_fn, errorfmt::ErrorFmt, numcell::NumCell,
|
||||
stack::Stack,
|
||||
|
|
|
|||
|
|
@ -240,31 +240,31 @@ impl WlSeatGlobal {
|
|||
}
|
||||
|
||||
pub fn get_mono(&self) -> Option<bool> {
|
||||
self.keyboard_node.get().get_parent_mono()
|
||||
self.keyboard_node.get().node_get_parent_mono()
|
||||
}
|
||||
|
||||
pub fn get_split(&self) -> Option<ContainerSplit> {
|
||||
self.keyboard_node.get().get_parent_split()
|
||||
self.keyboard_node.get().node_get_parent_split()
|
||||
}
|
||||
|
||||
pub fn set_mono(&self, mono: bool) {
|
||||
self.keyboard_node.get().set_parent_mono(mono)
|
||||
self.keyboard_node.get().node_set_parent_mono(mono)
|
||||
}
|
||||
|
||||
pub fn set_split(&self, axis: ContainerSplit) {
|
||||
self.keyboard_node.get().set_parent_split(axis)
|
||||
self.keyboard_node.get().node_set_parent_split(axis)
|
||||
}
|
||||
|
||||
pub fn create_split(&self, axis: ContainerSplit) {
|
||||
self.keyboard_node.get().create_split(axis)
|
||||
self.keyboard_node.get().node_create_split(axis)
|
||||
}
|
||||
|
||||
pub fn focus_parent(self: &Rc<Self>) {
|
||||
self.keyboard_node.get().focus_parent(self);
|
||||
self.keyboard_node.get().node_focus_parent(self);
|
||||
}
|
||||
|
||||
pub fn toggle_floating(self: &Rc<Self>) {
|
||||
self.keyboard_node.get().toggle_floating(self);
|
||||
self.keyboard_node.get().node_toggle_floating(self);
|
||||
}
|
||||
|
||||
pub fn get_rate(&self) -> (i32, i32) {
|
||||
|
|
@ -288,17 +288,17 @@ impl WlSeatGlobal {
|
|||
|
||||
pub fn close(self: &Rc<Self>) {
|
||||
let kb_node = self.keyboard_node.get();
|
||||
kb_node.close();
|
||||
kb_node.node_close();
|
||||
}
|
||||
|
||||
pub fn move_focus(self: &Rc<Self>, direction: Direction) {
|
||||
let kb_node = self.keyboard_node.get();
|
||||
kb_node.move_focus(self, direction);
|
||||
kb_node.node_move_focus(self, direction);
|
||||
}
|
||||
|
||||
pub fn move_focused(self: &Rc<Self>, direction: Direction) {
|
||||
let kb_node = self.keyboard_node.get();
|
||||
kb_node.move_self(direction);
|
||||
kb_node.node_move_self(direction);
|
||||
}
|
||||
|
||||
fn set_selection_<T: ipc::Vtable>(
|
||||
|
|
@ -312,7 +312,7 @@ impl WlSeatGlobal {
|
|||
if let Some(old) = field.set(src.clone()) {
|
||||
ipc::detach_seat::<T>(&old);
|
||||
}
|
||||
if let Some(client) = self.keyboard_node.get().client() {
|
||||
if let Some(client) = self.keyboard_node.get().node_client() {
|
||||
match src {
|
||||
Some(src) => ipc::offer_source_to::<T>(&src, &client),
|
||||
_ => T::for_each_device(self, client.id, |device| {
|
||||
|
|
|
|||
|
|
@ -118,18 +118,18 @@ impl NodeSeatState {
|
|||
while let Some((_, seat)) = self.grabs.pop() {
|
||||
seat.pointer_owner.revert_to_default(&seat);
|
||||
}
|
||||
let node_id = node.id();
|
||||
let node_id = node.node_id();
|
||||
while let Some((_, seat)) = self.dnd_targets.pop() {
|
||||
seat.pointer_owner.dnd_target_removed(&seat);
|
||||
}
|
||||
while let Some((_, seat)) = self.pointer_foci.pop() {
|
||||
let mut ps = seat.pointer_stack.borrow_mut();
|
||||
while let Some(last) = ps.pop() {
|
||||
if last.id() == node_id {
|
||||
if last.node_id() == node_id {
|
||||
break;
|
||||
}
|
||||
last.seat_state().leave(&seat);
|
||||
last.leave(&seat);
|
||||
last.node_seat_state().leave(&seat);
|
||||
last.node_leave(&seat);
|
||||
}
|
||||
seat.state.tree_changed();
|
||||
}
|
||||
|
|
@ -139,7 +139,7 @@ impl NodeSeatState {
|
|||
pub fn set_visible(&self, node: &dyn Node, visible: bool) {
|
||||
if !visible {
|
||||
if !self.kb_foci.is_empty() {
|
||||
node.active_changed(false);
|
||||
node.node_active_changed(false);
|
||||
}
|
||||
self.destroy_node2(node, false);
|
||||
}
|
||||
|
|
@ -251,14 +251,14 @@ impl WlSeatGlobal {
|
|||
}
|
||||
let node = self.keyboard_node.get();
|
||||
if shortcuts.is_empty() {
|
||||
node.key(self, key, state);
|
||||
node.node_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.mods(self, mods);
|
||||
node.node_mods(self, mods);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -273,17 +273,19 @@ impl WlSeatGlobal {
|
|||
Some(ws) => ws,
|
||||
_ => return None,
|
||||
};
|
||||
let is_container = new.is_container();
|
||||
let is_container = new.node_is_container();
|
||||
for tl in self.toplevel_focus_history.rev_iter() {
|
||||
match tl.as_node().get_workspace() {
|
||||
match tl.as_node().node_get_workspace() {
|
||||
Some(ws) if ws.id == workspace.id => {}
|
||||
_ => continue,
|
||||
};
|
||||
let parent_is_float = match tl.parent() {
|
||||
Some(pn) => pn.is_float(),
|
||||
Some(pn) => pn.node_is_float(),
|
||||
_ => false,
|
||||
};
|
||||
if !parent_is_float && (!is_container || !tl.as_node().is_contained_in(new.id())) {
|
||||
if !parent_is_float
|
||||
&& (!is_container || !tl.as_node().node_is_contained_in(new.node_id()))
|
||||
{
|
||||
return Some(tl.deref().clone());
|
||||
}
|
||||
}
|
||||
|
|
@ -561,7 +563,7 @@ impl WlSeatGlobal {
|
|||
k.send_modifiers(serial, mods_depressed, mods_latched, mods_locked, group)
|
||||
});
|
||||
|
||||
if self.keyboard_node.get().client_id() != Some(surface.client.id) {
|
||||
if self.keyboard_node.get().node_client_id() != Some(surface.client.id) {
|
||||
self.offer_selection::<WlDataDevice>(&self.selection, &surface.client);
|
||||
self.offer_selection::<ZwpPrimarySelectionDeviceV1>(
|
||||
&self.primary_selection,
|
||||
|
|
|
|||
|
|
@ -63,18 +63,18 @@ impl KbOwner for DefaultKbOwner {
|
|||
|
||||
fn set_kb_node(&self, seat: &Rc<WlSeatGlobal>, node: Rc<dyn Node>) {
|
||||
let old = seat.keyboard_node.get();
|
||||
if old.id() == node.id() {
|
||||
if old.node_id() == node.node_id() {
|
||||
return;
|
||||
}
|
||||
old.unfocus(seat);
|
||||
if old.seat_state().unfocus(seat) {
|
||||
old.active_changed(false);
|
||||
old.node_unfocus(seat);
|
||||
if old.node_seat_state().unfocus(seat) {
|
||||
old.node_active_changed(false);
|
||||
}
|
||||
|
||||
if node.seat_state().focus(seat) {
|
||||
node.active_changed(true);
|
||||
if node.node_seat_state().focus(seat) {
|
||||
node.node_active_changed(true);
|
||||
}
|
||||
node.clone().focus(seat);
|
||||
node.clone().node_focus(seat);
|
||||
seat.keyboard_node.set(node.clone());
|
||||
}
|
||||
|
||||
|
|
@ -84,7 +84,7 @@ impl KbOwner for DefaultKbOwner {
|
|||
_ => return,
|
||||
};
|
||||
let node = seat.keyboard_node.get();
|
||||
let ws = match node.get_workspace() {
|
||||
let ws = match node.node_get_workspace() {
|
||||
None => return,
|
||||
Some(ws) => ws,
|
||||
};
|
||||
|
|
@ -93,7 +93,7 @@ impl KbOwner for DefaultKbOwner {
|
|||
return;
|
||||
}
|
||||
for tl in seat.toplevel_focus_history.rev_iter() {
|
||||
if let Some(tl_ws) = tl.as_node().get_workspace() {
|
||||
if let Some(tl_ws) = tl.as_node().node_get_workspace() {
|
||||
if tl_ws.id == new_ws.id {
|
||||
self.set_kb_node(seat, tl.deref().clone().into_node());
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ use {
|
|||
wl_seat::{wl_pointer::PendingScroll, Dnd, DroppedDnd, WlSeatError, WlSeatGlobal},
|
||||
wl_surface::WlSurface,
|
||||
},
|
||||
tree::{FoundNode, Node},
|
||||
tree::{FoundNode, Node, SizedNode},
|
||||
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.axis_event(seat, &pending);
|
||||
node.node_axis_event(seat, &pending);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -140,8 +140,8 @@ impl PointerOwner for DefaultPointerOwner {
|
|||
buttons: SmallMap::new_with(button, ()),
|
||||
node: pn.clone(),
|
||||
}));
|
||||
pn.seat_state().add_pointer_grab(seat);
|
||||
pn.button(seat, button, state);
|
||||
pn.node_seat_state().add_pointer_grab(seat);
|
||||
pn.node_button(seat, button, state);
|
||||
}
|
||||
|
||||
fn axis_node(&self, seat: &Rc<WlSeatGlobal>) -> Option<Rc<dyn Node>> {
|
||||
|
|
@ -159,17 +159,19 @@ impl PointerOwner for DefaultPointerOwner {
|
|||
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 mut divergence = found_tree.len().min(stack.len());
|
||||
for (i, (found, stack)) in found_tree.iter().zip(stack.iter()).enumerate() {
|
||||
if found.node.id() != stack.id() {
|
||||
if found.node.node_id() != stack.node_id() {
|
||||
divergence = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (stack.len(), found_tree.len()) == (divergence, divergence) {
|
||||
if let Some(node) = found_tree.last() {
|
||||
node.node.clone().pointer_motion(
|
||||
node.node.clone().node_pointer_motion(
|
||||
seat,
|
||||
x.apply_fract(node.x),
|
||||
y.apply_fract(node.y),
|
||||
|
|
@ -177,15 +179,15 @@ impl PointerOwner for DefaultPointerOwner {
|
|||
}
|
||||
} else {
|
||||
if let Some(last) = stack.last() {
|
||||
last.pointer_unfocus(seat);
|
||||
last.node_pointer_unfocus(seat);
|
||||
}
|
||||
for old in stack.drain(divergence..).rev() {
|
||||
old.leave(seat);
|
||||
old.seat_state().leave(seat);
|
||||
old.node_leave(seat);
|
||||
old.node_seat_state().leave(seat);
|
||||
}
|
||||
if found_tree.len() == divergence {
|
||||
if let Some(node) = found_tree.last() {
|
||||
node.node.clone().pointer_motion(
|
||||
node.node.clone().node_pointer_motion(
|
||||
seat,
|
||||
x.apply_fract(node.x),
|
||||
y.apply_fract(node.y),
|
||||
|
|
@ -193,8 +195,8 @@ impl PointerOwner for DefaultPointerOwner {
|
|||
}
|
||||
} else {
|
||||
for new in found_tree.drain(divergence..) {
|
||||
new.node.seat_state().enter(seat);
|
||||
new.node.clone().pointer_enter(
|
||||
new.node.node_seat_state().enter(seat);
|
||||
new.node.clone().node_pointer_enter(
|
||||
seat,
|
||||
x.apply_fract(new.x),
|
||||
y.apply_fract(new.y),
|
||||
|
|
@ -203,7 +205,7 @@ impl PointerOwner for DefaultPointerOwner {
|
|||
}
|
||||
}
|
||||
if let Some(node) = stack.last() {
|
||||
node.pointer_focus(seat);
|
||||
node.node_pointer_focus(seat);
|
||||
}
|
||||
}
|
||||
found_tree.clear();
|
||||
|
|
@ -249,7 +251,7 @@ impl PointerOwner for GrabPointerOwner {
|
|||
KeyState::Released => {
|
||||
self.buttons.remove(&button);
|
||||
if self.buttons.is_empty() {
|
||||
self.node.seat_state().remove_pointer_grab(seat);
|
||||
self.node.node_seat_state().remove_pointer_grab(seat);
|
||||
seat.tree_changed.trigger();
|
||||
seat.pointer_owner
|
||||
.owner
|
||||
|
|
@ -260,7 +262,7 @@ impl PointerOwner for GrabPointerOwner {
|
|||
self.buttons.insert(button, ());
|
||||
}
|
||||
}
|
||||
self.node.clone().button(seat, button, state);
|
||||
self.node.clone().node_button(seat, button, state);
|
||||
}
|
||||
|
||||
fn axis_node(&self, _seat: &Rc<WlSeatGlobal>) -> Option<Rc<dyn Node>> {
|
||||
|
|
@ -269,11 +271,11 @@ impl PointerOwner for GrabPointerOwner {
|
|||
|
||||
fn handle_pointer_position(&self, seat: &Rc<WlSeatGlobal>) {
|
||||
let (x, y) = seat.pos.get();
|
||||
let pos = self.node.absolute_position();
|
||||
let pos = self.node.node_absolute_position();
|
||||
let (x_int, y_int) = pos.translate(x.round_down(), y.round_down());
|
||||
self.node
|
||||
.clone()
|
||||
.pointer_motion(seat, x.apply_fract(x_int), y.apply_fract(y_int));
|
||||
.node_pointer_motion(seat, x.apply_fract(x_int), y.apply_fract(y_int));
|
||||
}
|
||||
|
||||
fn start_drag(
|
||||
|
|
@ -290,7 +292,7 @@ impl PointerOwner for GrabPointerOwner {
|
|||
if self.buttons.len() != 1 {
|
||||
return Ok(());
|
||||
}
|
||||
if self.node.id() != origin.node_id {
|
||||
if self.node.node_id() != origin.node_id {
|
||||
return Ok(());
|
||||
}
|
||||
if let Some(icon) = &icon {
|
||||
|
|
@ -315,11 +317,11 @@ impl PointerOwner for GrabPointerOwner {
|
|||
{
|
||||
let mut stack = seat.pointer_stack.borrow_mut();
|
||||
for node in stack.drain(1..).rev() {
|
||||
node.leave(seat);
|
||||
node.seat_state().leave(seat);
|
||||
node.node_leave(seat);
|
||||
node.node_seat_state().leave(seat);
|
||||
}
|
||||
}
|
||||
self.node.seat_state().remove_pointer_grab(seat);
|
||||
self.node.node_seat_state().remove_pointer_grab(seat);
|
||||
// {
|
||||
// let old = seat.keyboard_node.set(seat.state.root.clone());
|
||||
// old.seat_state().unfocus(seat);
|
||||
|
|
@ -335,7 +337,7 @@ impl PointerOwner for GrabPointerOwner {
|
|||
}
|
||||
|
||||
fn revert_to_default(&self, seat: &Rc<WlSeatGlobal>) {
|
||||
self.node.seat_state().remove_pointer_grab(seat);
|
||||
self.node.node_seat_state().remove_pointer_grab(seat);
|
||||
seat.pointer_owner
|
||||
.owner
|
||||
.set(seat.pointer_owner.default.clone());
|
||||
|
|
@ -365,13 +367,13 @@ impl PointerOwner for DndPointerOwner {
|
|||
};
|
||||
let target = self.target.get();
|
||||
if should_drop {
|
||||
self.target.get().dnd_drop(&self.dnd);
|
||||
self.target.get().node_dnd_drop(&self.dnd);
|
||||
*seat.dropped_dnd.borrow_mut() = Some(DroppedDnd {
|
||||
dnd: self.dnd.clone(),
|
||||
});
|
||||
}
|
||||
target.dnd_leave(&self.dnd);
|
||||
target.seat_state().remove_dnd_target(seat);
|
||||
target.node_dnd_leave(&self.dnd);
|
||||
target.node_seat_state().remove_dnd_target(seat);
|
||||
if !should_drop {
|
||||
if let Some(src) = &self.dnd.src {
|
||||
ipc::detach_seat::<WlDataDevice>(src);
|
||||
|
|
@ -407,15 +409,15 @@ 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.id() != target.id() {
|
||||
target.dnd_leave(&self.dnd);
|
||||
target.seat_state().remove_dnd_target(seat);
|
||||
if node.node_id() != target.node_id() {
|
||||
target.node_dnd_leave(&self.dnd);
|
||||
target.node_seat_state().remove_dnd_target(seat);
|
||||
target = node;
|
||||
target.dnd_enter(&self.dnd, x, y);
|
||||
target.seat_state().add_dnd_target(seat);
|
||||
target.node_dnd_enter(&self.dnd, x, y);
|
||||
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.dnd_motion(&self.dnd, x, y);
|
||||
node.node_dnd_motion(&self.dnd, x, y);
|
||||
}
|
||||
self.pos_x.set(x);
|
||||
self.pos_y.set(y);
|
||||
|
|
@ -436,8 +438,8 @@ impl PointerOwner for DndPointerOwner {
|
|||
|
||||
fn cancel_dnd(&self, seat: &Rc<WlSeatGlobal>) {
|
||||
let target = self.target.get();
|
||||
target.dnd_leave(&self.dnd);
|
||||
target.seat_state().remove_dnd_target(seat);
|
||||
target.node_dnd_leave(&self.dnd);
|
||||
target.node_seat_state().remove_dnd_target(seat);
|
||||
if let Some(src) = &self.dnd.src {
|
||||
ipc::detach_seat::<WlDataDevice>(src);
|
||||
}
|
||||
|
|
@ -455,7 +457,7 @@ impl PointerOwner for DndPointerOwner {
|
|||
}
|
||||
|
||||
fn dnd_target_removed(&self, seat: &Rc<WlSeatGlobal>) {
|
||||
self.target.get().dnd_leave(&self.dnd);
|
||||
self.target.get().node_dnd_leave(&self.dnd);
|
||||
self.target.set(seat.state.root.clone());
|
||||
seat.state.tree_changed();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -170,7 +170,7 @@ impl WlPointer {
|
|||
return Ok(());
|
||||
}
|
||||
};
|
||||
if pointer_node.client_id() != Some(self.seat.client.id) {
|
||||
if pointer_node.node_client_id() != Some(self.seat.client.id) {
|
||||
return Ok(());
|
||||
}
|
||||
self.seat.global.set_app_cursor(cursor_opt);
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ use {
|
|||
render::Renderer,
|
||||
tree::{
|
||||
ContainerNode, ContainerSplit, FindTreeResult, FoundNode, Node, NodeId, NodeVisitor,
|
||||
ToplevelNode, WorkspaceNode,
|
||||
SizedNode, ToplevelNode, WorkspaceNode,
|
||||
},
|
||||
utils::{
|
||||
buffd::{MsgParser, MsgParserError},
|
||||
|
|
@ -367,7 +367,7 @@ impl WlSurface {
|
|||
self.unset_dnd_icons();
|
||||
self.unset_cursors();
|
||||
self.ext.get().on_surface_destroy()?;
|
||||
self.destroy_node(true);
|
||||
self.node_destroy(true);
|
||||
{
|
||||
let mut children = self.children.borrow_mut();
|
||||
if let Some(children) = &mut *children {
|
||||
|
|
@ -616,7 +616,7 @@ impl Object for WlSurface {
|
|||
fn break_loops(&self) {
|
||||
self.unset_dnd_icons();
|
||||
self.unset_cursors();
|
||||
self.destroy_node(true);
|
||||
self.node_destroy(true);
|
||||
*self.children.borrow_mut() = None;
|
||||
self.unset_ext();
|
||||
mem::take(self.frame_requests.borrow_mut().deref_mut());
|
||||
|
|
@ -628,35 +628,11 @@ impl Object for WlSurface {
|
|||
dedicated_add_obj!(WlSurface, WlSurfaceId, surfaces);
|
||||
|
||||
tree_id!(SurfaceNodeId);
|
||||
impl Node for WlSurface {
|
||||
impl SizedNode for WlSurface {
|
||||
fn id(&self) -> NodeId {
|
||||
self.node_id.into()
|
||||
}
|
||||
|
||||
fn close(&self) {
|
||||
if let Some(tl) = self.toplevel.get() {
|
||||
tl.close();
|
||||
}
|
||||
}
|
||||
|
||||
fn visible(&self) -> bool {
|
||||
self.visible.get()
|
||||
}
|
||||
|
||||
fn set_visible(&self, visible: bool) {
|
||||
self.visible.set(visible);
|
||||
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);
|
||||
}
|
||||
|
||||
fn seat_state(&self) -> &NodeSeatState {
|
||||
&self.seat_state
|
||||
}
|
||||
|
|
@ -665,7 +641,7 @@ impl Node for WlSurface {
|
|||
let children = self.children.borrow();
|
||||
if let Some(ch) = children.deref() {
|
||||
for ss in ch.subsurfaces.values() {
|
||||
ss.surface.destroy_node(false);
|
||||
ss.surface.node_destroy(false);
|
||||
}
|
||||
}
|
||||
if let Some(tl) = self.toplevel.get() {
|
||||
|
|
@ -687,8 +663,8 @@ impl Node for WlSurface {
|
|||
self.seat_state.destroy_node(self);
|
||||
}
|
||||
|
||||
fn 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) {
|
||||
|
|
@ -700,9 +676,27 @@ impl Node for WlSurface {
|
|||
}
|
||||
}
|
||||
|
||||
fn visible(&self) -> bool {
|
||||
self.visible.get()
|
||||
}
|
||||
|
||||
fn set_visible(&self, visible: bool) {
|
||||
self.visible.set(visible);
|
||||
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().get_workspace();
|
||||
return tl.as_node().node_get_workspace();
|
||||
}
|
||||
None
|
||||
}
|
||||
|
|
@ -711,21 +705,21 @@ impl Node for WlSurface {
|
|||
self.toplevel
|
||||
.get()
|
||||
.and_then(|t| t.parent())
|
||||
.and_then(|p| p.get_mono())
|
||||
.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.get_split())
|
||||
.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.set_mono(node)
|
||||
pn.node_set_mono(node)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -733,17 +727,17 @@ impl Node for WlSurface {
|
|||
fn set_parent_split(&self, split: ContainerSplit) {
|
||||
if let Some(tl) = self.toplevel.get() {
|
||||
if let Some(pn) = tl.parent() {
|
||||
pn.set_split(split);
|
||||
pn.node_set_split(split);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn create_split(self: Rc<Self>, split: ContainerSplit) {
|
||||
fn create_split(self: &Rc<Self>, split: ContainerSplit) {
|
||||
let tl = match self.toplevel.get() {
|
||||
Some(tl) => tl,
|
||||
_ => return,
|
||||
};
|
||||
let ws = match tl.as_node().get_workspace() {
|
||||
let ws = match tl.as_node().node_get_workspace() {
|
||||
Some(ws) => ws,
|
||||
_ => return,
|
||||
};
|
||||
|
|
@ -758,21 +752,27 @@ impl Node for WlSurface {
|
|||
tl.clone().into_node(),
|
||||
split,
|
||||
);
|
||||
pn.replace_child(tl.as_node(), cn);
|
||||
pn.node_replace_child(tl.as_node(), cn);
|
||||
}
|
||||
|
||||
fn move_focus(self: Rc<Self>, seat: &Rc<WlSeatGlobal>, direction: Direction) {
|
||||
fn close(&self) {
|
||||
if let Some(tl) = self.toplevel.get() {
|
||||
tl.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.move_focus_from_child(seat, tl.as_node(), direction);
|
||||
pn.node_move_focus_from_child(seat, tl.as_node(), direction);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn move_self(self: Rc<Self>, direction: Direction) {
|
||||
fn move_self(self: &Rc<Self>, direction: Direction) {
|
||||
if let Some(tl) = self.toplevel.get() {
|
||||
if let Some(pn) = tl.parent() {
|
||||
pn.move_child(tl.into_node(), direction);
|
||||
pn.node_move_child(tl.into_node(), direction);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -795,15 +795,15 @@ impl Node for WlSurface {
|
|||
seat.mods_surface(self, mods);
|
||||
}
|
||||
|
||||
fn button(self: Rc<Self>, seat: &Rc<WlSeatGlobal>, button: u32, state: KeyState) {
|
||||
fn button(self: &Rc<Self>, seat: &Rc<WlSeatGlobal>, button: u32, state: KeyState) {
|
||||
seat.button_surface(&self, button, state);
|
||||
}
|
||||
|
||||
fn axis_event(self: Rc<Self>, seat: &WlSeatGlobal, event: &PendingScroll) {
|
||||
fn axis_event(self: &Rc<Self>, seat: &WlSeatGlobal, event: &PendingScroll) {
|
||||
seat.scroll_surface(&*self, event);
|
||||
}
|
||||
|
||||
fn focus(self: Rc<Self>, seat: &Rc<WlSeatGlobal>) {
|
||||
fn 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();
|
||||
|
|
@ -813,11 +813,11 @@ impl Node for WlSurface {
|
|||
|
||||
fn focus_parent(&self, seat: &Rc<WlSeatGlobal>) {
|
||||
if let Some(tl) = self.toplevel.get() {
|
||||
tl.parent().map(|p| p.focus_self(seat));
|
||||
tl.parent().map(|p| p.node_focus_self(seat));
|
||||
}
|
||||
}
|
||||
|
||||
fn toggle_floating(self: Rc<Self>, _seat: &Rc<WlSeatGlobal>) {
|
||||
fn toggle_floating(self: &Rc<Self>, _seat: &Rc<WlSeatGlobal>) {
|
||||
if let Some(tl) = self.toplevel.get() {
|
||||
tl.toggle_floating();
|
||||
}
|
||||
|
|
@ -831,11 +831,11 @@ impl Node for WlSurface {
|
|||
seat.leave_surface(self);
|
||||
}
|
||||
|
||||
fn pointer_enter(self: Rc<Self>, seat: &Rc<WlSeatGlobal>, x: Fixed, y: Fixed) {
|
||||
fn 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 pointer_motion(self: &Rc<Self>, seat: &Rc<WlSeatGlobal>, x: Fixed, y: Fixed) {
|
||||
seat.motion_surface(&*self, x, y)
|
||||
}
|
||||
|
||||
|
|
@ -847,8 +847,8 @@ impl Node for WlSurface {
|
|||
Some(self.client.clone())
|
||||
}
|
||||
|
||||
fn into_surface(self: Rc<Self>) -> Option<Rc<WlSurface>> {
|
||||
Some(self)
|
||||
fn into_surface(self: &Rc<Self>) -> Option<Rc<WlSurface>> {
|
||||
Some(self.clone())
|
||||
}
|
||||
|
||||
fn dnd_drop(&self, dnd: &Dnd) {
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ use {
|
|||
leaks::Tracker,
|
||||
object::Object,
|
||||
rect::Rect,
|
||||
tree::{FindTreeResult, FoundNode, Node, WorkspaceNode},
|
||||
tree::{FindTreeResult, FoundNode, Node, SizedNode, WorkspaceNode},
|
||||
utils::{
|
||||
buffd::{MsgParser, MsgParserError},
|
||||
clonecell::CloneCell,
|
||||
|
|
@ -301,9 +301,9 @@ impl XdgSurface {
|
|||
}
|
||||
|
||||
fn set_visible(&self, visible: bool) {
|
||||
self.surface.set_visible(visible);
|
||||
self.surface.node_set_visible(visible);
|
||||
for popup in self.popups.lock().values() {
|
||||
popup.set_visible(visible);
|
||||
popup.node_set_visible(visible);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ use {
|
|||
object::Object,
|
||||
rect::Rect,
|
||||
render::Renderer,
|
||||
tree::{FindTreeResult, FoundNode, Node, NodeId, NodeVisitor, WorkspaceNode},
|
||||
tree::{FindTreeResult, FoundNode, Node, NodeId, NodeVisitor, SizedNode, WorkspaceNode},
|
||||
utils::{
|
||||
buffd::{MsgParser, MsgParserError},
|
||||
clonecell::CloneCell,
|
||||
|
|
@ -201,7 +201,7 @@ impl XdgPopup {
|
|||
|
||||
fn destroy(&self, parser: MsgParser<'_, '_>) -> Result<(), DestroyError> {
|
||||
let _req: Destroy = self.xdg.surface.client.parse(self, parser)?;
|
||||
self.destroy_node(true);
|
||||
self.node_destroy(true);
|
||||
{
|
||||
if let Some(parent) = self.parent.take() {
|
||||
parent.popups.remove(&self.id);
|
||||
|
|
@ -255,7 +255,7 @@ impl Object for XdgPopup {
|
|||
}
|
||||
|
||||
fn break_loops(&self) {
|
||||
self.destroy_node(true);
|
||||
self.node_destroy(true);
|
||||
self.parent.set(None);
|
||||
*self.display_link.borrow_mut() = None;
|
||||
*self.workspace_link.borrow_mut() = None;
|
||||
|
|
@ -264,7 +264,7 @@ impl Object for XdgPopup {
|
|||
|
||||
simple_add_obj!(XdgPopup);
|
||||
|
||||
impl Node for XdgPopup {
|
||||
impl SizedNode for XdgPopup {
|
||||
fn id(&self) -> NodeId {
|
||||
self.node_id.into()
|
||||
}
|
||||
|
|
@ -280,8 +280,8 @@ impl Node for XdgPopup {
|
|||
self.xdg.seat_state.destroy_node(self);
|
||||
}
|
||||
|
||||
fn 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) {
|
||||
|
|
@ -314,7 +314,7 @@ impl Node for XdgPopup {
|
|||
self.xdg.find_tree_at(x, y, tree)
|
||||
}
|
||||
|
||||
fn pointer_enter(self: Rc<Self>, seat: &Rc<WlSeatGlobal>, _x: Fixed, _y: Fixed) {
|
||||
fn pointer_enter(self: &Rc<Self>, seat: &Rc<WlSeatGlobal>, _x: Fixed, _y: Fixed) {
|
||||
seat.enter_popup(&self);
|
||||
}
|
||||
|
||||
|
|
@ -326,7 +326,7 @@ impl Node for XdgPopup {
|
|||
renderer.render_xdg_surface(&self.xdg, x, y)
|
||||
}
|
||||
|
||||
fn set_workspace(self: Rc<Self>, ws: &Rc<WorkspaceNode>) {
|
||||
fn set_workspace(self: &Rc<Self>, ws: &Rc<WorkspaceNode>) {
|
||||
self.xdg.set_workspace(ws);
|
||||
}
|
||||
|
||||
|
|
@ -363,7 +363,7 @@ impl XdgSurfaceExt for XdgPopup {
|
|||
*wl = Some(ws.stacked.add_last(self.clone()));
|
||||
*dl = Some(state.root.stacked.add_last(self.clone()));
|
||||
state.tree_changed();
|
||||
self.set_visible(
|
||||
self.node_set_visible(
|
||||
self.parent
|
||||
.get()
|
||||
.map(|p| p.surface.visible.get())
|
||||
|
|
@ -374,8 +374,8 @@ impl XdgSurfaceExt for XdgPopup {
|
|||
if wl.take().is_some() {
|
||||
drop(wl);
|
||||
drop(dl);
|
||||
self.set_visible(false);
|
||||
self.destroy_node(true);
|
||||
self.node_set_visible(false);
|
||||
self.node_destroy(true);
|
||||
self.send_popup_done();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,8 +17,8 @@ use {
|
|||
rect::Rect,
|
||||
render::Renderer,
|
||||
tree::{
|
||||
FindTreeResult, FoundNode, Node, NodeId, NodeVisitor, ToplevelData, ToplevelNode,
|
||||
ToplevelNodeId, WorkspaceNode,
|
||||
FindTreeResult, FoundNode, Node, NodeId, NodeVisitor, SizedNode, ToplevelData,
|
||||
ToplevelNode, ToplevelNodeId, WorkspaceNode,
|
||||
},
|
||||
utils::{
|
||||
buffd::{MsgParser, MsgParserError},
|
||||
|
|
@ -160,7 +160,7 @@ impl XdgToplevel {
|
|||
|
||||
fn destroy(self: &Rc<Self>, parser: MsgParser<'_, '_>) -> Result<(), DestroyError> {
|
||||
let _req: Destroy = self.xdg.surface.client.parse(self.deref(), parser)?;
|
||||
self.destroy_node(true);
|
||||
self.node_destroy(true);
|
||||
self.xdg.ext.set(None);
|
||||
{
|
||||
let mut children = self.children.borrow_mut();
|
||||
|
|
@ -202,7 +202,7 @@ impl XdgToplevel {
|
|||
title.clear();
|
||||
title.push_str(req.title);
|
||||
if let Some(parent) = self.parent_node.get() {
|
||||
parent.child_title_changed(self, &title);
|
||||
parent.node_child_title_changed(self, &title);
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
|
@ -222,7 +222,7 @@ impl XdgToplevel {
|
|||
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(float) = parent.into_float() {
|
||||
if let Some(float) = parent.node_into_float() {
|
||||
seat.move_(&float);
|
||||
}
|
||||
}
|
||||
|
|
@ -311,9 +311,9 @@ impl XdgToplevel {
|
|||
let extents = self.xdg.extents.get();
|
||||
parent
|
||||
.clone()
|
||||
.child_active_changed(self, self.toplevel_data.active_surfaces.get() > 0);
|
||||
parent.child_size_changed(self, extents.width(), extents.height());
|
||||
parent.child_title_changed(self, self.title.borrow_mut().deref());
|
||||
.node_child_active_changed(self, self.toplevel_data.active_surfaces.get() > 0);
|
||||
parent.node_child_size_changed(self, extents.width(), extents.height());
|
||||
parent.node_child_title_changed(self, self.title.borrow_mut().deref());
|
||||
}
|
||||
|
||||
fn map_floating(self: &Rc<Self>, workspace: &Rc<WorkspaceNode>) {
|
||||
|
|
@ -360,7 +360,7 @@ impl Object for XdgToplevel {
|
|||
}
|
||||
|
||||
fn break_loops(&self) {
|
||||
self.destroy_node(true);
|
||||
self.node_destroy(true);
|
||||
self.parent.set(None);
|
||||
let _children = mem::take(&mut *self.children.borrow_mut());
|
||||
}
|
||||
|
|
@ -368,15 +368,11 @@ impl Object for XdgToplevel {
|
|||
|
||||
dedicated_add_obj!(XdgToplevel, XdgToplevelId, xdg_toplevel);
|
||||
|
||||
impl Node for XdgToplevel {
|
||||
impl SizedNode for XdgToplevel {
|
||||
fn id(&self) -> NodeId {
|
||||
self.node_id.into()
|
||||
}
|
||||
|
||||
fn close(&self) {
|
||||
self.send_close();
|
||||
}
|
||||
|
||||
fn seat_state(&self) -> &NodeSeatState {
|
||||
&self.xdg.seat_state
|
||||
}
|
||||
|
|
@ -384,7 +380,7 @@ impl Node for XdgToplevel {
|
|||
fn destroy_node(&self, detach: bool) {
|
||||
if let Some(parent) = self.parent_node.take() {
|
||||
if detach {
|
||||
parent.remove_child(self);
|
||||
parent.node_remove_child(self);
|
||||
self.xdg.surface.client.state.tree_changed();
|
||||
}
|
||||
}
|
||||
|
|
@ -393,8 +389,8 @@ impl Node for XdgToplevel {
|
|||
self.xdg.seat_state.destroy_node(self)
|
||||
}
|
||||
|
||||
fn 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) {
|
||||
|
|
@ -416,16 +412,20 @@ impl Node for XdgToplevel {
|
|||
|
||||
fn is_contained_in(&self, other: NodeId) -> bool {
|
||||
if let Some(parent) = self.parent_node.get() {
|
||||
if parent.id() == other {
|
||||
if parent.node_id() == other {
|
||||
return true;
|
||||
}
|
||||
return parent.is_contained_in(other);
|
||||
return parent.node_is_contained_in(other);
|
||||
}
|
||||
false
|
||||
}
|
||||
|
||||
fn do_focus(self: Rc<Self>, seat: &Rc<WlSeatGlobal>, _direction: Direction) {
|
||||
seat.focus_toplevel(self);
|
||||
fn do_focus(self: &Rc<Self>, seat: &Rc<WlSeatGlobal>, _direction: Direction) {
|
||||
seat.focus_toplevel(self.clone());
|
||||
}
|
||||
|
||||
fn close(&self) {
|
||||
self.send_close();
|
||||
}
|
||||
|
||||
fn absolute_position(&self) -> Rect {
|
||||
|
|
@ -436,8 +436,8 @@ impl Node for XdgToplevel {
|
|||
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);
|
||||
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>) {
|
||||
|
|
@ -448,7 +448,7 @@ impl Node for XdgToplevel {
|
|||
renderer.render_xdg_surface(&self.xdg, x, y)
|
||||
}
|
||||
|
||||
fn change_extents(self: Rc<Self>, rect: &Rect) {
|
||||
fn change_extents(self: &Rc<Self>, rect: &Rect) {
|
||||
let nw = rect.width();
|
||||
let nh = rect.height();
|
||||
let de = self.xdg.absolute_desired_extents.get();
|
||||
|
|
@ -460,11 +460,11 @@ impl Node for XdgToplevel {
|
|||
self.xdg.set_absolute_desired_extents(rect);
|
||||
}
|
||||
|
||||
fn set_workspace(self: Rc<Self>, ws: &Rc<WorkspaceNode>) {
|
||||
fn set_workspace(self: &Rc<Self>, ws: &Rc<WorkspaceNode>) {
|
||||
self.xdg.set_workspace(ws);
|
||||
}
|
||||
|
||||
fn set_parent(self: Rc<Self>, parent: Rc<dyn Node>) {
|
||||
fn set_parent(self: &Rc<Self>, parent: Rc<dyn Node>) {
|
||||
self.parent_node.set(Some(parent));
|
||||
self.notify_parent();
|
||||
}
|
||||
|
|
@ -501,7 +501,7 @@ impl ToplevelNode for XdgToplevel {
|
|||
|
||||
fn set_active(&self, active: bool) {
|
||||
if let Some(parent) = self.parent_node.get() {
|
||||
parent.child_active_changed(self, active);
|
||||
parent.node_child_active_changed(self, active);
|
||||
}
|
||||
let changed = {
|
||||
let mut states = self.states.borrow_mut();
|
||||
|
|
@ -526,11 +526,11 @@ impl ToplevelNode for XdgToplevel {
|
|||
Some(p) => p,
|
||||
_ => return,
|
||||
};
|
||||
if parent.is_float() {
|
||||
parent.remove_child(&*self);
|
||||
if parent.node_is_float() {
|
||||
parent.node_remove_child(&*self);
|
||||
self.map_tiled();
|
||||
} else if let Some(ws) = self.xdg.workspace.get() {
|
||||
parent.remove_child(&*self);
|
||||
parent.node_remove_child(&*self);
|
||||
self.map_floating(&ws);
|
||||
}
|
||||
}
|
||||
|
|
@ -550,7 +550,7 @@ impl XdgSurfaceExt for XdgToplevel {
|
|||
let surface = &self.xdg.surface;
|
||||
if let Some(parent) = self.parent_node.get() {
|
||||
if surface.buffer.get().is_none() {
|
||||
parent.remove_child(&*self);
|
||||
parent.node_remove_child(&*self);
|
||||
{
|
||||
let new_parent = self.parent.get();
|
||||
let mut children = self.children.borrow_mut();
|
||||
|
|
|
|||
|
|
@ -11,8 +11,8 @@ use {
|
|||
render::Renderer,
|
||||
state::State,
|
||||
tree::{
|
||||
FindTreeResult, FoundNode, Node, NodeId, NodeVisitor, ToplevelData, ToplevelNode,
|
||||
WorkspaceNode,
|
||||
FindTreeResult, FoundNode, Node, NodeId, NodeVisitor, SizedNode, ToplevelData,
|
||||
ToplevelNode, WorkspaceNode,
|
||||
},
|
||||
utils::{
|
||||
clonecell::CloneCell, copyhashmap::CopyHashMap, linkedlist::LinkedNode,
|
||||
|
|
@ -189,7 +189,7 @@ impl XwindowData {
|
|||
let title = self.info.title.borrow_mut();
|
||||
if let Some(w) = self.window.get() {
|
||||
if let Some(p) = w.parent_node.get() {
|
||||
p.child_title_changed(w.deref(), title.as_deref().unwrap_or(""));
|
||||
p.node_child_title_changed(w.deref(), title.as_deref().unwrap_or(""));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -227,7 +227,7 @@ impl Xwindow {
|
|||
}
|
||||
|
||||
pub fn break_loops(&self) {
|
||||
self.destroy_node(true);
|
||||
self.node_destroy(true);
|
||||
self.surface.set_toplevel(None);
|
||||
}
|
||||
|
||||
|
|
@ -249,7 +249,7 @@ impl Xwindow {
|
|||
let extents = self.surface.extents.get();
|
||||
// let extents = self.xdg.extents.get();
|
||||
// parent.child_active_changed(self, self.active_surfaces.get() > 0);
|
||||
parent.child_size_changed(self, extents.width(), extents.height());
|
||||
parent.node_child_size_changed(self, extents.width(), extents.height());
|
||||
// parent.child_title_changed(self, self.title.borrow_mut().deref());
|
||||
}
|
||||
|
||||
|
|
@ -273,7 +273,7 @@ impl Xwindow {
|
|||
let map_change = self.map_change();
|
||||
match map_change {
|
||||
Change::None => return,
|
||||
Change::Unmap => self.destroy_node(true),
|
||||
Change::Unmap => self.node_destroy(true),
|
||||
Change::Map if self.data.info.override_redirect.get() => {
|
||||
*self.display_link.borrow_mut() =
|
||||
Some(self.data.state.root.stacked.add_last(self.clone()));
|
||||
|
|
@ -293,8 +293,8 @@ impl Xwindow {
|
|||
}
|
||||
}
|
||||
match map_change {
|
||||
Change::Unmap => self.set_visible(false),
|
||||
Change::Map => self.set_visible(true),
|
||||
Change::Unmap => self.node_set_visible(false),
|
||||
Change::Map => self.node_set_visible(true),
|
||||
Change::None => {}
|
||||
}
|
||||
self.data.state.tree_changed();
|
||||
|
|
@ -307,7 +307,7 @@ impl SurfaceExt for Xwindow {
|
|||
}
|
||||
|
||||
fn on_surface_destroy(&self) -> Result<(), WlSurfaceError> {
|
||||
self.destroy_node(true);
|
||||
self.node_destroy(true);
|
||||
self.surface.unset_ext();
|
||||
self.data.window.set(None);
|
||||
self.data.surface_id.set(None);
|
||||
|
|
@ -321,24 +321,11 @@ impl SurfaceExt for Xwindow {
|
|||
}
|
||||
}
|
||||
|
||||
impl Node for Xwindow {
|
||||
impl SizedNode for Xwindow {
|
||||
fn id(&self) -> NodeId {
|
||||
self.id.into()
|
||||
}
|
||||
|
||||
fn close(&self) {
|
||||
self.events.push(XWaylandEvent::Close(self.data.clone()));
|
||||
}
|
||||
|
||||
fn visible(&self) -> bool {
|
||||
self.surface.visible.get()
|
||||
}
|
||||
|
||||
fn set_visible(&self, visible: bool) {
|
||||
self.surface.set_visible(visible);
|
||||
self.seat_state.set_visible(self, visible);
|
||||
}
|
||||
|
||||
fn seat_state(&self) -> &NodeSeatState {
|
||||
&self.seat_state
|
||||
}
|
||||
|
|
@ -349,36 +336,49 @@ impl Node for Xwindow {
|
|||
self.workspace.take();
|
||||
self.focus_history.clear();
|
||||
if let Some(parent) = self.parent_node.take() {
|
||||
parent.remove_child(self);
|
||||
parent.node_remove_child(self);
|
||||
}
|
||||
self.surface.destroy_node(false);
|
||||
self.surface.node_destroy(false);
|
||||
self.seat_state.destroy_node(self);
|
||||
}
|
||||
|
||||
fn 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) {
|
||||
visitor.visit_surface(&self.surface);
|
||||
}
|
||||
|
||||
fn visible(&self) -> bool {
|
||||
self.surface.visible.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 is_contained_in(&self, other: NodeId) -> bool {
|
||||
if let Some(parent) = self.parent_node.get() {
|
||||
if parent.id() == other {
|
||||
if parent.node_id() == other {
|
||||
return true;
|
||||
}
|
||||
return parent.is_contained_in(other);
|
||||
return parent.node_is_contained_in(other);
|
||||
}
|
||||
false
|
||||
}
|
||||
|
||||
fn do_focus(self: Rc<Self>, seat: &Rc<WlSeatGlobal>, _direction: Direction) {
|
||||
seat.focus_toplevel(self);
|
||||
fn do_focus(self: &Rc<Self>, seat: &Rc<WlSeatGlobal>, _direction: Direction) {
|
||||
seat.focus_toplevel(self.clone());
|
||||
}
|
||||
|
||||
fn close(&self) {
|
||||
self.events.push(XWaylandEvent::Close(self.data.clone()));
|
||||
}
|
||||
|
||||
fn absolute_position(&self) -> Rect {
|
||||
|
|
@ -399,8 +399,8 @@ impl Node for Xwindow {
|
|||
FindTreeResult::Other
|
||||
}
|
||||
|
||||
fn pointer_enter(self: Rc<Self>, seat: &Rc<WlSeatGlobal>, _x: Fixed, _y: Fixed) {
|
||||
seat.enter_toplevel(self);
|
||||
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>) {
|
||||
|
|
@ -411,7 +411,7 @@ impl Node for Xwindow {
|
|||
renderer.render_surface(&self.surface, x, y)
|
||||
}
|
||||
|
||||
fn change_extents(self: Rc<Self>, rect: &Rect) {
|
||||
fn change_extents(self: &Rc<Self>, rect: &Rect) {
|
||||
let old = self.data.info.extents.replace(*rect);
|
||||
if old != *rect {
|
||||
self.events.push(XWaylandEvent::Configure(self.clone()));
|
||||
|
|
@ -421,11 +421,11 @@ impl Node for Xwindow {
|
|||
}
|
||||
}
|
||||
|
||||
fn set_workspace(self: Rc<Self>, ws: &Rc<WorkspaceNode>) {
|
||||
fn set_workspace(self: &Rc<Self>, ws: &Rc<WorkspaceNode>) {
|
||||
self.workspace.set(Some(ws.clone()));
|
||||
}
|
||||
|
||||
fn set_parent(self: Rc<Self>, parent: Rc<dyn Node>) {
|
||||
fn set_parent(self: &Rc<Self>, parent: Rc<dyn Node>) {
|
||||
self.parent_node.set(Some(parent));
|
||||
self.notify_parent();
|
||||
}
|
||||
|
|
@ -463,7 +463,7 @@ impl ToplevelNode for Xwindow {
|
|||
|
||||
fn set_active(&self, active: bool) {
|
||||
if let Some(pn) = self.parent_node.get() {
|
||||
pn.child_active_changed(self, active);
|
||||
pn.node_child_active_changed(self, active);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -476,11 +476,11 @@ impl ToplevelNode for Xwindow {
|
|||
Some(p) => p,
|
||||
_ => return,
|
||||
};
|
||||
if parent.is_float() {
|
||||
parent.remove_child(&*self);
|
||||
if parent.node_is_float() {
|
||||
parent.node_remove_child(&*self);
|
||||
self.data.state.map_tiled(self.clone());
|
||||
} else if let Some(ws) = self.workspace.get() {
|
||||
parent.remove_child(&*self);
|
||||
parent.node_remove_child(&*self);
|
||||
let extents = self.data.info.extents.get();
|
||||
self.data
|
||||
.state
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ use {
|
|||
object::Object,
|
||||
rect::Rect,
|
||||
render::Renderer,
|
||||
tree::{FindTreeResult, FoundNode, Node, NodeId, NodeVisitor, OutputNode},
|
||||
tree::{FindTreeResult, FoundNode, Node, NodeId, NodeVisitor, OutputNode, SizedNode},
|
||||
utils::{
|
||||
bitflags::BitflagsExt,
|
||||
buffd::{MsgParser, MsgParserError},
|
||||
|
|
@ -45,6 +45,7 @@ pub struct ZwlrLayerSurfaceV1 {
|
|||
pub output: Rc<OutputNode>,
|
||||
pub namespace: String,
|
||||
pub tracker: Tracker<Self>,
|
||||
output_pos: Cell<Rect>,
|
||||
pos: Cell<Rect>,
|
||||
mapped: Cell<bool>,
|
||||
layer: Cell<u32>,
|
||||
|
|
@ -89,7 +90,8 @@ impl ZwlrLayerSurfaceV1 {
|
|||
output: output.clone(),
|
||||
namespace: namespace.to_string(),
|
||||
tracker: Default::default(),
|
||||
pos: Cell::new(Default::default()),
|
||||
output_pos: Default::default(),
|
||||
pos: Default::default(),
|
||||
mapped: Cell::new(false),
|
||||
layer: Cell::new(layer),
|
||||
pending: Default::default(),
|
||||
|
|
@ -196,7 +198,7 @@ impl ZwlrLayerSurfaceV1 {
|
|||
|
||||
fn destroy(&self, parser: MsgParser<'_, '_>) -> Result<(), DestroyError> {
|
||||
let _req: Destroy = self.client.parse(self, parser)?;
|
||||
self.destroy_node(true);
|
||||
self.node_destroy(true);
|
||||
self.client.remove_obj(self)?;
|
||||
self.surface.unset_ext();
|
||||
Ok(())
|
||||
|
|
@ -262,6 +264,10 @@ impl ZwlrLayerSurfaceV1 {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
pub fn output_position(&self) -> Rect {
|
||||
self.output_pos.get()
|
||||
}
|
||||
|
||||
pub fn position(&self) -> Rect {
|
||||
self.pos.get()
|
||||
}
|
||||
|
|
@ -273,8 +279,8 @@ impl ZwlrLayerSurfaceV1 {
|
|||
anchor = LEFT | RIGHT | TOP | BOTTOM;
|
||||
}
|
||||
let opos = self.output.global.pos.get();
|
||||
let mut x1 = opos.x1();
|
||||
let mut y1 = opos.y1();
|
||||
let mut x1 = 0;
|
||||
let mut y1 = 0;
|
||||
if anchor.contains(LEFT) {
|
||||
if anchor.contains(RIGHT) {
|
||||
x1 += (opos.width() - width) / 2;
|
||||
|
|
@ -289,8 +295,9 @@ impl ZwlrLayerSurfaceV1 {
|
|||
} else if anchor.contains(BOTTOM) {
|
||||
y1 += opos.height() - height;
|
||||
}
|
||||
self.pos
|
||||
.set(Rect::new_sized(x1, y1, width, height).unwrap());
|
||||
let rect = Rect::new_sized(x1, y1, width, height).unwrap();
|
||||
self.output_pos.set(rect);
|
||||
self.pos.set(rect.move_(opos.x1(), opos.y1()));
|
||||
self.surface.set_absolute_position(x1, y1);
|
||||
self.client.state.tree_changed();
|
||||
}
|
||||
|
|
@ -306,7 +313,7 @@ impl SurfaceExt for ZwlrLayerSurfaceV1 {
|
|||
let buffer = self.surface.buffer.get();
|
||||
if self.mapped.get() {
|
||||
if buffer.is_none() {
|
||||
self.destroy_node(true);
|
||||
self.node_destroy(true);
|
||||
} else {
|
||||
let pos = self.pos.get();
|
||||
let (width, height) = self.size.get();
|
||||
|
|
@ -326,7 +333,7 @@ impl SurfaceExt for ZwlrLayerSurfaceV1 {
|
|||
let was_active = self.surface.seat_state.is_active();
|
||||
self.surface.seat_state.release_kb_focus();
|
||||
if was_active {
|
||||
self.surface.active_changed(false);
|
||||
self.surface.node_active_changed(false);
|
||||
}
|
||||
}
|
||||
KI_ON_DEMAND => self.surface.seat_state.release_kb_grab(),
|
||||
|
|
@ -346,7 +353,7 @@ impl SurfaceExt for ZwlrLayerSurfaceV1 {
|
|||
}
|
||||
}
|
||||
|
||||
impl Node for ZwlrLayerSurfaceV1 {
|
||||
impl SizedNode for ZwlrLayerSurfaceV1 {
|
||||
fn id(&self) -> NodeId {
|
||||
self.node_id.into()
|
||||
}
|
||||
|
|
@ -358,16 +365,16 @@ impl Node for ZwlrLayerSurfaceV1 {
|
|||
fn destroy_node(&self, _detach: bool) {
|
||||
self.link.set(None);
|
||||
self.mapped.set(false);
|
||||
self.surface.destroy_node(false);
|
||||
self.surface.node_destroy(false);
|
||||
self.seat_state.destroy_node(self);
|
||||
}
|
||||
|
||||
fn 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 visit_children(&self, visitor: &mut dyn NodeVisitor) {
|
||||
self.surface.clone().visit(visitor);
|
||||
self.surface.clone().node_visit(visitor);
|
||||
}
|
||||
|
||||
fn visible(&self) -> bool {
|
||||
|
|
@ -386,7 +393,7 @@ impl Node for ZwlrLayerSurfaceV1 {
|
|||
renderer.render_layer_surface(self, x, y);
|
||||
}
|
||||
|
||||
fn change_extents(self: Rc<Self>, _rect: &Rect) {
|
||||
fn change_extents(self: &Rc<Self>, _rect: &Rect) {
|
||||
self.compute_position();
|
||||
}
|
||||
}
|
||||
|
|
@ -415,7 +422,7 @@ impl Object for ZwlrLayerSurfaceV1 {
|
|||
}
|
||||
|
||||
fn break_loops(&self) {
|
||||
self.destroy_node(true);
|
||||
self.node_destroy(true);
|
||||
self.link.set(None);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ impl Framebuffer {
|
|||
fb: &self.gl,
|
||||
state,
|
||||
};
|
||||
node.render(&mut renderer, 0, 0);
|
||||
node.node_render(&mut renderer, 0, 0);
|
||||
if let Some(rect) = cursor_rect {
|
||||
let seats = state.globals.lock_seats();
|
||||
for seat in seats.values() {
|
||||
|
|
|
|||
|
|
@ -73,11 +73,11 @@ impl Renderer<'_> {
|
|||
self.render_workspace(&ws, x, y + th);
|
||||
}
|
||||
for stacked in self.state.root.stacked.iter() {
|
||||
if stacked.visible() {
|
||||
let pos = stacked.absolute_position();
|
||||
if stacked.node_visible() {
|
||||
let pos = stacked.node_absolute_position();
|
||||
if pos.intersects(&opos) {
|
||||
let (x, y) = opos.translate(pos.x1(), pos.y1());
|
||||
stacked.render(self, x, y);
|
||||
stacked.node_render(self, x, y);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -161,7 +161,9 @@ impl Renderer<'_> {
|
|||
let body = container.mono_body.get().move_(x, y);
|
||||
with_scissor(&body, || {
|
||||
let content = container.mono_content.get();
|
||||
child.node.render(self, x + content.x1(), y + content.y1());
|
||||
child
|
||||
.node
|
||||
.node_render(self, x + content.x1(), y + content.y1());
|
||||
});
|
||||
}
|
||||
} else {
|
||||
|
|
@ -174,7 +176,9 @@ impl Renderer<'_> {
|
|||
unsafe {
|
||||
with_scissor(&body, || {
|
||||
let content = child.content.get();
|
||||
child.node.render(self, x + content.x1(), y + content.y1());
|
||||
child
|
||||
.node
|
||||
.node_render(self, x + content.x1(), y + content.y1());
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
@ -333,7 +337,7 @@ impl Renderer<'_> {
|
|||
.unwrap();
|
||||
unsafe {
|
||||
with_scissor(&body, || {
|
||||
child.render(self, body.x1(), body.y1());
|
||||
child.node_render(self, body.x1(), body.y1());
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
12
src/state.rs
12
src/state.rs
|
|
@ -118,20 +118,20 @@ impl State {
|
|||
impl NodeVisitorBase for Walker {
|
||||
fn visit_container(&mut self, node: &Rc<ContainerNode>) {
|
||||
node.schedule_compute_render_data();
|
||||
node.visit_children(self);
|
||||
node.node_visit_children(self);
|
||||
}
|
||||
|
||||
fn visit_output(&mut self, node: &Rc<OutputNode>) {
|
||||
node.update_render_data();
|
||||
node.visit_children(self);
|
||||
node.node_visit_children(self);
|
||||
}
|
||||
|
||||
fn visit_float(&mut self, node: &Rc<FloatNode>) {
|
||||
node.schedule_render_titles();
|
||||
node.visit_children(self);
|
||||
node.node_visit_children(self);
|
||||
}
|
||||
}
|
||||
self.root.clone().visit(&mut Walker);
|
||||
self.root.clone().node_visit(&mut Walker);
|
||||
|
||||
let seats = self.globals.seats.lock();
|
||||
for seat in seats.values() {
|
||||
|
|
@ -162,7 +162,7 @@ impl State {
|
|||
if let Some(seat) = &seat {
|
||||
if let Some(prev) = seat.last_tiled_keyboard_toplevel(&*node) {
|
||||
if let Some(container) = prev.parent() {
|
||||
if let Some(container) = container.into_container() {
|
||||
if let Some(container) = container.node_into_container() {
|
||||
container.add_child_after(prev.as_node(), node);
|
||||
return;
|
||||
}
|
||||
|
|
@ -200,7 +200,7 @@ impl State {
|
|||
mut height: i32,
|
||||
workspace: &Rc<WorkspaceNode>,
|
||||
) {
|
||||
node.clone().set_workspace(workspace);
|
||||
node.clone().node_set_workspace(workspace);
|
||||
width += 2 * self.theme.border_width.get();
|
||||
height += 2 * self.theme.border_width.get() + self.theme.title_height.get();
|
||||
let output = workspace.output.get();
|
||||
|
|
|
|||
350
src/tree.rs
350
src/tree.rs
|
|
@ -68,14 +68,18 @@ pub enum FindTreeResult {
|
|||
Other,
|
||||
}
|
||||
|
||||
pub trait Node {
|
||||
pub trait SizedNode: Sized + 'static {
|
||||
fn id(&self) -> NodeId;
|
||||
fn seat_state(&self) -> &NodeSeatState;
|
||||
fn destroy_node(&self, detach: bool);
|
||||
fn visit(self: Rc<Self>, visitor: &mut dyn NodeVisitor);
|
||||
fn visit(self: &Rc<Self>, visitor: &mut dyn NodeVisitor);
|
||||
fn visit_children(&self, visitor: &mut dyn NodeVisitor);
|
||||
fn visible(&self) -> bool;
|
||||
|
||||
fn last_active_child(self: &Rc<Self>) -> Rc<dyn Node> {
|
||||
self.clone()
|
||||
}
|
||||
|
||||
fn set_visible(&self, visible: bool) {
|
||||
let _ = visible;
|
||||
}
|
||||
|
|
@ -89,7 +93,7 @@ pub trait Node {
|
|||
false
|
||||
}
|
||||
|
||||
fn child_title_changed(self: Rc<Self>, child: &dyn Node, title: &str) {
|
||||
fn child_title_changed(self: &Rc<Self>, child: &dyn Node, title: &str) {
|
||||
let _ = child;
|
||||
let _ = title;
|
||||
}
|
||||
|
|
@ -118,23 +122,23 @@ pub trait Node {
|
|||
None
|
||||
}
|
||||
|
||||
fn set_mono(self: Rc<Self>, child: Option<&dyn Node>) {
|
||||
fn set_mono(self: &Rc<Self>, child: Option<&dyn Node>) {
|
||||
let _ = child;
|
||||
}
|
||||
|
||||
fn set_split(self: Rc<Self>, split: ContainerSplit) {
|
||||
fn set_split(self: &Rc<Self>, split: ContainerSplit) {
|
||||
let _ = split;
|
||||
}
|
||||
|
||||
fn create_split(self: Rc<Self>, split: ContainerSplit) {
|
||||
fn create_split(self: &Rc<Self>, split: ContainerSplit) {
|
||||
let _ = split;
|
||||
}
|
||||
|
||||
fn focus_self(self: Rc<Self>, seat: &Rc<WlSeatGlobal>) {
|
||||
fn focus_self(self: &Rc<Self>, seat: &Rc<WlSeatGlobal>) {
|
||||
let _ = seat;
|
||||
}
|
||||
|
||||
fn do_focus(self: Rc<Self>, seat: &Rc<WlSeatGlobal>, direction: Direction) {
|
||||
fn do_focus(self: &Rc<Self>, seat: &Rc<WlSeatGlobal>, direction: Direction) {
|
||||
let _ = seat;
|
||||
let _ = direction;
|
||||
}
|
||||
|
|
@ -143,17 +147,17 @@ pub trait Node {
|
|||
// nothing
|
||||
}
|
||||
|
||||
fn move_focus(self: Rc<Self>, seat: &Rc<WlSeatGlobal>, direction: Direction) {
|
||||
fn move_focus(self: &Rc<Self>, seat: &Rc<WlSeatGlobal>, direction: Direction) {
|
||||
let _ = seat;
|
||||
let _ = direction;
|
||||
}
|
||||
|
||||
fn move_self(self: Rc<Self>, direction: Direction) {
|
||||
fn move_self(self: &Rc<Self>, direction: Direction) {
|
||||
let _ = direction;
|
||||
}
|
||||
|
||||
fn move_focus_from_child(
|
||||
self: Rc<Self>,
|
||||
self: &Rc<Self>,
|
||||
seat: &Rc<WlSeatGlobal>,
|
||||
child: &dyn Node,
|
||||
direction: Direction,
|
||||
|
|
@ -163,7 +167,7 @@ pub trait Node {
|
|||
let _ = child;
|
||||
}
|
||||
|
||||
fn move_child(self: Rc<Self>, child: Rc<dyn Node>, direction: Direction) {
|
||||
fn move_child(self: &Rc<Self>, child: Rc<dyn Node>, direction: Direction) {
|
||||
let _ = direction;
|
||||
let _ = child;
|
||||
}
|
||||
|
|
@ -191,18 +195,18 @@ pub trait Node {
|
|||
let _ = mods;
|
||||
}
|
||||
|
||||
fn button(self: Rc<Self>, seat: &Rc<WlSeatGlobal>, button: u32, state: KeyState) {
|
||||
fn button(self: &Rc<Self>, seat: &Rc<WlSeatGlobal>, button: u32, state: KeyState) {
|
||||
let _ = seat;
|
||||
let _ = button;
|
||||
let _ = state;
|
||||
}
|
||||
|
||||
fn axis_event(self: Rc<Self>, seat: &WlSeatGlobal, event: &PendingScroll) {
|
||||
fn axis_event(self: &Rc<Self>, seat: &WlSeatGlobal, event: &PendingScroll) {
|
||||
let _ = seat;
|
||||
let _ = event;
|
||||
}
|
||||
|
||||
fn focus(self: Rc<Self>, seat: &Rc<WlSeatGlobal>) {
|
||||
fn focus(self: &Rc<Self>, seat: &Rc<WlSeatGlobal>) {
|
||||
let _ = seat;
|
||||
}
|
||||
|
||||
|
|
@ -210,7 +214,7 @@ pub trait Node {
|
|||
let _ = seat;
|
||||
}
|
||||
|
||||
fn toggle_floating(self: Rc<Self>, seat: &Rc<WlSeatGlobal>) {
|
||||
fn toggle_floating(self: &Rc<Self>, seat: &Rc<WlSeatGlobal>) {
|
||||
let _ = seat;
|
||||
}
|
||||
|
||||
|
|
@ -225,12 +229,12 @@ pub trait Node {
|
|||
FindTreeResult::Other
|
||||
}
|
||||
|
||||
fn replace_child(self: Rc<Self>, old: &dyn Node, new: Rc<dyn Node>) {
|
||||
fn replace_child(self: &Rc<Self>, old: &dyn Node, new: Rc<dyn Node>) {
|
||||
let _ = old;
|
||||
let _ = new;
|
||||
}
|
||||
|
||||
fn remove_child(self: Rc<Self>, child: &dyn Node) {
|
||||
fn remove_child(self: &Rc<Self>, child: &dyn Node) {
|
||||
let _ = child;
|
||||
}
|
||||
|
||||
|
|
@ -238,7 +242,7 @@ pub trait Node {
|
|||
let _ = (child, width, height);
|
||||
}
|
||||
|
||||
fn child_active_changed(self: Rc<Self>, child: &dyn Node, active: bool) {
|
||||
fn child_active_changed(self: &Rc<Self>, child: &dyn Node, active: bool) {
|
||||
let _ = (child, active);
|
||||
}
|
||||
|
||||
|
|
@ -246,7 +250,7 @@ pub trait Node {
|
|||
let _ = seat;
|
||||
}
|
||||
|
||||
fn pointer_enter(self: Rc<Self>, seat: &Rc<WlSeatGlobal>, x: Fixed, y: Fixed) {
|
||||
fn pointer_enter(self: &Rc<Self>, seat: &Rc<WlSeatGlobal>, x: Fixed, y: Fixed) {
|
||||
let _ = seat;
|
||||
let _ = x;
|
||||
let _ = y;
|
||||
|
|
@ -260,7 +264,7 @@ pub trait Node {
|
|||
let _ = seat;
|
||||
}
|
||||
|
||||
fn pointer_motion(self: Rc<Self>, seat: &Rc<WlSeatGlobal>, x: Fixed, y: Fixed) {
|
||||
fn pointer_motion(self: &Rc<Self>, seat: &Rc<WlSeatGlobal>, x: Fixed, y: Fixed) {
|
||||
let _ = seat;
|
||||
let _ = x;
|
||||
let _ = y;
|
||||
|
|
@ -272,11 +276,11 @@ pub trait Node {
|
|||
let _ = y;
|
||||
}
|
||||
|
||||
fn into_float(self: Rc<Self>) -> Option<Rc<FloatNode>> {
|
||||
fn into_float(self: &Rc<Self>) -> Option<Rc<FloatNode>> {
|
||||
None
|
||||
}
|
||||
|
||||
fn into_container(self: Rc<Self>) -> Option<Rc<ContainerNode>> {
|
||||
fn into_container(self: &Rc<Self>) -> Option<Rc<ContainerNode>> {
|
||||
None
|
||||
}
|
||||
|
||||
|
|
@ -288,7 +292,7 @@ pub trait Node {
|
|||
false
|
||||
}
|
||||
|
||||
fn into_output(self: Rc<Self>) -> Option<Rc<OutputNode>> {
|
||||
fn into_output(self: &Rc<Self>) -> Option<Rc<OutputNode>> {
|
||||
None
|
||||
}
|
||||
|
||||
|
|
@ -297,7 +301,7 @@ pub trait Node {
|
|||
false
|
||||
}
|
||||
|
||||
fn insert_child(self: Rc<Self>, node: Rc<dyn Node>, direction: Direction) {
|
||||
fn insert_child(self: &Rc<Self>, node: Rc<dyn Node>, direction: Direction) {
|
||||
let _ = node;
|
||||
let _ = direction;
|
||||
}
|
||||
|
|
@ -310,15 +314,15 @@ pub trait Node {
|
|||
false
|
||||
}
|
||||
|
||||
fn change_extents(self: Rc<Self>, rect: &Rect) {
|
||||
fn change_extents(self: &Rc<Self>, rect: &Rect) {
|
||||
let _ = rect;
|
||||
}
|
||||
|
||||
fn set_workspace(self: Rc<Self>, ws: &Rc<WorkspaceNode>) {
|
||||
fn set_workspace(self: &Rc<Self>, ws: &Rc<WorkspaceNode>) {
|
||||
let _ = ws;
|
||||
}
|
||||
|
||||
fn set_parent(self: Rc<Self>, parent: Rc<dyn Node>) {
|
||||
fn set_parent(self: &Rc<Self>, parent: Rc<dyn Node>) {
|
||||
let _ = parent;
|
||||
}
|
||||
|
||||
|
|
@ -330,7 +334,7 @@ pub trait Node {
|
|||
self.client().map(|c| c.id)
|
||||
}
|
||||
|
||||
fn into_surface(self: Rc<Self>) -> Option<Rc<WlSurface>> {
|
||||
fn into_surface(self: &Rc<Self>) -> Option<Rc<WlSurface>> {
|
||||
None
|
||||
}
|
||||
|
||||
|
|
@ -355,6 +359,294 @@ pub trait Node {
|
|||
}
|
||||
}
|
||||
|
||||
pub trait Node {
|
||||
fn node_id(&self) -> NodeId;
|
||||
fn node_seat_state(&self) -> &NodeSeatState;
|
||||
fn node_destroy(&self, detach: bool);
|
||||
fn node_visit(self: Rc<Self>, visitor: &mut dyn NodeVisitor);
|
||||
fn node_visit_children(&self, visitor: &mut dyn NodeVisitor);
|
||||
fn node_visible(&self) -> bool;
|
||||
fn node_last_active_child(self: Rc<Self>) -> Rc<dyn Node>;
|
||||
fn node_set_visible(&self, visible: bool);
|
||||
fn node_get_workspace(&self) -> Option<Rc<WorkspaceNode>>;
|
||||
fn node_is_contained_in(&self, other: NodeId) -> bool;
|
||||
fn node_child_title_changed(self: Rc<Self>, child: &dyn Node, title: &str);
|
||||
fn node_get_parent_mono(&self) -> Option<bool>;
|
||||
fn node_get_parent_split(&self) -> Option<ContainerSplit>;
|
||||
fn node_set_parent_mono(&self, mono: bool);
|
||||
fn node_set_parent_split(&self, split: ContainerSplit);
|
||||
fn node_get_mono(&self) -> Option<bool>;
|
||||
fn node_get_split(&self) -> Option<ContainerSplit>;
|
||||
fn node_set_mono(self: Rc<Self>, child: Option<&dyn Node>);
|
||||
fn node_set_split(self: Rc<Self>, split: ContainerSplit);
|
||||
fn node_create_split(self: Rc<Self>, split: ContainerSplit);
|
||||
fn node_focus_self(self: Rc<Self>, seat: &Rc<WlSeatGlobal>);
|
||||
fn node_do_focus(self: Rc<Self>, seat: &Rc<WlSeatGlobal>, direction: Direction);
|
||||
fn node_close(&self);
|
||||
fn node_move_focus(self: Rc<Self>, seat: &Rc<WlSeatGlobal>, direction: Direction);
|
||||
fn node_move_self(self: Rc<Self>, direction: Direction);
|
||||
fn node_move_focus_from_child(
|
||||
self: Rc<Self>,
|
||||
seat: &Rc<WlSeatGlobal>,
|
||||
child: &dyn Node,
|
||||
direction: Direction,
|
||||
);
|
||||
fn node_move_child(self: Rc<Self>, child: Rc<dyn Node>, direction: Direction);
|
||||
fn node_absolute_position(&self) -> Rect;
|
||||
fn node_absolute_position_constrains_input(&self) -> bool;
|
||||
fn node_active_changed(&self, active: bool);
|
||||
fn node_key(&self, seat: &WlSeatGlobal, key: u32, state: u32);
|
||||
fn node_mods(&self, seat: &WlSeatGlobal, mods: ModifierState);
|
||||
fn node_button(self: Rc<Self>, seat: &Rc<WlSeatGlobal>, button: u32, state: KeyState);
|
||||
fn node_axis_event(self: Rc<Self>, seat: &WlSeatGlobal, event: &PendingScroll);
|
||||
fn node_focus(self: Rc<Self>, seat: &Rc<WlSeatGlobal>);
|
||||
fn node_focus_parent(&self, seat: &Rc<WlSeatGlobal>);
|
||||
fn node_toggle_floating(self: Rc<Self>, seat: &Rc<WlSeatGlobal>);
|
||||
fn node_unfocus(&self, seat: &WlSeatGlobal);
|
||||
fn node_find_tree_at(&self, x: i32, y: i32, tree: &mut Vec<FoundNode>) -> FindTreeResult;
|
||||
fn node_replace_child(self: Rc<Self>, old: &dyn Node, new: Rc<dyn Node>);
|
||||
fn node_remove_child(self: Rc<Self>, child: &dyn Node);
|
||||
fn node_child_size_changed(&self, child: &dyn Node, width: i32, height: i32);
|
||||
fn node_child_active_changed(self: Rc<Self>, child: &dyn Node, active: bool);
|
||||
fn node_leave(&self, seat: &WlSeatGlobal);
|
||||
fn node_pointer_enter(self: Rc<Self>, seat: &Rc<WlSeatGlobal>, x: Fixed, y: Fixed);
|
||||
fn node_pointer_unfocus(&self, seat: &Rc<WlSeatGlobal>);
|
||||
fn node_pointer_focus(&self, seat: &Rc<WlSeatGlobal>);
|
||||
fn node_pointer_motion(self: Rc<Self>, seat: &Rc<WlSeatGlobal>, x: Fixed, y: Fixed);
|
||||
fn node_render(&self, renderer: &mut Renderer, x: i32, y: i32);
|
||||
fn node_into_float(self: Rc<Self>) -> Option<Rc<FloatNode>>;
|
||||
fn node_into_container(self: Rc<Self>) -> Option<Rc<ContainerNode>>;
|
||||
fn node_is_container(&self) -> bool;
|
||||
fn node_is_output(&self) -> bool;
|
||||
fn node_into_output(self: Rc<Self>) -> Option<Rc<OutputNode>>;
|
||||
fn node_accepts_child(&self, node: &dyn Node) -> bool;
|
||||
fn node_insert_child(self: Rc<Self>, node: Rc<dyn Node>, direction: Direction);
|
||||
fn node_is_float(&self) -> bool;
|
||||
fn node_is_workspace(&self) -> bool;
|
||||
fn node_change_extents(self: Rc<Self>, rect: &Rect);
|
||||
fn node_set_workspace(self: Rc<Self>, ws: &Rc<WorkspaceNode>);
|
||||
fn node_set_parent(self: Rc<Self>, parent: Rc<dyn Node>);
|
||||
fn node_client(&self) -> Option<Rc<Client>>;
|
||||
fn node_client_id(&self) -> Option<ClientId>;
|
||||
fn node_into_surface(self: Rc<Self>) -> Option<Rc<WlSurface>>;
|
||||
fn node_dnd_drop(&self, dnd: &Dnd);
|
||||
fn node_dnd_leave(&self, dnd: &Dnd);
|
||||
fn node_dnd_enter(&self, dnd: &Dnd, x: Fixed, y: Fixed);
|
||||
fn node_dnd_motion(&self, dnd: &Dnd, x: Fixed, y: Fixed);
|
||||
}
|
||||
|
||||
impl<T: SizedNode> Node for T {
|
||||
fn node_id(&self) -> NodeId {
|
||||
<Self as SizedNode>::id(self)
|
||||
}
|
||||
fn node_seat_state(&self) -> &NodeSeatState {
|
||||
<Self as SizedNode>::seat_state(self)
|
||||
}
|
||||
fn node_destroy(&self, detach: bool) {
|
||||
<Self as SizedNode>::destroy_node(self, detach)
|
||||
}
|
||||
fn node_visit(self: Rc<Self>, visitor: &mut dyn NodeVisitor) {
|
||||
<Self as SizedNode>::visit(&self, visitor)
|
||||
}
|
||||
fn node_visit_children(&self, visitor: &mut dyn NodeVisitor) {
|
||||
<Self as SizedNode>::visit_children(self, visitor)
|
||||
}
|
||||
fn node_visible(&self) -> bool {
|
||||
<Self as SizedNode>::visible(self)
|
||||
}
|
||||
fn node_last_active_child(self: Rc<Self>) -> Rc<dyn Node> {
|
||||
<Self as SizedNode>::last_active_child(&self)
|
||||
}
|
||||
fn node_set_visible(&self, visible: bool) {
|
||||
<Self as SizedNode>::set_visible(self, visible)
|
||||
}
|
||||
fn node_get_workspace(&self) -> Option<Rc<WorkspaceNode>> {
|
||||
<Self as SizedNode>::get_workspace(self)
|
||||
}
|
||||
fn node_is_contained_in(&self, other: NodeId) -> bool {
|
||||
<Self as SizedNode>::is_contained_in(self, other)
|
||||
}
|
||||
fn node_child_title_changed(self: Rc<Self>, child: &dyn Node, title: &str) {
|
||||
<Self as SizedNode>::child_title_changed(&self, child, title)
|
||||
}
|
||||
fn node_get_parent_mono(&self) -> Option<bool> {
|
||||
<Self as SizedNode>::get_parent_mono(self)
|
||||
}
|
||||
fn node_get_parent_split(&self) -> Option<ContainerSplit> {
|
||||
<Self as SizedNode>::get_parent_split(self)
|
||||
}
|
||||
fn node_set_parent_mono(&self, mono: bool) {
|
||||
<Self as SizedNode>::set_parent_mono(self, mono)
|
||||
}
|
||||
fn node_set_parent_split(&self, split: ContainerSplit) {
|
||||
<Self as SizedNode>::set_parent_split(self, split)
|
||||
}
|
||||
fn node_get_mono(&self) -> Option<bool> {
|
||||
<Self as SizedNode>::get_mono(self)
|
||||
}
|
||||
fn node_get_split(&self) -> Option<ContainerSplit> {
|
||||
<Self as SizedNode>::get_split(self)
|
||||
}
|
||||
fn node_set_mono(self: Rc<Self>, child: Option<&dyn Node>) {
|
||||
<Self as SizedNode>::set_mono(&self, child)
|
||||
}
|
||||
fn node_set_split(self: Rc<Self>, split: ContainerSplit) {
|
||||
<Self as SizedNode>::set_split(&self, split)
|
||||
}
|
||||
fn node_create_split(self: Rc<Self>, split: ContainerSplit) {
|
||||
<Self as SizedNode>::create_split(&self, split)
|
||||
}
|
||||
fn node_focus_self(self: Rc<Self>, seat: &Rc<WlSeatGlobal>) {
|
||||
<Self as SizedNode>::focus_self(&self, seat)
|
||||
}
|
||||
fn node_do_focus(self: Rc<Self>, seat: &Rc<WlSeatGlobal>, direction: Direction) {
|
||||
<Self as SizedNode>::do_focus(&self, seat, direction)
|
||||
}
|
||||
fn node_close(&self) {
|
||||
<Self as SizedNode>::close(self)
|
||||
}
|
||||
fn node_move_focus(self: Rc<Self>, seat: &Rc<WlSeatGlobal>, direction: Direction) {
|
||||
<Self as SizedNode>::move_focus(&self, seat, direction)
|
||||
}
|
||||
fn node_move_self(self: Rc<Self>, direction: Direction) {
|
||||
<Self as SizedNode>::move_self(&self, direction)
|
||||
}
|
||||
fn node_move_focus_from_child(
|
||||
self: Rc<Self>,
|
||||
seat: &Rc<WlSeatGlobal>,
|
||||
child: &dyn Node,
|
||||
direction: Direction,
|
||||
) {
|
||||
<Self as SizedNode>::move_focus_from_child(&self, seat, child, direction)
|
||||
}
|
||||
fn node_move_child(self: Rc<Self>, child: Rc<dyn Node>, direction: Direction) {
|
||||
<Self as SizedNode>::move_child(&self, child, direction)
|
||||
}
|
||||
fn node_absolute_position(&self) -> Rect {
|
||||
<Self as SizedNode>::absolute_position(self)
|
||||
}
|
||||
fn node_absolute_position_constrains_input(&self) -> bool {
|
||||
<Self as SizedNode>::absolute_position_constrains_input(self)
|
||||
}
|
||||
fn node_active_changed(&self, active: bool) {
|
||||
<Self as SizedNode>::active_changed(self, active)
|
||||
}
|
||||
fn node_key(&self, seat: &WlSeatGlobal, key: u32, state: u32) {
|
||||
<Self as SizedNode>::key(self, seat, key, state)
|
||||
}
|
||||
fn node_mods(&self, seat: &WlSeatGlobal, mods: ModifierState) {
|
||||
<Self as SizedNode>::mods(self, seat, mods)
|
||||
}
|
||||
fn node_button(self: Rc<Self>, seat: &Rc<WlSeatGlobal>, button: u32, state: KeyState) {
|
||||
<Self as SizedNode>::button(&self, seat, button, state)
|
||||
}
|
||||
fn node_axis_event(self: Rc<Self>, seat: &WlSeatGlobal, event: &PendingScroll) {
|
||||
<Self as SizedNode>::axis_event(&self, seat, event)
|
||||
}
|
||||
fn node_focus(self: Rc<Self>, seat: &Rc<WlSeatGlobal>) {
|
||||
<Self as SizedNode>::focus(&self, seat)
|
||||
}
|
||||
fn node_focus_parent(&self, seat: &Rc<WlSeatGlobal>) {
|
||||
<Self as SizedNode>::focus_parent(self, seat)
|
||||
}
|
||||
fn node_toggle_floating(self: Rc<Self>, seat: &Rc<WlSeatGlobal>) {
|
||||
<Self as SizedNode>::toggle_floating(&self, seat)
|
||||
}
|
||||
fn node_unfocus(&self, seat: &WlSeatGlobal) {
|
||||
<Self as SizedNode>::unfocus(self, seat)
|
||||
}
|
||||
fn node_find_tree_at(&self, x: i32, y: i32, tree: &mut Vec<FoundNode>) -> FindTreeResult {
|
||||
<Self as SizedNode>::find_tree_at(self, x, y, tree)
|
||||
}
|
||||
fn node_replace_child(self: Rc<Self>, old: &dyn Node, new: Rc<dyn Node>) {
|
||||
<Self as SizedNode>::replace_child(&self, old, new)
|
||||
}
|
||||
fn node_remove_child(self: Rc<Self>, child: &dyn Node) {
|
||||
<Self as SizedNode>::remove_child(&self, child)
|
||||
}
|
||||
fn node_child_size_changed(&self, child: &dyn Node, width: i32, height: i32) {
|
||||
<Self as SizedNode>::child_size_changed(self, child, width, height)
|
||||
}
|
||||
fn node_child_active_changed(self: Rc<Self>, child: &dyn Node, active: bool) {
|
||||
<Self as SizedNode>::child_active_changed(&self, child, active)
|
||||
}
|
||||
fn node_leave(&self, seat: &WlSeatGlobal) {
|
||||
<Self as SizedNode>::leave(self, seat)
|
||||
}
|
||||
fn node_pointer_enter(self: Rc<Self>, seat: &Rc<WlSeatGlobal>, x: Fixed, y: Fixed) {
|
||||
<Self as SizedNode>::pointer_enter(&self, seat, x, y)
|
||||
}
|
||||
fn node_pointer_unfocus(&self, seat: &Rc<WlSeatGlobal>) {
|
||||
<Self as SizedNode>::pointer_unfocus(self, seat)
|
||||
}
|
||||
fn node_pointer_focus(&self, seat: &Rc<WlSeatGlobal>) {
|
||||
<Self as SizedNode>::pointer_focus(self, seat)
|
||||
}
|
||||
fn node_pointer_motion(self: Rc<Self>, seat: &Rc<WlSeatGlobal>, x: Fixed, y: Fixed) {
|
||||
<Self as SizedNode>::pointer_motion(&self, seat, x, y)
|
||||
}
|
||||
fn node_render(&self, renderer: &mut Renderer, x: i32, y: i32) {
|
||||
<Self as SizedNode>::render(self, renderer, x, y)
|
||||
}
|
||||
fn node_into_float(self: Rc<Self>) -> Option<Rc<FloatNode>> {
|
||||
<Self as SizedNode>::into_float(&self)
|
||||
}
|
||||
fn node_into_container(self: Rc<Self>) -> Option<Rc<ContainerNode>> {
|
||||
<Self as SizedNode>::into_container(&self)
|
||||
}
|
||||
fn node_is_container(&self) -> bool {
|
||||
<Self as SizedNode>::is_container(self)
|
||||
}
|
||||
fn node_is_output(&self) -> bool {
|
||||
<Self as SizedNode>::is_output(self)
|
||||
}
|
||||
fn node_into_output(self: Rc<Self>) -> Option<Rc<OutputNode>> {
|
||||
<Self as SizedNode>::into_output(&self)
|
||||
}
|
||||
fn node_accepts_child(&self, node: &dyn Node) -> bool {
|
||||
<Self as SizedNode>::accepts_child(self, node)
|
||||
}
|
||||
fn node_insert_child(self: Rc<Self>, node: Rc<dyn Node>, direction: Direction) {
|
||||
<Self as SizedNode>::insert_child(&self, node, direction)
|
||||
}
|
||||
fn node_is_float(&self) -> bool {
|
||||
<Self as SizedNode>::is_float(self)
|
||||
}
|
||||
fn node_is_workspace(&self) -> bool {
|
||||
<Self as SizedNode>::is_workspace(self)
|
||||
}
|
||||
fn node_change_extents(self: Rc<Self>, rect: &Rect) {
|
||||
<Self as SizedNode>::change_extents(&self, rect)
|
||||
}
|
||||
fn node_set_workspace(self: Rc<Self>, ws: &Rc<WorkspaceNode>) {
|
||||
<Self as SizedNode>::set_workspace(&self, ws)
|
||||
}
|
||||
fn node_set_parent(self: Rc<Self>, parent: Rc<dyn Node>) {
|
||||
<Self as SizedNode>::set_parent(&self, parent)
|
||||
}
|
||||
fn node_client(&self) -> Option<Rc<Client>> {
|
||||
<Self as SizedNode>::client(self)
|
||||
}
|
||||
fn node_client_id(&self) -> Option<ClientId> {
|
||||
<Self as SizedNode>::client_id(self)
|
||||
}
|
||||
fn node_into_surface(self: Rc<Self>) -> Option<Rc<WlSurface>> {
|
||||
<Self as SizedNode>::into_surface(&self)
|
||||
}
|
||||
fn node_dnd_drop(&self, dnd: &Dnd) {
|
||||
<Self as SizedNode>::dnd_drop(self, dnd)
|
||||
}
|
||||
fn node_dnd_leave(&self, dnd: &Dnd) {
|
||||
<Self as SizedNode>::dnd_leave(self, dnd)
|
||||
}
|
||||
fn node_dnd_enter(&self, dnd: &Dnd, x: Fixed, y: Fixed) {
|
||||
<Self as SizedNode>::dnd_enter(self, dnd, x, y)
|
||||
}
|
||||
fn node_dnd_motion(&self, dnd: &Dnd, x: Fixed, y: Fixed) {
|
||||
<Self as SizedNode>::dnd_motion(self, dnd, x, y)
|
||||
}
|
||||
}
|
||||
|
||||
pub struct FoundNode {
|
||||
pub node: Rc<dyn Node>,
|
||||
pub x: i32,
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ use {
|
|||
theme::Color,
|
||||
tree::{
|
||||
generic_node_visitor, walker::NodeVisitor, FindTreeResult, FoundNode, Node, NodeId,
|
||||
WorkspaceNode,
|
||||
SizedNode, WorkspaceNode,
|
||||
},
|
||||
utils::{
|
||||
clonecell::CloneCell,
|
||||
|
|
@ -169,11 +169,11 @@ impl ContainerNode {
|
|||
child: Rc<dyn Node>,
|
||||
split: ContainerSplit,
|
||||
) -> Rc<Self> {
|
||||
child.clone().set_workspace(workspace);
|
||||
child.clone().node_set_workspace(workspace);
|
||||
let children = LinkedList::new();
|
||||
let mut child_nodes = AHashMap::new();
|
||||
child_nodes.insert(
|
||||
child.id(),
|
||||
child.node_id(),
|
||||
children.add_last(ContainerChild {
|
||||
node: child.clone(),
|
||||
active: Default::default(),
|
||||
|
|
@ -215,7 +215,7 @@ impl ContainerNode {
|
|||
visible: Cell::new(false),
|
||||
scroll: Cell::new(0.0),
|
||||
});
|
||||
child.set_parent(slf.clone());
|
||||
child.node_set_parent(slf.clone());
|
||||
slf
|
||||
}
|
||||
|
||||
|
|
@ -246,7 +246,7 @@ impl ContainerNode {
|
|||
let node = self
|
||||
.child_nodes
|
||||
.borrow()
|
||||
.get(&prev.id())
|
||||
.get(&prev.node_id())
|
||||
.map(|n| n.to_ref());
|
||||
if let Some(node) = node {
|
||||
f(&node, new);
|
||||
|
|
@ -271,7 +271,7 @@ impl ContainerNode {
|
|||
{
|
||||
let new_ref = {
|
||||
let mut links = self.child_nodes.borrow_mut();
|
||||
if links.contains_key(&new.id()) {
|
||||
if links.contains_key(&new.node_id()) {
|
||||
log::error!("Tried to add a child to a container that already contains the child");
|
||||
return;
|
||||
}
|
||||
|
|
@ -286,12 +286,12 @@ impl ContainerNode {
|
|||
focus_history: Default::default(),
|
||||
});
|
||||
let r = link.to_ref();
|
||||
links.insert(new.id(), link);
|
||||
links.insert(new.node_id(), link);
|
||||
r
|
||||
};
|
||||
new.clone().set_workspace(&self.workspace.get());
|
||||
new.clone().set_parent(self.clone());
|
||||
new.set_visible(self.visible.get());
|
||||
new.clone().node_set_workspace(&self.workspace.get());
|
||||
new.clone().node_set_parent(self.clone());
|
||||
new.node_set_visible(self.visible.get());
|
||||
let num_children = self.num_children.fetch_add(1) + 1;
|
||||
self.update_content_size();
|
||||
let new_child_factor = 1.0 / num_children as f64;
|
||||
|
|
@ -350,7 +350,7 @@ impl ContainerNode {
|
|||
child
|
||||
.node
|
||||
.clone()
|
||||
.change_extents(&mb.move_(self.abs_x1.get(), self.abs_y1.get()));
|
||||
.node_change_extents(&mb.move_(self.abs_x1.get(), self.abs_y1.get()));
|
||||
self.mono_content
|
||||
.set(child.content.get().at_point(mb.x1(), mb.y1()));
|
||||
|
||||
|
|
@ -456,7 +456,7 @@ impl ContainerNode {
|
|||
.unwrap(),
|
||||
);
|
||||
let body = body.move_(self.abs_x1.get(), self.abs_y1.get());
|
||||
child.node.clone().change_extents(&body);
|
||||
child.node.clone().node_change_extents(&body);
|
||||
child.position_content();
|
||||
}
|
||||
}
|
||||
|
|
@ -601,7 +601,7 @@ impl ContainerNode {
|
|||
}
|
||||
title.push_str("]");
|
||||
}
|
||||
self.parent.get().child_title_changed(&**self, &title);
|
||||
self.parent.get().node_child_title_changed(&**self, &title);
|
||||
}
|
||||
|
||||
pub fn schedule_compute_render_data(self: &Rc<Self>) {
|
||||
|
|
@ -676,21 +676,25 @@ impl ContainerNode {
|
|||
|
||||
fn activate_child(self: &Rc<Self>, child: &NodeRef<ContainerChild>) {
|
||||
if let Some(mc) = self.mono_child.get() {
|
||||
if mc.node.id() == child.node.id() {
|
||||
if mc.node.node_id() == child.node.node_id() {
|
||||
return;
|
||||
}
|
||||
let mut seats = SmallVec::<[_; 3]>::new();
|
||||
mc.node.visit_children(&mut generic_node_visitor(|node| {
|
||||
node.seat_state().for_each_kb_focus(|s| {
|
||||
seats.push(s);
|
||||
});
|
||||
}));
|
||||
mc.node.set_visible(false);
|
||||
mc.node
|
||||
.node_visit_children(&mut generic_node_visitor(|node| {
|
||||
node.node_seat_state().for_each_kb_focus(|s| {
|
||||
seats.push(s);
|
||||
});
|
||||
}));
|
||||
mc.node.node_set_visible(false);
|
||||
for seat in seats {
|
||||
child.node.clone().do_focus(&seat, Direction::Unspecified);
|
||||
child
|
||||
.node
|
||||
.clone()
|
||||
.node_do_focus(&seat, Direction::Unspecified);
|
||||
}
|
||||
self.mono_child.set(Some(child.clone()));
|
||||
child.node.set_visible(true);
|
||||
child.node.node_set_visible(true);
|
||||
self.schedule_layout();
|
||||
} else {
|
||||
}
|
||||
|
|
@ -726,11 +730,37 @@ pub async fn container_render_data(state: Rc<State>) {
|
|||
}
|
||||
}
|
||||
|
||||
impl Node for ContainerNode {
|
||||
impl SizedNode for ContainerNode {
|
||||
fn id(&self) -> NodeId {
|
||||
self.id.into()
|
||||
}
|
||||
|
||||
fn seat_state(&self) -> &NodeSeatState {
|
||||
&self.seat_state
|
||||
}
|
||||
|
||||
fn destroy_node(&self, detach: bool) {
|
||||
if detach {
|
||||
self.parent.get().node_remove_child(self);
|
||||
}
|
||||
mem::take(self.seats.borrow_mut().deref_mut());
|
||||
let mut cn = self.child_nodes.borrow_mut();
|
||||
for (_, n) in cn.drain() {
|
||||
n.node.node_destroy(false);
|
||||
}
|
||||
self.seat_state.destroy_node(self);
|
||||
}
|
||||
|
||||
fn visit(self: &Rc<Self>, visitor: &mut dyn NodeVisitor) {
|
||||
visitor.visit_container(self);
|
||||
}
|
||||
|
||||
fn visit_children(&self, visitor: &mut dyn NodeVisitor) {
|
||||
for child in self.children.iter() {
|
||||
child.node.clone().node_visit(visitor);
|
||||
}
|
||||
}
|
||||
|
||||
fn visible(&self) -> bool {
|
||||
self.visible.get()
|
||||
}
|
||||
|
|
@ -738,51 +768,25 @@ impl Node for ContainerNode {
|
|||
fn set_visible(&self, visible: bool) {
|
||||
self.visible.set(visible);
|
||||
for child in self.children.iter() {
|
||||
child.node.set_visible(visible);
|
||||
child.node.node_set_visible(visible);
|
||||
}
|
||||
self.seat_state.set_visible(self, visible);
|
||||
}
|
||||
|
||||
fn seat_state(&self) -> &NodeSeatState {
|
||||
&self.seat_state
|
||||
}
|
||||
|
||||
fn destroy_node(&self, detach: bool) {
|
||||
if detach {
|
||||
self.parent.get().remove_child(self);
|
||||
}
|
||||
mem::take(self.seats.borrow_mut().deref_mut());
|
||||
let mut cn = self.child_nodes.borrow_mut();
|
||||
for (_, n) in cn.drain() {
|
||||
n.node.destroy_node(false);
|
||||
}
|
||||
self.seat_state.destroy_node(self);
|
||||
}
|
||||
|
||||
fn visit(self: Rc<Self>, visitor: &mut dyn NodeVisitor) {
|
||||
visitor.visit_container(&self);
|
||||
}
|
||||
|
||||
fn visit_children(&self, visitor: &mut dyn NodeVisitor) {
|
||||
for child in self.children.iter() {
|
||||
child.node.clone().visit(visitor);
|
||||
}
|
||||
}
|
||||
|
||||
fn get_workspace(&self) -> Option<Rc<WorkspaceNode>> {
|
||||
Some(self.workspace.get())
|
||||
}
|
||||
|
||||
fn is_contained_in(&self, other: NodeId) -> bool {
|
||||
let parent = self.parent.get();
|
||||
if parent.id() == other {
|
||||
if parent.node_id() == other {
|
||||
return true;
|
||||
}
|
||||
parent.is_contained_in(other)
|
||||
parent.node_is_contained_in(other)
|
||||
}
|
||||
|
||||
fn child_title_changed(self: Rc<Self>, child: &dyn Node, title: &str) {
|
||||
let child = match self.child_nodes.borrow_mut().get(&child.id()) {
|
||||
fn child_title_changed(self: &Rc<Self>, child: &dyn Node, title: &str) {
|
||||
let child = match self.child_nodes.borrow_mut().get(&child.node_id()) {
|
||||
Some(cn) => cn.to_ref(),
|
||||
_ => return,
|
||||
};
|
||||
|
|
@ -806,23 +810,57 @@ impl Node for ContainerNode {
|
|||
Some(self.split.get())
|
||||
}
|
||||
|
||||
fn set_mono(self: Rc<Self>, child: Option<&dyn Node>) {
|
||||
if self.mono_child.get().is_some() != child.is_some() {
|
||||
fn set_mono(self: &Rc<Self>, child: Option<&dyn Node>) {
|
||||
if self.mono_child.get().is_some() == child.is_some() {
|
||||
return;
|
||||
}
|
||||
let child = {
|
||||
let children = self.child_nodes.borrow_mut();
|
||||
let child = match child {
|
||||
Some(c) => match children.get(&c.id()) {
|
||||
match child {
|
||||
Some(c) => match children.get(&c.node_id()) {
|
||||
Some(c) => Some(c.to_ref()),
|
||||
_ => return,
|
||||
_ => {
|
||||
log::warn!("set_mono called with a node that is not a child");
|
||||
return;
|
||||
}
|
||||
},
|
||||
_ => None,
|
||||
};
|
||||
self.mono_child.set(child);
|
||||
self.schedule_layout();
|
||||
self.update_title();
|
||||
}
|
||||
};
|
||||
if self.visible.get() {
|
||||
if let Some(child) = &child {
|
||||
let child_id = child.node.node_id();
|
||||
let mut seats = SmallVec::<[_; 3]>::new();
|
||||
for other in self.children.iter() {
|
||||
if other.node.node_id() != child_id {
|
||||
other
|
||||
.node
|
||||
.node_visit_children(&mut generic_node_visitor(|node| {
|
||||
node.node_seat_state().for_each_kb_focus(|s| {
|
||||
seats.push(s);
|
||||
});
|
||||
}));
|
||||
other.node.node_set_visible(false);
|
||||
}
|
||||
}
|
||||
for seat in seats {
|
||||
child
|
||||
.node
|
||||
.clone()
|
||||
.node_do_focus(&seat, Direction::Unspecified);
|
||||
}
|
||||
} else {
|
||||
for child in self.children.iter() {
|
||||
child.node.node_set_visible(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
self.mono_child.set(child);
|
||||
self.schedule_layout();
|
||||
self.update_title();
|
||||
}
|
||||
|
||||
fn set_split(self: Rc<Self>, split: ContainerSplit) {
|
||||
fn set_split(self: &Rc<Self>, split: ContainerSplit) {
|
||||
if self.split.replace(split) != split {
|
||||
self.update_content_size();
|
||||
self.schedule_layout();
|
||||
|
|
@ -830,11 +868,11 @@ impl Node for ContainerNode {
|
|||
}
|
||||
}
|
||||
|
||||
fn focus_self(self: Rc<Self>, seat: &Rc<WlSeatGlobal>) {
|
||||
seat.focus_node(self);
|
||||
fn focus_self(self: &Rc<Self>, seat: &Rc<WlSeatGlobal>) {
|
||||
seat.focus_node(self.clone());
|
||||
}
|
||||
|
||||
fn do_focus(self: Rc<Self>, seat: &Rc<WlSeatGlobal>, direction: Direction) {
|
||||
fn do_focus(self: &Rc<Self>, seat: &Rc<WlSeatGlobal>, direction: Direction) {
|
||||
let node = if let Some(cn) = self.mono_child.get() {
|
||||
Some(cn)
|
||||
} else {
|
||||
|
|
@ -851,31 +889,37 @@ impl Node for ContainerNode {
|
|||
}
|
||||
};
|
||||
if let Some(node) = node {
|
||||
node.node.clone().do_focus(seat, direction);
|
||||
node.node.clone().node_do_focus(seat, direction);
|
||||
}
|
||||
}
|
||||
|
||||
fn move_focus(self: Rc<Self>, seat: &Rc<WlSeatGlobal>, direction: Direction) {
|
||||
fn close(&self) {
|
||||
for child in self.children.iter() {
|
||||
child.node.node_close();
|
||||
}
|
||||
}
|
||||
|
||||
fn move_focus(self: &Rc<Self>, seat: &Rc<WlSeatGlobal>, direction: Direction) {
|
||||
if direction == Direction::Down {
|
||||
self.do_focus(seat, direction);
|
||||
return;
|
||||
}
|
||||
self.parent
|
||||
.get()
|
||||
.move_focus_from_child(seat, &*self, direction);
|
||||
.node_move_focus_from_child(seat, &**self, direction);
|
||||
}
|
||||
|
||||
fn move_self(self: Rc<Self>, direction: Direction) {
|
||||
self.parent.get().move_child(self, direction);
|
||||
fn move_self(self: &Rc<Self>, direction: Direction) {
|
||||
self.parent.get().node_move_child(self.clone(), direction);
|
||||
}
|
||||
|
||||
fn move_focus_from_child(
|
||||
self: Rc<Self>,
|
||||
self: &Rc<Self>,
|
||||
seat: &Rc<WlSeatGlobal>,
|
||||
child: &dyn Node,
|
||||
direction: Direction,
|
||||
) {
|
||||
let child = match self.child_nodes.borrow_mut().get(&child.id()) {
|
||||
let child = match self.child_nodes.borrow_mut().get(&child.node_id()) {
|
||||
Some(c) => c.to_ref(),
|
||||
_ => return,
|
||||
};
|
||||
|
|
@ -893,7 +937,7 @@ impl Node for ContainerNode {
|
|||
if !in_line {
|
||||
self.parent
|
||||
.get()
|
||||
.move_focus_from_child(seat, &*self, direction);
|
||||
.node_move_focus_from_child(seat, &**self, direction);
|
||||
return;
|
||||
}
|
||||
let prev = match direction {
|
||||
|
|
@ -912,30 +956,31 @@ impl Node for ContainerNode {
|
|||
None => {
|
||||
self.parent
|
||||
.get()
|
||||
.move_focus_from_child(seat, &*self, direction);
|
||||
.node_move_focus_from_child(seat, &**self, direction);
|
||||
return;
|
||||
}
|
||||
};
|
||||
if mc.is_some() {
|
||||
self.activate_child(&sibling);
|
||||
} else {
|
||||
sibling.node.clone().do_focus(seat, direction);
|
||||
sibling.node.clone().node_do_focus(seat, direction);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
fn move_child(self: Rc<Self>, child: Rc<dyn Node>, direction: Direction) {
|
||||
fn move_child(self: &Rc<Self>, child: Rc<dyn Node>, direction: Direction) {
|
||||
// CASE 1: This is the only child of the container. Replace the container by the child.
|
||||
if self.num_children.get() == 1 {
|
||||
let parent = self.parent.get();
|
||||
if parent.accepts_child(&*child) {
|
||||
parent.replace_child(&*self, child.clone());
|
||||
if parent.node_accepts_child(&*child) {
|
||||
parent.node_replace_child(&**self, child.clone());
|
||||
}
|
||||
return;
|
||||
}
|
||||
let (split, prev) = direction_to_split(direction);
|
||||
// CASE 2: We're moving the child within the container.
|
||||
if split == self.split.get() {
|
||||
let cc = match self.child_nodes.borrow_mut().get(&child.id()) {
|
||||
let cc = match self.child_nodes.borrow_mut().get(&child.node_id()) {
|
||||
Some(l) => l.to_ref(),
|
||||
None => return,
|
||||
};
|
||||
|
|
@ -944,9 +989,9 @@ impl Node for ContainerNode {
|
|||
false => cc.next(),
|
||||
};
|
||||
if let Some(neighbor) = neighbor {
|
||||
if neighbor.node.accepts_child(&*child) {
|
||||
if neighbor.node.node_accepts_child(&*child) {
|
||||
self.remove_child(&*child);
|
||||
neighbor.node.clone().insert_child(child, direction);
|
||||
neighbor.node.clone().node_insert_child(child, direction);
|
||||
return;
|
||||
}
|
||||
match prev {
|
||||
|
|
@ -959,19 +1004,19 @@ impl Node for ContainerNode {
|
|||
}
|
||||
// CASE 3: We're moving the child out of the container.
|
||||
let mut neighbor = self.clone();
|
||||
let mut parent_opt = self.parent.get().into_container();
|
||||
let mut parent_opt = self.parent.get().node_into_container();
|
||||
while let Some(parent) = &parent_opt {
|
||||
if parent.split.get() == split {
|
||||
break;
|
||||
}
|
||||
neighbor = parent.clone();
|
||||
parent_opt = parent.parent.get().into_container();
|
||||
parent_opt = parent.parent.get().node_into_container();
|
||||
}
|
||||
let parent = match parent_opt {
|
||||
Some(p) => p,
|
||||
_ => return,
|
||||
};
|
||||
self.clone().remove_child(&*child);
|
||||
self.clone().node_remove_child(&*child);
|
||||
match prev {
|
||||
true => parent.add_child_before(&*neighbor, child.clone()),
|
||||
false => parent.add_child_after(&*neighbor, child.clone()),
|
||||
|
|
@ -990,10 +1035,10 @@ impl Node for ContainerNode {
|
|||
|
||||
fn active_changed(&self, active: bool) {
|
||||
self.active.set(active);
|
||||
self.parent.get().child_active_changed(self, active);
|
||||
self.parent.get().node_child_active_changed(self, active);
|
||||
}
|
||||
|
||||
fn button(self: Rc<Self>, seat: &Rc<WlSeatGlobal>, button: u32, state: KeyState) {
|
||||
fn button(self: &Rc<Self>, seat: &Rc<WlSeatGlobal>, button: u32, state: KeyState) {
|
||||
if button != BTN_LEFT {
|
||||
return;
|
||||
}
|
||||
|
|
@ -1051,7 +1096,7 @@ impl Node for ContainerNode {
|
|||
}
|
||||
}
|
||||
|
||||
fn axis_event(self: Rc<Self>, seat: &WlSeatGlobal, event: &PendingScroll) {
|
||||
fn axis_event(self: &Rc<Self>, seat: &WlSeatGlobal, event: &PendingScroll) {
|
||||
let mut seat_datas = self.seats.borrow_mut();
|
||||
let seat_data = match seat_datas.get_mut(&seat.id()) {
|
||||
Some(s) => s,
|
||||
|
|
@ -1089,13 +1134,13 @@ impl Node for ContainerNode {
|
|||
}
|
||||
|
||||
fn focus_parent(&self, seat: &Rc<WlSeatGlobal>) {
|
||||
self.parent.get().focus_self(seat);
|
||||
self.parent.get().node_focus_self(seat);
|
||||
}
|
||||
|
||||
fn toggle_floating(self: Rc<Self>, _seat: &Rc<WlSeatGlobal>) {
|
||||
fn toggle_floating(self: &Rc<Self>, _seat: &Rc<WlSeatGlobal>) {
|
||||
let parent = self.parent.get();
|
||||
parent.clone().remove_child(&*self);
|
||||
if parent.is_float() {
|
||||
parent.clone().node_remove_child(self.deref());
|
||||
if parent.node_is_float() {
|
||||
self.state.map_tiled(self.clone());
|
||||
} else {
|
||||
self.state.map_floating(
|
||||
|
|
@ -1116,7 +1161,7 @@ impl Node for ContainerNode {
|
|||
x,
|
||||
y,
|
||||
});
|
||||
child.node.find_tree_at(x, y, tree);
|
||||
child.node.node_find_tree_at(x, y, tree);
|
||||
}
|
||||
};
|
||||
if let Some(child) = self.mono_child.get() {
|
||||
|
|
@ -1132,14 +1177,14 @@ impl Node for ContainerNode {
|
|||
FindTreeResult::AcceptsInput
|
||||
}
|
||||
|
||||
fn replace_child(self: Rc<Self>, old: &dyn Node, new: Rc<dyn Node>) {
|
||||
let node = match self.child_nodes.borrow_mut().remove(&old.id()) {
|
||||
fn replace_child(self: &Rc<Self>, old: &dyn Node, new: Rc<dyn Node>) {
|
||||
let node = match self.child_nodes.borrow_mut().remove(&old.node_id()) {
|
||||
Some(c) => c,
|
||||
None => return,
|
||||
};
|
||||
let (have_mc, was_mc) = match self.mono_child.get() {
|
||||
None => (false, false),
|
||||
Some(mc) => (true, mc.node.id() == old.id()),
|
||||
Some(mc) => (true, mc.node.node_id() == old.node_id()),
|
||||
};
|
||||
node.focus_history.set(None);
|
||||
let link = node.append(ContainerChild {
|
||||
|
|
@ -1160,27 +1205,32 @@ impl Node for ContainerNode {
|
|||
} else if !have_mc {
|
||||
body = Some(link.body.get());
|
||||
};
|
||||
self.child_nodes.borrow_mut().insert(new.id(), link);
|
||||
new.clone().set_parent(self.clone());
|
||||
new.clone().set_workspace(&self.workspace.get());
|
||||
self.child_nodes.borrow_mut().insert(new.node_id(), link);
|
||||
new.clone().node_set_parent(self.clone());
|
||||
new.clone().node_set_workspace(&self.workspace.get());
|
||||
if let Some(body) = body {
|
||||
let body = body.move_(self.abs_x1.get(), self.abs_y1.get());
|
||||
new.clone().change_extents(&body);
|
||||
new.clone().node_change_extents(&body);
|
||||
}
|
||||
}
|
||||
|
||||
fn remove_child(self: Rc<Self>, child: &dyn Node) {
|
||||
let node = match self.child_nodes.borrow_mut().remove(&child.id()) {
|
||||
fn remove_child(self: &Rc<Self>, child: &dyn Node) {
|
||||
let node = match self.child_nodes.borrow_mut().remove(&child.node_id()) {
|
||||
Some(c) => c,
|
||||
None => return,
|
||||
};
|
||||
let mut mono_child = None;
|
||||
node.focus_history.set(None);
|
||||
if let Some(mono) = self.mono_child.get() {
|
||||
if mono.node.id() == child.id() {
|
||||
self.mono_child.take();
|
||||
mono_child = node.next();
|
||||
if mono_child.is_none() {
|
||||
mono_child = node.prev();
|
||||
if mono.node.node_id() == child.node_id() {
|
||||
let mut new = self.focus_history.last().map(|n| n.deref().clone());
|
||||
if new.is_none() {
|
||||
new = node.next();
|
||||
if new.is_none() {
|
||||
new = node.prev();
|
||||
}
|
||||
}
|
||||
if let Some(child) = &new {
|
||||
self.activate_child(child);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1192,7 +1242,7 @@ impl Node for ContainerNode {
|
|||
let num_children = self.num_children.fetch_sub(1) - 1;
|
||||
if num_children == 0 {
|
||||
self.seats.borrow_mut().clear();
|
||||
self.parent.get().remove_child(&*self);
|
||||
self.parent.get().node_remove_child(self.deref());
|
||||
return;
|
||||
}
|
||||
self.update_content_size();
|
||||
|
|
@ -1211,9 +1261,6 @@ impl Node for ContainerNode {
|
|||
sum += factor;
|
||||
}
|
||||
}
|
||||
if mono_child.is_some() {
|
||||
self.mono_child.set(mono_child);
|
||||
}
|
||||
self.sum_factors.set(sum);
|
||||
self.update_title();
|
||||
self.schedule_layout();
|
||||
|
|
@ -1222,12 +1269,12 @@ impl Node for ContainerNode {
|
|||
|
||||
fn child_size_changed(&self, child: &dyn Node, width: i32, height: i32) {
|
||||
let cn = self.child_nodes.borrow();
|
||||
if let Some(node) = cn.get(&child.id()) {
|
||||
if let Some(node) = cn.get(&child.node_id()) {
|
||||
let rect = Rect::new(0, 0, width, height).unwrap();
|
||||
node.content.set(rect);
|
||||
node.position_content();
|
||||
if let Some(mono) = self.mono_child.get() {
|
||||
if mono.node.id() == node.node.id() {
|
||||
if mono.node.node_id() == node.node.node_id() {
|
||||
let body = self.mono_body.get();
|
||||
self.mono_content.set(rect.at_point(body.x1(), body.y1()));
|
||||
}
|
||||
|
|
@ -1235,8 +1282,8 @@ impl Node for ContainerNode {
|
|||
}
|
||||
}
|
||||
|
||||
fn child_active_changed(self: Rc<Self>, child: &dyn Node, active: bool) {
|
||||
let node = match self.child_nodes.borrow_mut().get(&child.id()) {
|
||||
fn child_active_changed(self: &Rc<Self>, child: &dyn Node, active: bool) {
|
||||
let node = match self.child_nodes.borrow_mut().get(&child.node_id()) {
|
||||
Some(l) => l.to_ref(),
|
||||
None => return,
|
||||
};
|
||||
|
|
@ -1246,7 +1293,7 @@ impl Node for ContainerNode {
|
|||
self.schedule_compute_render_data();
|
||||
}
|
||||
|
||||
fn pointer_enter(self: Rc<Self>, seat: &Rc<WlSeatGlobal>, x: Fixed, y: Fixed) {
|
||||
fn pointer_enter(self: &Rc<Self>, seat: &Rc<WlSeatGlobal>, x: Fixed, y: Fixed) {
|
||||
self.pointer_move(seat, x.round_down(), y.round_down());
|
||||
}
|
||||
|
||||
|
|
@ -1265,7 +1312,7 @@ impl Node for ContainerNode {
|
|||
}
|
||||
}
|
||||
|
||||
fn pointer_motion(self: Rc<Self>, seat: &Rc<WlSeatGlobal>, x: Fixed, y: Fixed) {
|
||||
fn pointer_motion(self: &Rc<Self>, seat: &Rc<WlSeatGlobal>, x: Fixed, y: Fixed) {
|
||||
self.pointer_move(seat, x.round_down(), y.round_down());
|
||||
}
|
||||
|
||||
|
|
@ -1273,8 +1320,8 @@ impl Node for ContainerNode {
|
|||
renderer.render_container(self, x, y);
|
||||
}
|
||||
|
||||
fn into_container(self: Rc<Self>) -> Option<Rc<ContainerNode>> {
|
||||
Some(self)
|
||||
fn into_container(self: &Rc<Self>) -> Option<Rc<ContainerNode>> {
|
||||
Some(self.clone())
|
||||
}
|
||||
|
||||
fn is_container(&self) -> bool {
|
||||
|
|
@ -1285,7 +1332,7 @@ impl Node for ContainerNode {
|
|||
true
|
||||
}
|
||||
|
||||
fn insert_child(self: Rc<Self>, node: Rc<dyn Node>, direction: Direction) {
|
||||
fn insert_child(self: &Rc<Self>, node: Rc<dyn Node>, direction: Direction) {
|
||||
let (split, right) = direction_to_split(direction);
|
||||
if split != self.split.get() || right {
|
||||
self.append_child(node);
|
||||
|
|
@ -1294,7 +1341,7 @@ impl Node for ContainerNode {
|
|||
}
|
||||
}
|
||||
|
||||
fn change_extents(self: Rc<Self>, rect: &Rect) {
|
||||
fn change_extents(self: &Rc<Self>, rect: &Rect) {
|
||||
self.abs_x1.set(rect.x1());
|
||||
self.abs_y1.set(rect.y1());
|
||||
let mut size_changed = false;
|
||||
|
|
@ -1306,45 +1353,39 @@ impl Node for ContainerNode {
|
|||
self.cancel_seat_ops();
|
||||
self.parent
|
||||
.get()
|
||||
.child_size_changed(&*self, rect.width(), rect.height());
|
||||
.node_child_size_changed(self.deref(), rect.width(), rect.height());
|
||||
} else {
|
||||
if let Some(c) = self.mono_child.get() {
|
||||
let body = self
|
||||
.mono_body
|
||||
.get()
|
||||
.move_(self.abs_x1.get(), self.abs_y1.get());
|
||||
c.node.clone().change_extents(&body);
|
||||
c.node.clone().node_change_extents(&body);
|
||||
} else {
|
||||
for child in self.children.iter() {
|
||||
let body = child.body.get().move_(self.abs_x1.get(), self.abs_y1.get());
|
||||
child.node.clone().change_extents(&body);
|
||||
child.node.clone().node_change_extents(&body);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn set_workspace(self: Rc<Self>, ws: &Rc<WorkspaceNode>) {
|
||||
fn set_workspace(self: &Rc<Self>, ws: &Rc<WorkspaceNode>) {
|
||||
for child in self.children.iter() {
|
||||
child.node.clone().set_workspace(ws);
|
||||
child.node.clone().node_set_workspace(ws);
|
||||
}
|
||||
self.workspace.set(ws.clone());
|
||||
}
|
||||
|
||||
fn set_parent(self: Rc<Self>, parent: Rc<dyn Node>) {
|
||||
fn set_parent(self: &Rc<Self>, parent: Rc<dyn Node>) {
|
||||
self.parent.set(parent.clone());
|
||||
parent
|
||||
.clone()
|
||||
.child_active_changed(&*self, self.active.get());
|
||||
parent.child_size_changed(&*self, self.width.get(), self.height.get());
|
||||
.node_child_active_changed(self.deref(), self.active.get());
|
||||
parent.node_child_size_changed(self.deref(), self.width.get(), self.height.get());
|
||||
parent
|
||||
.clone()
|
||||
.child_title_changed(&*self, self.title.borrow_mut().deref());
|
||||
}
|
||||
|
||||
fn close(&self) {
|
||||
for child in self.children.iter() {
|
||||
child.node.close();
|
||||
}
|
||||
.node_child_title_changed(self.deref(), self.title.borrow_mut().deref());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,9 @@ use {
|
|||
wl_seat::{NodeSeatState, WlSeatGlobal},
|
||||
zwlr_layer_shell_v1::{OVERLAY, TOP},
|
||||
},
|
||||
tree::{walker::NodeVisitor, FindTreeResult, FoundNode, Node, NodeId, OutputNode},
|
||||
tree::{
|
||||
walker::NodeVisitor, FindTreeResult, FoundNode, Node, NodeId, OutputNode, SizedNode,
|
||||
},
|
||||
utils::{copyhashmap::CopyHashMap, linkedlist::LinkedList},
|
||||
},
|
||||
std::{ops::Deref, rc::Rc},
|
||||
|
|
@ -30,7 +32,7 @@ impl DisplayNode {
|
|||
}
|
||||
}
|
||||
|
||||
impl Node for DisplayNode {
|
||||
impl SizedNode for DisplayNode {
|
||||
fn id(&self) -> NodeId {
|
||||
self.id
|
||||
}
|
||||
|
|
@ -39,24 +41,20 @@ impl Node for DisplayNode {
|
|||
&self.seat_state
|
||||
}
|
||||
|
||||
fn visible(&self) -> bool {
|
||||
true
|
||||
}
|
||||
|
||||
fn destroy_node(&self, _detach: bool) {
|
||||
let mut outputs = self.outputs.lock();
|
||||
for output in outputs.values() {
|
||||
output.destroy_node(false);
|
||||
output.node_destroy(false);
|
||||
}
|
||||
outputs.clear();
|
||||
for stacked in self.stacked.iter() {
|
||||
stacked.destroy_node(false);
|
||||
stacked.node_destroy(false);
|
||||
}
|
||||
self.seat_state.destroy_node(self);
|
||||
}
|
||||
|
||||
fn visit(self: Rc<Self>, visitor: &mut dyn NodeVisitor) {
|
||||
visitor.visit_display(&self);
|
||||
fn visit(self: &Rc<Self>, visitor: &mut dyn NodeVisitor) {
|
||||
visitor.visit_display(self);
|
||||
}
|
||||
|
||||
fn visit_children(&self, visitor: &mut dyn NodeVisitor) {
|
||||
|
|
@ -65,10 +63,14 @@ impl Node for DisplayNode {
|
|||
visitor.visit_output(output);
|
||||
}
|
||||
for stacked in self.stacked.iter() {
|
||||
stacked.deref().clone().visit(visitor);
|
||||
stacked.deref().clone().node_visit(visitor);
|
||||
}
|
||||
}
|
||||
|
||||
fn visible(&self) -> bool {
|
||||
true
|
||||
}
|
||||
|
||||
fn find_tree_at(&self, x: i32, y: i32, tree: &mut Vec<FoundNode>) -> FindTreeResult {
|
||||
let outputs = self.outputs.lock();
|
||||
for output in outputs.values() {
|
||||
|
|
@ -90,8 +92,8 @@ impl Node for DisplayNode {
|
|||
}
|
||||
}
|
||||
for stacked in self.stacked.rev_iter() {
|
||||
let ext = stacked.absolute_position();
|
||||
if stacked.absolute_position_constrains_input() && !ext.contains(x, y) {
|
||||
let ext = stacked.node_absolute_position();
|
||||
if stacked.node_absolute_position_constrains_input() && !ext.contains(x, y) {
|
||||
// TODO: make constrain always true
|
||||
continue;
|
||||
}
|
||||
|
|
@ -102,7 +104,7 @@ impl Node for DisplayNode {
|
|||
x,
|
||||
y,
|
||||
});
|
||||
match stacked.find_tree_at(x, y, tree) {
|
||||
match stacked.node_find_tree_at(x, y, tree) {
|
||||
FindTreeResult::AcceptsInput => {
|
||||
return FindTreeResult::AcceptsInput;
|
||||
}
|
||||
|
|
@ -120,7 +122,7 @@ impl Node for DisplayNode {
|
|||
x,
|
||||
y,
|
||||
});
|
||||
output.find_tree_at(x, y, tree);
|
||||
output.node_find_tree_at(x, y, tree);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,7 +9,9 @@ use {
|
|||
state::State,
|
||||
text,
|
||||
theme::Color,
|
||||
tree::{walker::NodeVisitor, FindTreeResult, FoundNode, Node, NodeId, WorkspaceNode},
|
||||
tree::{
|
||||
walker::NodeVisitor, FindTreeResult, FoundNode, Node, NodeId, SizedNode, WorkspaceNode,
|
||||
},
|
||||
utils::{clonecell::CloneCell, errorfmt::ErrorFmt, linkedlist::LinkedNode},
|
||||
},
|
||||
ahash::AHashMap,
|
||||
|
|
@ -113,8 +115,8 @@ impl FloatNode {
|
|||
floater
|
||||
.workspace_link
|
||||
.set(Some(ws.stacked.add_last(floater.clone())));
|
||||
child.clone().set_workspace(ws);
|
||||
child.clone().set_parent(floater.clone());
|
||||
child.clone().node_set_workspace(ws);
|
||||
child.clone().node_set_parent(floater.clone());
|
||||
floater.schedule_layout();
|
||||
floater
|
||||
}
|
||||
|
|
@ -149,7 +151,7 @@ impl FloatNode {
|
|||
(pos.height() - 2 * bw - th - 1).max(0),
|
||||
)
|
||||
.unwrap();
|
||||
child.clone().change_extents(&cpos);
|
||||
child.clone().node_change_extents(&cpos);
|
||||
self.layout_scheduled.set(false);
|
||||
self.schedule_render_titles();
|
||||
}
|
||||
|
|
@ -318,7 +320,7 @@ impl Debug for FloatNode {
|
|||
}
|
||||
}
|
||||
|
||||
impl Node for FloatNode {
|
||||
impl SizedNode for FloatNode {
|
||||
fn id(&self) -> NodeId {
|
||||
self.id.into()
|
||||
}
|
||||
|
|
@ -327,6 +329,25 @@ impl Node for FloatNode {
|
|||
&self.seat_state
|
||||
}
|
||||
|
||||
fn destroy_node(&self, _detach: bool) {
|
||||
let _v = self.display_link.take();
|
||||
let _v = self.workspace_link.take();
|
||||
if let Some(child) = self.child.get() {
|
||||
child.node_destroy(false);
|
||||
}
|
||||
self.seat_state.destroy_node(self);
|
||||
}
|
||||
|
||||
fn visit(self: &Rc<Self>, visitor: &mut dyn NodeVisitor) {
|
||||
visitor.visit_float(self);
|
||||
}
|
||||
|
||||
fn visit_children(&self, visitor: &mut dyn NodeVisitor) {
|
||||
if let Some(c) = self.child.get() {
|
||||
c.node_visit(visitor);
|
||||
}
|
||||
}
|
||||
|
||||
fn visible(&self) -> bool {
|
||||
self.visible.get()
|
||||
}
|
||||
|
|
@ -334,35 +355,16 @@ impl Node for FloatNode {
|
|||
fn set_visible(&self, visible: bool) {
|
||||
self.visible.set(visible);
|
||||
if let Some(child) = self.child.get() {
|
||||
child.set_visible(visible);
|
||||
child.node_set_visible(visible);
|
||||
}
|
||||
self.seat_state.set_visible(self, visible);
|
||||
}
|
||||
|
||||
fn destroy_node(&self, _detach: bool) {
|
||||
let _v = self.display_link.take();
|
||||
let _v = self.workspace_link.take();
|
||||
if let Some(child) = self.child.get() {
|
||||
child.destroy_node(false);
|
||||
}
|
||||
self.seat_state.destroy_node(self);
|
||||
}
|
||||
|
||||
fn visit(self: Rc<Self>, visitor: &mut dyn NodeVisitor) {
|
||||
visitor.visit_float(&self);
|
||||
}
|
||||
|
||||
fn visit_children(&self, visitor: &mut dyn NodeVisitor) {
|
||||
if let Some(c) = self.child.get() {
|
||||
c.visit(visitor);
|
||||
}
|
||||
}
|
||||
|
||||
fn get_workspace(&self) -> Option<Rc<WorkspaceNode>> {
|
||||
Some(self.workspace.get())
|
||||
}
|
||||
|
||||
fn child_title_changed(self: Rc<Self>, _child: &dyn Node, title: &str) {
|
||||
fn child_title_changed(self: &Rc<Self>, _child: &dyn Node, title: &str) {
|
||||
let mut t = self.title.borrow_mut();
|
||||
if t.deref() != title {
|
||||
t.clear();
|
||||
|
|
@ -375,7 +377,7 @@ impl Node for FloatNode {
|
|||
self.position.get()
|
||||
}
|
||||
|
||||
fn button(self: Rc<Self>, seat: &Rc<WlSeatGlobal>, button: u32, state: KeyState) {
|
||||
fn button(self: &Rc<Self>, seat: &Rc<WlSeatGlobal>, button: u32, state: KeyState) {
|
||||
if button != BTN_LEFT {
|
||||
return;
|
||||
}
|
||||
|
|
@ -443,27 +445,27 @@ impl Node for FloatNode {
|
|||
x,
|
||||
y,
|
||||
});
|
||||
child.find_tree_at(x, y, tree)
|
||||
child.node_find_tree_at(x, y, tree)
|
||||
}
|
||||
|
||||
fn replace_child(self: Rc<Self>, _old: &dyn Node, new: Rc<dyn Node>) {
|
||||
fn replace_child(self: &Rc<Self>, _old: &dyn Node, new: Rc<dyn Node>) {
|
||||
self.child.set(Some(new.clone()));
|
||||
new.clone().set_parent(self.clone());
|
||||
new.clone().set_workspace(&self.workspace.get());
|
||||
new.clone().node_set_parent(self.clone());
|
||||
new.clone().node_set_workspace(&self.workspace.get());
|
||||
self.schedule_layout();
|
||||
}
|
||||
|
||||
fn remove_child(self: Rc<Self>, _child: &dyn Node) {
|
||||
fn remove_child(self: &Rc<Self>, _child: &dyn Node) {
|
||||
self.child.set(None);
|
||||
self.display_link.set(None);
|
||||
self.workspace_link.set(None);
|
||||
}
|
||||
|
||||
fn child_active_changed(self: Rc<Self>, _child: &dyn Node, active: bool) {
|
||||
fn child_active_changed(self: &Rc<Self>, _child: &dyn Node, active: bool) {
|
||||
self.active.set(active);
|
||||
}
|
||||
|
||||
fn pointer_enter(self: Rc<Self>, seat: &Rc<WlSeatGlobal>, x: Fixed, y: Fixed) {
|
||||
fn pointer_enter(self: &Rc<Self>, seat: &Rc<WlSeatGlobal>, x: Fixed, y: Fixed) {
|
||||
self.pointer_move(seat, x.round_down(), y.round_down());
|
||||
}
|
||||
|
||||
|
|
@ -482,7 +484,7 @@ impl Node for FloatNode {
|
|||
}
|
||||
}
|
||||
|
||||
fn pointer_motion(self: Rc<Self>, seat: &Rc<WlSeatGlobal>, x: Fixed, y: Fixed) {
|
||||
fn pointer_motion(self: &Rc<Self>, seat: &Rc<WlSeatGlobal>, x: Fixed, y: Fixed) {
|
||||
self.pointer_move(seat, x.round_down(), y.round_down());
|
||||
}
|
||||
|
||||
|
|
@ -490,8 +492,8 @@ impl Node for FloatNode {
|
|||
renderer.render_floating(self, x, y)
|
||||
}
|
||||
|
||||
fn into_float(self: Rc<Self>) -> Option<Rc<FloatNode>> {
|
||||
Some(self)
|
||||
fn into_float(self: &Rc<Self>) -> Option<Rc<FloatNode>> {
|
||||
Some(self.clone())
|
||||
}
|
||||
|
||||
fn accepts_child(&self, _node: &dyn Node) -> bool {
|
||||
|
|
@ -502,9 +504,9 @@ impl Node for FloatNode {
|
|||
true
|
||||
}
|
||||
|
||||
fn set_workspace(self: Rc<Self>, ws: &Rc<WorkspaceNode>) {
|
||||
fn set_workspace(self: &Rc<Self>, ws: &Rc<WorkspaceNode>) {
|
||||
if let Some(c) = self.child.get() {
|
||||
c.set_workspace(ws);
|
||||
c.node_set_workspace(ws);
|
||||
}
|
||||
self.workspace_link
|
||||
.set(Some(ws.stacked.add_last(self.clone())));
|
||||
|
|
|
|||
|
|
@ -13,7 +13,9 @@ use {
|
|||
state::State,
|
||||
text,
|
||||
theme::Color,
|
||||
tree::{walker::NodeVisitor, FindTreeResult, FoundNode, Node, NodeId, WorkspaceNode},
|
||||
tree::{
|
||||
walker::NodeVisitor, FindTreeResult, FoundNode, Node, NodeId, SizedNode, WorkspaceNode,
|
||||
},
|
||||
utils::{clonecell::CloneCell, errorfmt::ErrorFmt, linkedlist::LinkedList},
|
||||
},
|
||||
std::{
|
||||
|
|
@ -147,10 +149,10 @@ impl OutputNode {
|
|||
if old.id == ws.id {
|
||||
return;
|
||||
}
|
||||
old.set_visible(false);
|
||||
old.node_set_visible(false);
|
||||
}
|
||||
ws.set_visible(true);
|
||||
ws.clone().change_extents(&self.workspace_rect());
|
||||
ws.node_set_visible(true);
|
||||
ws.clone().node_change_extents(&self.workspace_rect());
|
||||
}
|
||||
|
||||
fn workspace_rect(&self) -> Rect {
|
||||
|
|
@ -188,11 +190,11 @@ impl OutputNode {
|
|||
self.global.pos.set(*rect);
|
||||
self.update_render_data();
|
||||
if let Some(c) = self.workspace.get() {
|
||||
c.change_extents(&self.workspace_rect());
|
||||
c.node_change_extents(&self.workspace_rect());
|
||||
}
|
||||
for layer in &self.layers {
|
||||
for surface in layer.iter() {
|
||||
surface.deref().clone().change_extents(&rect);
|
||||
surface.deref().clone().node_change_extents(&rect);
|
||||
}
|
||||
}
|
||||
self.global.send_mode();
|
||||
|
|
@ -208,10 +210,10 @@ impl OutputNode {
|
|||
let len = tree.len();
|
||||
for layer in layers.iter().copied() {
|
||||
for surface in self.layers[layer as usize].rev_iter() {
|
||||
let pos = surface.absolute_position();
|
||||
let pos = surface.output_position();
|
||||
if pos.contains(x, y) {
|
||||
let (x, y) = pos.translate(x, y);
|
||||
if surface.find_tree_at(x, y, tree) == FindTreeResult::AcceptsInput {
|
||||
if surface.node_find_tree_at(x, y, tree) == FindTreeResult::AcceptsInput {
|
||||
return FindTreeResult::AcceptsInput;
|
||||
}
|
||||
tree.truncate(len);
|
||||
|
|
@ -247,7 +249,7 @@ impl Debug for OutputNode {
|
|||
}
|
||||
}
|
||||
|
||||
impl Node for OutputNode {
|
||||
impl SizedNode for OutputNode {
|
||||
fn id(&self) -> NodeId {
|
||||
self.id.into()
|
||||
}
|
||||
|
|
@ -256,24 +258,20 @@ impl Node for OutputNode {
|
|||
&self.seat_state
|
||||
}
|
||||
|
||||
fn visible(&self) -> bool {
|
||||
true
|
||||
}
|
||||
|
||||
fn destroy_node(&self, detach: bool) {
|
||||
if detach {
|
||||
self.state.root.clone().remove_child(self);
|
||||
self.state.root.clone().node_remove_child(self);
|
||||
}
|
||||
self.workspace.set(None);
|
||||
let workspaces: Vec<_> = self.workspaces.iter().map(|e| e.deref().clone()).collect();
|
||||
for workspace in workspaces {
|
||||
workspace.destroy_node(false);
|
||||
workspace.node_destroy(false);
|
||||
}
|
||||
self.seat_state.destroy_node(self);
|
||||
}
|
||||
|
||||
fn visit(self: Rc<Self>, visitor: &mut dyn NodeVisitor) {
|
||||
visitor.visit_output(&self);
|
||||
fn visit(self: &Rc<Self>, visitor: &mut dyn NodeVisitor) {
|
||||
visitor.visit_output(self);
|
||||
}
|
||||
|
||||
fn visit_children(&self, visitor: &mut dyn NodeVisitor) {
|
||||
|
|
@ -287,6 +285,10 @@ impl Node for OutputNode {
|
|||
}
|
||||
}
|
||||
|
||||
fn visible(&self) -> bool {
|
||||
true
|
||||
}
|
||||
|
||||
fn absolute_position(&self) -> Rect {
|
||||
self.global.pos.get()
|
||||
}
|
||||
|
|
@ -302,7 +304,7 @@ impl Node for OutputNode {
|
|||
x,
|
||||
y,
|
||||
});
|
||||
ws.find_tree_at(x, y, tree);
|
||||
ws.node_find_tree_at(x, y, tree);
|
||||
}
|
||||
if tree.len() == len {
|
||||
self.find_layer_surface_at(x, y, &[BOTTOM, BACKGROUND], tree);
|
||||
|
|
@ -311,7 +313,7 @@ impl Node for OutputNode {
|
|||
FindTreeResult::AcceptsInput
|
||||
}
|
||||
|
||||
fn remove_child(self: Rc<Self>, _child: &dyn Node) {
|
||||
fn remove_child(self: &Rc<Self>, _child: &dyn Node) {
|
||||
unimplemented!();
|
||||
}
|
||||
|
||||
|
|
@ -327,7 +329,7 @@ impl Node for OutputNode {
|
|||
true
|
||||
}
|
||||
|
||||
fn into_output(self: Rc<Self>) -> Option<Rc<OutputNode>> {
|
||||
Some(self)
|
||||
fn into_output(self: &Rc<Self>) -> Option<Rc<OutputNode>> {
|
||||
Some(self.clone())
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,43 +13,43 @@ use {
|
|||
|
||||
pub trait NodeVisitorBase: Sized {
|
||||
fn visit_surface(&mut self, node: &Rc<WlSurface>) {
|
||||
node.visit_children(self);
|
||||
node.node_visit_children(self);
|
||||
}
|
||||
|
||||
fn visit_container(&mut self, node: &Rc<ContainerNode>) {
|
||||
node.visit_children(self);
|
||||
node.node_visit_children(self);
|
||||
}
|
||||
|
||||
fn visit_toplevel(&mut self, node: &Rc<XdgToplevel>) {
|
||||
node.visit_children(self);
|
||||
node.node_visit_children(self);
|
||||
}
|
||||
|
||||
fn visit_popup(&mut self, node: &Rc<XdgPopup>) {
|
||||
node.visit_children(self);
|
||||
node.node_visit_children(self);
|
||||
}
|
||||
|
||||
fn visit_display(&mut self, node: &Rc<DisplayNode>) {
|
||||
node.visit_children(self);
|
||||
node.node_visit_children(self);
|
||||
}
|
||||
|
||||
fn visit_output(&mut self, node: &Rc<OutputNode>) {
|
||||
node.visit_children(self);
|
||||
node.node_visit_children(self);
|
||||
}
|
||||
|
||||
fn visit_float(&mut self, node: &Rc<FloatNode>) {
|
||||
node.visit_children(self);
|
||||
node.node_visit_children(self);
|
||||
}
|
||||
|
||||
fn visit_workspace(&mut self, node: &Rc<WorkspaceNode>) {
|
||||
node.visit_children(self);
|
||||
node.node_visit_children(self);
|
||||
}
|
||||
|
||||
fn visit_layer_surface(&mut self, node: &Rc<ZwlrLayerSurfaceV1>) {
|
||||
node.visit_children(self);
|
||||
node.node_visit_children(self);
|
||||
}
|
||||
|
||||
fn visit_xwindow(&mut self, node: &Rc<Xwindow>) {
|
||||
node.visit_children(self);
|
||||
node.node_visit_children(self);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -119,52 +119,52 @@ pub fn generic_node_visitor<F: FnMut(Rc<dyn Node>)>(f: F) -> GenericNodeVisitor<
|
|||
impl<F: FnMut(Rc<dyn Node>)> NodeVisitor for GenericNodeVisitor<F> {
|
||||
fn visit_surface(&mut self, node: &Rc<WlSurface>) {
|
||||
(self.f)(node.clone());
|
||||
node.visit_children(self);
|
||||
node.node_visit_children(self);
|
||||
}
|
||||
|
||||
fn visit_container(&mut self, node: &Rc<ContainerNode>) {
|
||||
(self.f)(node.clone());
|
||||
node.visit_children(self);
|
||||
node.node_visit_children(self);
|
||||
}
|
||||
|
||||
fn visit_toplevel(&mut self, node: &Rc<XdgToplevel>) {
|
||||
(self.f)(node.clone());
|
||||
node.visit_children(self);
|
||||
node.node_visit_children(self);
|
||||
}
|
||||
|
||||
fn visit_popup(&mut self, node: &Rc<XdgPopup>) {
|
||||
(self.f)(node.clone());
|
||||
node.visit_children(self);
|
||||
node.node_visit_children(self);
|
||||
}
|
||||
|
||||
fn visit_display(&mut self, node: &Rc<DisplayNode>) {
|
||||
(self.f)(node.clone());
|
||||
node.visit_children(self);
|
||||
node.node_visit_children(self);
|
||||
}
|
||||
|
||||
fn visit_output(&mut self, node: &Rc<OutputNode>) {
|
||||
(self.f)(node.clone());
|
||||
node.visit_children(self);
|
||||
node.node_visit_children(self);
|
||||
}
|
||||
|
||||
fn visit_float(&mut self, node: &Rc<FloatNode>) {
|
||||
(self.f)(node.clone());
|
||||
node.visit_children(self);
|
||||
node.node_visit_children(self);
|
||||
}
|
||||
|
||||
fn visit_workspace(&mut self, node: &Rc<WorkspaceNode>) {
|
||||
(self.f)(node.clone());
|
||||
node.visit_children(self);
|
||||
node.node_visit_children(self);
|
||||
}
|
||||
|
||||
fn visit_layer_surface(&mut self, node: &Rc<ZwlrLayerSurfaceV1>) {
|
||||
(self.f)(node.clone());
|
||||
node.visit_children(self);
|
||||
node.node_visit_children(self);
|
||||
}
|
||||
|
||||
fn visit_xwindow(&mut self, node: &Rc<Xwindow>) {
|
||||
(self.f)(node.clone());
|
||||
node.visit_children(self);
|
||||
node.node_visit_children(self);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ use {
|
|||
render::Renderer,
|
||||
tree::{
|
||||
container::ContainerNode, walker::NodeVisitor, FindTreeResult, FoundNode, Node, NodeId,
|
||||
OutputNode,
|
||||
OutputNode, SizedNode,
|
||||
},
|
||||
utils::{
|
||||
clonecell::CloneCell,
|
||||
|
|
@ -33,14 +33,14 @@ pub struct WorkspaceNode {
|
|||
impl WorkspaceNode {
|
||||
pub fn set_container(self: &Rc<Self>, container: &Rc<ContainerNode>) {
|
||||
let pos = self.position.get();
|
||||
container.clone().change_extents(&pos);
|
||||
container.clone().set_workspace(self);
|
||||
container.set_visible(self.visible.get());
|
||||
container.clone().node_change_extents(&pos);
|
||||
container.clone().node_set_workspace(self);
|
||||
container.node_set_visible(self.visible.get());
|
||||
self.container.set(Some(container.clone()));
|
||||
}
|
||||
}
|
||||
|
||||
impl Node for WorkspaceNode {
|
||||
impl SizedNode for WorkspaceNode {
|
||||
fn id(&self) -> NodeId {
|
||||
self.id.into()
|
||||
}
|
||||
|
|
@ -49,6 +49,27 @@ impl Node for WorkspaceNode {
|
|||
&self.seat_state
|
||||
}
|
||||
|
||||
fn destroy_node(&self, detach: bool) {
|
||||
if detach {
|
||||
self.output.get().node_remove_child(self);
|
||||
}
|
||||
self.output_link.set(None);
|
||||
if let Some(container) = self.container.take() {
|
||||
container.node_destroy(false);
|
||||
}
|
||||
self.seat_state.destroy_node(self);
|
||||
}
|
||||
|
||||
fn visit(self: &Rc<Self>, visitor: &mut dyn NodeVisitor) {
|
||||
visitor.visit_workspace(self);
|
||||
}
|
||||
|
||||
fn visit_children(&self, visitor: &mut dyn NodeVisitor) {
|
||||
if let Some(c) = self.container.get() {
|
||||
visitor.visit_container(&c);
|
||||
}
|
||||
}
|
||||
|
||||
fn visible(&self) -> bool {
|
||||
self.visible.get()
|
||||
}
|
||||
|
|
@ -56,32 +77,11 @@ impl Node for WorkspaceNode {
|
|||
fn set_visible(&self, visible: bool) {
|
||||
self.visible.set(visible);
|
||||
if let Some(container) = self.container.get() {
|
||||
container.set_visible(visible);
|
||||
container.node_set_visible(visible);
|
||||
}
|
||||
self.seat_state.set_visible(self, visible);
|
||||
}
|
||||
|
||||
fn destroy_node(&self, detach: bool) {
|
||||
if detach {
|
||||
self.output.get().remove_child(self);
|
||||
}
|
||||
self.output_link.set(None);
|
||||
if let Some(container) = self.container.take() {
|
||||
container.destroy_node(false);
|
||||
}
|
||||
self.seat_state.destroy_node(self);
|
||||
}
|
||||
|
||||
fn visit(self: Rc<Self>, visitor: &mut dyn NodeVisitor) {
|
||||
visitor.visit_workspace(&self);
|
||||
}
|
||||
|
||||
fn visit_children(&self, visitor: &mut dyn NodeVisitor) {
|
||||
if let Some(c) = self.container.get() {
|
||||
visitor.visit_container(&c);
|
||||
}
|
||||
}
|
||||
|
||||
fn absolute_position(&self) -> Rect {
|
||||
self.position.get()
|
||||
}
|
||||
|
|
@ -93,12 +93,12 @@ impl Node for WorkspaceNode {
|
|||
x,
|
||||
y,
|
||||
});
|
||||
n.find_tree_at(x, y, tree);
|
||||
n.node_find_tree_at(x, y, tree);
|
||||
}
|
||||
FindTreeResult::AcceptsInput
|
||||
}
|
||||
|
||||
fn remove_child(self: Rc<Self>, _child: &dyn Node) {
|
||||
fn remove_child(self: &Rc<Self>, _child: &dyn Node) {
|
||||
self.container.set(None);
|
||||
}
|
||||
|
||||
|
|
@ -111,17 +111,17 @@ impl Node for WorkspaceNode {
|
|||
}
|
||||
|
||||
fn accepts_child(&self, node: &dyn Node) -> bool {
|
||||
node.is_container()
|
||||
node.node_is_container()
|
||||
}
|
||||
|
||||
fn is_workspace(&self) -> bool {
|
||||
true
|
||||
}
|
||||
|
||||
fn change_extents(self: Rc<Self>, rect: &Rect) {
|
||||
fn change_extents(self: &Rc<Self>, rect: &Rect) {
|
||||
self.position.set(*rect);
|
||||
if let Some(c) = self.container.get() {
|
||||
c.change_extents(rect);
|
||||
c.node_change_extents(rect);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1229,7 +1229,7 @@ impl Wm {
|
|||
let or = or != 0;
|
||||
if data.info.override_redirect.replace(or) != or {
|
||||
if let Some(window) = data.window.get() {
|
||||
window.destroy_node(true);
|
||||
window.node_destroy(true);
|
||||
window.map_status_changed();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue