Add a way to override the element ID for primary output check
Browse files at this commit026ad8f3778f07da49f0d005739f47cfa6269a36Parent: 07614011 changed file +28 -9
- src/niri.rs +28 -9
src/niri.rsmodified+28 -9
| @@ -20,7 +20,8 @@ use smithay::backend::renderer::element::surface::{ | |||
| 20 | }; | 20 | }; |
| 21 | use smithay::backend::renderer::element::utils::{select_dmabuf_feedback, RelocateRenderElement}; | 21 | use smithay::backend::renderer::element::utils::{select_dmabuf_feedback, RelocateRenderElement}; |
| 22 | use smithay::backend::renderer::element::{ | 22 | use smithay::backend::renderer::element::{ |
| 23 | - default_primary_scanout_output_compare, AsRenderElements, Kind, RenderElementStates, | 23 | + default_primary_scanout_output_compare, AsRenderElements, Id, Kind, PrimaryScanoutOutput, |
| 24 | + RenderElementStates, | ||
| 24 | }; | 25 | }; |
| 25 | use smithay::backend::renderer::gles::GlesRenderer; | 26 | use smithay::backend::renderer::gles::GlesRenderer; |
| 26 | use smithay::desktop::utils::{ | 27 | use smithay::desktop::utils::{ |
| @@ -274,6 +275,9 @@ struct SurfaceFrameThrottlingState { | |||
| 274 | last_sent_at: RefCell<Option<(Output, u32)>>, | 275 | last_sent_at: RefCell<Option<(Output, u32)>>, |
| 275 | } | 276 | } |
| 276 | 277 | ||
| 278 | +#[derive(Default)] | ||
| 279 | +pub struct WindowOffscreenId(pub RefCell<Option<Id>>); | ||
| 280 | + | ||
| 277 | impl Default for SurfaceFrameThrottlingState { | 281 | impl Default for SurfaceFrameThrottlingState { |
| 278 | fn default() -> Self { | 282 | fn default() -> Self { |
| 279 | Self { | 283 | Self { |
| @@ -2156,15 +2160,30 @@ impl Niri { | |||
| 2156 | // not in a unified way with the pointer surfaces, which makes the logic elsewhere simpler. | 2160 | // not in a unified way with the pointer surfaces, which makes the logic elsewhere simpler. |
| 2157 | 2161 | ||
| 2158 | for win in self.layout.windows_for_output(output) { | 2162 | for win in self.layout.windows_for_output(output) { |
| 2163 | + let offscreen_id = win | ||
| 2164 | + .user_data() | ||
| 2165 | + .get_or_insert(WindowOffscreenId::default) | ||
| 2166 | + .0 | ||
| 2167 | + .borrow(); | ||
| 2168 | + let offscreen_id = offscreen_id.as_ref(); | ||
| 2169 | + | ||
| 2159 | win.with_surfaces(|surface, states| { | 2170 | win.with_surfaces(|surface, states| { |
| 2160 | - update_surface_primary_scanout_output( | 2171 | + states |
| 2161 | - surface, | 2172 | + .data_map |
| 2162 | - output, | 2173 | + .insert_if_missing_threadsafe(Mutex::<PrimaryScanoutOutput>::default); |
| 2163 | - states, | 2174 | + let surface_primary_scanout_output = states |
| 2164 | - render_element_states, | 2175 | + .data_map |
| 2165 | - // Windows are shown only on one output at a time. | 2176 | + .get::<Mutex<PrimaryScanoutOutput>>() |
| 2166 | - |_, _, output, _| output, | 2177 | + .unwrap(); |
| 2167 | - ); | 2178 | + surface_primary_scanout_output |
| 2179 | + .lock() | ||
| 2180 | + .unwrap() | ||
| 2181 | + .update_from_render_element_states( | ||
| 2182 | + offscreen_id.cloned().unwrap_or_else(|| surface.into()), | ||
| 2183 | + output, | ||
| 2184 | + render_element_states, | ||
| 2185 | + |_, _, output, _| output, | ||
| 2186 | + ); | ||
| 2168 | }); | 2187 | }); |
| 2169 | } | 2188 | } |
| 2170 | 2189 | ||