forge
Explore
Log in

Don't you dare go Hollow

Make send_frame() a function on Mapped

Browse files at this commit

bfd81fc2904ba35ae7ccb979e8cb4b2d244fb2ddIvan MolodetskikhParent: 0dd8e88
We'll add some extra logic there.
src/layout/mod.rsmodified+29 -0
@@ -476,6 +476,13 @@ impl<W: LayoutElement> InteractiveMoveState<W> {
476 _ => None,476 _ => None,
477 }477 }
478 }478 }
479+
480+ fn moving_mut(&mut self) -> Option<&mut InteractiveMoveData<W>> {
481+ match self {
482+ InteractiveMoveState::Moving(move_) => Some(move_),
483+ _ => None,
484+ }
485+ }
479 }486 }
480 487
481 impl<W: LayoutElement> InteractiveMoveData<W> {488 impl<W: LayoutElement> InteractiveMoveData<W> {
@@ -1608,6 +1615,28 @@ impl<W: LayoutElement> Layout<W> {
1608 moving_window.chain(mon_windows)1615 moving_window.chain(mon_windows)
1609 }1616 }
1610 1617
1618+ pub fn windows_for_output_mut(&mut self, output: &Output) -> impl Iterator<Item = &mut W> + '_ {
1619+ let MonitorSet::Normal { monitors, .. } = &mut self.monitor_set else {
1620+ panic!()
1621+ };
1622+
1623+ let moving_window = self
1624+ .interactive_move
1625+ .as_mut()
1626+ .and_then(|x| x.moving_mut())
1627+ .filter(|move_| move_.output == *output)
1628+ .map(|move_| move_.tile.window_mut())
1629+ .into_iter();
1630+
1631+ let mon = monitors
1632+ .iter_mut()
1633+ .find(|mon| &mon.output == output)
1634+ .unwrap();
1635+ let mon_windows = mon.workspaces.iter_mut().flat_map(|ws| ws.windows_mut());
1636+
1637+ moving_window.chain(mon_windows)
1638+ }
1639+
1611 pub fn with_windows(&self, mut f: impl FnMut(&W, Option<&Output>, Option<WorkspaceId>)) {1640 pub fn with_windows(&self, mut f: impl FnMut(&W, Option<&Output>, Option<WorkspaceId>)) {
1612 if let Some(InteractiveMoveState::Moving(move_)) = &self.interactive_move {1641 if let Some(InteractiveMoveState::Moving(move_)) = &self.interactive_move {
1613 f(move_.tile.window(), Some(&move_.output), None);1642 f(move_.tile.window(), Some(&move_.output), None);
src/niri.rsmodified+6 -6
@@ -3895,7 +3895,7 @@ impl Niri {
3895 }3895 }
3896 }3896 }
3897 3897
3898- pub fn send_frame_callbacks(&self, output: &Output) {3898+ pub fn send_frame_callbacks(&mut self, output: &Output) {
3899 let _span = tracy_client::span!("Niri::send_frame_callbacks");3899 let _span = tracy_client::span!("Niri::send_frame_callbacks");
3900 3900
3901 let state = self.output_state.get(output).unwrap();3901 let state = self.output_state.get(output).unwrap();
@@ -3936,8 +3936,8 @@ impl Niri {
3936 3936
3937 let frame_callback_time = get_monotonic_time();3937 let frame_callback_time = get_monotonic_time();
3938 3938
3939- for mapped in self.layout.windows_for_output(output) {3939+ for mapped in self.layout.windows_for_output_mut(output) {
3940- mapped.window.send_frame(3940+ mapped.send_frame(
3941 output,3941 output,
3942 frame_callback_time,3942 frame_callback_time,
3943 FRAME_CALLBACK_THROTTLE,3943 FRAME_CALLBACK_THROTTLE,
@@ -3985,7 +3985,7 @@ impl Niri {
3985 }3985 }
3986 }3986 }
3987 3987
3988- pub fn send_frame_callbacks_on_fallback_timer(&self) {3988+ pub fn send_frame_callbacks_on_fallback_timer(&mut self) {
3989 let _span = tracy_client::span!("Niri::send_frame_callbacks_on_fallback_timer");3989 let _span = tracy_client::span!("Niri::send_frame_callbacks_on_fallback_timer");
3990 3990
3991 // Make up a bogus output; we don't care about it here anyway, just the throttling timer.3991 // Make up a bogus output; we don't care about it here anyway, just the throttling timer.
@@ -4002,8 +4002,8 @@ impl Niri {
4002 4002
4003 let frame_callback_time = get_monotonic_time();4003 let frame_callback_time = get_monotonic_time();
4004 4004
4005- self.layout.with_windows(|mapped, _, _| {4005+ self.layout.with_windows_mut(|mapped, _| {
4006- mapped.window.send_frame(4006+ mapped.send_frame(
4007 output,4007 output,
4008 frame_callback_time,4008 frame_callback_time,
4009 FRAME_CALLBACK_THROTTLE,4009 FRAME_CALLBACK_THROTTLE,
src/window/mapped.rsmodified+14 -1
@@ -13,7 +13,7 @@ use smithay::reexports::wayland_protocols::xdg::shell::server::xdg_toplevel;
13 use smithay::reexports::wayland_server::protocol::wl_surface::WlSurface;13 use smithay::reexports::wayland_server::protocol::wl_surface::WlSurface;
14 use smithay::reexports::wayland_server::Resource as _;14 use smithay::reexports::wayland_server::Resource as _;
15 use smithay::utils::{Logical, Point, Rectangle, Scale, Serial, Size, Transform};15 use smithay::utils::{Logical, Point, Rectangle, Scale, Serial, Size, Transform};
16-use smithay::wayland::compositor::{remove_pre_commit_hook, with_states, HookId};16+use smithay::wayland::compositor::{remove_pre_commit_hook, with_states, HookId, SurfaceData};
17 use smithay::wayland::seat::WaylandFocus;17 use smithay::wayland::seat::WaylandFocus;
18 use smithay::wayland::shell::xdg::{SurfaceCachedState, ToplevelSurface};18 use smithay::wayland::shell::xdg::{SurfaceCachedState, ToplevelSurface};
19 use wayland_backend::server::Credentials;19 use wayland_backend::server::Credentials;
@@ -413,6 +413,19 @@ impl Mapped {
413 WindowCastRenderElements::from(elem)413 WindowCastRenderElements::from(elem)
414 })414 })
415 }415 }
416+
417+ pub fn send_frame<T, F>(
418+ &mut self,
419+ output: &Output,
420+ time: T,
421+ throttle: Option<Duration>,
422+ primary_scan_out_output: F,
423+ ) where
424+ T: Into<Duration>,
425+ F: FnMut(&WlSurface, &SurfaceData) -> Option<Output> + Copy,
426+ {
427+ self.window.send_frame(output, time, throttle, primary_scan_out_output);
428+ }
416 }429 }
417 430
418 impl Drop for Mapped {431 impl Drop for Mapped {