Fix render elements looking off on screenshots
Browse files at this commitdf36eac25bd7e0f29781e40b06ca34fc72cf3388Parent: 609b1a02 changed files +34 -2
- src/layout/mod.rs +18 -0
- src/niri.rs +16 -2
src/layout/mod.rsmodified+18 -0
| @@ -1413,6 +1413,24 @@ impl<W: LayoutElement> Layout<W> { | |||
| 1413 | } | 1413 | } |
| 1414 | } | 1414 | } |
| 1415 | 1415 | ||
| 1416 | + pub fn update_render_elements_all(&mut self) { | ||
| 1417 | + let _span = tracy_client::span!("Layout::update_render_elements_all"); | ||
| 1418 | + | ||
| 1419 | + let MonitorSet::Normal { | ||
| 1420 | + monitors, | ||
| 1421 | + active_monitor_idx, | ||
| 1422 | + .. | ||
| 1423 | + } = &mut self.monitor_set | ||
| 1424 | + else { | ||
| 1425 | + error!("update_render_elements_all called with no monitors"); | ||
| 1426 | + return; | ||
| 1427 | + }; | ||
| 1428 | + | ||
| 1429 | + for (idx, mon) in monitors.iter_mut().enumerate() { | ||
| 1430 | + mon.update_render_elements(idx == *active_monitor_idx); | ||
| 1431 | + } | ||
| 1432 | + } | ||
| 1433 | + | ||
| 1416 | pub fn update_shaders(&mut self) { | 1434 | pub fn update_shaders(&mut self) { |
| 1417 | match &mut self.monitor_set { | 1435 | match &mut self.monitor_set { |
| 1418 | MonitorSet::Normal { monitors, .. } => { | 1436 | MonitorSet::Normal { monitors, .. } => { |
src/niri.rsmodified+16 -2
| @@ -3268,6 +3268,8 @@ impl Niri { | |||
| 3268 | let output = screencopy.output().clone(); | 3268 | let output = screencopy.output().clone(); |
| 3269 | ensure!(self.output_state.contains_key(&output), "output is missing"); | 3269 | ensure!(self.output_state.contains_key(&output), "output is missing"); |
| 3270 | 3270 | ||
| 3271 | + self.layout.update_render_elements(&output); | ||
| 3272 | + | ||
| 3271 | backend | 3273 | backend |
| 3272 | .with_primary_renderer(move |renderer| { | 3274 | .with_primary_renderer(move |renderer| { |
| 3273 | let elements = self | 3275 | let elements = self |
| @@ -3359,6 +3361,8 @@ impl Niri { | |||
| 3359 | return; | 3361 | return; |
| 3360 | }; | 3362 | }; |
| 3361 | 3363 | ||
| 3364 | + self.layout.update_render_elements_all(); | ||
| 3365 | + | ||
| 3362 | let screenshots = self | 3366 | let screenshots = self |
| 3363 | .global_space | 3367 | .global_space |
| 3364 | .outputs() | 3368 | .outputs() |
| @@ -3410,9 +3414,15 @@ impl Niri { | |||
| 3410 | self.queue_redraw_all(); | 3414 | self.queue_redraw_all(); |
| 3411 | } | 3415 | } |
| 3412 | 3416 | ||
| 3413 | - pub fn screenshot(&self, renderer: &mut GlesRenderer, output: &Output) -> anyhow::Result<()> { | 3417 | + pub fn screenshot( |
| 3418 | + &mut self, | ||
| 3419 | + renderer: &mut GlesRenderer, | ||
| 3420 | + output: &Output, | ||
| 3421 | + ) -> anyhow::Result<()> { | ||
| 3414 | let _span = tracy_client::span!("Niri::screenshot"); | 3422 | let _span = tracy_client::span!("Niri::screenshot"); |
| 3415 | 3423 | ||
| 3424 | + self.layout.update_render_elements(output); | ||
| 3425 | + | ||
| 3416 | let size = output.current_mode().unwrap().size; | 3426 | let size = output.current_mode().unwrap().size; |
| 3417 | let transform = output.current_transform(); | 3427 | let transform = output.current_transform(); |
| 3418 | let size = transform.transform_size(size); | 3428 | let size = transform.transform_size(size); |
| @@ -3555,13 +3565,15 @@ impl Niri { | |||
| 3555 | 3565 | ||
| 3556 | #[cfg(feature = "dbus")] | 3566 | #[cfg(feature = "dbus")] |
| 3557 | pub fn screenshot_all_outputs( | 3567 | pub fn screenshot_all_outputs( |
| 3558 | - &self, | 3568 | + &mut self, |
| 3559 | renderer: &mut GlesRenderer, | 3569 | renderer: &mut GlesRenderer, |
| 3560 | include_pointer: bool, | 3570 | include_pointer: bool, |
| 3561 | on_done: impl FnOnce(PathBuf) + Send + 'static, | 3571 | on_done: impl FnOnce(PathBuf) + Send + 'static, |
| 3562 | ) -> anyhow::Result<()> { | 3572 | ) -> anyhow::Result<()> { |
| 3563 | let _span = tracy_client::span!("Niri::screenshot_all_outputs"); | 3573 | let _span = tracy_client::span!("Niri::screenshot_all_outputs"); |
| 3564 | 3574 | ||
| 3575 | + self.layout.update_render_elements_all(); | ||
| 3576 | + | ||
| 3565 | let outputs: Vec<_> = self.global_space.outputs().cloned().collect(); | 3577 | let outputs: Vec<_> = self.global_space.outputs().cloned().collect(); |
| 3566 | 3578 | ||
| 3567 | // FIXME: support multiple outputs, needs fixing multi-scale handling and cropping. | 3579 | // FIXME: support multiple outputs, needs fixing multi-scale handling and cropping. |
| @@ -3773,6 +3785,8 @@ impl Niri { | |||
| 3773 | pub fn do_screen_transition(&mut self, renderer: &mut GlesRenderer, delay_ms: Option<u16>) { | 3785 | pub fn do_screen_transition(&mut self, renderer: &mut GlesRenderer, delay_ms: Option<u16>) { |
| 3774 | let _span = tracy_client::span!("Niri::do_screen_transition"); | 3786 | let _span = tracy_client::span!("Niri::do_screen_transition"); |
| 3775 | 3787 | ||
| 3788 | + self.layout.update_render_elements_all(); | ||
| 3789 | + | ||
| 3776 | let textures: Vec<_> = self | 3790 | let textures: Vec<_> = self |
| 3777 | .output_state | 3791 | .output_state |
| 3778 | .keys() | 3792 | .keys() |