1
0
Fork 0
forked from wry/wry

Merge pull request #506 from mahkoh/jorth/restack-damage

tree: restack containing float when node is activated
This commit is contained in:
mahkoh 2025-07-17 08:54:55 +02:00 committed by GitHub
commit a3c0631f4e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 80 additions and 20 deletions

View file

@ -1741,7 +1741,7 @@ impl ConfigProxyHandler {
fn handle_get_window_floating(&self, window: Window) -> Result<(), CphError> {
let window = self.get_window(window)?;
self.respond(Response::GetWindowFloating {
floating: window.tl_data().is_floating.get(),
floating: window.tl_data().parent_is_float.get(),
});
Ok(())
}

View file

@ -6,6 +6,6 @@ fixed_root_criterion!(TlmMatchFloating, floating);
impl CritFixedRootCriterion<ToplevelData> for TlmMatchFloating {
fn matches(&self, data: &ToplevelData) -> bool {
data.is_floating.get()
data.parent_is_float.get()
}
}

View file

@ -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 });
}
if data.visible.get() {

View file

@ -582,7 +582,7 @@ impl WlSeatGlobal {
pub fn get_floating(self: &Rc<Self>) -> Option<bool> {
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,
}
}

View file

@ -338,6 +338,7 @@ impl<T: SimplePointerOwnerUsecase> PointerOwner for SimplePointerOwner<T> {
node: pn.clone(),
serial,
}));
pn.node_restack();
pn.node_seat_state().add_pointer_grab(seat);
seat.handle_node_button(pn, time_usec, button, state, serial);
}

View file

@ -94,9 +94,11 @@ impl ToolOwner for DefaultToolOwner {
if state == ToolButtonState::Released {
return;
}
let node = tool.node.get();
node.node_restack();
let owner = Rc::new(GrabToolOwner {
buttons: Default::default(),
node: tool.node.get(),
node,
});
tool.tool_owner.owner.set(owner.clone());
owner.button(tool, time_usec, button, state);

View file

@ -71,6 +71,7 @@ impl TouchOwner for DefaultTouchOwner {
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());
node.node.node_seat_state().touch_begin(seat);
node.node.node_restack();
let owner = Rc::new(GrabTouchOwner {
node: node.node,
down_ids: Default::default(),

View file

@ -17,10 +17,10 @@ use {
state::State,
text::TextTexture,
tree::{
ContainingNode, Direction, FindTreeResult, FindTreeUsecase, FoundNode, Node, NodeId,
OutputNode, TddType, TileDragDestination, ToplevelData, ToplevelNode, ToplevelNodeBase,
ToplevelType, WorkspaceNode, default_tile_drag_bounds, toplevel_set_floating,
walker::NodeVisitor,
ContainingNode, Direction, FindTreeResult, FindTreeUsecase, FloatNode, FoundNode, Node,
NodeId, OutputNode, TddType, TileDragDestination, ToplevelData, ToplevelNode,
ToplevelNodeBase, ToplevelType, WorkspaceNode, default_tile_drag_bounds,
toplevel_set_floating, walker::NodeVisitor,
},
utils::{
asyncevent::AsyncEvent,
@ -2063,6 +2063,10 @@ impl ContainingNode for ContainerNode {
fn cnode_set_pinned(self: Rc<Self>, pinned: bool) {
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 {
@ -2176,6 +2180,12 @@ impl ToplevelNodeBase for ContainerNode {
};
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) {

View file

@ -1,5 +1,5 @@
use {
crate::tree::{Node, ToplevelNode, WorkspaceNode},
crate::tree::{FloatNode, Node, ToplevelNode, WorkspaceNode},
std::rc::Rc,
};
@ -37,4 +37,7 @@ pub trait ContainingNode: Node {
fn cnode_set_pinned(self: Rc<Self>, pinned: bool) {
let _ = pinned;
}
fn cnode_get_float(self: Rc<Self>) -> Option<Rc<FloatNode>> {
None
}
}

View file

@ -519,6 +519,9 @@ impl FloatNode {
fn restack(&self) {
if let Some(dl) = &*self.display_link.borrow() {
if dl.next().is_none() {
return;
}
self.state.damage(self.position.get());
self.state.root.stacked.add_last_existing(&dl);
if let Some(tl) = self.child.get() {
@ -958,6 +961,10 @@ impl ContainingNode for FloatNode {
}
self.toggle_pinned();
}
fn cnode_get_float(self: Rc<Self>) -> Option<Rc<FloatNode>> {
Some(self)
}
}
impl StackedNode for FloatNode {
@ -981,3 +988,13 @@ impl PinnedNode for FloatNode {
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();
}
}
}

View file

@ -26,8 +26,8 @@ use {
rect::Rect,
state::State,
tree::{
ContainerNode, ContainerSplit, ContainingNode, Direction, Node, NodeId, OutputNode,
PlaceholderNode, WorkspaceNode,
ContainerNode, ContainerSplit, ContainingNode, Direction, FloatNode, Node, NodeId,
OutputNode, PlaceholderNode, WorkspaceNode,
},
utils::{
array_to_tuple::ArrayToTuple,
@ -35,6 +35,7 @@ use {
copyhashmap::CopyHashMap,
hash_map_ext::HashMapExt,
numcell::NumCell,
rc_eq::rc_eq,
threshold_counter::ThresholdCounter,
toplevel_identifier::{ToplevelIdentifier, toplevel_identifier},
},
@ -67,6 +68,7 @@ pub trait ToplevelNode: ToplevelNodeBase {
fn tl_destroy(&self);
fn tl_pinned(&self) -> 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 {
@ -112,13 +114,25 @@ impl<T: ToplevelNodeBase> ToplevelNode for T {
data.mapped_during_iteration.set(data.state.eng.iteration());
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();
if was_floating != is_floating {
data.property_changed(TL_CHANGED_FLOATING);
}
data.is_floating.set(is_floating);
self.tl_set_workspace(&parent.cnode_workspace());
data.parent_is_float.set(is_floating);
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) {
@ -173,7 +187,7 @@ impl<T: ToplevelNodeBase> ToplevelNode for T {
sc.buffer_size_changed();
}
}
if data.is_floating.get() {
if data.parent_is_float.get() {
data.float_width.set(rect.width());
data.float_height.set(rect.height());
}
@ -207,6 +221,11 @@ impl<T: ToplevelNodeBase> ToplevelNode for T {
};
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 {
@ -266,6 +285,10 @@ pub trait ToplevelNodeBase: Node {
.is_some()
.then_some(self.node_absolute_position())
}
fn tl_push_float(&self, float: Option<&Rc<FloatNode>>) {
let _ = float;
}
}
pub struct FullscreenedData {
@ -316,7 +339,8 @@ pub struct ToplevelData {
pub state: Rc<State>,
pub active_surfaces: ThresholdCounter,
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_height: Cell<i32>,
pub pinned: Cell<bool>,
@ -369,7 +393,8 @@ impl ToplevelData {
state: state.clone(),
active_surfaces: Default::default(),
visible: Cell::new(false),
is_floating: Default::default(),
parent_is_float: Default::default(),
float: Default::default(),
float_width: Default::default(),
float_height: Default::default(),
pinned: Cell::new(false),
@ -491,6 +516,7 @@ impl ToplevelData {
if let Some(parent) = self.parent.take() {
parent.cnode_remove_child(node);
}
self.float.take();
self.workspace.take();
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() {
return;
}
if data.is_floating.get() == floating {
if data.parent_is_float.get() == floating {
return;
}
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);
}
}
if tl.tl_data().is_floating.get() {
if tl.tl_data().parent_is_float.get() {
let (width, height) = tl.tl_data().float_size(ws);
state.map_floating(tl.clone(), width, height, ws, None);
} else {