forge
Explore
Log in

Don't you dare go Hollow

Lift output clones from queue_redraw()

Browse files at this commit

f3f02aca2058dd7adc4d75707ded2b5d8887a258Ivan MolodetskikhParent: 021a2a1
src/backend/tty.rsmodified+4 -4
@@ -884,7 +884,7 @@ impl Tty {
884 // Power on all monitors if necessary and queue a redraw on the new one.884 // Power on all monitors if necessary and queue a redraw on the new one.
885 niri.event_loop.insert_idle(move |state| {885 niri.event_loop.insert_idle(move |state| {
886 state.niri.activate_monitors(&mut state.backend);886 state.niri.activate_monitors(&mut state.backend);
887- state.niri.queue_redraw(output);887+ state.niri.queue_redraw(&output);
888 });888 });
889 889
890 Ok(())890 Ok(())
@@ -1067,7 +1067,7 @@ impl Tty {
1067 .non_continuous_frame(surface.vblank_frame_name);1067 .non_continuous_frame(surface.vblank_frame_name);
1068 surface.vblank_frame = Some(vblank_frame);1068 surface.vblank_frame = Some(vblank_frame);
1069 1069
1070- niri.queue_redraw(output);1070+ niri.queue_redraw(&output);
1071 } else {1071 } else {
1072 niri.send_frame_callbacks(&output);1072 niri.send_frame_callbacks(&output);
1073 }1073 }
@@ -1100,7 +1100,7 @@ impl Tty {
1100 }1100 }
1101 1101
1102 if output_state.unfinished_animations_remain {1102 if output_state.unfinished_animations_remain {
1103- niri.queue_redraw(output);1103+ niri.queue_redraw(&output);
1104 } else {1104 } else {
1105 niri.send_frame_callbacks(&output);1105 niri.send_frame_callbacks(&output);
1106 }1106 }
@@ -1538,7 +1538,7 @@ impl Tty {
1538 output.change_current_state(Some(wl_mode), None, None, None);1538 output.change_current_state(Some(wl_mode), None, None, None);
1539 output.set_preferred(wl_mode);1539 output.set_preferred(wl_mode);
1540 output_state.frame_clock = FrameClock::new(Some(refresh_interval(mode)));1540 output_state.frame_clock = FrameClock::new(Some(refresh_interval(mode)));
1541- niri.output_resized(output);1541+ niri.output_resized(&output);
1542 }1542 }
1543 1543
1544 for (connector, crtc) in device.drm_scanner.crtcs() {1544 for (connector, crtc) in device.drm_scanner.crtcs() {
src/backend/winit.rsmodified+2 -4
@@ -102,13 +102,11 @@ impl Winit {
102 mode.width = size.w.clamp(0, u16::MAX as i32) as u16;102 mode.width = size.w.clamp(0, u16::MAX as i32) as u16;
103 mode.height = size.h.clamp(0, u16::MAX as i32) as u16;103 mode.height = size.h.clamp(0, u16::MAX as i32) as u16;
104 104
105- state.niri.output_resized(winit.output.clone());105+ state.niri.output_resized(&winit.output);
106 }106 }
107 WinitEvent::Input(event) => state.process_input_event(event),107 WinitEvent::Input(event) => state.process_input_event(event),
108 WinitEvent::Focus(_) => (),108 WinitEvent::Focus(_) => (),
109- WinitEvent::Redraw => state109+ WinitEvent::Redraw => state.niri.queue_redraw(&state.backend.winit().output),
110- .niri
111- .queue_redraw(state.backend.winit().output.clone()),
112 WinitEvent::CloseRequested => state.niri.stop_signal.stop(),110 WinitEvent::CloseRequested => state.niri.stop_signal.stop(),
113 })111 })
114 .unwrap();112 .unwrap();
src/handlers/compositor.rsmodified+6 -6
@@ -168,7 +168,7 @@ impl CompositorHandler for State {
168 self.maybe_warp_cursor_to_focus();168 self.maybe_warp_cursor_to_focus();
169 }169 }
170 170
171- self.niri.queue_redraw(output);171+ self.niri.queue_redraw(&output);
172 }172 }
173 return;173 return;
174 }174 }
@@ -206,7 +206,7 @@ impl CompositorHandler for State {
206 let unmapped = Unmapped::new(window);206 let unmapped = Unmapped::new(window);
207 self.niri.unmapped_windows.insert(surface.clone(), unmapped);207 self.niri.unmapped_windows.insert(surface.clone(), unmapped);
208 208
209- self.niri.queue_redraw(output);209+ self.niri.queue_redraw(&output);
210 return;210 return;
211 }211 }
212 212
@@ -216,7 +216,7 @@ impl CompositorHandler for State {
216 // Popup placement depends on window size which might have changed.216 // Popup placement depends on window size which might have changed.
217 self.update_reactive_popups(&window, &output);217 self.update_reactive_popups(&window, &output);
218 218
219- self.niri.queue_redraw(output);219+ self.niri.queue_redraw(&output);
220 return;220 return;
221 }221 }
222 222
@@ -230,7 +230,7 @@ impl CompositorHandler for State {
230 let output = output.clone();230 let output = output.clone();
231 window.on_commit();231 window.on_commit();
232 self.niri.layout.update_window(&window);232 self.niri.layout.update_window(&window);
233- self.niri.queue_redraw(output);233+ self.niri.queue_redraw(&output);
234 return;234 return;
235 }235 }
236 236
@@ -238,7 +238,7 @@ impl CompositorHandler for State {
238 self.popups_handle_commit(surface);238 self.popups_handle_commit(surface);
239 if let Some(popup) = self.niri.popups.find_popup(surface) {239 if let Some(popup) = self.niri.popups.find_popup(surface) {
240 if let Some(output) = self.output_for_popup(&popup) {240 if let Some(output) = self.output_for_popup(&popup) {
241- self.niri.queue_redraw(output.clone());241+ self.niri.queue_redraw(&output.clone());
242 }242 }
243 }243 }
244 244
@@ -263,7 +263,7 @@ impl CompositorHandler for State {
263 for (output, state) in &self.niri.output_state {263 for (output, state) in &self.niri.output_state {
264 if let Some(lock_surface) = &state.lock_surface {264 if let Some(lock_surface) = &state.lock_surface {
265 if lock_surface.wl_surface() == surface {265 if lock_surface.wl_surface() == surface {
266- self.niri.queue_redraw(output.clone());266+ self.niri.queue_redraw(&output.clone());
267 break;267 break;
268 }268 }
269 }269 }
src/handlers/layer_shell.rsmodified+2 -2
@@ -50,7 +50,7 @@ impl WlrLayerShellHandler for State {
50 None50 None
51 };51 };
52 if let Some(output) = output {52 if let Some(output) = output {
53- self.niri.output_resized(output);53+ self.niri.output_resized(&output);
54 }54 }
55 }55 }
56 56
@@ -107,6 +107,6 @@ impl State {
107 }107 }
108 drop(map);108 drop(map);
109 109
110- self.niri.output_resized(output);110+ self.niri.output_resized(&output);
111 }111 }
112 }112 }
src/handlers/xdg_shell.rsmodified+3 -3
@@ -391,12 +391,12 @@ impl XdgShellHandler for State {
391 self.maybe_warp_cursor_to_focus();391 self.maybe_warp_cursor_to_focus();
392 }392 }
393 393
394- self.niri.queue_redraw(output);394+ self.niri.queue_redraw(&output);
395 }395 }
396 396
397 fn popup_destroyed(&mut self, surface: PopupSurface) {397 fn popup_destroyed(&mut self, surface: PopupSurface) {
398 if let Some(output) = self.output_for_popup(&PopupKind::Xdg(surface)) {398 if let Some(output) = self.output_for_popup(&PopupKind::Xdg(surface)) {
399- self.niri.queue_redraw(output.clone());399+ self.niri.queue_redraw(&output.clone());
400 }400 }
401 }401 }
402 402
@@ -756,7 +756,7 @@ impl State {
756 self.niri.layout.update_window(&window);756 self.niri.layout.update_window(&window);
757 757
758 if let Some(output) = output {758 if let Some(output) = output {
759- self.niri.queue_redraw(output);759+ self.niri.queue_redraw(&output);
760 }760 }
761 }761 }
762 }762 }
src/input.rsmodified+4 -4
@@ -1449,7 +1449,7 @@ impl State {
1449 .workspace_switch_gesture_update(delta_y, timestamp);1449 .workspace_switch_gesture_update(delta_y, timestamp);
1450 if let Some(output) = res {1450 if let Some(output) = res {
1451 if let Some(output) = output {1451 if let Some(output) = output {
1452- self.niri.queue_redraw(output);1452+ self.niri.queue_redraw(&output);
1453 }1453 }
1454 handled = true;1454 handled = true;
1455 }1455 }
@@ -1460,7 +1460,7 @@ impl State {
1460 .view_offset_gesture_update(delta_x, timestamp);1460 .view_offset_gesture_update(delta_x, timestamp);
1461 if let Some(output) = res {1461 if let Some(output) = res {
1462 if let Some(output) = output {1462 if let Some(output) = output {
1463- self.niri.queue_redraw(output);1463+ self.niri.queue_redraw(&output);
1464 }1464 }
1465 handled = true;1465 handled = true;
1466 }1466 }
@@ -1494,13 +1494,13 @@ impl State {
1494 .layout1494 .layout
1495 .workspace_switch_gesture_end(event.cancelled());1495 .workspace_switch_gesture_end(event.cancelled());
1496 if let Some(output) = res {1496 if let Some(output) = res {
1497- self.niri.queue_redraw(output);1497+ self.niri.queue_redraw(&output);
1498 handled = true;1498 handled = true;
1499 }1499 }
1500 1500
1501 let res = self.niri.layout.view_offset_gesture_end(event.cancelled());1501 let res = self.niri.layout.view_offset_gesture_end(event.cancelled());
1502 if let Some(output) = res {1502 if let Some(output) = res {
1503- self.niri.queue_redraw(output);1503+ self.niri.queue_redraw(&output);
1504 handled = true;1504 handled = true;
1505 }1505 }
1506 1506
src/niri.rsmodified+36 -32
@@ -338,6 +338,27 @@ pub enum CenterCoords {
338 #[derive(Default)]338 #[derive(Default)]
339 pub struct WindowOffscreenId(pub RefCell<Option<Id>>);339 pub struct WindowOffscreenId(pub RefCell<Option<Id>>);
340 340
341+impl RedrawState {
342+ fn queue_redraw(self) -> Self {
343+ match self {
344+ RedrawState::Idle => RedrawState::Queued,
345+ RedrawState::WaitingForEstimatedVBlank(token) => {
346+ RedrawState::WaitingForEstimatedVBlankAndQueued(token)
347+ }
348+
349+ // A redraw is already queued.
350+ value @ (RedrawState::Queued | RedrawState::WaitingForEstimatedVBlankAndQueued(_)) => {
351+ value
352+ }
353+
354+ // We're waiting for VBlank, request a redraw afterwards.
355+ RedrawState::WaitingForVBlank { .. } => RedrawState::WaitingForVBlank {
356+ redraw_needed: true,
357+ },
358+ }
359+ }
360+}
361+
341 impl Default for SurfaceFrameThrottlingState {362 impl Default for SurfaceFrameThrottlingState {
342 fn default() -> Self {363 fn default() -> Self {
343 Self {364 Self {
@@ -863,7 +884,7 @@ impl State {
863 }884 }
864 }885 }
865 for output in resized_outputs {886 for output in resized_outputs {
866- self.niri.output_resized(output);887+ self.niri.output_resized(&output);
867 }888 }
868 889
869 self.backend.on_output_config_changed(&mut self.niri);890 self.backend.on_output_config_changed(&mut self.niri);
@@ -955,7 +976,7 @@ impl State {
955 }976 }
956 }977 }
957 ScreenCastToNiri::StopCast { session_id } => self.niri.stop_cast(session_id),978 ScreenCastToNiri::StopCast { session_id } => self.niri.stop_cast(session_id),
958- ScreenCastToNiri::Redraw(output) => self.niri.queue_redraw(output),979+ ScreenCastToNiri::Redraw(output) => self.niri.queue_redraw(&output),
959 }980 }
960 }981 }
961 982
@@ -1423,7 +1444,7 @@ impl Niri {
1423 new_position.x, new_position.y1444 new_position.x, new_position.y
1424 );1445 );
1425 output.change_current_state(None, None, None, Some(new_position));1446 output.change_current_state(None, None, None, Some(new_position));
1426- self.queue_redraw(output);1447+ self.queue_redraw(&output);
1427 }1448 }
1428 }1449 }
1429 }1450 }
@@ -1548,27 +1569,26 @@ impl Niri {
1548 }1569 }
1549 }1570 }
1550 1571
1551- pub fn output_resized(&mut self, output: Output) {1572+ pub fn output_resized(&mut self, output: &Output) {
1552- let output_size = output_size(&output);1573+ let output_size = output_size(output);
1553 let is_locked = self.is_locked();1574 let is_locked = self.is_locked();
1554 1575
1555- layer_map_for_output(&output).arrange();1576+ layer_map_for_output(output).arrange();
1556- self.layout.update_output_size(&output);1577+ self.layout.update_output_size(output);
1557 1578
1558- if let Some(state) = self.output_state.get_mut(&output) {1579+ if let Some(state) = self.output_state.get_mut(output) {
1559 state.background_buffer.resize(output_size);1580 state.background_buffer.resize(output_size);
1560 1581
1561 state.lock_color_buffer.resize(output_size);1582 state.lock_color_buffer.resize(output_size);
1562 if is_locked {1583 if is_locked {
1563 if let Some(lock_surface) = &state.lock_surface {1584 if let Some(lock_surface) = &state.lock_surface {
1564- configure_lock_surface(lock_surface, &output);1585+ configure_lock_surface(lock_surface, output);
1565 }1586 }
1566 }1587 }
1567 }1588 }
1568 1589
1569 // If the output size changed with an open screenshot UI, close the screenshot UI.1590 // If the output size changed with an open screenshot UI, close the screenshot UI.
1570- if let Some((old_size, old_scale, old_transform)) = self.screenshot_ui.output_size(&output)1591+ if let Some((old_size, old_scale, old_transform)) = self.screenshot_ui.output_size(output) {
1571- {
1572 let transform = output.current_transform();1592 let transform = output.current_transform();
1573 let output_mode = output.current_mode().unwrap();1593 let output_mode = output.current_mode().unwrap();
1574 let size = transform.transform_size(output_mode.size);1594 let size = transform.transform_size(output_mode.size);
@@ -1879,31 +1899,15 @@ impl Niri {
1879 1899
1880 /// Schedules an immediate redraw on all outputs if one is not already scheduled.1900 /// Schedules an immediate redraw on all outputs if one is not already scheduled.
1881 pub fn queue_redraw_all(&mut self) {1901 pub fn queue_redraw_all(&mut self) {
1882- let outputs: Vec<_> = self.output_state.keys().cloned().collect();1902+ for state in self.output_state.values_mut() {
1883- for output in outputs {1903+ state.redraw_state = mem::take(&mut state.redraw_state).queue_redraw();
1884- self.queue_redraw(output);
1885 }1904 }
1886 }1905 }
1887 1906
1888 /// Schedules an immediate redraw if one is not already scheduled.1907 /// Schedules an immediate redraw if one is not already scheduled.
1889- pub fn queue_redraw(&mut self, output: Output) {1908+ pub fn queue_redraw(&mut self, output: &Output) {
1890- let state = self.output_state.get_mut(&output).unwrap();1909+ let state = self.output_state.get_mut(output).unwrap();
1891- state.redraw_state = match mem::take(&mut state.redraw_state) {1910+ state.redraw_state = mem::take(&mut state.redraw_state).queue_redraw();
1892- RedrawState::Idle => RedrawState::Queued,
1893- RedrawState::WaitingForEstimatedVBlank(token) => {
1894- RedrawState::WaitingForEstimatedVBlankAndQueued(token)
1895- }
1896-
1897- // A redraw is already queued.
1898- value @ (RedrawState::Queued | RedrawState::WaitingForEstimatedVBlankAndQueued(_)) => {
1899- value
1900- }
1901-
1902- // We're waiting for VBlank, request a redraw afterwards.
1903- RedrawState::WaitingForVBlank { .. } => RedrawState::WaitingForVBlank {
1904- redraw_needed: true,
1905- },
1906- };
1907 }1911 }
1908 1912
1909 pub fn redraw_queued_outputs(&mut self, backend: &mut Backend) {1913 pub fn redraw_queued_outputs(&mut self, backend: &mut Backend) {