Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

surface: fix subsurface property propagation #150

Merged
merged 1 commit into from
Apr 4, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 12 additions & 26 deletions src/ifs/wl_surface/wl_subsurface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,21 +76,16 @@ impl PendingSubsurfaceData {
}
}

fn update_children_attach(
surface: &WlSubsurface,
mut sync: bool,
depth: u32,
) -> Result<(), WlSubsurfaceError> {
fn update_children_attach(surface: &WlSubsurface) -> Result<(), WlSubsurfaceError> {
if surface.depth.get() > MAX_SUBSURFACE_DEPTH {
return Err(WlSubsurfaceError::MaxDepthExceeded);
}
let children = surface.surface.children.borrow();
if let Some(children) = &*children {
for child in children.subsurfaces.values() {
child.depth.set(depth + 1);
if depth + 1 > MAX_SUBSURFACE_DEPTH {
return Err(WlSubsurfaceError::MaxDepthExceeded);
}
child.sync_ancestor.set(sync);
sync |= child.sync_requested.get();
update_children_attach(child, sync, depth + 1)?;
child.sync_ancestor.set(surface.sync());
child.depth.set(surface.depth.get() + 1);
update_children_attach(child)?;
}
}
Ok(())
Expand All @@ -108,7 +103,7 @@ impl WlSubsurface {
sync_ancestor: Cell::new(false),
node: RefCell::new(None),
latest_node: Default::default(),
depth: NumCell::new(0),
depth: NumCell::new(1),
tracker: Default::default(),
had_buffer: Cell::new(false),
}
Expand Down Expand Up @@ -154,16 +149,9 @@ impl WlSubsurface {
if self.surface.id == self.parent.get_root().id {
return Err(WlSubsurfaceError::Ancestor(self.surface.id, self.parent.id));
}
let mut sync_ancestor = false;
let mut depth = 1;
{
if let Some(ss) = self.parent.ext.get().into_subsurface() {
sync_ancestor = ss.sync();
depth = ss.depth.get() + 1;
if depth >= MAX_SUBSURFACE_DEPTH {
return Err(WlSubsurfaceError::MaxDepthExceeded);
}
}
if let Some(ss) = self.parent.ext.get().into_subsurface() {
self.sync_ancestor.set(ss.sync());
self.depth.set(ss.depth.get() + 1);
}
let node = {
let mut data = self.parent.children.borrow_mut();
Expand All @@ -177,10 +165,8 @@ impl WlSubsurface {
self.latest_node.set(Some(node.to_ref()));
self.pending().node = Some(node);
self.surface.set_toplevel(self.parent.toplevel.get());
self.sync_ancestor.set(sync_ancestor);
self.depth.set(depth);
self.surface.ext.set(self.clone());
update_children_attach(self, sync_ancestor, depth)?;
update_children_attach(self)?;
Ok(())
}

Expand Down
Loading