Avoid sending frame callbacks to invisible surfaces
Browse files at this commit5b6b3fcfbe61695b0e5d27e8a08592a9ebd412b0Parent: d8a511b4 changed files +135 -132
- src/backend/tty.rs +2 -0
- src/backend/winit.rs +3 -0
- src/layout.rs +1 -108
- src/niri.rs +129 -24
src/backend/tty.rsmodified+2 -0
| @@ -807,6 +807,8 @@ impl Tty { | |||
| 807 | } | 807 | } |
| 808 | } | 808 | } |
| 809 | 809 | ||
| 810 | + niri.update_primary_scanout_output(output, &res.states); | ||
| 811 | + | ||
| 810 | if res.damage.is_some() { | 812 | if res.damage.is_some() { |
| 811 | let presentation_feedbacks = | 813 | let presentation_feedbacks = |
| 812 | niri.take_presentation_feedbacks(output, &res.states); | 814 | niri.take_presentation_feedbacks(output, &res.states); |
src/backend/winit.rsmodified+3 -0
| @@ -161,6 +161,9 @@ impl Winit { | |||
| 161 | .damage_tracker | 161 | .damage_tracker |
| 162 | .render_output(self.backend.renderer(), age, elements, [0.1, 0.1, 0.1, 1.0]) | 162 | .render_output(self.backend.renderer(), age, elements, [0.1, 0.1, 0.1, 1.0]) |
| 163 | .unwrap(); | 163 | .unwrap(); |
| 164 | + | ||
| 165 | + niri.update_primary_scanout_output(output, &res.states); | ||
| 166 | + | ||
| 164 | if let Some(damage) = res.damage { | 167 | if let Some(damage) = res.damage { |
| 165 | if self | 168 | if self |
| 166 | .config | 169 | .config |
src/layout.rsmodified+1 -108
| @@ -48,8 +48,7 @@ use smithay::reexports::wayland_protocols::xdg::shell::server::xdg_toplevel; | |||
| 48 | use smithay::reexports::wayland_server::protocol::wl_surface::WlSurface; | 48 | use smithay::reexports::wayland_server::protocol::wl_surface::WlSurface; |
| 49 | use smithay::render_elements; | 49 | use smithay::render_elements; |
| 50 | use smithay::utils::{Logical, Point, Rectangle, Scale, Size}; | 50 | use smithay::utils::{Logical, Point, Rectangle, Scale, Size}; |
| 51 | -use smithay::wayland::compositor::{with_states, SurfaceData}; | 51 | +use smithay::wayland::compositor::with_states; |
| 52 | -use smithay::wayland::dmabuf::DmabufFeedback; | ||
| 53 | use smithay::wayland::shell::xdg::SurfaceCachedState; | 52 | use smithay::wayland::shell::xdg::SurfaceCachedState; |
| 54 | 53 | ||
| 55 | use crate::animation::Animation; | 54 | use crate::animation::Animation; |
| @@ -80,23 +79,6 @@ pub trait LayoutElement: SpaceElement + PartialEq + Clone { | |||
| 80 | fn min_size(&self) -> Size<i32, Logical>; | 79 | fn min_size(&self) -> Size<i32, Logical>; |
| 81 | fn max_size(&self) -> Size<i32, Logical>; | 80 | fn max_size(&self) -> Size<i32, Logical>; |
| 82 | fn is_wl_surface(&self, wl_surface: &WlSurface) -> bool; | 81 | fn is_wl_surface(&self, wl_surface: &WlSurface) -> bool; |
| 83 | - fn send_frame<T, F>( | ||
| 84 | - &self, | ||
| 85 | - output: &Output, | ||
| 86 | - time: T, | ||
| 87 | - throttle: Option<Duration>, | ||
| 88 | - primary_scan_out_output: F, | ||
| 89 | - ) where | ||
| 90 | - T: Into<Duration>, | ||
| 91 | - F: FnMut(&WlSurface, &SurfaceData) -> Option<Output> + Copy; | ||
| 92 | - fn send_dmabuf_feedback<'a, P, F>( | ||
| 93 | - &self, | ||
| 94 | - output: &Output, | ||
| 95 | - primary_scan_out_output: P, | ||
| 96 | - select_dmabuf_feedback: F, | ||
| 97 | - ) where | ||
| 98 | - P: FnMut(&WlSurface, &SurfaceData) -> Option<Output> + Copy, | ||
| 99 | - F: Fn(&WlSurface, &SurfaceData) -> &'a DmabufFeedback + Copy; | ||
| 100 | } | 82 | } |
| 101 | 83 | ||
| 102 | #[derive(Debug)] | 84 | #[derive(Debug)] |
| @@ -253,31 +235,6 @@ impl LayoutElement for Window { | |||
| 253 | fn is_wl_surface(&self, wl_surface: &WlSurface) -> bool { | 235 | fn is_wl_surface(&self, wl_surface: &WlSurface) -> bool { |
| 254 | self.toplevel().wl_surface() == wl_surface | 236 | self.toplevel().wl_surface() == wl_surface |
| 255 | } | 237 | } |
| 256 | - | ||
| 257 | - fn send_frame<T, F>( | ||
| 258 | - &self, | ||
| 259 | - output: &Output, | ||
| 260 | - time: T, | ||
| 261 | - throttle: Option<Duration>, | ||
| 262 | - primary_scan_out_output: F, | ||
| 263 | - ) where | ||
| 264 | - T: Into<Duration>, | ||
| 265 | - F: FnMut(&WlSurface, &SurfaceData) -> Option<Output> + Copy, | ||
| 266 | - { | ||
| 267 | - self.send_frame(output, time, throttle, primary_scan_out_output); | ||
| 268 | - } | ||
| 269 | - | ||
| 270 | - fn send_dmabuf_feedback<'a, P, F>( | ||
| 271 | - &self, | ||
| 272 | - output: &Output, | ||
| 273 | - primary_scan_out_output: P, | ||
| 274 | - select_dmabuf_feedback: F, | ||
| 275 | - ) where | ||
| 276 | - P: FnMut(&WlSurface, &SurfaceData) -> Option<Output> + Copy, | ||
| 277 | - F: Fn(&WlSurface, &SurfaceData) -> &'a DmabufFeedback + Copy, | ||
| 278 | - { | ||
| 279 | - self.send_dmabuf_feedback(output, primary_scan_out_output, select_dmabuf_feedback); | ||
| 280 | - } | ||
| 281 | } | 238 | } |
| 282 | 239 | ||
| 283 | impl FocusRing { | 240 | impl FocusRing { |
| @@ -579,31 +536,6 @@ impl<W: LayoutElement> MonitorSet<W> { | |||
| 579 | } | 536 | } |
| 580 | } | 537 | } |
| 581 | 538 | ||
| 582 | - pub fn send_frame( | ||
| 583 | - &self, | ||
| 584 | - output: &Output, | ||
| 585 | - time: Duration, | ||
| 586 | - should_send: &impl Fn(&SurfaceData) -> bool, | ||
| 587 | - ) { | ||
| 588 | - if let MonitorSet::Normal { monitors, .. } = self { | ||
| 589 | - for mon in monitors { | ||
| 590 | - if &mon.output == output { | ||
| 591 | - mon.workspaces[mon.active_workspace_idx].send_frame(time, should_send); | ||
| 592 | - } | ||
| 593 | - } | ||
| 594 | - } | ||
| 595 | - } | ||
| 596 | - | ||
| 597 | - pub fn send_dmabuf_feedback(&self, output: &Output, feedback: &DmabufFeedback) { | ||
| 598 | - if let MonitorSet::Normal { monitors, .. } = self { | ||
| 599 | - for mon in monitors { | ||
| 600 | - if &mon.output == output { | ||
| 601 | - mon.workspaces[mon.active_workspace_idx].send_dmabuf_feedback(feedback); | ||
| 602 | - } | ||
| 603 | - } | ||
| 604 | - } | ||
| 605 | - } | ||
| 606 | - | ||
| 607 | pub fn find_window_and_output(&self, wl_surface: &WlSurface) -> Option<(W, Output)> { | 539 | pub fn find_window_and_output(&self, wl_surface: &WlSurface) -> Option<(W, Output)> { |
| 608 | if let MonitorSet::Normal { monitors, .. } = self { | 540 | if let MonitorSet::Normal { monitors, .. } = self { |
| 609 | for mon in monitors { | 541 | for mon in monitors { |
| @@ -1853,22 +1785,6 @@ impl<W: LayoutElement> Workspace<W> { | |||
| 1853 | self.add_window(window, true); | 1785 | self.add_window(window, true); |
| 1854 | } | 1786 | } |
| 1855 | 1787 | ||
| 1856 | - fn send_frame(&self, time: Duration, should_send: &impl Fn(&SurfaceData) -> bool) { | ||
| 1857 | - let output = self.output.as_ref().unwrap(); | ||
| 1858 | - for win in self.windows() { | ||
| 1859 | - win.send_frame(output, time, None, |_, states| { | ||
| 1860 | - should_send(states).then(|| output.clone()) | ||
| 1861 | - }); | ||
| 1862 | - } | ||
| 1863 | - } | ||
| 1864 | - | ||
| 1865 | - fn send_dmabuf_feedback(&self, feedback: &DmabufFeedback) { | ||
| 1866 | - let output = self.output.as_ref().unwrap(); | ||
| 1867 | - for win in self.windows() { | ||
| 1868 | - win.send_dmabuf_feedback(output, |_, _| Some(output.clone()), |_, _| feedback); | ||
| 1869 | - } | ||
| 1870 | - } | ||
| 1871 | - | ||
| 1872 | fn view_pos(&self) -> i32 { | 1788 | fn view_pos(&self) -> i32 { |
| 1873 | self.column_x(self.active_column_idx) + self.view_offset - PADDING | 1789 | self.column_x(self.active_column_idx) + self.view_offset - PADDING |
| 1874 | } | 1790 | } |
| @@ -2458,29 +2374,6 @@ mod tests { | |||
| 2458 | fn is_wl_surface(&self, _wl_surface: &WlSurface) -> bool { | 2374 | fn is_wl_surface(&self, _wl_surface: &WlSurface) -> bool { |
| 2459 | false | 2375 | false |
| 2460 | } | 2376 | } |
| 2461 | - | ||
| 2462 | - fn send_frame<T, F>( | ||
| 2463 | - &self, | ||
| 2464 | - _output: &Output, | ||
| 2465 | - _time: T, | ||
| 2466 | - _throttle: Option<Duration>, | ||
| 2467 | - _primary_scan_out_output: F, | ||
| 2468 | - ) where | ||
| 2469 | - T: Into<Duration>, | ||
| 2470 | - F: FnMut(&WlSurface, &SurfaceData) -> Option<Output> + Copy, | ||
| 2471 | - { | ||
| 2472 | - } | ||
| 2473 | - | ||
| 2474 | - fn send_dmabuf_feedback<'a, P, F>( | ||
| 2475 | - &self, | ||
| 2476 | - _output: &Output, | ||
| 2477 | - _primary_scan_out_output: P, | ||
| 2478 | - _select_dmabuf_feedback: F, | ||
| 2479 | - ) where | ||
| 2480 | - P: FnMut(&WlSurface, &SurfaceData) -> Option<Output> + Copy, | ||
| 2481 | - F: Fn(&WlSurface, &SurfaceData) -> &'a DmabufFeedback + Copy, | ||
| 2482 | - { | ||
| 2483 | - } | ||
| 2484 | } | 2377 | } |
| 2485 | 2378 | ||
| 2486 | fn arbitrary_bbox() -> impl Strategy<Value = Rectangle<i32, Logical>> { | 2379 | fn arbitrary_bbox() -> impl Strategy<Value = Rectangle<i32, Logical>> { |
src/niri.rsmodified+129 -24
| @@ -18,13 +18,15 @@ use smithay::backend::renderer::element::surface::{ | |||
| 18 | use smithay::backend::renderer::element::texture::TextureRenderElement; | 18 | use smithay::backend::renderer::element::texture::TextureRenderElement; |
| 19 | use smithay::backend::renderer::element::utils::{Relocate, RelocateRenderElement}; | 19 | use smithay::backend::renderer::element::utils::{Relocate, RelocateRenderElement}; |
| 20 | use smithay::backend::renderer::element::{ | 20 | use smithay::backend::renderer::element::{ |
| 21 | - render_elements, AsRenderElements, Kind, RenderElement, RenderElementStates, | 21 | + default_primary_scanout_output_compare, render_elements, AsRenderElements, Kind, RenderElement, |
| 22 | + RenderElementStates, | ||
| 22 | }; | 23 | }; |
| 23 | use smithay::backend::renderer::gles::{GlesMapping, GlesRenderer, GlesTexture}; | 24 | use smithay::backend::renderer::gles::{GlesMapping, GlesRenderer, GlesTexture}; |
| 24 | use smithay::backend::renderer::{Bind, ExportMem, Frame, ImportAll, Offscreen, Renderer}; | 25 | use smithay::backend::renderer::{Bind, ExportMem, Frame, ImportAll, Offscreen, Renderer}; |
| 25 | use smithay::desktop::utils::{ | 26 | use smithay::desktop::utils::{ |
| 26 | send_dmabuf_feedback_surface_tree, send_frames_surface_tree, | 27 | send_dmabuf_feedback_surface_tree, send_frames_surface_tree, |
| 27 | - surface_presentation_feedback_flags_from_states, take_presentation_feedback_surface_tree, | 28 | + surface_presentation_feedback_flags_from_states, surface_primary_scanout_output, |
| 29 | + take_presentation_feedback_surface_tree, update_surface_primary_scanout_output, | ||
| 28 | OutputPresentationFeedback, | 30 | OutputPresentationFeedback, |
| 29 | }; | 31 | }; |
| 30 | use smithay::desktop::{layer_map_for_output, PopupManager, Space, Window, WindowSurfaceType}; | 32 | use smithay::desktop::{layer_map_for_output, PopupManager, Space, Window, WindowSurfaceType}; |
| @@ -49,7 +51,8 @@ use smithay::utils::{ | |||
| 49 | IsAlive, Logical, Physical, Point, Rectangle, Scale, Size, Transform, SERIAL_COUNTER, | 51 | IsAlive, Logical, Physical, Point, Rectangle, Scale, Size, Transform, SERIAL_COUNTER, |
| 50 | }; | 52 | }; |
| 51 | use smithay::wayland::compositor::{ | 53 | use smithay::wayland::compositor::{ |
| 52 | - with_states, CompositorClientState, CompositorState, SurfaceData, | 54 | + with_states, with_surface_tree_downward, CompositorClientState, CompositorState, SurfaceData, |
| 55 | + TraversalAction, | ||
| 53 | }; | 56 | }; |
| 54 | use smithay::wayland::data_device::DataDeviceState; | 57 | use smithay::wayland::data_device::DataDeviceState; |
| 55 | use smithay::wayland::dmabuf::DmabufFeedback; | 58 | use smithay::wayland::dmabuf::DmabufFeedback; |
| @@ -1160,6 +1163,16 @@ impl Niri { | |||
| 1160 | } | 1163 | } |
| 1161 | 1164 | ||
| 1162 | // Send the frame callbacks. | 1165 | // Send the frame callbacks. |
| 1166 | + // | ||
| 1167 | + // FIXME: The logic here could be a bit smarter. Currently, during an animation, the | ||
| 1168 | + // surfaces that are visible for the very last frame (e.g. because the camera is moving | ||
| 1169 | + // away) will receive frame callbacks, and the surfaces that are invisible but will become | ||
| 1170 | + // visible next frame will not receive frame callbacks (so they will show stale contents for | ||
| 1171 | + // one frame). We could advance the animations for the next frame and send frame callbacks | ||
| 1172 | + // according to the expected new positions. | ||
| 1173 | + // | ||
| 1174 | + // However, this should probably be restricted to sending frame callbacks to more surfaces, | ||
| 1175 | + // to err on the safe side. | ||
| 1163 | self.send_frame_callbacks(output); | 1176 | self.send_frame_callbacks(output); |
| 1164 | 1177 | ||
| 1165 | // Render and send to PipeWire screencast streams. | 1178 | // Render and send to PipeWire screencast streams. |
| @@ -1172,10 +1185,95 @@ impl Niri { | |||
| 1172 | } | 1185 | } |
| 1173 | } | 1186 | } |
| 1174 | 1187 | ||
| 1188 | + pub fn update_primary_scanout_output( | ||
| 1189 | + &self, | ||
| 1190 | + output: &Output, | ||
| 1191 | + render_element_states: &RenderElementStates, | ||
| 1192 | + ) { | ||
| 1193 | + // FIXME: potentially tweak the compare function. The default one currently always prefers a | ||
| 1194 | + // higher refresh-rate output, which is not always desirable (i.e. with a very small | ||
| 1195 | + // overlap). | ||
| 1196 | + // | ||
| 1197 | + // While we only have cursors and DnD icons crossing output boundaries though, it doesn't | ||
| 1198 | + // matter all that much. | ||
| 1199 | + if let CursorImageStatus::Surface(surface) = &self.cursor_image { | ||
| 1200 | + with_surface_tree_downward( | ||
| 1201 | + surface, | ||
| 1202 | + (), | ||
| 1203 | + |_, _, _| TraversalAction::DoChildren(()), | ||
| 1204 | + |surface, states, _| { | ||
| 1205 | + update_surface_primary_scanout_output( | ||
| 1206 | + surface, | ||
| 1207 | + output, | ||
| 1208 | + states, | ||
| 1209 | + render_element_states, | ||
| 1210 | + default_primary_scanout_output_compare, | ||
| 1211 | + ); | ||
| 1212 | + }, | ||
| 1213 | + |_, _, _| true, | ||
| 1214 | + ); | ||
| 1215 | + } | ||
| 1216 | + | ||
| 1217 | + if let Some(surface) = &self.dnd_icon { | ||
| 1218 | + with_surface_tree_downward( | ||
| 1219 | + surface, | ||
| 1220 | + (), | ||
| 1221 | + |_, _, _| TraversalAction::DoChildren(()), | ||
| 1222 | + |surface, states, _| { | ||
| 1223 | + update_surface_primary_scanout_output( | ||
| 1224 | + surface, | ||
| 1225 | + output, | ||
| 1226 | + states, | ||
| 1227 | + render_element_states, | ||
| 1228 | + default_primary_scanout_output_compare, | ||
| 1229 | + ); | ||
| 1230 | + }, | ||
| 1231 | + |_, _, _| true, | ||
| 1232 | + ); | ||
| 1233 | + } | ||
| 1234 | + | ||
| 1235 | + // We're only updating the current output's windows and layer surfaces. This should be fine | ||
| 1236 | + // as in niri they can only be rendered on a single output at a time. | ||
| 1237 | + // | ||
| 1238 | + // The reason to do this at all is that it keeps track of whether the surface is visible or | ||
| 1239 | + // not in a unified way with the pointer surfaces, which makes the logic elsewhere simpler. | ||
| 1240 | + | ||
| 1241 | + for win in self.monitor_set.windows_for_output(output) { | ||
| 1242 | + win.with_surfaces(|surface, states| { | ||
| 1243 | + update_surface_primary_scanout_output( | ||
| 1244 | + surface, | ||
| 1245 | + output, | ||
| 1246 | + states, | ||
| 1247 | + render_element_states, | ||
| 1248 | + // Windows are shown only on one output at a time. | ||
| 1249 | + |_, _, output, _| output, | ||
| 1250 | + ); | ||
| 1251 | + }); | ||
| 1252 | + } | ||
| 1253 | + | ||
| 1254 | + for surface in layer_map_for_output(output).layers() { | ||
| 1255 | + surface.with_surfaces(|surface, states| { | ||
| 1256 | + update_surface_primary_scanout_output( | ||
| 1257 | + surface, | ||
| 1258 | + output, | ||
| 1259 | + states, | ||
| 1260 | + render_element_states, | ||
| 1261 | + // Layer surfaces are shown only on one output at a time. | ||
| 1262 | + |_, _, output, _| output, | ||
| 1263 | + ); | ||
| 1264 | + }); | ||
| 1265 | + } | ||
| 1266 | + } | ||
| 1267 | + | ||
| 1175 | fn send_dmabuf_feedbacks(&self, output: &Output, feedback: &DmabufFeedback) { | 1268 | fn send_dmabuf_feedbacks(&self, output: &Output, feedback: &DmabufFeedback) { |
| 1176 | let _span = tracy_client::span!("Niri::send_dmabuf_feedbacks"); | 1269 | let _span = tracy_client::span!("Niri::send_dmabuf_feedbacks"); |
| 1177 | 1270 | ||
| 1178 | - self.monitor_set.send_dmabuf_feedback(output, feedback); | 1271 | + // We can unconditionally send the current output's feedback to regular and layer-shell |
| 1272 | + // surfaces, as they can only be displayed on a single output at a time. Even if a surface | ||
| 1273 | + // is currently invisible, this is the DMABUF feedback that it should know about. | ||
| 1274 | + for win in self.monitor_set.windows_for_output(output) { | ||
| 1275 | + win.send_dmabuf_feedback(output, |_, _| Some(output.clone()), |_, _| feedback); | ||
| 1276 | + } | ||
| 1179 | 1277 | ||
| 1180 | for surface in layer_map_for_output(output).layers() { | 1278 | for surface in layer_map_for_output(output).layers() { |
| 1181 | surface.send_dmabuf_feedback(output, |_, _| Some(output.clone()), |_, _| feedback); | 1279 | surface.send_dmabuf_feedback(output, |_, _| Some(output.clone()), |_, _| feedback); |
| @@ -1185,7 +1283,7 @@ impl Niri { | |||
| 1185 | send_dmabuf_feedback_surface_tree( | 1283 | send_dmabuf_feedback_surface_tree( |
| 1186 | surface, | 1284 | surface, |
| 1187 | output, | 1285 | output, |
| 1188 | - |_, _| Some(output.clone()), | 1286 | + surface_primary_scanout_output, |
| 1189 | |_, _| feedback, | 1287 | |_, _| feedback, |
| 1190 | ); | 1288 | ); |
| 1191 | } | 1289 | } |
| @@ -1194,7 +1292,7 @@ impl Niri { | |||
| 1194 | send_dmabuf_feedback_surface_tree( | 1292 | send_dmabuf_feedback_surface_tree( |
| 1195 | surface, | 1293 | surface, |
| 1196 | output, | 1294 | output, |
| 1197 | - |_, _| Some(output.clone()), | 1295 | + surface_primary_scanout_output, |
| 1198 | |_, _| feedback, | 1296 | |_, _| feedback, |
| 1199 | ); | 1297 | ); |
| 1200 | } | 1298 | } |
| @@ -1206,7 +1304,16 @@ impl Niri { | |||
| 1206 | let state = self.output_state.get(output).unwrap(); | 1304 | let state = self.output_state.get(output).unwrap(); |
| 1207 | let sequence = state.current_estimated_sequence; | 1305 | let sequence = state.current_estimated_sequence; |
| 1208 | 1306 | ||
| 1209 | - let should_send = |states: &SurfaceData| { | 1307 | + let should_send = |surface: &WlSurface, states: &SurfaceData| { |
| 1308 | + // Do the standard primary scanout output check. For pointer surfaces it deduplicates | ||
| 1309 | + // the frame callbacks across potentially multiple outputs, and for regular windows and | ||
| 1310 | + // layer-shell surfaces it avoids sending frame callbacks to invisible surfaces. | ||
| 1311 | + let current_primary_output = surface_primary_scanout_output(surface, states); | ||
| 1312 | + if current_primary_output.as_ref() != Some(output) { | ||
| 1313 | + return None; | ||
| 1314 | + } | ||
| 1315 | + | ||
| 1316 | + // Next, check the throttling status. | ||
| 1210 | let frame_throttling_state = states | 1317 | let frame_throttling_state = states |
| 1211 | .data_map | 1318 | .data_map |
| 1212 | .get_or_insert(SurfaceFrameThrottlingState::default); | 1319 | .get_or_insert(SurfaceFrameThrottlingState::default); |
| @@ -1226,31 +1333,29 @@ impl Niri { | |||
| 1226 | if let Some(sequence) = sequence { | 1333 | if let Some(sequence) = sequence { |
| 1227 | *last_sent_at = Some((output.clone(), sequence)); | 1334 | *last_sent_at = Some((output.clone(), sequence)); |
| 1228 | } | 1335 | } |
| 1229 | - } | ||
| 1230 | 1336 | ||
| 1231 | - send | 1337 | + Some(output.clone()) |
| 1338 | + } else { | ||
| 1339 | + None | ||
| 1340 | + } | ||
| 1232 | }; | 1341 | }; |
| 1233 | 1342 | ||
| 1234 | let frame_callback_time = get_monotonic_time(); | 1343 | let frame_callback_time = get_monotonic_time(); |
| 1235 | - self.monitor_set | 1344 | + |
| 1236 | - .send_frame(output, frame_callback_time, &should_send); | 1345 | + for win in self.monitor_set.windows_for_output(output) { |
| 1346 | + win.send_frame(output, frame_callback_time, None, should_send); | ||
| 1347 | + } | ||
| 1237 | 1348 | ||
| 1238 | for surface in layer_map_for_output(output).layers() { | 1349 | for surface in layer_map_for_output(output).layers() { |
| 1239 | - surface.send_frame(output, frame_callback_time, None, |_, states| { | 1350 | + surface.send_frame(output, frame_callback_time, None, should_send); |
| 1240 | - should_send(states).then(|| output.clone()) | ||
| 1241 | - }); | ||
| 1242 | } | 1351 | } |
| 1243 | 1352 | ||
| 1244 | if let Some(surface) = &self.dnd_icon { | 1353 | if let Some(surface) = &self.dnd_icon { |
| 1245 | - send_frames_surface_tree(surface, output, frame_callback_time, None, |_, states| { | 1354 | + send_frames_surface_tree(surface, output, frame_callback_time, None, should_send); |
| 1246 | - should_send(states).then(|| output.clone()) | ||
| 1247 | - }); | ||
| 1248 | } | 1355 | } |
| 1249 | 1356 | ||
| 1250 | if let CursorImageStatus::Surface(surface) = &self.cursor_image { | 1357 | if let CursorImageStatus::Surface(surface) = &self.cursor_image { |
| 1251 | - send_frames_surface_tree(surface, output, frame_callback_time, None, |_, states| { | 1358 | + send_frames_surface_tree(surface, output, frame_callback_time, None, should_send); |
| 1252 | - should_send(states).then(|| output.clone()) | ||
| 1253 | - }); | ||
| 1254 | } | 1359 | } |
| 1255 | } | 1360 | } |
| 1256 | 1361 | ||
| @@ -1265,7 +1370,7 @@ impl Niri { | |||
| 1265 | take_presentation_feedback_surface_tree( | 1370 | take_presentation_feedback_surface_tree( |
| 1266 | surface, | 1371 | surface, |
| 1267 | &mut feedback, | 1372 | &mut feedback, |
| 1268 | - |_, _| Some(output.clone()), | 1373 | + surface_primary_scanout_output, |
| 1269 | |surface, _| { | 1374 | |surface, _| { |
| 1270 | surface_presentation_feedback_flags_from_states(surface, render_element_states) | 1375 | surface_presentation_feedback_flags_from_states(surface, render_element_states) |
| 1271 | }, | 1376 | }, |
| @@ -1276,7 +1381,7 @@ impl Niri { | |||
| 1276 | take_presentation_feedback_surface_tree( | 1381 | take_presentation_feedback_surface_tree( |
| 1277 | surface, | 1382 | surface, |
| 1278 | &mut feedback, | 1383 | &mut feedback, |
| 1279 | - |_, _| Some(output.clone()), | 1384 | + surface_primary_scanout_output, |
| 1280 | |surface, _| { | 1385 | |surface, _| { |
| 1281 | surface_presentation_feedback_flags_from_states(surface, render_element_states) | 1386 | surface_presentation_feedback_flags_from_states(surface, render_element_states) |
| 1282 | }, | 1387 | }, |
| @@ -1286,7 +1391,7 @@ impl Niri { | |||
| 1286 | for win in self.monitor_set.windows_for_output(output) { | 1391 | for win in self.monitor_set.windows_for_output(output) { |
| 1287 | win.take_presentation_feedback( | 1392 | win.take_presentation_feedback( |
| 1288 | &mut feedback, | 1393 | &mut feedback, |
| 1289 | - |_, _| Some(output.clone()), | 1394 | + surface_primary_scanout_output, |
| 1290 | |surface, _| { | 1395 | |surface, _| { |
| 1291 | surface_presentation_feedback_flags_from_states(surface, render_element_states) | 1396 | surface_presentation_feedback_flags_from_states(surface, render_element_states) |
| 1292 | }, | 1397 | }, |
| @@ -1296,7 +1401,7 @@ impl Niri { | |||
| 1296 | for surface in layer_map_for_output(output).layers() { | 1401 | for surface in layer_map_for_output(output).layers() { |
| 1297 | surface.take_presentation_feedback( | 1402 | surface.take_presentation_feedback( |
| 1298 | &mut feedback, | 1403 | &mut feedback, |
| 1299 | - |_, _| Some(output.clone()), | 1404 | + surface_primary_scanout_output, |
| 1300 | |surface, _| { | 1405 | |surface, _| { |
| 1301 | surface_presentation_feedback_flags_from_states(surface, render_element_states) | 1406 | surface_presentation_feedback_flags_from_states(surface, render_element_states) |
| 1302 | }, | 1407 | }, |