diff --git a/src/desktop/layer.rs b/src/desktop/layer.rs index 427f96d..2d0f16f 100644 --- a/src/desktop/layer.rs +++ b/src/desktop/layer.rs @@ -438,15 +438,20 @@ impl LayerSurface { ) -> Vec> { let mut damage = Vec::new(); if let Some(surface) = self.get_surface() { - damage.extend(damage_from_surface_tree(surface, (0, 0), for_values)); + damage.extend( + damage_from_surface_tree(surface, (0, 0), for_values) + .into_iter() + .flat_map(|rect| rect.intersection(self.bbox())), + ); for (popup, location) in PopupManager::popups_for_surface(surface) .ok() .into_iter() .flatten() { if let Some(surface) = popup.get_surface() { + let bbox = bbox_from_surface_tree(surface, location); let popup_damage = damage_from_surface_tree(surface, location, for_values); - damage.extend(popup_damage); + damage.extend(popup_damage.into_iter().flat_map(|rect| rect.intersection(bbox))); } } } diff --git a/src/desktop/window.rs b/src/desktop/window.rs index 7b8b6a3..762676d 100644 --- a/src/desktop/window.rs +++ b/src/desktop/window.rs @@ -266,15 +266,20 @@ impl Window { ) -> Vec> { let mut damage = Vec::new(); if let Some(surface) = self.0.toplevel.get_surface() { - damage.extend(damage_from_surface_tree(surface, (0, 0), for_values)); + damage.extend( + damage_from_surface_tree(surface, (0, 0), for_values) + .into_iter() + .flat_map(|rect| rect.intersection(self.bbox())), + ); for (popup, location) in PopupManager::popups_for_surface(surface) .ok() .into_iter() .flatten() { if let Some(surface) = popup.get_surface() { + let bbox = bbox_from_surface_tree(surface, location); let popup_damage = damage_from_surface_tree(surface, location, for_values); - damage.extend(popup_damage); + damage.extend(popup_damage.into_iter().flat_map(|rect| rect.intersection(bbox))); } } }