toplevel: store containing float
This commit is contained in:
parent
a333198658
commit
a97e92ccea
4 changed files with 51 additions and 8 deletions
|
|
@ -17,10 +17,10 @@ use {
|
||||||
state::State,
|
state::State,
|
||||||
text::TextTexture,
|
text::TextTexture,
|
||||||
tree::{
|
tree::{
|
||||||
ContainingNode, Direction, FindTreeResult, FindTreeUsecase, FoundNode, Node, NodeId,
|
ContainingNode, Direction, FindTreeResult, FindTreeUsecase, FloatNode, FoundNode, Node,
|
||||||
OutputNode, TddType, TileDragDestination, ToplevelData, ToplevelNode, ToplevelNodeBase,
|
NodeId, OutputNode, TddType, TileDragDestination, ToplevelData, ToplevelNode,
|
||||||
ToplevelType, WorkspaceNode, default_tile_drag_bounds, toplevel_set_floating,
|
ToplevelNodeBase, ToplevelType, WorkspaceNode, default_tile_drag_bounds,
|
||||||
walker::NodeVisitor,
|
toplevel_set_floating, walker::NodeVisitor,
|
||||||
},
|
},
|
||||||
utils::{
|
utils::{
|
||||||
asyncevent::AsyncEvent,
|
asyncevent::AsyncEvent,
|
||||||
|
|
@ -2063,6 +2063,10 @@ impl ContainingNode for ContainerNode {
|
||||||
fn cnode_set_pinned(self: Rc<Self>, pinned: bool) {
|
fn cnode_set_pinned(self: Rc<Self>, pinned: bool) {
|
||||||
self.tl_set_pinned(false, pinned);
|
self.tl_set_pinned(false, pinned);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn cnode_get_float(self: Rc<Self>) -> Option<Rc<FloatNode>> {
|
||||||
|
self.tl_data().float.get()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ToplevelNodeBase for ContainerNode {
|
impl ToplevelNodeBase for ContainerNode {
|
||||||
|
|
@ -2176,6 +2180,12 @@ impl ToplevelNodeBase for ContainerNode {
|
||||||
};
|
};
|
||||||
child.node.tl_tile_drag_bounds(split, start) / 2
|
child.node.tl_tile_drag_bounds(split, start) / 2
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn tl_push_float(&self, float: Option<&Rc<FloatNode>>) {
|
||||||
|
for child in self.children.iter() {
|
||||||
|
child.node.tl_set_float(float);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn direction_to_split(dir: Direction) -> (ContainerSplit, bool) {
|
fn direction_to_split(dir: Direction) -> (ContainerSplit, bool) {
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
use {
|
use {
|
||||||
crate::tree::{Node, ToplevelNode, WorkspaceNode},
|
crate::tree::{FloatNode, Node, ToplevelNode, WorkspaceNode},
|
||||||
std::rc::Rc,
|
std::rc::Rc,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -37,4 +37,7 @@ pub trait ContainingNode: Node {
|
||||||
fn cnode_set_pinned(self: Rc<Self>, pinned: bool) {
|
fn cnode_set_pinned(self: Rc<Self>, pinned: bool) {
|
||||||
let _ = pinned;
|
let _ = pinned;
|
||||||
}
|
}
|
||||||
|
fn cnode_get_float(self: Rc<Self>) -> Option<Rc<FloatNode>> {
|
||||||
|
None
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -958,6 +958,10 @@ impl ContainingNode for FloatNode {
|
||||||
}
|
}
|
||||||
self.toggle_pinned();
|
self.toggle_pinned();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn cnode_get_float(self: Rc<Self>) -> Option<Rc<FloatNode>> {
|
||||||
|
Some(self)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl StackedNode for FloatNode {
|
impl StackedNode for FloatNode {
|
||||||
|
|
|
||||||
|
|
@ -26,8 +26,8 @@ use {
|
||||||
rect::Rect,
|
rect::Rect,
|
||||||
state::State,
|
state::State,
|
||||||
tree::{
|
tree::{
|
||||||
ContainerNode, ContainerSplit, ContainingNode, Direction, Node, NodeId, OutputNode,
|
ContainerNode, ContainerSplit, ContainingNode, Direction, FloatNode, Node, NodeId,
|
||||||
PlaceholderNode, WorkspaceNode,
|
OutputNode, PlaceholderNode, WorkspaceNode,
|
||||||
},
|
},
|
||||||
utils::{
|
utils::{
|
||||||
array_to_tuple::ArrayToTuple,
|
array_to_tuple::ArrayToTuple,
|
||||||
|
|
@ -35,6 +35,7 @@ use {
|
||||||
copyhashmap::CopyHashMap,
|
copyhashmap::CopyHashMap,
|
||||||
hash_map_ext::HashMapExt,
|
hash_map_ext::HashMapExt,
|
||||||
numcell::NumCell,
|
numcell::NumCell,
|
||||||
|
rc_eq::rc_eq,
|
||||||
threshold_counter::ThresholdCounter,
|
threshold_counter::ThresholdCounter,
|
||||||
toplevel_identifier::{ToplevelIdentifier, toplevel_identifier},
|
toplevel_identifier::{ToplevelIdentifier, toplevel_identifier},
|
||||||
},
|
},
|
||||||
|
|
@ -67,6 +68,7 @@ pub trait ToplevelNode: ToplevelNodeBase {
|
||||||
fn tl_destroy(&self);
|
fn tl_destroy(&self);
|
||||||
fn tl_pinned(&self) -> bool;
|
fn tl_pinned(&self) -> bool;
|
||||||
fn tl_set_pinned(&self, self_pinned: bool, pinned: bool);
|
fn tl_set_pinned(&self, self_pinned: bool, pinned: bool);
|
||||||
|
fn tl_set_float(&self, float: Option<&Rc<FloatNode>>);
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T: ToplevelNodeBase> ToplevelNode for T {
|
impl<T: ToplevelNodeBase> ToplevelNode for T {
|
||||||
|
|
@ -118,7 +120,19 @@ impl<T: ToplevelNodeBase> ToplevelNode for T {
|
||||||
data.property_changed(TL_CHANGED_FLOATING);
|
data.property_changed(TL_CHANGED_FLOATING);
|
||||||
}
|
}
|
||||||
data.parent_is_float.set(is_floating);
|
data.parent_is_float.set(is_floating);
|
||||||
self.tl_set_workspace(&parent.cnode_workspace());
|
self.tl_set_workspace(&parent.clone().cnode_workspace());
|
||||||
|
{
|
||||||
|
let float = parent.cnode_get_float();
|
||||||
|
let prev = data.float.set(float.clone());
|
||||||
|
let same = match (&prev, &float) {
|
||||||
|
(None, None) => true,
|
||||||
|
(Some(prev), Some(float)) => rc_eq(prev, float),
|
||||||
|
_ => false,
|
||||||
|
};
|
||||||
|
if !same {
|
||||||
|
self.tl_push_float(float.as_ref());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn tl_extents_changed(&self) {
|
fn tl_extents_changed(&self) {
|
||||||
|
|
@ -207,6 +221,11 @@ impl<T: ToplevelNodeBase> ToplevelNode for T {
|
||||||
};
|
};
|
||||||
parent.cnode_set_pinned(pinned);
|
parent.cnode_set_pinned(pinned);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn tl_set_float(&self, float: Option<&Rc<FloatNode>>) {
|
||||||
|
self.tl_data().float.set(float.cloned());
|
||||||
|
self.tl_push_float(float);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait ToplevelNodeBase: Node {
|
pub trait ToplevelNodeBase: Node {
|
||||||
|
|
@ -266,6 +285,10 @@ pub trait ToplevelNodeBase: Node {
|
||||||
.is_some()
|
.is_some()
|
||||||
.then_some(self.node_absolute_position())
|
.then_some(self.node_absolute_position())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn tl_push_float(&self, float: Option<&Rc<FloatNode>>) {
|
||||||
|
let _ = float;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct FullscreenedData {
|
pub struct FullscreenedData {
|
||||||
|
|
@ -317,6 +340,7 @@ pub struct ToplevelData {
|
||||||
pub active_surfaces: ThresholdCounter,
|
pub active_surfaces: ThresholdCounter,
|
||||||
pub visible: Cell<bool>,
|
pub visible: Cell<bool>,
|
||||||
pub parent_is_float: Cell<bool>,
|
pub parent_is_float: Cell<bool>,
|
||||||
|
pub float: CloneCell<Option<Rc<FloatNode>>>,
|
||||||
pub float_width: Cell<i32>,
|
pub float_width: Cell<i32>,
|
||||||
pub float_height: Cell<i32>,
|
pub float_height: Cell<i32>,
|
||||||
pub pinned: Cell<bool>,
|
pub pinned: Cell<bool>,
|
||||||
|
|
@ -370,6 +394,7 @@ impl ToplevelData {
|
||||||
active_surfaces: Default::default(),
|
active_surfaces: Default::default(),
|
||||||
visible: Cell::new(false),
|
visible: Cell::new(false),
|
||||||
parent_is_float: Default::default(),
|
parent_is_float: Default::default(),
|
||||||
|
float: Default::default(),
|
||||||
float_width: Default::default(),
|
float_width: Default::default(),
|
||||||
float_height: Default::default(),
|
float_height: Default::default(),
|
||||||
pinned: Cell::new(false),
|
pinned: Cell::new(false),
|
||||||
|
|
@ -491,6 +516,7 @@ impl ToplevelData {
|
||||||
if let Some(parent) = self.parent.take() {
|
if let Some(parent) = self.parent.take() {
|
||||||
parent.cnode_remove_child(node);
|
parent.cnode_remove_child(node);
|
||||||
}
|
}
|
||||||
|
self.float.take();
|
||||||
self.workspace.take();
|
self.workspace.take();
|
||||||
self.seat_state.destroy_node(node);
|
self.seat_state.destroy_node(node);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue