autocommit 2022-04-23 00:55:20 CEST
This commit is contained in:
parent
436f383cd6
commit
e3b3d848c3
32 changed files with 1773 additions and 2451 deletions
|
|
@ -5,7 +5,6 @@ use {
|
|||
crate::{
|
||||
client::ClientError,
|
||||
ifs::{
|
||||
wl_seat::NodeSeatState,
|
||||
wl_surface::{
|
||||
xdg_surface::{
|
||||
xdg_popup::{XdgPopup, XdgPopupError},
|
||||
|
|
@ -18,7 +17,7 @@ use {
|
|||
leaks::Tracker,
|
||||
object::Object,
|
||||
rect::Rect,
|
||||
tree::{FindTreeResult, FoundNode, Node, SizedNode, WorkspaceNode},
|
||||
tree::{FindTreeResult, FoundNode, WorkspaceNode},
|
||||
utils::{
|
||||
buffd::{MsgParser, MsgParserError},
|
||||
clonecell::CloneCell,
|
||||
|
|
@ -67,7 +66,6 @@ pub struct XdgSurface {
|
|||
ext: CloneCell<Option<Rc<dyn XdgSurfaceExt>>>,
|
||||
popups: CopyHashMap<XdgPopupId, Rc<XdgPopup>>,
|
||||
pending: PendingXdgSurfaceData,
|
||||
seat_state: NodeSeatState,
|
||||
pub workspace: CloneCell<Option<Rc<WorkspaceNode>>>,
|
||||
pub tracker: Tracker<Self>,
|
||||
}
|
||||
|
|
@ -106,7 +104,6 @@ impl XdgSurface {
|
|||
ext: Default::default(),
|
||||
popups: Default::default(),
|
||||
pending: Default::default(),
|
||||
seat_state: Default::default(),
|
||||
workspace: Default::default(),
|
||||
tracker: Default::default(),
|
||||
}
|
||||
|
|
@ -152,10 +149,10 @@ impl XdgSurface {
|
|||
|
||||
fn destroy_node(&self) {
|
||||
self.workspace.set(None);
|
||||
self.surface.destroy_node(false);
|
||||
self.surface.destroy_node();
|
||||
let popups = self.popups.lock();
|
||||
for popup in popups.values() {
|
||||
popup.destroy_node(true);
|
||||
popup.destroy_node();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -301,7 +298,7 @@ impl XdgSurface {
|
|||
}
|
||||
|
||||
fn set_visible(&self, visible: bool) {
|
||||
self.surface.node_set_visible(visible);
|
||||
self.surface.set_visible(visible);
|
||||
for popup in self.popups.lock().values() {
|
||||
popup.set_visible(visible);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ use {
|
|||
object::Object,
|
||||
rect::Rect,
|
||||
render::Renderer,
|
||||
tree::{FindTreeResult, FoundNode, Node, NodeId, NodeVisitor, SizedNode, WorkspaceNode},
|
||||
tree::{FindTreeResult, FoundNode, Node, NodeId, NodeVisitor, StackedNode, WorkspaceNode},
|
||||
utils::{
|
||||
buffd::{MsgParser, MsgParserError},
|
||||
clonecell::CloneCell,
|
||||
|
|
@ -39,10 +39,11 @@ pub struct XdgPopup {
|
|||
pub xdg: Rc<XdgSurface>,
|
||||
pub(super) parent: CloneCell<Option<Rc<XdgSurface>>>,
|
||||
relative_position: Cell<Rect>,
|
||||
display_link: RefCell<Option<LinkedNode<Rc<dyn Node>>>>,
|
||||
workspace_link: RefCell<Option<LinkedNode<Rc<dyn Node>>>>,
|
||||
display_link: RefCell<Option<LinkedNode<Rc<dyn StackedNode>>>>,
|
||||
workspace_link: RefCell<Option<LinkedNode<Rc<dyn StackedNode>>>>,
|
||||
pos: RefCell<XdgPositioned>,
|
||||
pub tracker: Tracker<Self>,
|
||||
seat_state: NodeSeatState,
|
||||
}
|
||||
|
||||
impl Debug for XdgPopup {
|
||||
|
|
@ -72,6 +73,7 @@ impl XdgPopup {
|
|||
workspace_link: RefCell::new(None),
|
||||
pos: RefCell::new(pos),
|
||||
tracker: Default::default(),
|
||||
seat_state: Default::default(),
|
||||
})
|
||||
}
|
||||
|
||||
|
|
@ -201,7 +203,7 @@ impl XdgPopup {
|
|||
|
||||
fn destroy(&self, parser: MsgParser<'_, '_>) -> Result<(), DestroyError> {
|
||||
let _req: Destroy = self.xdg.surface.client.parse(self, parser)?;
|
||||
self.node_destroy(true);
|
||||
self.destroy_node();
|
||||
{
|
||||
if let Some(parent) = self.parent.take() {
|
||||
parent.popups.remove(&self.id);
|
||||
|
|
@ -235,6 +237,19 @@ impl XdgPopup {
|
|||
fn get_parent_workspace(&self) -> Option<Rc<WorkspaceNode>> {
|
||||
self.parent.get()?.workspace.get()
|
||||
}
|
||||
|
||||
pub fn set_visible(&self, visible: bool) {
|
||||
// log::info!("set visible = {}", visible);
|
||||
self.xdg.set_visible(visible);
|
||||
self.seat_state.set_visible(self, visible);
|
||||
}
|
||||
|
||||
pub fn destroy_node(&self) {
|
||||
let _v = self.display_link.borrow_mut().take();
|
||||
let _v = self.workspace_link.borrow_mut().take();
|
||||
self.xdg.destroy_node();
|
||||
self.seat_state.destroy_node(self);
|
||||
}
|
||||
}
|
||||
|
||||
object_base! {
|
||||
|
|
@ -255,7 +270,7 @@ impl Object for XdgPopup {
|
|||
}
|
||||
|
||||
fn break_loops(&self) {
|
||||
self.node_destroy(true);
|
||||
self.destroy_node();
|
||||
self.parent.set(None);
|
||||
*self.display_link.borrow_mut() = None;
|
||||
*self.workspace_link.borrow_mut() = None;
|
||||
|
|
@ -264,80 +279,57 @@ impl Object for XdgPopup {
|
|||
|
||||
simple_add_obj!(XdgPopup);
|
||||
|
||||
impl SizedNode for XdgPopup {
|
||||
fn id(&self) -> NodeId {
|
||||
impl Node for XdgPopup {
|
||||
fn node_id(&self) -> NodeId {
|
||||
self.node_id.into()
|
||||
}
|
||||
|
||||
fn seat_state(&self) -> &NodeSeatState {
|
||||
&self.xdg.seat_state
|
||||
fn node_seat_state(&self) -> &NodeSeatState {
|
||||
&self.seat_state
|
||||
}
|
||||
|
||||
fn destroy_node(&self, _detach: bool) {
|
||||
let _v = self.display_link.borrow_mut().take();
|
||||
let _v = self.workspace_link.borrow_mut().take();
|
||||
self.xdg.destroy_node();
|
||||
self.xdg.seat_state.destroy_node(self);
|
||||
fn node_visit(self: Rc<Self>, visitor: &mut dyn NodeVisitor) {
|
||||
visitor.visit_popup(&self);
|
||||
}
|
||||
|
||||
fn visit(self: &Rc<Self>, visitor: &mut dyn NodeVisitor) {
|
||||
visitor.visit_popup(self);
|
||||
}
|
||||
|
||||
fn visit_children(&self, visitor: &mut dyn NodeVisitor) {
|
||||
fn node_visit_children(&self, visitor: &mut dyn NodeVisitor) {
|
||||
visitor.visit_surface(&self.xdg.surface);
|
||||
}
|
||||
|
||||
fn visible(&self) -> bool {
|
||||
fn node_visible(&self) -> bool {
|
||||
self.xdg.surface.visible.get()
|
||||
}
|
||||
|
||||
fn parent(&self) -> Option<Rc<dyn Node>> {
|
||||
self.parent
|
||||
.get()
|
||||
.and_then(|x| x.workspace.get().map(|w| w as Rc<dyn Node>))
|
||||
}
|
||||
|
||||
fn set_visible(&self, visible: bool) {
|
||||
// log::info!("set visible = {}", visible);
|
||||
self.xdg.set_visible(visible);
|
||||
self.xdg.seat_state.set_visible(self, visible);
|
||||
}
|
||||
|
||||
fn get_workspace(&self) -> Option<Rc<WorkspaceNode>> {
|
||||
self.xdg.workspace.get()
|
||||
}
|
||||
|
||||
fn absolute_position(&self) -> Rect {
|
||||
fn node_absolute_position(&self) -> Rect {
|
||||
self.xdg.absolute_desired_extents.get()
|
||||
}
|
||||
|
||||
fn absolute_position_constrains_input(&self) -> bool {
|
||||
false
|
||||
}
|
||||
|
||||
fn find_tree_at(&self, x: i32, y: i32, tree: &mut Vec<FoundNode>) -> FindTreeResult {
|
||||
fn node_find_tree_at(&self, x: i32, y: i32, tree: &mut Vec<FoundNode>) -> FindTreeResult {
|
||||
self.xdg.find_tree_at(x, y, tree)
|
||||
}
|
||||
|
||||
fn pointer_enter(self: &Rc<Self>, seat: &Rc<WlSeatGlobal>, _x: Fixed, _y: Fixed) {
|
||||
seat.enter_popup(&self);
|
||||
}
|
||||
|
||||
fn pointer_focus(&self, seat: &Rc<WlSeatGlobal>) {
|
||||
seat.set_known_cursor(KnownCursor::Default);
|
||||
}
|
||||
|
||||
fn render(&self, renderer: &mut Renderer, x: i32, y: i32) {
|
||||
fn node_render(&self, renderer: &mut Renderer, x: i32, y: i32) {
|
||||
renderer.render_xdg_surface(&self.xdg, x, y)
|
||||
}
|
||||
|
||||
fn set_workspace(self: &Rc<Self>, ws: &Rc<WorkspaceNode>) {
|
||||
self.xdg.set_workspace(ws);
|
||||
fn node_client(&self) -> Option<Rc<Client>> {
|
||||
Some(self.xdg.surface.client.clone())
|
||||
}
|
||||
|
||||
fn client(&self) -> Option<Rc<Client>> {
|
||||
Some(self.xdg.surface.client.clone())
|
||||
fn node_on_pointer_enter(self: Rc<Self>, seat: &Rc<WlSeatGlobal>, _x: Fixed, _y: Fixed) {
|
||||
seat.enter_popup(&self);
|
||||
}
|
||||
|
||||
fn node_on_pointer_focus(&self, seat: &Rc<WlSeatGlobal>) {
|
||||
seat.set_known_cursor(KnownCursor::Default);
|
||||
}
|
||||
}
|
||||
|
||||
impl StackedNode for XdgPopup {
|
||||
stacked_node_impl!();
|
||||
|
||||
fn stacked_absolute_position_constrains_input(&self) -> bool {
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -381,7 +373,7 @@ impl XdgSurfaceExt for XdgPopup {
|
|||
drop(wl);
|
||||
drop(dl);
|
||||
self.set_visible(false);
|
||||
self.destroy_node(true);
|
||||
self.destroy_node();
|
||||
self.send_popup_done();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,10 +7,7 @@ use {
|
|||
fixed::Fixed,
|
||||
ifs::{
|
||||
wl_seat::{NodeSeatState, WlSeatGlobal},
|
||||
wl_surface::{
|
||||
xdg_surface::{XdgSurface, XdgSurfaceError, XdgSurfaceExt},
|
||||
WlSurface,
|
||||
},
|
||||
wl_surface::xdg_surface::{XdgSurface, XdgSurfaceError, XdgSurfaceExt},
|
||||
},
|
||||
leaks::Tracker,
|
||||
object::Object,
|
||||
|
|
@ -18,9 +15,8 @@ use {
|
|||
render::Renderer,
|
||||
state::State,
|
||||
tree::{
|
||||
FindTreeResult, FoundNode, FullscreenData, Node, NodeId, NodeVisitor,
|
||||
SizedFullscreenNode, SizedNode, SizedToplevelNode, ToplevelData, ToplevelNodeId,
|
||||
WorkspaceNode,
|
||||
FindTreeResult, FoundNode, Node, NodeId, NodeVisitor, ToplevelData, ToplevelNode,
|
||||
ToplevelNodeId, WorkspaceNode,
|
||||
},
|
||||
utils::{
|
||||
buffd::{MsgParser, MsgParserError},
|
||||
|
|
@ -78,7 +74,6 @@ pub struct XdgToplevel {
|
|||
pub state: Rc<State>,
|
||||
pub xdg: Rc<XdgSurface>,
|
||||
pub node_id: ToplevelNodeId,
|
||||
pub parent_node: CloneCell<Option<Rc<dyn Node>>>,
|
||||
pub parent: CloneCell<Option<Rc<XdgToplevel>>>,
|
||||
pub children: RefCell<AHashMap<XdgToplevelId, Rc<XdgToplevel>>>,
|
||||
states: RefCell<AHashSet<u32>>,
|
||||
|
|
@ -88,10 +83,8 @@ pub struct XdgToplevel {
|
|||
min_height: Cell<Option<i32>>,
|
||||
max_width: Cell<Option<i32>>,
|
||||
max_height: Cell<Option<i32>>,
|
||||
title: RefCell<String>,
|
||||
pub tracker: Tracker<Self>,
|
||||
toplevel_data: ToplevelData,
|
||||
fullscreen_data: FullscreenData,
|
||||
}
|
||||
|
||||
impl Debug for XdgToplevel {
|
||||
|
|
@ -107,12 +100,12 @@ impl XdgToplevel {
|
|||
states.insert(STATE_TILED_RIGHT);
|
||||
states.insert(STATE_TILED_TOP);
|
||||
states.insert(STATE_TILED_BOTTOM);
|
||||
let state = &surface.surface.client.state;
|
||||
Self {
|
||||
id,
|
||||
state: surface.surface.client.state.clone(),
|
||||
state: state.clone(),
|
||||
xdg: surface.clone(),
|
||||
node_id: surface.surface.client.state.node_ids.next(),
|
||||
parent_node: Default::default(),
|
||||
node_id: state.node_ids.next(),
|
||||
parent: Default::default(),
|
||||
children: RefCell::new(Default::default()),
|
||||
states: RefCell::new(states),
|
||||
|
|
@ -122,10 +115,12 @@ impl XdgToplevel {
|
|||
min_height: Cell::new(None),
|
||||
max_width: Cell::new(None),
|
||||
max_height: Cell::new(None),
|
||||
title: RefCell::new("".to_string()),
|
||||
tracker: Default::default(),
|
||||
toplevel_data: Default::default(),
|
||||
fullscreen_data: Default::default(),
|
||||
toplevel_data: ToplevelData::new(
|
||||
state,
|
||||
String::new(),
|
||||
Some(surface.surface.client.clone()),
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -172,7 +167,7 @@ impl XdgToplevel {
|
|||
|
||||
fn destroy(self: &Rc<Self>, parser: MsgParser<'_, '_>) -> Result<(), DestroyError> {
|
||||
let _req: Destroy = self.xdg.surface.client.parse(self.deref(), parser)?;
|
||||
self.node_destroy(true);
|
||||
self.tl_destroy();
|
||||
self.xdg.ext.set(None);
|
||||
{
|
||||
let mut children = self.children.borrow_mut();
|
||||
|
|
@ -210,13 +205,8 @@ impl XdgToplevel {
|
|||
|
||||
fn set_title(&self, parser: MsgParser<'_, '_>) -> Result<(), SetTitleError> {
|
||||
let req: SetTitle = self.xdg.surface.client.parse(self, parser)?;
|
||||
let mut title = self.title.borrow_mut();
|
||||
title.clear();
|
||||
title.push_str(req.title);
|
||||
if let Some(parent) = self.parent_node.get() {
|
||||
parent.node_child_title_changed(self, &title);
|
||||
}
|
||||
self.fullscreen_data.set_title(&title);
|
||||
*self.toplevel_data.title.borrow_mut() = req.title.to_string();
|
||||
self.tl_title_changed();
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
|
@ -234,7 +224,7 @@ impl XdgToplevel {
|
|||
fn move_(&self, parser: MsgParser<'_, '_>) -> Result<(), MoveError> {
|
||||
let req: Move = self.xdg.surface.client.parse(self, parser)?;
|
||||
let seat = self.xdg.surface.client.lookup(req.seat)?;
|
||||
if let Some(parent) = self.parent_node.get() {
|
||||
if let Some(parent) = self.toplevel_data.parent.get() {
|
||||
if let Some(float) = parent.node_into_float() {
|
||||
seat.move_(&float);
|
||||
}
|
||||
|
|
@ -314,7 +304,7 @@ impl XdgToplevel {
|
|||
} else {
|
||||
break 'set_fullscreen;
|
||||
};
|
||||
self.fullscreen_data
|
||||
self.toplevel_data
|
||||
.set_fullscreen(&client.state, self.clone(), &output);
|
||||
}
|
||||
self.send_current_configure();
|
||||
|
|
@ -327,7 +317,7 @@ impl XdgToplevel {
|
|||
) -> Result<(), UnsetFullscreenError> {
|
||||
let _req: UnsetFullscreen = self.xdg.surface.client.parse(self.deref(), parser)?;
|
||||
self.states.borrow_mut().remove(&STATE_FULLSCREEN);
|
||||
self.fullscreen_data
|
||||
self.toplevel_data
|
||||
.unset_fullscreen(&self.state, self.clone());
|
||||
self.send_current_configure();
|
||||
Ok(())
|
||||
|
|
@ -339,18 +329,18 @@ impl XdgToplevel {
|
|||
}
|
||||
|
||||
fn notify_parent(&self) {
|
||||
let parent = match self.parent_node.get() {
|
||||
let parent = match self.toplevel_data.parent.get() {
|
||||
Some(p) => p,
|
||||
_ => return,
|
||||
};
|
||||
let extents = self.xdg.extents.get();
|
||||
parent.clone().node_child_active_changed(
|
||||
self,
|
||||
self.toplevel_data.active_surfaces.get() > 0,
|
||||
self.toplevel_data.active_children.get() > 0,
|
||||
1,
|
||||
);
|
||||
parent.node_child_size_changed(self, extents.width(), extents.height());
|
||||
parent.node_child_title_changed(self, self.title.borrow_mut().deref());
|
||||
parent.node_child_title_changed(self, self.toplevel_data.title.borrow_mut().deref());
|
||||
}
|
||||
|
||||
fn map_floating(self: &Rc<Self>, workspace: &Rc<WorkspaceNode>) {
|
||||
|
|
@ -396,7 +386,7 @@ impl Object for XdgToplevel {
|
|||
}
|
||||
|
||||
fn break_loops(&self) {
|
||||
self.node_destroy(true);
|
||||
self.tl_destroy();
|
||||
self.parent.set(None);
|
||||
let _children = mem::take(&mut *self.children.borrow_mut());
|
||||
}
|
||||
|
|
@ -404,145 +394,73 @@ impl Object for XdgToplevel {
|
|||
|
||||
dedicated_add_obj!(XdgToplevel, XdgToplevelId, xdg_toplevel);
|
||||
|
||||
impl SizedNode for XdgToplevel {
|
||||
fn id(&self) -> NodeId {
|
||||
impl Node for XdgToplevel {
|
||||
fn node_id(&self) -> NodeId {
|
||||
self.node_id.into()
|
||||
}
|
||||
|
||||
fn seat_state(&self) -> &NodeSeatState {
|
||||
&self.xdg.seat_state
|
||||
fn node_seat_state(&self) -> &NodeSeatState {
|
||||
&self.toplevel_data.seat_state
|
||||
}
|
||||
|
||||
fn destroy_node(&self, detach: bool) {
|
||||
self.fullscreen_data.destroy_node();
|
||||
if let Some(parent) = self.parent_node.take() {
|
||||
if detach {
|
||||
parent.node_remove_child(self);
|
||||
self.state.tree_changed();
|
||||
}
|
||||
}
|
||||
self.toplevel_data.clear();
|
||||
self.xdg.destroy_node();
|
||||
self.xdg.seat_state.destroy_node(self)
|
||||
fn node_visit(self: Rc<Self>, visitor: &mut dyn NodeVisitor) {
|
||||
visitor.visit_toplevel(&self);
|
||||
}
|
||||
|
||||
fn visit(self: &Rc<Self>, visitor: &mut dyn NodeVisitor) {
|
||||
visitor.visit_toplevel(self);
|
||||
}
|
||||
|
||||
fn visit_children(&self, visitor: &mut dyn NodeVisitor) {
|
||||
fn node_visit_children(&self, visitor: &mut dyn NodeVisitor) {
|
||||
visitor.visit_surface(&self.xdg.surface);
|
||||
}
|
||||
|
||||
fn visible(&self) -> bool {
|
||||
fn node_visible(&self) -> bool {
|
||||
self.xdg.surface.visible.get()
|
||||
}
|
||||
|
||||
fn parent(&self) -> Option<Rc<dyn Node>> {
|
||||
self.parent_node.get()
|
||||
}
|
||||
|
||||
fn set_visible(&self, visible: bool) {
|
||||
// log::info!("set_visible {}", visible);
|
||||
// if !visible {
|
||||
// log::info!("\n{:?}", Backtrace::new());
|
||||
// }
|
||||
self.xdg.set_visible(visible);
|
||||
self.xdg.seat_state.set_visible(self, visible);
|
||||
}
|
||||
|
||||
fn get_workspace(&self) -> Option<Rc<WorkspaceNode>> {
|
||||
self.xdg.workspace.get()
|
||||
}
|
||||
|
||||
fn do_focus(self: &Rc<Self>, seat: &Rc<WlSeatGlobal>, _direction: Direction) {
|
||||
seat.focus_toplevel(self.clone());
|
||||
}
|
||||
|
||||
fn close(self: &Rc<Self>) {
|
||||
self.send_close();
|
||||
}
|
||||
|
||||
fn absolute_position(&self) -> Rect {
|
||||
fn node_absolute_position(&self) -> Rect {
|
||||
self.xdg.absolute_desired_extents.get()
|
||||
}
|
||||
|
||||
fn toggle_floating(self: &Rc<Self>, _seat: &Rc<WlSeatGlobal>) {
|
||||
let parent = match self.parent_node.get() {
|
||||
Some(p) => p,
|
||||
_ => return,
|
||||
};
|
||||
if parent.node_is_float() {
|
||||
parent.node_remove_child2(self.deref(), true);
|
||||
self.map_tiled();
|
||||
} else if let Some(ws) = self.xdg.workspace.get() {
|
||||
parent.node_remove_child2(self.deref(), true);
|
||||
self.map_floating(&ws);
|
||||
}
|
||||
fn node_do_focus(self: Rc<Self>, seat: &Rc<WlSeatGlobal>, _direction: Direction) {
|
||||
seat.focus_toplevel(self.clone());
|
||||
}
|
||||
|
||||
fn find_tree_at(&self, x: i32, y: i32, tree: &mut Vec<FoundNode>) -> FindTreeResult {
|
||||
fn node_find_tree_at(&self, x: i32, y: i32, tree: &mut Vec<FoundNode>) -> FindTreeResult {
|
||||
self.xdg.find_tree_at(x, y, tree)
|
||||
}
|
||||
|
||||
fn pointer_enter(self: &Rc<Self>, seat: &Rc<WlSeatGlobal>, _x: Fixed, _y: Fixed) {
|
||||
seat.enter_toplevel(self.clone());
|
||||
}
|
||||
|
||||
fn pointer_focus(&self, seat: &Rc<WlSeatGlobal>) {
|
||||
seat.set_known_cursor(KnownCursor::Default);
|
||||
}
|
||||
|
||||
fn render(&self, renderer: &mut Renderer, x: i32, y: i32) {
|
||||
fn node_render(&self, renderer: &mut Renderer, x: i32, y: i32) {
|
||||
renderer.render_xdg_surface(&self.xdg, x, y)
|
||||
}
|
||||
|
||||
fn change_extents(self: &Rc<Self>, rect: &Rect) {
|
||||
let nw = rect.width();
|
||||
let nh = rect.height();
|
||||
let de = self.xdg.absolute_desired_extents.get();
|
||||
if de.width() != nw || de.height() != nh {
|
||||
if self.toplevel_data.is_floating.get() {
|
||||
self.toplevel_data.float_width.set(rect.width());
|
||||
self.toplevel_data.float_height.set(rect.height());
|
||||
}
|
||||
self.send_configure_checked(nw, nh);
|
||||
self.xdg.do_send_configure();
|
||||
self.xdg.surface.client.flush();
|
||||
}
|
||||
self.xdg.set_absolute_desired_extents(rect);
|
||||
}
|
||||
|
||||
fn set_workspace(self: &Rc<Self>, ws: &Rc<WorkspaceNode>) {
|
||||
self.xdg.set_workspace(ws);
|
||||
}
|
||||
|
||||
fn set_parent(self: &Rc<Self>, parent: Rc<dyn Node>) {
|
||||
self.toplevel_data.is_floating.set(parent.node_is_float());
|
||||
self.parent_node.set(Some(parent));
|
||||
self.notify_parent();
|
||||
}
|
||||
|
||||
fn client(&self) -> Option<Rc<Client>> {
|
||||
fn node_client(&self) -> Option<Rc<Client>> {
|
||||
Some(self.xdg.surface.client.clone())
|
||||
}
|
||||
|
||||
fn node_toplevel(self: Rc<Self>) -> Option<Rc<dyn crate::tree::ToplevelNode>> {
|
||||
Some(self)
|
||||
}
|
||||
|
||||
fn node_on_pointer_enter(self: Rc<Self>, seat: &Rc<WlSeatGlobal>, _x: Fixed, _y: Fixed) {
|
||||
seat.enter_toplevel(self.clone());
|
||||
}
|
||||
|
||||
fn node_on_pointer_focus(&self, seat: &Rc<WlSeatGlobal>) {
|
||||
seat.set_known_cursor(KnownCursor::Default);
|
||||
}
|
||||
}
|
||||
|
||||
impl SizedToplevelNode for XdgToplevel {
|
||||
fn data(&self) -> &ToplevelData {
|
||||
impl ToplevelNode for XdgToplevel {
|
||||
tl_node_impl!();
|
||||
|
||||
fn tl_data(&self) -> &ToplevelData {
|
||||
&self.toplevel_data
|
||||
}
|
||||
|
||||
fn accepts_keyboard_focus(&self) -> bool {
|
||||
true
|
||||
}
|
||||
|
||||
fn default_surface(&self) -> Option<Rc<WlSurface>> {
|
||||
fn tl_default_focus_child(&self) -> Option<Rc<dyn Node>> {
|
||||
Some(self.xdg.surface.clone())
|
||||
}
|
||||
|
||||
fn set_active(&self, active: bool) {
|
||||
if let Some(parent) = self.parent_node.get() {
|
||||
fn tl_set_active(&self, active: bool) {
|
||||
if let Some(parent) = self.toplevel_data.parent.get() {
|
||||
parent.node_child_active_changed(self, active, 1);
|
||||
}
|
||||
let changed = {
|
||||
|
|
@ -559,26 +477,67 @@ impl SizedToplevelNode for XdgToplevel {
|
|||
}
|
||||
}
|
||||
|
||||
fn activate(&self) {
|
||||
// nothing
|
||||
fn tl_set_workspace(self: Rc<Self>, ws: &Rc<WorkspaceNode>) {
|
||||
self.toplevel_data.workspace.set(Some(ws.clone()));
|
||||
self.xdg.set_workspace(ws);
|
||||
}
|
||||
|
||||
fn set_fullscreen(self: &Rc<Self>, fullscreen: bool) {
|
||||
let state = &self.state;
|
||||
if fullscreen {
|
||||
if let Some(ws) = self.xdg.workspace.get() {
|
||||
self.fullscreen_data
|
||||
.set_fullscreen(state, self.clone(), &ws.output.get());
|
||||
fn tl_change_extents(self: Rc<Self>, rect: &Rect) {
|
||||
let nw = rect.width();
|
||||
let nh = rect.height();
|
||||
let de = self.xdg.absolute_desired_extents.get();
|
||||
if de.width() != nw || de.height() != nh {
|
||||
if self.toplevel_data.is_floating.get() {
|
||||
self.toplevel_data.float_width.set(rect.width());
|
||||
self.toplevel_data.float_height.set(rect.height());
|
||||
}
|
||||
} else {
|
||||
self.fullscreen_data.unset_fullscreen(state, self.clone());
|
||||
self.send_configure_checked(nw, nh);
|
||||
self.xdg.do_send_configure();
|
||||
self.xdg.surface.client.flush();
|
||||
}
|
||||
self.send_current_configure();
|
||||
self.xdg.set_absolute_desired_extents(rect);
|
||||
}
|
||||
|
||||
fn fullscreen(&self) -> bool {
|
||||
self.fullscreen_data.is_fullscreen.get()
|
||||
fn tl_close(self: Rc<Self>) {
|
||||
self.send_close();
|
||||
}
|
||||
|
||||
fn tl_set_visible(&self, visible: bool) {
|
||||
// log::info!("set_visible {}", visible);
|
||||
// if !visible {
|
||||
// log::info!("\n{:?}", Backtrace::new());
|
||||
// }
|
||||
self.xdg.set_visible(visible);
|
||||
self.toplevel_data.set_visible(self, visible);
|
||||
}
|
||||
|
||||
fn tl_destroy(&self) {
|
||||
self.toplevel_data.destroy_node(self);
|
||||
self.xdg.destroy_node();
|
||||
}
|
||||
|
||||
// fn move_to_workspace(self: &Rc<Self>, workspace: &Rc<WorkspaceNode>) {
|
||||
// let parent = match self.parent_node.get() {
|
||||
// Some(p) => p,
|
||||
// _ => return,
|
||||
// };
|
||||
// if self.fullscreen_data.is_fullscreen.get() {
|
||||
// if workspace.fullscreen.get().is_some() {
|
||||
// log::info!("Not moving fullscreen node to workspace {} because that workspace already contains a fullscreen node", workspace.name);
|
||||
// return;
|
||||
// }
|
||||
// parent.node_remove_child2(self.deref(), workspace.visible());
|
||||
// workspace.fullscreen.set(Some(self.clone()));
|
||||
// self.state.tree_changed();
|
||||
// return;
|
||||
// }
|
||||
// parent.node_remove_child2(self.deref(), workspace.visible());
|
||||
// if self.toplevel_data.is_floating.get() {
|
||||
// self.map_floating(workspace);
|
||||
// } else {
|
||||
// self.map_tiled()
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
impl XdgSurfaceExt for XdgToplevel {
|
||||
|
|
@ -589,9 +548,9 @@ impl XdgSurfaceExt for XdgToplevel {
|
|||
|
||||
fn post_commit(self: Rc<Self>) {
|
||||
let surface = &self.xdg.surface;
|
||||
if let Some(parent) = self.parent_node.get() {
|
||||
if self.toplevel_data.parent.get().is_some() {
|
||||
if surface.buffer.get().is_none() {
|
||||
parent.node_remove_child(&*self);
|
||||
self.tl_destroy();
|
||||
{
|
||||
let new_parent = self.parent.get();
|
||||
let mut children = self.children.borrow_mut();
|
||||
|
|
@ -629,26 +588,12 @@ impl XdgSurfaceExt for XdgToplevel {
|
|||
|
||||
fn extents_changed(&self) {
|
||||
self.notify_parent();
|
||||
if self.parent_node.get().is_some() {
|
||||
if self.toplevel_data.parent.get().is_some() {
|
||||
self.state.tree_changed();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl SizedFullscreenNode for XdgToplevel {
|
||||
fn on_set_fullscreen(&self, _workspace: &Rc<WorkspaceNode>) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
fn on_unset_fullscreen(&self) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
fn title(&self) -> String {
|
||||
self.title.borrow_mut().clone()
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum XdgToplevelError {
|
||||
#[error("Could not process `destroy` request")]
|
||||
|
|
|
|||
|
|
@ -4,21 +4,17 @@ use {
|
|||
cursor::KnownCursor,
|
||||
fixed::Fixed,
|
||||
ifs::{
|
||||
wl_seat::{NodeSeatState, SeatId, WlSeatGlobal},
|
||||
wl_seat::{NodeSeatState, WlSeatGlobal},
|
||||
wl_surface::{SurfaceExt, SurfaceRole, WlSurface, WlSurfaceError},
|
||||
},
|
||||
rect::Rect,
|
||||
render::Renderer,
|
||||
state::State,
|
||||
tree::{
|
||||
FindTreeResult, FoundNode, FullscreenData, Node, NodeId, NodeVisitor,
|
||||
SizedFullscreenNode, SizedNode, SizedToplevelNode, ToplevelData, ToplevelNode,
|
||||
WorkspaceNode,
|
||||
},
|
||||
utils::{
|
||||
clonecell::CloneCell, copyhashmap::CopyHashMap, linkedlist::LinkedNode,
|
||||
smallmap::SmallMap,
|
||||
FindTreeResult, FoundNode, Node, NodeId, NodeVisitor, StackedNode, ToplevelData,
|
||||
ToplevelNode,
|
||||
},
|
||||
utils::{clonecell::CloneCell, copyhashmap::CopyHashMap, linkedlist::LinkedNode},
|
||||
wire::WlSurfaceId,
|
||||
wire_xcon::CreateNotify,
|
||||
xwayland::XWaylandEvent,
|
||||
|
|
@ -139,11 +135,8 @@ pub struct Xwindow {
|
|||
pub data: Rc<XwindowData>,
|
||||
pub surface: Rc<WlSurface>,
|
||||
pub parent_node: CloneCell<Option<Rc<dyn Node>>>,
|
||||
pub focus_history: SmallMap<SeatId, LinkedNode<Rc<dyn ToplevelNode>>, 1>,
|
||||
pub workspace: CloneCell<Option<Rc<WorkspaceNode>>>,
|
||||
pub display_link: RefCell<Option<LinkedNode<Rc<dyn Node>>>>,
|
||||
pub display_link: RefCell<Option<LinkedNode<Rc<dyn StackedNode>>>>,
|
||||
pub toplevel_data: ToplevelData,
|
||||
pub fullscreen_data: FullscreenData,
|
||||
}
|
||||
|
||||
impl XwindowData {
|
||||
|
|
@ -212,11 +205,12 @@ impl Xwindow {
|
|||
data: data.clone(),
|
||||
surface: surface.clone(),
|
||||
parent_node: Default::default(),
|
||||
focus_history: Default::default(),
|
||||
workspace: Default::default(),
|
||||
display_link: Default::default(),
|
||||
toplevel_data: Default::default(),
|
||||
fullscreen_data: Default::default(),
|
||||
toplevel_data: ToplevelData::new(
|
||||
&data.state,
|
||||
data.info.title.borrow_mut().clone().unwrap_or_default(),
|
||||
Some(surface.client.clone()),
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -226,7 +220,7 @@ impl Xwindow {
|
|||
}
|
||||
|
||||
pub fn break_loops(&self) {
|
||||
self.node_destroy(true);
|
||||
self.tl_destroy();
|
||||
self.surface.set_toplevel(None);
|
||||
}
|
||||
|
||||
|
|
@ -248,7 +242,7 @@ impl Xwindow {
|
|||
let extents = self.surface.extents.get();
|
||||
parent.clone().node_child_active_changed(
|
||||
self,
|
||||
self.toplevel_data.active_surfaces.get() > 0,
|
||||
self.toplevel_data.active_children.get() > 0,
|
||||
1,
|
||||
);
|
||||
parent.node_child_size_changed(self, extents.width(), extents.height());
|
||||
|
|
@ -283,10 +277,11 @@ impl Xwindow {
|
|||
.info
|
||||
.pending_extents
|
||||
.set(self.data.info.extents.take());
|
||||
self.node_destroy(true);
|
||||
self.tl_destroy();
|
||||
}
|
||||
Change::Map if self.data.info.override_redirect.get() => {
|
||||
self.change_extents(&self.data.info.pending_extents.get());
|
||||
self.clone()
|
||||
.tl_change_extents(&self.data.info.pending_extents.get());
|
||||
*self.display_link.borrow_mut() =
|
||||
Some(self.data.state.root.stacked.add_last(self.clone()));
|
||||
self.data.state.tree_changed();
|
||||
|
|
@ -305,8 +300,8 @@ impl Xwindow {
|
|||
}
|
||||
}
|
||||
match map_change {
|
||||
Change::Unmap => self.node_set_visible(false),
|
||||
Change::Map => self.node_set_visible(true),
|
||||
Change::Unmap => self.tl_set_visible(false),
|
||||
Change::Map => self.tl_set_visible(true),
|
||||
Change::None => {}
|
||||
}
|
||||
self.data.state.tree_changed();
|
||||
|
|
@ -319,7 +314,7 @@ impl SurfaceExt for Xwindow {
|
|||
}
|
||||
|
||||
fn on_surface_destroy(&self) -> Result<(), WlSurfaceError> {
|
||||
self.node_destroy(true);
|
||||
self.tl_destroy();
|
||||
self.surface.unset_ext();
|
||||
self.data.window.set(None);
|
||||
self.data.surface_id.set(None);
|
||||
|
|
@ -336,69 +331,36 @@ impl SurfaceExt for Xwindow {
|
|||
}
|
||||
}
|
||||
|
||||
impl SizedNode for Xwindow {
|
||||
fn id(&self) -> NodeId {
|
||||
impl Node for Xwindow {
|
||||
fn node_id(&self) -> NodeId {
|
||||
self.id.into()
|
||||
}
|
||||
|
||||
fn seat_state(&self) -> &NodeSeatState {
|
||||
fn node_seat_state(&self) -> &NodeSeatState {
|
||||
&self.seat_state
|
||||
}
|
||||
|
||||
fn destroy_node(&self, _detach: bool) {
|
||||
self.toplevel_data.clear();
|
||||
self.display_link.borrow_mut().take();
|
||||
self.workspace.take();
|
||||
self.focus_history.clear();
|
||||
if let Some(parent) = self.parent_node.take() {
|
||||
parent.node_remove_child(self);
|
||||
}
|
||||
self.surface.node_destroy(false);
|
||||
self.seat_state.destroy_node(self);
|
||||
fn node_visit(self: Rc<Self>, visitor: &mut dyn NodeVisitor) {
|
||||
visitor.visit_xwindow(&self);
|
||||
}
|
||||
|
||||
fn visit(self: &Rc<Self>, visitor: &mut dyn NodeVisitor) {
|
||||
visitor.visit_xwindow(self);
|
||||
}
|
||||
|
||||
fn visit_children(&self, visitor: &mut dyn NodeVisitor) {
|
||||
fn node_visit_children(&self, visitor: &mut dyn NodeVisitor) {
|
||||
visitor.visit_surface(&self.surface);
|
||||
}
|
||||
|
||||
fn visible(&self) -> bool {
|
||||
fn node_visible(&self) -> bool {
|
||||
self.surface.visible.get()
|
||||
}
|
||||
|
||||
fn parent(&self) -> Option<Rc<dyn Node>> {
|
||||
self.parent_node.get()
|
||||
}
|
||||
|
||||
fn set_visible(&self, visible: bool) {
|
||||
self.surface.node_set_visible(visible);
|
||||
self.seat_state.set_visible(self, visible);
|
||||
}
|
||||
|
||||
fn get_workspace(&self) -> Option<Rc<WorkspaceNode>> {
|
||||
self.workspace.get()
|
||||
}
|
||||
|
||||
fn do_focus(self: &Rc<Self>, seat: &Rc<WlSeatGlobal>, _direction: Direction) {
|
||||
seat.focus_toplevel(self.clone());
|
||||
}
|
||||
|
||||
fn close(self: &Rc<Self>) {
|
||||
self.data
|
||||
.state
|
||||
.xwayland
|
||||
.queue
|
||||
.push(XWaylandEvent::Close(self.data.clone()));
|
||||
}
|
||||
|
||||
fn absolute_position(&self) -> Rect {
|
||||
fn node_absolute_position(&self) -> Rect {
|
||||
self.data.info.extents.get()
|
||||
}
|
||||
|
||||
fn find_tree_at(&self, x: i32, y: i32, tree: &mut Vec<FoundNode>) -> FindTreeResult {
|
||||
fn node_do_focus(self: Rc<Self>, seat: &Rc<WlSeatGlobal>, _direction: Direction) {
|
||||
seat.focus_toplevel(self.clone());
|
||||
}
|
||||
|
||||
fn node_find_tree_at(&self, x: i32, y: i32, tree: &mut Vec<FoundNode>) -> FindTreeResult {
|
||||
if let Some(buffer) = self.surface.buffer.get() {
|
||||
if x < buffer.rect.width() && y < buffer.rect.height() {
|
||||
tree.push(FoundNode {
|
||||
|
|
@ -412,19 +374,58 @@ impl SizedNode for Xwindow {
|
|||
FindTreeResult::Other
|
||||
}
|
||||
|
||||
fn pointer_enter(self: &Rc<Self>, seat: &Rc<WlSeatGlobal>, _x: Fixed, _y: Fixed) {
|
||||
seat.enter_toplevel(self.clone());
|
||||
}
|
||||
|
||||
fn pointer_focus(&self, seat: &Rc<WlSeatGlobal>) {
|
||||
seat.set_known_cursor(KnownCursor::Default);
|
||||
}
|
||||
|
||||
fn render(&self, renderer: &mut Renderer, x: i32, y: i32) {
|
||||
fn node_render(&self, renderer: &mut Renderer, x: i32, y: i32) {
|
||||
renderer.render_surface(&self.surface, x, y)
|
||||
}
|
||||
|
||||
fn change_extents(self: &Rc<Self>, rect: &Rect) {
|
||||
fn node_client(&self) -> Option<Rc<Client>> {
|
||||
Some(self.data.client.clone())
|
||||
}
|
||||
|
||||
fn node_toplevel(self: Rc<Self>) -> Option<Rc<dyn ToplevelNode>> {
|
||||
Some(self)
|
||||
}
|
||||
|
||||
fn node_on_pointer_enter(self: Rc<Self>, seat: &Rc<WlSeatGlobal>, _x: Fixed, _y: Fixed) {
|
||||
seat.enter_toplevel(self.clone());
|
||||
}
|
||||
|
||||
fn node_on_pointer_focus(&self, seat: &Rc<WlSeatGlobal>) {
|
||||
seat.set_known_cursor(KnownCursor::Default);
|
||||
}
|
||||
}
|
||||
|
||||
impl ToplevelNode for Xwindow {
|
||||
tl_node_impl!();
|
||||
|
||||
fn tl_data(&self) -> &ToplevelData {
|
||||
&self.toplevel_data
|
||||
}
|
||||
|
||||
fn tl_default_focus_child(&self) -> Option<Rc<dyn Node>> {
|
||||
Some(self.surface.clone())
|
||||
}
|
||||
|
||||
fn tl_accepts_keyboard_focus(&self) -> bool {
|
||||
self.data.info.never_focus.get().not()
|
||||
&& self.data.info.input_model.get() != XInputModel::None
|
||||
}
|
||||
|
||||
fn tl_set_active(&self, active: bool) {
|
||||
if let Some(pn) = self.parent_node.get() {
|
||||
pn.node_child_active_changed(self, active, 1);
|
||||
}
|
||||
}
|
||||
|
||||
fn tl_on_activate(&self) {
|
||||
self.data
|
||||
.state
|
||||
.xwayland
|
||||
.queue
|
||||
.push(XWaylandEvent::Activate(self.data.clone()));
|
||||
}
|
||||
|
||||
fn tl_change_extents(self: Rc<Self>, rect: &Rect) {
|
||||
// log::info!("xwin {} change_extents {:?}", self.data.window_id, rect);
|
||||
let old = self.data.info.extents.replace(*rect);
|
||||
if old != *rect {
|
||||
|
|
@ -445,111 +446,28 @@ impl SizedNode for Xwindow {
|
|||
}
|
||||
}
|
||||
|
||||
fn set_workspace(self: &Rc<Self>, ws: &Rc<WorkspaceNode>) {
|
||||
self.workspace.set(Some(ws.clone()));
|
||||
fn tl_close(self: Rc<Self>) {
|
||||
self.data
|
||||
.state
|
||||
.xwayland
|
||||
.queue
|
||||
.push(XWaylandEvent::Close(self.data.clone()));
|
||||
}
|
||||
|
||||
fn set_parent(self: &Rc<Self>, parent: Rc<dyn Node>) {
|
||||
self.toplevel_data.is_floating.set(parent.node_is_float());
|
||||
self.parent_node.set(Some(parent));
|
||||
self.notify_parent();
|
||||
fn tl_set_visible(&self, visible: bool) {
|
||||
self.surface.set_visible(visible);
|
||||
self.seat_state.set_visible(self, visible);
|
||||
}
|
||||
|
||||
fn client(&self) -> Option<Rc<Client>> {
|
||||
Some(self.data.client.clone())
|
||||
}
|
||||
|
||||
fn toggle_floating(self: &Rc<Self>, _seat: &Rc<WlSeatGlobal>) {
|
||||
let parent = match self.parent_node.get() {
|
||||
Some(p) => p,
|
||||
_ => return,
|
||||
};
|
||||
if parent.node_is_float() {
|
||||
parent.node_remove_child2(self.deref(), true);
|
||||
self.data.state.map_tiled(self.clone());
|
||||
} else if let Some(ws) = self.workspace.get() {
|
||||
parent.node_remove_child2(self.deref(), true);
|
||||
let (width, height) = self.toplevel_data.float_size(&ws);
|
||||
self.data
|
||||
.state
|
||||
.map_floating(self.clone(), width, height, &ws);
|
||||
}
|
||||
fn tl_destroy(&self) {
|
||||
self.toplevel_data.destroy_node(self);
|
||||
self.display_link.borrow_mut().take();
|
||||
self.surface.destroy_node();
|
||||
}
|
||||
}
|
||||
|
||||
impl SizedToplevelNode for Xwindow {
|
||||
fn data(&self) -> &ToplevelData {
|
||||
&self.toplevel_data
|
||||
}
|
||||
|
||||
fn accepts_keyboard_focus(&self) -> bool {
|
||||
self.data.info.never_focus.get().not()
|
||||
&& self.data.info.input_model.get() != XInputModel::None
|
||||
}
|
||||
|
||||
fn default_surface(&self) -> Option<Rc<WlSurface>> {
|
||||
Some(self.surface.clone())
|
||||
}
|
||||
|
||||
fn set_active(&self, active: bool) {
|
||||
if let Some(pn) = self.parent_node.get() {
|
||||
pn.node_child_active_changed(self, active, 1);
|
||||
}
|
||||
}
|
||||
|
||||
fn activate(&self) {
|
||||
self.data
|
||||
.state
|
||||
.xwayland
|
||||
.queue
|
||||
.push(XWaylandEvent::Activate(self.data.clone()));
|
||||
}
|
||||
|
||||
fn set_fullscreen(self: &Rc<Self>, fullscreen: bool) {
|
||||
if fullscreen {
|
||||
if let Some(ws) = self.workspace.get() {
|
||||
self.fullscreen_data.set_fullscreen(
|
||||
&self.data.state,
|
||||
self.clone(),
|
||||
&ws.output.get(),
|
||||
);
|
||||
}
|
||||
} else {
|
||||
self.fullscreen_data
|
||||
.unset_fullscreen(&self.data.state, self.clone());
|
||||
}
|
||||
}
|
||||
|
||||
fn fullscreen(&self) -> bool {
|
||||
self.fullscreen_data.is_fullscreen.get()
|
||||
}
|
||||
}
|
||||
|
||||
impl SizedFullscreenNode for Xwindow {
|
||||
fn on_set_fullscreen(&self, _workspace: &Rc<WorkspaceNode>) {
|
||||
self.data
|
||||
.state
|
||||
.xwayland
|
||||
.queue
|
||||
.push(XWaylandEvent::SetFullscreen(self.data.clone(), true));
|
||||
}
|
||||
|
||||
fn on_unset_fullscreen(&self) {
|
||||
self.data
|
||||
.state
|
||||
.xwayland
|
||||
.queue
|
||||
.push(XWaylandEvent::SetFullscreen(self.data.clone(), false));
|
||||
}
|
||||
|
||||
fn title(&self) -> String {
|
||||
self.data
|
||||
.info
|
||||
.title
|
||||
.borrow_mut()
|
||||
.clone()
|
||||
.unwrap_or_default()
|
||||
}
|
||||
impl StackedNode for Xwindow {
|
||||
stacked_node_impl!();
|
||||
}
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ use {
|
|||
object::Object,
|
||||
rect::Rect,
|
||||
render::Renderer,
|
||||
tree::{FindTreeResult, FoundNode, Node, NodeId, NodeVisitor, OutputNode, SizedNode},
|
||||
tree::{FindTreeResult, FoundNode, Node, NodeId, NodeVisitor, OutputNode},
|
||||
utils::{
|
||||
bitflags::BitflagsExt,
|
||||
buffd::{MsgParser, MsgParserError},
|
||||
|
|
@ -198,7 +198,7 @@ impl ZwlrLayerSurfaceV1 {
|
|||
|
||||
fn destroy(&self, parser: MsgParser<'_, '_>) -> Result<(), DestroyError> {
|
||||
let _req: Destroy = self.client.parse(self, parser)?;
|
||||
self.node_destroy(true);
|
||||
self.destroy_node();
|
||||
self.client.remove_obj(self)?;
|
||||
self.surface.unset_ext();
|
||||
Ok(())
|
||||
|
|
@ -272,7 +272,7 @@ impl ZwlrLayerSurfaceV1 {
|
|||
self.pos.get()
|
||||
}
|
||||
|
||||
fn compute_position(&self) {
|
||||
pub fn compute_position(&self) {
|
||||
let (width, height) = self.size.get();
|
||||
let mut anchor = self.anchor.get();
|
||||
if anchor == 0 {
|
||||
|
|
@ -301,6 +301,13 @@ impl ZwlrLayerSurfaceV1 {
|
|||
self.surface.set_absolute_position(x1, y1);
|
||||
self.client.state.tree_changed();
|
||||
}
|
||||
|
||||
pub fn destroy_node(&self) {
|
||||
self.link.set(None);
|
||||
self.mapped.set(false);
|
||||
self.surface.destroy_node();
|
||||
self.seat_state.destroy_node(self);
|
||||
}
|
||||
}
|
||||
|
||||
impl SurfaceExt for ZwlrLayerSurfaceV1 {
|
||||
|
|
@ -313,7 +320,7 @@ impl SurfaceExt for ZwlrLayerSurfaceV1 {
|
|||
let buffer = self.surface.buffer.get();
|
||||
if self.mapped.get() {
|
||||
if buffer.is_none() {
|
||||
self.node_destroy(true);
|
||||
self.destroy_node();
|
||||
} else {
|
||||
let pos = self.pos.get();
|
||||
let (width, height) = self.size.get();
|
||||
|
|
@ -353,53 +360,38 @@ impl SurfaceExt for ZwlrLayerSurfaceV1 {
|
|||
}
|
||||
}
|
||||
|
||||
impl SizedNode for ZwlrLayerSurfaceV1 {
|
||||
fn id(&self) -> NodeId {
|
||||
impl Node for ZwlrLayerSurfaceV1 {
|
||||
fn node_id(&self) -> NodeId {
|
||||
self.node_id.into()
|
||||
}
|
||||
|
||||
fn seat_state(&self) -> &NodeSeatState {
|
||||
fn node_seat_state(&self) -> &NodeSeatState {
|
||||
&self.seat_state
|
||||
}
|
||||
|
||||
fn destroy_node(&self, _detach: bool) {
|
||||
self.link.set(None);
|
||||
self.mapped.set(false);
|
||||
self.surface.node_destroy(false);
|
||||
self.seat_state.destroy_node(self);
|
||||
fn node_visit(self: Rc<Self>, visitor: &mut dyn NodeVisitor) {
|
||||
visitor.visit_layer_surface(&self);
|
||||
}
|
||||
|
||||
fn visit(self: &Rc<Self>, visitor: &mut dyn NodeVisitor) {
|
||||
visitor.visit_layer_surface(self);
|
||||
fn node_visit_children(&self, visitor: &mut dyn NodeVisitor) {
|
||||
visitor.visit_surface(&self.surface);
|
||||
}
|
||||
|
||||
fn visit_children(&self, visitor: &mut dyn NodeVisitor) {
|
||||
self.surface.visit(visitor);
|
||||
}
|
||||
|
||||
fn visible(&self) -> bool {
|
||||
fn node_visible(&self) -> bool {
|
||||
true
|
||||
}
|
||||
|
||||
fn parent(&self) -> Option<Rc<dyn Node>> {
|
||||
Some(self.output.clone())
|
||||
}
|
||||
|
||||
fn absolute_position(&self) -> Rect {
|
||||
fn node_absolute_position(&self) -> Rect {
|
||||
self.pos.get()
|
||||
}
|
||||
|
||||
fn find_tree_at(&self, x: i32, y: i32, tree: &mut Vec<FoundNode>) -> FindTreeResult {
|
||||
fn node_find_tree_at(&self, x: i32, y: i32, tree: &mut Vec<FoundNode>) -> FindTreeResult {
|
||||
self.surface.find_tree_at_(x, y, tree)
|
||||
}
|
||||
|
||||
fn render(&self, renderer: &mut Renderer, x: i32, y: i32) {
|
||||
fn node_render(&self, renderer: &mut Renderer, x: i32, y: i32) {
|
||||
renderer.render_layer_surface(self, x, y);
|
||||
}
|
||||
|
||||
fn change_extents(self: &Rc<Self>, _rect: &Rect) {
|
||||
self.compute_position();
|
||||
}
|
||||
}
|
||||
|
||||
object_base! {
|
||||
|
|
@ -426,7 +418,7 @@ impl Object for ZwlrLayerSurfaceV1 {
|
|||
}
|
||||
|
||||
fn break_loops(&self) {
|
||||
self.node_destroy(true);
|
||||
self.destroy_node();
|
||||
self.link.set(None);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue