shell: Fix definition of surface_tree_offset()
Using `with_surface_tree_downward()` is wrong because it will traverse other branches of the surface tree than the one containing `surface`, and add their offsets. It's simple enough to instead walk up the surface tree.
This commit is contained in:
parent
7d0d374fd8
commit
84d2a9d297
1 changed files with 16 additions and 30 deletions
|
|
@ -46,7 +46,7 @@ use smithay::{
|
||||||
},
|
},
|
||||||
wayland::{
|
wayland::{
|
||||||
compositor::{
|
compositor::{
|
||||||
SubsurfaceCachedState, SurfaceData, TraversalAction, with_states,
|
SubsurfaceCachedState, SurfaceData, TraversalAction, get_parent, with_states,
|
||||||
with_surface_tree_downward,
|
with_surface_tree_downward,
|
||||||
},
|
},
|
||||||
seat::WaylandFocus,
|
seat::WaylandFocus,
|
||||||
|
|
@ -675,38 +675,24 @@ impl CosmicSurface {
|
||||||
root: &WlSurface,
|
root: &WlSurface,
|
||||||
surface: &WlSurface,
|
surface: &WlSurface,
|
||||||
) -> Option<Point<i32, Logical>> {
|
) -> Option<Point<i32, Logical>> {
|
||||||
if root == surface {
|
let mut offset = Point::<i32, Logical>::default();
|
||||||
return Some(Point::default());
|
let mut parent = surface.clone();
|
||||||
}
|
loop {
|
||||||
|
if parent == *root {
|
||||||
let found = AtomicBool::new(false);
|
return Some(offset);
|
||||||
let mut found_offset = Point::<i32, Logical>::default();
|
} else if let Some(s) = get_parent(&parent) {
|
||||||
|
offset += with_states(&parent, |states| {
|
||||||
with_surface_tree_downward(
|
states
|
||||||
root,
|
|
||||||
Point::<i32, Logical>::default(),
|
|
||||||
|s, states, parent_offset| {
|
|
||||||
let mut offset = *parent_offset;
|
|
||||||
if s != root {
|
|
||||||
offset += states
|
|
||||||
.cached_state
|
.cached_state
|
||||||
.get::<SubsurfaceCachedState>()
|
.get::<SubsurfaceCachedState>()
|
||||||
.current()
|
.current()
|
||||||
.location;
|
.location
|
||||||
}
|
});
|
||||||
TraversalAction::DoChildren(offset)
|
parent = s;
|
||||||
},
|
} else {
|
||||||
|s, _, offset| {
|
// `parent` is now root of subsurface tree; `surface` is not a subsurface child of `root`
|
||||||
if s == surface {
|
break;
|
||||||
found_offset = *offset;
|
}
|
||||||
found.store(true, Ordering::SeqCst);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|_, _, _| !found.load(Ordering::SeqCst),
|
|
||||||
);
|
|
||||||
|
|
||||||
if found.load(Ordering::SeqCst) {
|
|
||||||
return Some(found_offset);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (popup, popup_offset) in PopupManager::popups_for_surface(root) {
|
for (popup, popup_offset) in PopupManager::popups_for_surface(root) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue