Simplify popup position computation

This commit is contained in:
Ivan Molodetskikh
2026-04-12 09:23:45 +03:00
parent 45582ad095
commit b81cb13c2c
2 changed files with 10 additions and 16 deletions
+6 -10
View File
@@ -224,26 +224,22 @@ impl MappedLayer {
location: Point<f64, Logical>,
push: &mut dyn FnMut(LayerSurfaceRenderElement<R>),
) {
let scale = Scale::from(self.scale);
let alpha = self.rules.opacity.unwrap_or(1.).clamp(0., 1.);
let location = location + self.bob_offset();
if ctx.target.should_block_out(self.rules.block_out_from) {
return;
}
// Layer surfaces don't have extra geometry like windows.
let buf_pos = location;
let scale = Scale::from(self.scale);
let alpha = self.rules.opacity.unwrap_or(1.).clamp(0., 1.);
let location = location + self.bob_offset();
let surface = self.surface.wl_surface();
for (popup, popup_offset) in PopupManager::popups_for_surface(surface) {
// Layer surfaces don't have extra geometry like windows.
let offset = popup_offset - popup.geometry().loc;
for (popup, offset) in PopupManager::popups_for_surface(surface) {
let surface_loc = location + (offset - popup.geometry().loc).to_f64();
push_elements_from_surface_tree(
ctx.renderer,
popup.wl_surface(),
(buf_pos + offset.to_f64()).to_physical_precise_round(scale),
surface_loc.to_physical_precise_round(scale),
scale,
alpha,
Kind::ScanoutCandidate,
+4 -6
View File
@@ -655,20 +655,18 @@ impl LayoutElement for Mapped {
return;
}
let buf_pos = location - self.window.geometry().loc.to_f64();
let surface = self.toplevel().wl_surface();
let mut push = |elem: WaylandSurfaceRenderElement<R>| push(elem.into());
for (popup, popup_offset) in PopupManager::popups_for_surface(surface) {
let offset = self.window.geometry().loc + popup_offset - popup.geometry().loc;
for (popup, offset) in PopupManager::popups_for_surface(surface) {
let surface_loc = location + (offset - popup.geometry().loc).to_f64();
push_elements_from_surface_tree(
ctx.renderer,
popup.wl_surface(),
(buf_pos + offset.to_f64()).to_physical_precise_round(scale),
surface_loc.to_physical_precise_round(scale),
scale,
alpha,
Kind::ScanoutCandidate,
&mut push,
&mut |elem| push(elem.into()),
);
}
}