Repository navigation
allow events while waiting for a synchronous reply - #68
Merged
Merged
Conversation
Source.readSynchronousReplyOrEvent returns either the reply or an event that arrived before it, so callers that can receive events read in a loop and handle them as a case of the result. readReplyFull/readReplyHeader read the rest of the reply. Source.rejectEvent handles unexpected events (skips MappingNotify, fails on anything else), and the existing helpers (readSynchronousReply1/Full/Header, synchronousQueryExtension, ...) keep their signatures and behavior on top of it. Some servers (e.g. MobaXterm's Moba/X) send ConfigureNotify as soon as a window is created. present and draw now track the window size from it while waiting for their QueryTextExtents reply, testexample logs it, and dbe queries its extension before creating the window. Fixes #66 Amp-Thread-ID: https://ampcode.com/threads/T-01a14b88-aff8-717e-bb9f-364137832240 Co-authored-by: Amp <amp@ampcode.com>
marler8997
force-pushed
the
sync-event-handler
branch
from
October 18, 2026 04:00
2b7ce03 to
932aa50
Compare
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.
Fixes #66. Supersedes #65.
Source.readSynchronousReplyOrEvent(sequence)returns a tagged union: either the reply or an event that arrived before it. Callers that can receive events read in a loop and handle the event as a case of the result, then read the rest of the reply with the newreadReplyFull/readReplyHeader:Source.rejectEventkeeps the previous behavior for unexpected events (skipMappingNotify, log and fail on anything else). The existing helpers (readSynchronousReply1/Full/Header,draft.synchronousQueryExtension,synchronousGetKeyboardMapping,keymap.Full.initSynchronous) keep their signatures and use it, so this is an additive API change and examples that can't receive events are unchanged.Moba/X sends a
ConfigureNotifyas soon as a window is created, which crashed the examples that selectStructureNotifyand then do synchronous requests:QueryTextExtentsreplyreadReplyhelper used by all its synchronous requestsVerification
zig build install install-xauth test-non-interactivepasses; x86_64 windows compiles.ConfigureNotifyafter anyCreateWindowselectingStructureNotify(mimicking Moba/X): dbe, present, draw, testexample and text all keep running (before this change the first four failed withexpected Reply but got ConfigureNotify); a temporary log showed present and draw picking up the 600x400 size. All other examples run normally.https://ampcode.com/threads/T-01a14b88-aff8-717e-bb9f-364137832240