Skip to content

fix(win32): drive animations and timers during modal size-move loops (#2908) - #2918

Merged
Hona merged 1 commit into
devfrom
fix/win32-modal-sizemove-animations
Nov 30, 2026
Merged

Hona merged 1 commit into
devfrom
fix/win32-modal-sizemove-animations

Conversation

@Hona

@Hona Hona commented Nov 30, 2026

Copy link
Copy Markdown
Member

Fixes #2908

Root cause

Pressing and holding a Windows window's title bar or resize border enters user32's modal size-move loop (WM_ENTERSIZEMOVE..WM_EXITSIZEMOVE), where winit's AboutToWait and NewEvents callbacks do not run. Continuous animations park in Redraw::Wants, and stepped loops or scheduled timers (such as Spinner Cycle { fps: 60.0 } or Tx::wake_after) never wake until the pointer moves or releases.

PR #2753 added a modal WM_TIMER only for ResizeSync::On after the first resize step entered State::Dragging. It did not run between WM_ENTERSIZEMOVE and the first size step, during held moves, for stepped/timer-driven loops, or when ResizeSync was Off / Auto.

Changes

  • Explicit modal size-move tick state machine (crates/rune/src/platform/win32/dpi_drag.rs):
    • Added ModalDemand::{Idle, Continuous, At(Instant)}, TimerMode::{Continuous, Scheduled}, ModalTickState::{Outside, InLoopIdle, InLoopArmed}, ModalTickEvent, ModalTickEffect, and pure step_modal_tick (rune::machine).
    • Replaced the MOVING vector and ResizeSync-only tick_active flag with one per-HWND MODAL table for every subclassed window.
    • Records redraw demand in memory while outside the modal loop (zero Win32 calls), arms WM_TIMER immediately at WM_ENTERSIZEMOVE when needed, invalidates (InvalidateRect(..., 0)) on each tick so winit delivers RedrawRequested, adjusts/disarms on state edges without resetting running timers on rapid resize steps, and kills the timer on Idle, WM_EXITSIZEMOVE, or WM_NCDESTROY.
  • Window-wide modal demand policy (crates/rune/src/window/win32/modal_tick.rs, crates/rune/src/window/host/any_host.rs, crates/rune/src/window/win32/resize_sync.rs):
    • Added pure compute_modal_demand and Host::sync_modal_tick, synced at the end of window_event_in_turn, user_event_in_turn, turn_ends_in_turn, and ResizeSync drag/priming/release transitions.
    • Covers continuous animations (Loader, springs, compositor, pending Redraw), stepped Cycle loops (Spinner) and scheduled timers (poll_deadline, backoff, video_layers), and ResizeSync DComp priming while arming zero timers for idle or non-drawable windows.
  • Tests (crates/rune/src/platform/win32/dpi_drag_tests.rs, crates/rune/src/window/win32/modal_tick_tests.rs):
    • Added 11 focused unit and state-machine integration tests covering held move and held resize across ResizeSync::On and ResizeSync::Off, idle vs animating vs stepped Spinner / caret timers, early-fire recovery, mid-hold background wakes, ResizeSync priming and fallback, and WM_EXITSIZEMOVE / WM_NCDESTROY cleanup.

Verification

  • cargo check -p rune --lib (0 warnings in touched files)
  • cargo check -p rune --lib --target wasm32-unknown-unknown (0 warnings)
  • cargo test -p rune --lib dpi_drag (5 passed, 0 failed)
  • cargo test -p rune --lib modal_tick (6 passed, 0 failed)
  • cargo test -p rune --lib resize_sync (32 passed, 0 failed)
  • scripts/file-size.sh (0 errors, 0 folder-shape issues)
  • Not run locally: live interactive Windows title bar / resize border hold visual verification with kit-gallery.

@Hona
Hona merged commit 1bffd17 into dev Nov 30, 2026
5 checks passed
@Hona
Hona deleted the fix/win32-modal-sizemove-animations branch November 30, 2026 02:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Windows: animations freeze while a window move or resize is held still

1 participant