tree: move common code out of ToplevelNode trait
This commit is contained in:
parent
8430278264
commit
1d1d542839
12 changed files with 100 additions and 90 deletions
|
|
@ -28,27 +28,33 @@ use {
|
|||
|
||||
tree_id!(ToplevelNodeId);
|
||||
|
||||
pub trait ToplevelNode: Node {
|
||||
pub trait ToplevelNode: ToplevelNodeBase {
|
||||
fn tl_as_node(&self) -> &dyn Node;
|
||||
fn tl_into_node(self: Rc<Self>) -> Rc<dyn Node>;
|
||||
fn tl_into_dyn(self: Rc<Self>) -> Rc<dyn ToplevelNode>;
|
||||
fn tl_surface_active_changed(&self, active: bool);
|
||||
fn tl_set_fullscreen(self: Rc<Self>, fullscreen: bool);
|
||||
fn tl_title_changed(&self);
|
||||
fn tl_set_parent(&self, parent: Rc<dyn ContainingNode>);
|
||||
fn tl_active_changed(&self);
|
||||
fn tl_extents_changed(&self);
|
||||
fn tl_set_workspace(self: Rc<Self>, ws: &Rc<WorkspaceNode>);
|
||||
fn tl_change_extents(self: Rc<Self>, rect: &Rect);
|
||||
fn tl_set_visible(&self, visible: bool);
|
||||
fn tl_destroy(&self);
|
||||
}
|
||||
|
||||
fn tl_data(&self) -> &ToplevelData;
|
||||
|
||||
fn tl_default_focus_child(&self) -> Option<Rc<dyn Node>> {
|
||||
None
|
||||
impl<T: ToplevelNodeBase> ToplevelNode for T {
|
||||
fn tl_as_node(&self) -> &dyn Node {
|
||||
self
|
||||
}
|
||||
|
||||
fn tl_accepts_keyboard_focus(&self) -> bool {
|
||||
true
|
||||
fn tl_into_node(self: Rc<Self>) -> Rc<dyn Node> {
|
||||
self
|
||||
}
|
||||
|
||||
fn tl_set_active(&self, active: bool) {
|
||||
let _ = active;
|
||||
}
|
||||
|
||||
fn tl_on_activate(&self) {
|
||||
// nothing
|
||||
fn tl_into_dyn(self: Rc<Self>) -> Rc<dyn ToplevelNode> {
|
||||
self
|
||||
}
|
||||
|
||||
fn tl_surface_active_changed(&self, active: bool) {
|
||||
|
|
@ -70,13 +76,6 @@ pub trait ToplevelNode: Node {
|
|||
}
|
||||
}
|
||||
|
||||
fn tl_focus_child(&self, seat: SeatId) -> Option<Rc<dyn Node>> {
|
||||
self.tl_data()
|
||||
.focus_node
|
||||
.get(&seat)
|
||||
.or_else(|| self.tl_default_focus_child())
|
||||
}
|
||||
|
||||
fn tl_set_fullscreen(self: Rc<Self>, fullscreen: bool) {
|
||||
let data = self.tl_data();
|
||||
if fullscreen {
|
||||
|
|
@ -92,7 +91,7 @@ pub trait ToplevelNode: Node {
|
|||
let data = self.tl_data();
|
||||
let title = data.title.borrow_mut();
|
||||
if let Some(parent) = data.parent.get() {
|
||||
parent.node_child_title_changed(self.tl_as_node(), &title);
|
||||
parent.node_child_title_changed(self, &title);
|
||||
}
|
||||
if let Some(data) = data.fullscrceen_data.borrow_mut().deref() {
|
||||
*data.placeholder.tl_data().title.borrow_mut() = title.clone();
|
||||
|
|
@ -139,10 +138,6 @@ pub trait ToplevelNode: Node {
|
|||
self.tl_set_workspace_ext(ws);
|
||||
}
|
||||
|
||||
fn tl_set_workspace_ext(self: Rc<Self>, ws: &Rc<WorkspaceNode>) {
|
||||
let _ = ws;
|
||||
}
|
||||
|
||||
fn tl_change_extents(self: Rc<Self>, rect: &Rect) {
|
||||
let data = self.tl_data();
|
||||
if data.is_floating.get() {
|
||||
|
|
@ -152,19 +147,56 @@ pub trait ToplevelNode: Node {
|
|||
self.tl_change_extents_impl(rect)
|
||||
}
|
||||
|
||||
fn tl_change_extents_impl(self: Rc<Self>, rect: &Rect);
|
||||
fn tl_set_visible(&self, visible: bool) {
|
||||
self.tl_set_visible_impl(visible);
|
||||
self.tl_data().set_visible(self, visible);
|
||||
}
|
||||
|
||||
fn tl_close(self: Rc<Self>) {
|
||||
fn tl_destroy(&self) {
|
||||
self.tl_data().destroy_node(self);
|
||||
self.tl_destroy_impl();
|
||||
}
|
||||
}
|
||||
|
||||
pub trait ToplevelNodeBase: Node {
|
||||
fn tl_data(&self) -> &ToplevelData;
|
||||
|
||||
fn tl_default_focus_child(&self) -> Option<Rc<dyn Node>> {
|
||||
None
|
||||
}
|
||||
|
||||
fn tl_accepts_keyboard_focus(&self) -> bool {
|
||||
true
|
||||
}
|
||||
|
||||
fn tl_set_active(&self, active: bool) {
|
||||
let _ = active;
|
||||
}
|
||||
|
||||
fn tl_on_activate(&self) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
fn tl_set_visible(&self, visible: bool);
|
||||
fn tl_destroy(&self);
|
||||
|
||||
fn tl_last_active_child(self: Rc<Self>) -> Rc<dyn ToplevelNode> {
|
||||
self.tl_into_dyn()
|
||||
fn tl_focus_child(&self, seat: SeatId) -> Option<Rc<dyn Node>> {
|
||||
self.tl_data()
|
||||
.focus_node
|
||||
.get(&seat)
|
||||
.or_else(|| self.tl_default_focus_child())
|
||||
}
|
||||
|
||||
fn tl_set_workspace_ext(self: Rc<Self>, ws: &Rc<WorkspaceNode>) {
|
||||
let _ = ws;
|
||||
}
|
||||
|
||||
fn tl_change_extents_impl(self: Rc<Self>, rect: &Rect);
|
||||
|
||||
fn tl_close(self: Rc<Self>);
|
||||
|
||||
fn tl_set_visible_impl(&self, visible: bool);
|
||||
fn tl_destroy_impl(&self);
|
||||
|
||||
fn tl_last_active_child(self: Rc<Self>) -> Rc<dyn ToplevelNode>;
|
||||
|
||||
fn tl_scanout_surface(&self) -> Option<Rc<WlSurface>> {
|
||||
None
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue