Acknowledge _NET_WM_SYNC_REQUEST only after the resized frame on X11 - #193
Open
treeform wants to merge 1 commit into
Open
Acknowledge _NET_WM_SYNC_REQUEST only after the resized frame on X11#193treeform wants to merge 1 commit into
treeform wants to merge 1 commit into
Conversation
The sync counter was updated at the top of every poll, before the events of that poll were handled. When the window manager's sync request landed at the end of one poll and its ConfigureNotify in the next, the counter told the compositor the frame was done while the window was still drawn at the old size, so KWin showed one frame with black stripes on the right and bottom edge. The window now tracks the handshake: a request marks it pending, the ConfigureNotify marks it configured, and the counter is only set on the following poll, after a frame at the new size went by. The event loop also waits briefly for the ConfigureNotify that follows a request so the next frame is already the new size. Adds tests/test_x11.nim, which plays the window manager side under Xvfb and checks the counter against XSyncQueryCounter, and runs it in CI on Ubuntu. Follows the intent of #156 by levovix0 without the temporary vsync toggle and the cached size, which are unrelated to the sync handshake. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
On X11 the
_NET_WM_SYNC_REQUESTcounter was set at the top of everypollEvents, before that poll's events were handled. If the window manager's sync request arrived at the end of one poll and itsConfigureNotifyin the next, windy acknowledged the frame while the window was still drawn at the old size. KWin then composited that frame, which is the one-frame black stripe on the right and bottom edge reported in #156.This tracks the handshake per window:
SyncRequested, remember the counter valueConfigureNotify→SyncConfiguredXSyncSetCounter, back toSyncIdleThe event loop also waits up to 10 ms for the
ConfigureNotifythat follows a sync request, so the frame drawn after the poll is already the new size. A request that never gets a configure is never acknowledged, which is what the EWMH protocol expects.This follows the intent of #156 by @levovix0. Left out on purpose: the temporary vsync disable after a resize and the cached
sizegetter, which are unrelated to the sync handshake (the cache also madesize=wait its full timeout, sinceblockUntilnever polls events).Test
tests/test_x11.nimplays the window manager side under a bare Xvfb: it sends the_NET_WM_SYNC_REQUESTclient message, resizes withXResizeWindow, and reads the counter back withXSyncQueryCounter. It checks:Against the old unconditional ack the test fails at the split case, which is exactly the reported bug. CI runs it on Ubuntu under
xvfb-runwith Mesa llvmpipe.Validation
nim r tests/test_x11.nimunder Xvfb (Docker, linux/amd64, Nim 2.2.4): passesnim c tests/test.nim,examples/basic.nim,examples/callbacks.nim,examples/property_changes.nimon Linux: compileNot verified on a real KWin session, I do not have one at hand. @levovix0 if you can try this on your setup that would confirm the visual fix.
🤖 Generated with Claude Code