tree: add Node::node_location
This commit is contained in:
parent
f75051281b
commit
289c201a69
20 changed files with 152 additions and 45 deletions
|
|
@ -6,6 +6,7 @@ use {
|
|||
},
|
||||
leaks::Tracker,
|
||||
object::{Object, Version},
|
||||
tree::NodeLocation,
|
||||
wire::{ExtSessionLockV1Id, ext_session_lock_v1::*},
|
||||
},
|
||||
std::{cell::Cell, rc::Rc},
|
||||
|
|
@ -87,7 +88,7 @@ impl ExtSessionLockV1RequestHandler for ExtSessionLockV1 {
|
|||
node.set_lock_surface(Some(new.clone()));
|
||||
let pos = node.global.pos.get();
|
||||
new.change_extents(pos);
|
||||
new.surface.set_output(&node);
|
||||
new.surface.set_output(&node, NodeLocation::Output(node.id));
|
||||
self.client.state.tree_changed();
|
||||
}
|
||||
Ok(())
|
||||
|
|
|
|||
|
|
@ -79,8 +79,8 @@ use {
|
|||
rect::Rect,
|
||||
state::{DeviceHandlerData, State},
|
||||
tree::{
|
||||
ContainerNode, ContainerSplit, Direction, FoundNode, Node, NodeId, OutputNode,
|
||||
ToplevelNode, WorkspaceNode, generic_node_visitor, toplevel_create_split,
|
||||
ContainerNode, ContainerSplit, Direction, FoundNode, Node, NodeId, NodeLocation,
|
||||
OutputNode, ToplevelNode, WorkspaceNode, generic_node_visitor, toplevel_create_split,
|
||||
toplevel_parent_container, toplevel_set_floating, toplevel_set_workspace,
|
||||
},
|
||||
utils::{
|
||||
|
|
@ -717,7 +717,9 @@ impl WlSeatGlobal {
|
|||
serial: u64,
|
||||
) -> Result<(), WlSeatError> {
|
||||
if let Some(icon) = &icon {
|
||||
icon.surface().set_output(&self.pointer_cursor.output());
|
||||
let output = self.pointer_cursor.output();
|
||||
icon.surface()
|
||||
.set_output(&output, NodeLocation::Output(output.id));
|
||||
}
|
||||
self.pointer_owner
|
||||
.start_drag(self, origin, source, icon, serial)
|
||||
|
|
@ -1082,7 +1084,8 @@ impl WlSeatGlobal {
|
|||
impl CursorUserOwner for WlSeatGlobal {
|
||||
fn output_changed(&self, output: &Rc<OutputNode>) {
|
||||
if let Some(dnd) = self.pointer_owner.dnd_icon() {
|
||||
dnd.surface().set_output(output);
|
||||
dnd.surface()
|
||||
.set_output(output, NodeLocation::Output(output.id));
|
||||
}
|
||||
if let Some(drag) = self.pointer_owner.toplevel_drag()
|
||||
&& let Some(tl) = drag.toplevel.get()
|
||||
|
|
|
|||
|
|
@ -76,8 +76,8 @@ use {
|
|||
renderer::Renderer,
|
||||
tree::{
|
||||
BeforeLatchListener, BeforeLatchResult, ContainerNode, FindTreeResult, FoundNode,
|
||||
LatchListener, Node, NodeId, NodeVisitor, NodeVisitorBase, OutputNode, PlaceholderNode,
|
||||
PresentationListener, ToplevelNode, VblankListener,
|
||||
LatchListener, Node, NodeId, NodeLocation, NodeVisitor, NodeVisitorBase, OutputNode,
|
||||
PlaceholderNode, PresentationListener, ToplevelNode, VblankListener,
|
||||
},
|
||||
utils::{
|
||||
cell_ext::CellExt, clonecell::CloneCell, copyhashmap::CopyHashMap,
|
||||
|
|
@ -319,6 +319,7 @@ pub struct WlSurface {
|
|||
idle_inhibitors: SmallMap<ZwpIdleInhibitorV1Id, Rc<ZwpIdleInhibitorV1>, 1>,
|
||||
viewporter: CloneCell<Option<Rc<WpViewport>>>,
|
||||
output: CloneCell<Rc<OutputNode>>,
|
||||
location: Cell<NodeLocation>,
|
||||
fractional_scale: CloneCell<Option<Rc<WpFractionalScaleV1>>>,
|
||||
pub constraints: SmallMap<SeatId, Rc<SeatConstraint>, 1>,
|
||||
xwayland_serial: Cell<Option<u64>>,
|
||||
|
|
@ -623,6 +624,7 @@ pub struct StackElement {
|
|||
|
||||
impl WlSurface {
|
||||
pub fn new(id: WlSurfaceId, client: &Rc<Client>, version: Version, slf: &Weak<Self>) -> Self {
|
||||
let dummy_output = client.state.dummy_output.get().unwrap();
|
||||
Self {
|
||||
id,
|
||||
node_id: client.state.node_ids.next(),
|
||||
|
|
@ -662,7 +664,8 @@ impl WlSurface {
|
|||
tracker: Default::default(),
|
||||
idle_inhibitors: Default::default(),
|
||||
viewporter: Default::default(),
|
||||
output: CloneCell::new(client.state.dummy_output.get().unwrap()),
|
||||
location: Cell::new(NodeLocation::Output(dummy_output.id)),
|
||||
output: CloneCell::new(dummy_output),
|
||||
fractional_scale: Default::default(),
|
||||
constraints: Default::default(),
|
||||
xwayland_serial: Default::default(),
|
||||
|
|
@ -715,7 +718,8 @@ impl WlSurface {
|
|||
self.output.get()
|
||||
}
|
||||
|
||||
pub fn set_output(&self, output: &Rc<OutputNode>) {
|
||||
pub fn set_output(&self, output: &Rc<OutputNode>, location: NodeLocation) {
|
||||
self.location.set(location);
|
||||
let old = self.output.set(output.clone());
|
||||
if old.id == output.id {
|
||||
return;
|
||||
|
|
@ -737,7 +741,7 @@ impl WlSurface {
|
|||
let children = self.children.borrow_mut();
|
||||
if let Some(children) = &*children {
|
||||
for ss in children.subsurfaces.values() {
|
||||
ss.surface.set_output(output);
|
||||
ss.surface.set_output(output, location);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1788,6 +1792,10 @@ impl Node for WlSurface {
|
|||
Some(self.output.get())
|
||||
}
|
||||
|
||||
fn node_location(&self) -> Option<NodeLocation> {
|
||||
Some(self.location.get())
|
||||
}
|
||||
|
||||
fn node_active_changed(&self, active: bool) {
|
||||
if let Some(tl) = self.toplevel.get() {
|
||||
tl.tl_surface_active_changed(active);
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ use {
|
|||
rect::Rect,
|
||||
renderer::Renderer,
|
||||
scale::Scale,
|
||||
tree::{Node, NodeVisitorBase, OutputNode},
|
||||
tree::{Node, NodeLocation, NodeVisitorBase, OutputNode},
|
||||
},
|
||||
std::{cell::Cell, ops::Deref, rc::Rc},
|
||||
};
|
||||
|
|
@ -133,7 +133,8 @@ impl Cursor for CursorSurface {
|
|||
}
|
||||
|
||||
fn set_output(&self, output: &Rc<OutputNode>) {
|
||||
self.surface.set_output(output);
|
||||
self.surface
|
||||
.set_output(output, NodeLocation::Output(output.id));
|
||||
}
|
||||
|
||||
fn handle_set(self: Rc<Self>) {
|
||||
|
|
|
|||
|
|
@ -10,7 +10,10 @@ use {
|
|||
leaks::Tracker,
|
||||
object::{Object, Version},
|
||||
rect::Rect,
|
||||
tree::{FindTreeResult, FindTreeUsecase, FoundNode, Node, NodeId, NodeVisitor, OutputNode},
|
||||
tree::{
|
||||
FindTreeResult, FindTreeUsecase, FoundNode, Node, NodeId, NodeLocation, NodeVisitor,
|
||||
OutputNode,
|
||||
},
|
||||
utils::numcell::NumCell,
|
||||
wire::{ExtSessionLockSurfaceV1Id, WlSurfaceId, ext_session_lock_surface_v1::*},
|
||||
},
|
||||
|
|
@ -131,6 +134,10 @@ impl Node for ExtSessionLockSurfaceV1 {
|
|||
self.output.node()
|
||||
}
|
||||
|
||||
fn node_location(&self) -> Option<NodeLocation> {
|
||||
self.surface.node_location()
|
||||
}
|
||||
|
||||
fn node_find_tree_at(
|
||||
&self,
|
||||
x: i32,
|
||||
|
|
|
|||
|
|
@ -11,8 +11,8 @@ use {
|
|||
},
|
||||
rect::Rect,
|
||||
tree::{
|
||||
FindTreeResult, FindTreeUsecase, FoundNode, Node, NodeId, NodeVisitor, OutputNode,
|
||||
StackedNode,
|
||||
FindTreeResult, FindTreeUsecase, FoundNode, Node, NodeId, NodeLocation, NodeVisitor,
|
||||
OutputNode, StackedNode,
|
||||
},
|
||||
utils::{
|
||||
copyhashmap::CopyHashMap,
|
||||
|
|
@ -300,6 +300,10 @@ impl<T: TrayItem> Node for T {
|
|||
self.data().output.node()
|
||||
}
|
||||
|
||||
fn node_location(&self) -> Option<NodeLocation> {
|
||||
self.data().surface.node_location()
|
||||
}
|
||||
|
||||
fn node_find_tree_at(
|
||||
&self,
|
||||
x: i32,
|
||||
|
|
@ -328,7 +332,8 @@ fn install<T: TrayItem>(item: &Rc<T>) -> Result<(), TrayItemError> {
|
|||
data.surface.ext.set(item.clone());
|
||||
data.surface.set_visible(false);
|
||||
if let Some(node) = data.output.node() {
|
||||
data.surface.set_output(&node);
|
||||
data.surface
|
||||
.set_output(&node, NodeLocation::Output(node.id));
|
||||
item.send_initial_configure();
|
||||
}
|
||||
Ok(())
|
||||
|
|
|
|||
|
|
@ -186,7 +186,8 @@ impl WlSubsurface {
|
|||
update_children_attach(self)?;
|
||||
let (x, y) = self.parent.buffer_abs_pos.get().position();
|
||||
self.surface.set_absolute_position(x, y);
|
||||
self.surface.set_output(&self.parent.output.get());
|
||||
self.surface
|
||||
.set_output(&self.parent.output.get(), self.parent.location.get());
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -12,8 +12,9 @@ use {
|
|||
state::State,
|
||||
tree::{
|
||||
ContainerSplit, Direction, FindTreeResult, FindTreeUsecase, FoundNode, Node, NodeId,
|
||||
NodeVisitor, OutputNode, StackedNode, TileDragDestination, ToplevelData, ToplevelNode,
|
||||
ToplevelNodeBase, ToplevelType, WorkspaceNode, default_tile_drag_destination,
|
||||
NodeLocation, NodeVisitor, OutputNode, StackedNode, TileDragDestination, ToplevelData,
|
||||
ToplevelNode, ToplevelNodeBase, ToplevelType, WorkspaceNode,
|
||||
default_tile_drag_destination,
|
||||
},
|
||||
utils::{clonecell::CloneCell, copyhashmap::CopyHashMap, linkedlist::LinkedNode},
|
||||
wire::WlSurfaceId,
|
||||
|
|
@ -370,6 +371,10 @@ impl Node for Xwindow {
|
|||
self.toplevel_data.output_opt()
|
||||
}
|
||||
|
||||
fn node_location(&self) -> Option<NodeLocation> {
|
||||
self.x.surface.node_location()
|
||||
}
|
||||
|
||||
fn node_do_focus(self: Rc<Self>, seat: &Rc<WlSeatGlobal>, _direction: Direction) {
|
||||
seat.focus_toplevel(self.clone());
|
||||
}
|
||||
|
|
@ -446,7 +451,7 @@ impl ToplevelNodeBase for Xwindow {
|
|||
}
|
||||
|
||||
fn tl_set_workspace_ext(&self, ws: &Rc<WorkspaceNode>) {
|
||||
self.x.surface.set_output(&ws.output.get());
|
||||
self.x.surface.set_output(&ws.output.get(), ws.location());
|
||||
}
|
||||
|
||||
fn tl_change_extents_impl(self: Rc<Self>, rect: &Rect) {
|
||||
|
|
@ -456,7 +461,9 @@ impl ToplevelNodeBase for Xwindow {
|
|||
if self.data.info.override_redirect.get() {
|
||||
let (x, y) = rect.center();
|
||||
let output = self.data.state.find_closest_output(x, y).0;
|
||||
self.x.surface.set_output(&output);
|
||||
self.x
|
||||
.surface
|
||||
.set_output(&output, NodeLocation::Output(output.id));
|
||||
} else {
|
||||
self.data
|
||||
.state
|
||||
|
|
|
|||
|
|
@ -18,7 +18,9 @@ use {
|
|||
leaks::Tracker,
|
||||
object::Object,
|
||||
rect::Rect,
|
||||
tree::{FindTreeResult, FoundNode, Node, OutputNode, StackedNode, WorkspaceNode},
|
||||
tree::{
|
||||
FindTreeResult, FoundNode, Node, NodeLocation, OutputNode, StackedNode, WorkspaceNode,
|
||||
},
|
||||
utils::{
|
||||
clonecell::CloneCell,
|
||||
copyhashmap::CopyHashMap,
|
||||
|
|
@ -233,7 +235,7 @@ impl XdgSurface {
|
|||
|
||||
fn set_workspace(&self, ws: &Rc<WorkspaceNode>) {
|
||||
self.workspace.set(Some(ws.clone()));
|
||||
self.surface.set_output(&ws.output.get());
|
||||
self.surface.set_output(&ws.output.get(), ws.location());
|
||||
let pu = self.popups.lock();
|
||||
for pu in pu.values() {
|
||||
pu.popup.xdg.set_workspace(ws);
|
||||
|
|
@ -241,7 +243,8 @@ impl XdgSurface {
|
|||
}
|
||||
|
||||
pub fn set_output(&self, output: &Rc<OutputNode>) {
|
||||
self.surface.set_output(output);
|
||||
self.surface
|
||||
.set_output(output, NodeLocation::Output(output.id));
|
||||
let pu = self.popups.lock();
|
||||
for pu in pu.values() {
|
||||
pu.popup.xdg.set_output(output);
|
||||
|
|
|
|||
|
|
@ -19,8 +19,8 @@ use {
|
|||
rect::Rect,
|
||||
renderer::Renderer,
|
||||
tree::{
|
||||
FindTreeResult, FindTreeUsecase, FoundNode, Node, NodeId, NodeVisitor, OutputNode,
|
||||
StackedNode,
|
||||
FindTreeResult, FindTreeUsecase, FoundNode, Node, NodeId, NodeLocation, NodeVisitor,
|
||||
OutputNode, StackedNode,
|
||||
},
|
||||
utils::clonecell::CloneCell,
|
||||
wire::{XdgPopupId, xdg_popup::*},
|
||||
|
|
@ -319,6 +319,10 @@ impl Node for XdgPopup {
|
|||
self.xdg.workspace.get().map(|w| w.output.get())
|
||||
}
|
||||
|
||||
fn node_location(&self) -> Option<NodeLocation> {
|
||||
self.xdg.surface.node_location()
|
||||
}
|
||||
|
||||
fn node_find_tree_at(
|
||||
&self,
|
||||
x: i32,
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ use {
|
|||
state::State,
|
||||
tree::{
|
||||
ContainerSplit, Direction, FindTreeResult, FindTreeUsecase, FoundNode, Node, NodeId,
|
||||
NodeVisitor, OutputNode, TileDragDestination, ToplevelData, ToplevelNode,
|
||||
NodeLocation, NodeVisitor, OutputNode, TileDragDestination, ToplevelData, ToplevelNode,
|
||||
ToplevelNodeBase, ToplevelNodeId, ToplevelType, WorkspaceNode,
|
||||
default_tile_drag_destination,
|
||||
},
|
||||
|
|
@ -512,7 +512,7 @@ impl XdgToplevel {
|
|||
self.extents_changed();
|
||||
if let Some(workspace) = self.xdg.workspace.get() {
|
||||
let output = workspace.output.get();
|
||||
surface.set_output(&output);
|
||||
surface.set_output(&output, workspace.location());
|
||||
}
|
||||
// {
|
||||
// let seats = surface.client.state.globals.lock_seats();
|
||||
|
|
@ -573,6 +573,10 @@ impl Node for XdgToplevel {
|
|||
self.toplevel_data.output_opt()
|
||||
}
|
||||
|
||||
fn node_location(&self) -> Option<NodeLocation> {
|
||||
self.xdg.surface.node_location()
|
||||
}
|
||||
|
||||
fn node_do_focus(self: Rc<Self>, seat: &Rc<WlSeatGlobal>, _direction: Direction) {
|
||||
seat.focus_toplevel(self.clone());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,8 +15,8 @@ use {
|
|||
rect::Rect,
|
||||
renderer::Renderer,
|
||||
tree::{
|
||||
FindTreeResult, FindTreeUsecase, FoundNode, Node, NodeId, NodeVisitor, OutputNode,
|
||||
StackedNode,
|
||||
FindTreeResult, FindTreeUsecase, FoundNode, Node, NodeId, NodeLocation, NodeVisitor,
|
||||
OutputNode, StackedNode,
|
||||
},
|
||||
utils::{
|
||||
bitflags::BitflagsExt,
|
||||
|
|
@ -187,7 +187,8 @@ impl ZwlrLayerSurfaceV1 {
|
|||
}
|
||||
self.surface.ext.set(self.clone());
|
||||
if let Some(output) = self.output.node() {
|
||||
self.surface.set_output(&output);
|
||||
self.surface
|
||||
.set_output(&output, NodeLocation::Output(output.id));
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
|
@ -658,6 +659,10 @@ impl Node for ZwlrLayerSurfaceV1 {
|
|||
self.output.node()
|
||||
}
|
||||
|
||||
fn node_location(&self) -> Option<NodeLocation> {
|
||||
self.surface.node_location()
|
||||
}
|
||||
|
||||
fn node_find_tree_at(
|
||||
&self,
|
||||
x: i32,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue