Simplify popup position computation
Browse files at this commitb81cb13c2c4739b4cc190df44a6ffd4c6f8686d2Parent: 45582ad2 changed files +10 -16
- src/layer/mapped.rs +6 -10
- src/window/mapped.rs +4 -6
src/layer/mapped.rsmodified+6 -10
| @@ -224,26 +224,22 @@ impl MappedLayer { | |||
| 224 | location: Point<f64, Logical>, | 224 | location: Point<f64, Logical>, |
| 225 | push: &mut dyn FnMut(LayerSurfaceRenderElement<R>), | 225 | push: &mut dyn FnMut(LayerSurfaceRenderElement<R>), |
| 226 | ) { | 226 | ) { |
| 227 | - let scale = Scale::from(self.scale); | ||
| 228 | - let alpha = self.rules.opacity.unwrap_or(1.).clamp(0., 1.); | ||
| 229 | - let location = location + self.bob_offset(); | ||
| 230 | - | ||
| 231 | if ctx.target.should_block_out(self.rules.block_out_from) { | 227 | if ctx.target.should_block_out(self.rules.block_out_from) { |
| 232 | return; | 228 | return; |
| 233 | } | 229 | } |
| 234 | 230 | ||
| 235 | - // Layer surfaces don't have extra geometry like windows. | 231 | + let scale = Scale::from(self.scale); |
| 236 | - let buf_pos = location; | 232 | + let alpha = self.rules.opacity.unwrap_or(1.).clamp(0., 1.); |
| 233 | + let location = location + self.bob_offset(); | ||
| 237 | 234 | ||
| 238 | let surface = self.surface.wl_surface(); | 235 | let surface = self.surface.wl_surface(); |
| 239 | - for (popup, popup_offset) in PopupManager::popups_for_surface(surface) { | 236 | + for (popup, offset) in PopupManager::popups_for_surface(surface) { |
| 240 | - // Layer surfaces don't have extra geometry like windows. | 237 | + let surface_loc = location + (offset - popup.geometry().loc).to_f64(); |
| 241 | - let offset = popup_offset - popup.geometry().loc; | ||
| 242 | 238 | ||
| 243 | push_elements_from_surface_tree( | 239 | push_elements_from_surface_tree( |
| 244 | ctx.renderer, | 240 | ctx.renderer, |
| 245 | popup.wl_surface(), | 241 | popup.wl_surface(), |
| 246 | - (buf_pos + offset.to_f64()).to_physical_precise_round(scale), | 242 | + surface_loc.to_physical_precise_round(scale), |
| 247 | scale, | 243 | scale, |
| 248 | alpha, | 244 | alpha, |
| 249 | Kind::ScanoutCandidate, | 245 | Kind::ScanoutCandidate, |
src/window/mapped.rsmodified+4 -6
| @@ -655,20 +655,18 @@ impl LayoutElement for Mapped { | |||
| 655 | return; | 655 | return; |
| 656 | } | 656 | } |
| 657 | 657 | ||
| 658 | - let buf_pos = location - self.window.geometry().loc.to_f64(); | ||
| 659 | let surface = self.toplevel().wl_surface(); | 658 | let surface = self.toplevel().wl_surface(); |
| 660 | - let mut push = |elem: WaylandSurfaceRenderElement<R>| push(elem.into()); | 659 | + for (popup, offset) in PopupManager::popups_for_surface(surface) { |
| 661 | - for (popup, popup_offset) in PopupManager::popups_for_surface(surface) { | 660 | + let surface_loc = location + (offset - popup.geometry().loc).to_f64(); |
| 662 | - let offset = self.window.geometry().loc + popup_offset - popup.geometry().loc; | ||
| 663 | 661 | ||
| 664 | push_elements_from_surface_tree( | 662 | push_elements_from_surface_tree( |
| 665 | ctx.renderer, | 663 | ctx.renderer, |
| 666 | popup.wl_surface(), | 664 | popup.wl_surface(), |
| 667 | - (buf_pos + offset.to_f64()).to_physical_precise_round(scale), | 665 | + surface_loc.to_physical_precise_round(scale), |
| 668 | scale, | 666 | scale, |
| 669 | alpha, | 667 | alpha, |
| 670 | Kind::ScanoutCandidate, | 668 | Kind::ScanoutCandidate, |
| 671 | - &mut push, | 669 | + &mut |elem| push(elem.into()), |
| 672 | ); | 670 | ); |
| 673 | } | 671 | } |
| 674 | } | 672 | } |