Merge pull request #506 from mahkoh/jorth/restack-damage
tree: restack containing float when node is activated
This commit is contained in:
commit
a3c0631f4e
11 changed files with 80 additions and 20 deletions
|
|
@ -1741,7 +1741,7 @@ impl ConfigProxyHandler {
|
||||||
fn handle_get_window_floating(&self, window: Window) -> Result<(), CphError> {
|
fn handle_get_window_floating(&self, window: Window) -> Result<(), CphError> {
|
||||||
let window = self.get_window(window)?;
|
let window = self.get_window(window)?;
|
||||||
self.respond(Response::GetWindowFloating {
|
self.respond(Response::GetWindowFloating {
|
||||||
floating: window.tl_data().is_floating.get(),
|
floating: window.tl_data().parent_is_float.get(),
|
||||||
});
|
});
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,6 @@ fixed_root_criterion!(TlmMatchFloating, floating);
|
||||||
|
|
||||||
impl CritFixedRootCriterion<ToplevelData> for TlmMatchFloating {
|
impl CritFixedRootCriterion<ToplevelData> for TlmMatchFloating {
|
||||||
fn matches(&self, data: &ToplevelData) -> bool {
|
fn matches(&self, data: &ToplevelData) -> bool {
|
||||||
data.is_floating.get()
|
data.parent_is_float.get()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -197,7 +197,7 @@ impl JayTreeQuery {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if data.is_floating.get() {
|
if data.parent_is_float.get() {
|
||||||
self.client.event(Floating { self_id: self.id });
|
self.client.event(Floating { self_id: self.id });
|
||||||
}
|
}
|
||||||
if data.visible.get() {
|
if data.visible.get() {
|
||||||
|
|
|
||||||
|
|
@ -582,7 +582,7 @@ impl WlSeatGlobal {
|
||||||
|
|
||||||
pub fn get_floating(self: &Rc<Self>) -> Option<bool> {
|
pub fn get_floating(self: &Rc<Self>) -> Option<bool> {
|
||||||
match self.keyboard_node.get().node_toplevel() {
|
match self.keyboard_node.get().node_toplevel() {
|
||||||
Some(tl) => Some(tl.tl_data().is_floating.get()),
|
Some(tl) => Some(tl.tl_data().parent_is_float.get()),
|
||||||
_ => None,
|
_ => None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -338,6 +338,7 @@ impl<T: SimplePointerOwnerUsecase> PointerOwner for SimplePointerOwner<T> {
|
||||||
node: pn.clone(),
|
node: pn.clone(),
|
||||||
serial,
|
serial,
|
||||||
}));
|
}));
|
||||||
|
pn.node_restack();
|
||||||
pn.node_seat_state().add_pointer_grab(seat);
|
pn.node_seat_state().add_pointer_grab(seat);
|
||||||
seat.handle_node_button(pn, time_usec, button, state, serial);
|
seat.handle_node_button(pn, time_usec, button, state, serial);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -94,9 +94,11 @@ impl ToolOwner for DefaultToolOwner {
|
||||||
if state == ToolButtonState::Released {
|
if state == ToolButtonState::Released {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
let node = tool.node.get();
|
||||||
|
node.node_restack();
|
||||||
let owner = Rc::new(GrabToolOwner {
|
let owner = Rc::new(GrabToolOwner {
|
||||||
buttons: Default::default(),
|
buttons: Default::default(),
|
||||||
node: tool.node.get(),
|
node,
|
||||||
});
|
});
|
||||||
tool.tool_owner.owner.set(owner.clone());
|
tool.tool_owner.owner.set(owner.clone());
|
||||||
owner.button(tool, time_usec, button, state);
|
owner.button(tool, time_usec, button, state);
|
||||||
|
|
|
||||||
|
|
@ -71,6 +71,7 @@ impl TouchOwner for DefaultTouchOwner {
|
||||||
fn down(&self, seat: &Rc<WlSeatGlobal>, time_usec: u64, id: i32, x: Fixed, y: Fixed) {
|
fn down(&self, seat: &Rc<WlSeatGlobal>, time_usec: u64, id: i32, x: Fixed, y: Fixed) {
|
||||||
let node = seat.state.node_at(x.round_down(), y.round_down());
|
let node = seat.state.node_at(x.round_down(), y.round_down());
|
||||||
node.node.node_seat_state().touch_begin(seat);
|
node.node.node_seat_state().touch_begin(seat);
|
||||||
|
node.node.node_restack();
|
||||||
let owner = Rc::new(GrabTouchOwner {
|
let owner = Rc::new(GrabTouchOwner {
|
||||||
node: node.node,
|
node: node.node,
|
||||||
down_ids: Default::default(),
|
down_ids: Default::default(),
|
||||||
|
|
|
||||||
|
|
@ -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
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -519,6 +519,9 @@ impl FloatNode {
|
||||||
|
|
||||||
fn restack(&self) {
|
fn restack(&self) {
|
||||||
if let Some(dl) = &*self.display_link.borrow() {
|
if let Some(dl) = &*self.display_link.borrow() {
|
||||||
|
if dl.next().is_none() {
|
||||||
|
return;
|
||||||
|
}
|
||||||
self.state.damage(self.position.get());
|
self.state.damage(self.position.get());
|
||||||
self.state.root.stacked.add_last_existing(&dl);
|
self.state.root.stacked.add_last_existing(&dl);
|
||||||
if let Some(tl) = self.child.get() {
|
if let Some(tl) = self.child.get() {
|
||||||
|
|
@ -958,6 +961,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 {
|
||||||
|
|
@ -981,3 +988,13 @@ impl PinnedNode for FloatNode {
|
||||||
self.set_workspace_(workspace, false, update_visible);
|
self.set_workspace_(workspace, false, update_visible);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl dyn Node {
|
||||||
|
pub fn node_restack(self: &Rc<Self>) {
|
||||||
|
if let Some(tl) = self.clone().node_toplevel()
|
||||||
|
&& let Some(float) = tl.tl_data().float.get()
|
||||||
|
{
|
||||||
|
float.restack();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -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 {
|
||||||
|
|
@ -112,13 +114,25 @@ impl<T: ToplevelNodeBase> ToplevelNode for T {
|
||||||
data.mapped_during_iteration.set(data.state.eng.iteration());
|
data.mapped_during_iteration.set(data.state.eng.iteration());
|
||||||
data.property_changed(TL_CHANGED_NEW);
|
data.property_changed(TL_CHANGED_NEW);
|
||||||
}
|
}
|
||||||
let was_floating = data.is_floating.get();
|
let was_floating = data.parent_is_float.get();
|
||||||
let is_floating = parent.node_is_float();
|
let is_floating = parent.node_is_float();
|
||||||
if was_floating != is_floating {
|
if was_floating != is_floating {
|
||||||
data.property_changed(TL_CHANGED_FLOATING);
|
data.property_changed(TL_CHANGED_FLOATING);
|
||||||
}
|
}
|
||||||
data.is_floating.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) {
|
||||||
|
|
@ -173,7 +187,7 @@ impl<T: ToplevelNodeBase> ToplevelNode for T {
|
||||||
sc.buffer_size_changed();
|
sc.buffer_size_changed();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if data.is_floating.get() {
|
if data.parent_is_float.get() {
|
||||||
data.float_width.set(rect.width());
|
data.float_width.set(rect.width());
|
||||||
data.float_height.set(rect.height());
|
data.float_height.set(rect.height());
|
||||||
}
|
}
|
||||||
|
|
@ -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 {
|
||||||
|
|
@ -316,7 +339,8 @@ pub struct ToplevelData {
|
||||||
pub state: Rc<State>,
|
pub state: Rc<State>,
|
||||||
pub active_surfaces: ThresholdCounter,
|
pub active_surfaces: ThresholdCounter,
|
||||||
pub visible: Cell<bool>,
|
pub visible: Cell<bool>,
|
||||||
pub is_floating: 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>,
|
||||||
|
|
@ -369,7 +393,8 @@ impl ToplevelData {
|
||||||
state: state.clone(),
|
state: state.clone(),
|
||||||
active_surfaces: Default::default(),
|
active_surfaces: Default::default(),
|
||||||
visible: Cell::new(false),
|
visible: Cell::new(false),
|
||||||
is_floating: 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);
|
||||||
}
|
}
|
||||||
|
|
@ -910,7 +936,7 @@ pub fn toplevel_set_floating(state: &Rc<State>, tl: Rc<dyn ToplevelNode>, floati
|
||||||
if data.is_fullscreen.get() {
|
if data.is_fullscreen.get() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if data.is_floating.get() == floating {
|
if data.parent_is_float.get() == floating {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let parent = match data.parent.get() {
|
let parent = match data.parent.get() {
|
||||||
|
|
@ -949,7 +975,7 @@ pub fn toplevel_set_workspace(state: &Rc<State>, tl: Rc<dyn ToplevelNode>, ws: &
|
||||||
old_ws.clone().node_do_focus(&focus, Direction::Unspecified);
|
old_ws.clone().node_do_focus(&focus, Direction::Unspecified);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if tl.tl_data().is_floating.get() {
|
if tl.tl_data().parent_is_float.get() {
|
||||||
let (width, height) = tl.tl_data().float_size(ws);
|
let (width, height) = tl.tl_data().float_size(ws);
|
||||||
state.map_floating(tl.clone(), width, height, ws, None);
|
state.map_floating(tl.clone(), width, height, ws, None);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue