Skip to content

Commit

Permalink
Merge pull request #102 from mahkoh/jorth/fix-tl-change-extents
Browse files Browse the repository at this point in the history
tree: various fixes
  • Loading branch information
mahkoh authored Feb 22, 2024
2 parents 8555e9e + fe804b8 commit c1421fc
Show file tree
Hide file tree
Showing 16 changed files with 271 additions and 233 deletions.
7 changes: 5 additions & 2 deletions src/ifs/wl_seat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -574,15 +574,18 @@ impl WlSeatGlobal {
_ => return,
};
if let Some(pn) = pn.node_into_containing_node() {
let cn = ContainerNode::new(&self.state, &ws, pn.clone(), tl.clone(), axis);
let cn = ContainerNode::new(&self.state, &ws, tl.clone(), axis);
pn.cnode_replace_child(tl.tl_as_node(), cn);
}
}

pub fn focus_parent(self: &Rc<Self>) {
if let Some(tl) = self.keyboard_node.get().node_toplevel() {
if let Some(parent) = tl.tl_data().parent.get() {
self.focus_node(parent.cnode_into_node());
if let Some(tl) = parent.node_toplevel() {
self.focus_node(tl.tl_into_node());
self.state.damage();
}
}
}
}
Expand Down
18 changes: 9 additions & 9 deletions src/ifs/wl_surface/x_surface/xwindow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use {
state::State,
tree::{
Direction, FindTreeResult, FoundNode, Node, NodeId, NodeVisitor, StackedNode,
ToplevelData, ToplevelNode, WorkspaceNode,
ToplevelData, ToplevelNode, ToplevelNodeBase, WorkspaceNode,
},
utils::{clonecell::CloneCell, copyhashmap::CopyHashMap, linkedlist::LinkedNode},
wire::WlSurfaceId,
Expand Down Expand Up @@ -357,9 +357,7 @@ impl Node for Xwindow {
}
}

impl ToplevelNode for Xwindow {
tl_node_impl!();

impl ToplevelNodeBase for Xwindow {
fn tl_data(&self) -> &ToplevelData {
&self.toplevel_data
}
Expand All @@ -381,7 +379,7 @@ impl ToplevelNode for Xwindow {
Some(self.x.surface.clone())
}

fn tl_set_workspace_ext(self: Rc<Self>, ws: &Rc<WorkspaceNode>) {
fn tl_set_workspace_ext(&self, ws: &Rc<WorkspaceNode>) {
self.x.surface.set_output(&ws.output.get());
}

Expand Down Expand Up @@ -410,17 +408,19 @@ impl ToplevelNode for Xwindow {
.push(XWaylandEvent::Close(self.data.clone()));
}

fn tl_set_visible(&self, visible: bool) {
fn tl_set_visible_impl(&self, visible: bool) {
self.x.surface.set_visible(visible);
self.toplevel_data.set_visible(self, visible);
}

fn tl_destroy(&self) {
self.toplevel_data.destroy_node(self);
fn tl_destroy_impl(&self) {
self.display_link.borrow_mut().take();
self.x.surface.destroy_node();
}

fn tl_last_active_child(self: Rc<Self>) -> Rc<dyn ToplevelNode> {
self
}

fn tl_scanout_surface(&self) -> Option<Rc<WlSurface>> {
Some(self.x.surface.clone())
}
Expand Down
18 changes: 9 additions & 9 deletions src/ifs/wl_surface/xdg_surface/xdg_toplevel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use {
state::State,
tree::{
Direction, FindTreeResult, FoundNode, Node, NodeId, NodeVisitor, ToplevelData,
ToplevelNode, ToplevelNodeId, WorkspaceNode,
ToplevelNode, ToplevelNodeBase, ToplevelNodeId, WorkspaceNode,
},
utils::{
buffd::{MsgParser, MsgParserError},
Expand Down Expand Up @@ -453,9 +453,7 @@ impl Node for XdgToplevel {
}
}

impl ToplevelNode for XdgToplevel {
tl_node_impl!();

impl ToplevelNodeBase for XdgToplevel {
fn tl_data(&self) -> &ToplevelData {
&self.toplevel_data
}
Expand All @@ -479,7 +477,7 @@ impl ToplevelNode for XdgToplevel {
Some(self.xdg.surface.clone())
}

fn tl_set_workspace_ext(self: Rc<Self>, ws: &Rc<WorkspaceNode>) {
fn tl_set_workspace_ext(&self, ws: &Rc<WorkspaceNode>) {
self.xdg.set_workspace(ws);
}

Expand All @@ -499,13 +497,12 @@ impl ToplevelNode for XdgToplevel {
self.send_close();
}

fn tl_set_visible(&self, visible: bool) {
fn tl_set_visible_impl(&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);
if self.xdg.base.version >= SUSPENDED_SINCE {
if visible {
self.states.borrow_mut().remove(&STATE_SUSPENDED);
Expand All @@ -516,8 +513,7 @@ impl ToplevelNode for XdgToplevel {
}
}

fn tl_destroy(&self) {
self.toplevel_data.destroy_node(self);
fn tl_destroy_impl(&self) {
self.xdg.destroy_node();
}

Expand All @@ -544,6 +540,10 @@ impl ToplevelNode for XdgToplevel {
// }
// }

fn tl_last_active_child(self: Rc<Self>) -> Rc<dyn ToplevelNode> {
self
}

fn tl_scanout_surface(&self) -> Option<Rc<WlSurface>> {
Some(self.xdg.surface.clone())
}
Expand Down
2 changes: 1 addition & 1 deletion src/it/test_ifs/test_xdg_toplevel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use {
test_transport::TestTransport,
testrun::ParseFull,
},
tree::{ContainerNode, ToplevelNode},
tree::{ContainerNode, ToplevelNodeBase},
utils::buffd::MsgParser,
wire::{xdg_toplevel::*, XdgToplevelId},
},
Expand Down
2 changes: 1 addition & 1 deletion src/it/tests/t0010_fullscreen_focus.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use {
crate::{
it::{test_error::TestError, testrun::TestRun},
tree::ToplevelNode,
tree::ToplevelNodeBase,
},
std::rc::Rc,
};
Expand Down
2 changes: 1 addition & 1 deletion src/it/tests/t0014_container_scroll_focus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use {
test_error::{TestErrorExt, TestResult},
testrun::TestRun,
},
tree::ToplevelNode,
tree::ToplevelNodeBase,
},
jay_config::Axis,
std::rc::Rc,
Expand Down
2 changes: 1 addition & 1 deletion src/it/tests/t0015_scroll_partial.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use {
crate::{
it::{test_error::TestResult, testrun::TestRun},
tree::ToplevelNode,
tree::ToplevelNodeBase,
},
std::rc::Rc,
};
Expand Down
16 changes: 0 additions & 16 deletions src/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -476,22 +476,6 @@ macro_rules! fatal {
}}
}

macro_rules! tl_node_impl {
() => {
fn tl_as_node(&self) -> &dyn Node {
self
}

fn tl_into_node(self: Rc<Self>) -> Rc<dyn Node> {
self
}

fn tl_into_dyn(self: Rc<Self>) -> Rc<dyn ToplevelNode> {
self
}
};
}

macro_rules! stacked_node_impl {
() => {
fn stacked_as_node(&self) -> &dyn Node {
Expand Down
2 changes: 1 addition & 1 deletion src/renderer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use {
state::State,
theme::Color,
tree::{
ContainerNode, DisplayNode, FloatNode, OutputNode, PlaceholderNode, ToplevelNode,
ContainerNode, DisplayNode, FloatNode, OutputNode, PlaceholderNode, ToplevelNodeBase,
WorkspaceNode,
},
},
Expand Down
7 changes: 3 additions & 4 deletions src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ use {
theme::{Color, Theme},
tree::{
ContainerNode, ContainerSplit, Direction, DisplayNode, FloatNode, Node, NodeIds,
NodeVisitorBase, OutputNode, PlaceholderNode, ToplevelNode, WorkspaceNode,
NodeVisitorBase, OutputNode, PlaceholderNode, ToplevelNode, ToplevelNodeBase,
WorkspaceNode,
},
utils::{
activation_token::ActivationToken, asyncevent::AsyncEvent, clonecell::CloneCell,
Expand Down Expand Up @@ -507,8 +508,7 @@ impl State {
c.append_child(node);
}
} else {
let container =
ContainerNode::new(self, ws, ws.clone(), node, ContainerSplit::Horizontal);
let container = ContainerNode::new(self, ws, node, ContainerSplit::Horizontal);
ws.set_container(&container);
}
}
Expand All @@ -520,7 +520,6 @@ impl State {
mut height: i32,
workspace: &Rc<WorkspaceNode>,
) {
node.clone().tl_set_workspace(workspace);
width += 2 * self.theme.sizes.border_width.get();
height += 2 * self.theme.sizes.border_width.get() + self.theme.sizes.title_height.get() + 1;
let output = workspace.output.get();
Expand Down
Loading

0 comments on commit c1421fc

Please sign in to comment.