Repository navigation
Description
Follows #47, which covers the right and bottom edges.
What happens
Dragging a window's left or top edge, the whole page jumps sideways (or up) by the drag distance on each step, then snaps back when the new frame lands. The gap opens at the opposite edge, the one not being dragged. Right and bottom edges don't do this. Same machine as #47 (Windows 11, RTX 4070, 239 Hz).
Cause
- A left or top drag moves the window's origin. Until the app presents a frame at the new size, DWM shows the last frame pinned to the client area's new top-left, so the old frame moves with the edge.
- Drawing each step sooner (Windows: live resize lags and stretches on every edge #47) shortens this but can't remove it: the shifted frame is visible in the moment between DWM moving the window and the new present.
- Rune can't correct it, because wgpu owns the composition tree. With
Dx12SwapchainKind::DxgiFromVisual, wgpu-hal creates its ownIDCompositionDevice, target and root visual for the HWND (wgpu-hal30,dx12/dcomp.rs,InnerState::init) and never exposes them.
Proposed approach (researched, not prototyped)
- Rune owns the tree. Create the
IDCompositionDevice, a target for the HWND, a root visual and a content visual, and make the surface withwgpu::SurfaceTargetUnsafe::CompositionVisual(content)(wgpu 30, DX12 only). Behaviour, screenshots and transparency should stay identical; this step only moves ownership. - Offset during a left/top drag. In the size-move subclass (
platform/win32/dpi_drag.rsalready watchesWM_ENTERSIZEMOVE/WM_EXITSIZEMOVE), readWM_SIZING's edge (WMSZ_LEFT,WMSZ_TOPand the corners). For each step:- set the content visual's offset to the origin's movement since the last presented frame (
SetOffsetX(+dx),SetOffsetY(+dy)), so the old frame stays where it was on screen, andCommit()before returning; - when the frame at the new size presents, reset the offsets to 0 and
Commit()again.
- set the content visual's offset to the origin's movement since the last presented frame (
- Keep Windows: live resize lags and stretches on every edge #47's pieces: draw in
Resizedduring the loop, one oversized drawable for the drag, and clearing to the page colour.
Risk to verify first
The window move (applied by DWM) and the visual offset (a DirectComposition commit) must land in the same composed frame. If they are a frame apart, the page wobbles by one step instead of jumping, which is still visible. Check this before building the rest: a test window that moves its origin and offsets a solid-colour visual in the same step, watched at 240 Hz or captured with PresentMon. If the commit lands late, IDCompositionDevice::WaitForCommitCompletion or committing from WM_WINDOWPOSCHANGING (before the move is applied) are the next things to try.
Scope
- DX12 only. Vulkan keeps the HWND swapchain and today's behaviour.
- The same tree is what Mica/Acrylic backdrops and native video visuals need.
research/11-platform-shells.mdalready plans anIDCompositionDevice/ target / visual tree for the Windows shell, aftergpui_windows.
Acceptance
- Dragging the left or top edge (or a corner) at full speed, the page doesn't move on screen; only the uncovered strip at the dragged edge shows the page colour.
- Right and bottom edges, transparent windows, overlays and screenshots are unchanged.
- No extra frame of lag in step time against Windows: live resize lags and stretches on every edge #47's numbers.
I can test any change on this machine (NVIDIA RTX 4070, plus the Intel iGPU via WGPU_ADAPTER_NAME=intel).
Activity