diff --git a/src/app.rs b/src/app.rs index 3ed2ee4..69cf858 100644 --- a/src/app.rs +++ b/src/app.rs @@ -657,6 +657,17 @@ pub trait App: 'static /// The event loop will keep requesting redraws at ~60 fps until this returns `false`. fn is_animating( &self ) -> bool { false } + /// Return `true` when a finger-tracked swipe or an [`Self::is_animating`] + /// slide only repositions the app's input-transparent subsurfaces + /// ([`Self::subsurfaces`]) while the main surface buffer stays unchanged. + /// The runtime then skips the per-frame main re-raster that + /// [`Self::on_swipe_progress`] and `is_animating` would otherwise force, + /// keeping the animation pumped (motion events during the drag, a bare + /// frame callback while `is_animating`) and letting the per-frame + /// subsurface reconcile carry the motion. Use it for a slide-to-reveal + /// panel over a static main surface. + fn subsurface_motion_only( &self ) -> bool { false } + /// Return `true` while the next frame should swap the expensive /// Glass passes for cheap fallbacks — currently the /// `backdrop-filter` blur drops from a 41-tap kernel to a 9-tap diff --git a/src/event_loop/handlers.rs b/src/event_loop/handlers.rs index 1f35282..8b3a01b 100644 --- a/src/event_loop/handlers.rs +++ b/src/event_loop/handlers.rs @@ -620,8 +620,24 @@ impl Dispatch for AppData state.main.frame_pending = false; if is_animating { - state.view_dirty = true; - state.main.request_redraw(); + if state.app.subsurface_motion_only() + { + // The main buffer is unchanged; only the subsurface + // moves (repositioned by the per-frame reconcile). + // Keep the vsync cadence with a bare frame callback + + // commit — no buffer attach, no re-raster. + if let Some( wl ) = state.main.surface.try_wl_surface().cloned() + { + let _ = wl.frame( &state.qh, super::SurfaceFocus::Main ); + wl.commit(); + state.main.frame_pending = true; + } + } + else + { + state.view_dirty = true; + state.main.request_redraw(); + } } } super::SurfaceFocus::Overlay( id ) => diff --git a/src/input/dispatch/outcomes.rs b/src/input/dispatch/outcomes.rs index 4722892..e274c26 100644 --- a/src/input/dispatch/outcomes.rs +++ b/src/input/dispatch/outcomes.rs @@ -50,12 +50,18 @@ impl AppData if let Some( v ) = down { self.app.on_swipe_down_progress( v ); } if let Some( v ) = horizontal { self.app.on_swipe_horizontal_progress( v ); } // Swipe-progress callbacks mutate app state outside - // `update`, so the cached view tree is stale. - self.dirty_caches(); - self.surface_mut( focus ).request_redraw(); - for ss in self.overlays.values_mut() + // `update`, so the cached view tree is stale — unless the + // motion only slides a subsurface over a static main + // surface, in which case the per-frame subsurface reconcile + // carries the move and a main re-raster is wasted work. + if !self.app.subsurface_motion_only() { - ss.request_redraw(); + self.dirty_caches(); + self.surface_mut( focus ).request_redraw(); + for ss in self.overlays.values_mut() + { + ss.request_redraw(); + } } } }