Add DesktopSize / ExtendedDesktopSize pseudo-encoding support#12
Open
rsp2k wants to merge 1 commit into
Open
Conversation
The RFB pseudo-encodings -223 (DesktopSize) and -308 (ExtendedDesktopSize) carry server-side geometry change notifications. asyncvnc2 currently has no parser for them, so when a server pushes one (TigerVNC does this on every xrandr resize, for example), Enc(...) raises ValueError and the connection drops on the next byte read. - Add DESKTOP_SIZE and EXTENDED_DESKTOP_SIZE to Enc with the proper negative wire values - SetEncodings writer uses signed=True so negative pseudo-encodings serialize correctly when callers opt them in via EncList - Video.read converts the unsigned wire integer back to signed for pseudo-encodings (existing raise-on-unknown behavior preserved) - Two new dispatch branches drain the pseudo-encoding payload and update Video.width/height through a small _handle_desktop_resize helper. The helper only invalidates the framebuffer on actual size changes -- servers commonly echo the current size on connect, and invalidating on echo would deadlock the screenshot loop - Client.screenshot re-requests on incomplete updates so callers don't deadlock when an unsolicited pseudo-encoding rect arrives mid-screenshot - Enc.default() now excludes pseudo-encodings (filter value > 0) with a docstring warning about TigerVNC: that build treats EDS in SetEncodings as a subscription, returning EDS-only FBU responses that starve the screenshot path. Callers wanting subscription-style resize notifications opt in deliberately via EncList + EDS Tests in tests/test_desktop_size.py cover _handle_desktop_resize no-op vs invalidate semantics and Video.read parsing of DESKTOP_SIZE plus EDS rects (including multi-screen payloads).
rsp2k
marked this pull request as ready for review
June 14, 2026 04:45
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.
The RFB pseudo-encodings -223 (DesktopSize) and -308 (ExtendedDesktopSize) carry server-side geometry change notifications. asyncvnc2 currently has no parser for them, so when a server pushes one (TigerVNC does this on every
xrandrresize, for example),Enc(...)raisesValueErrorand the connection drops on the next byte read.What changed
EncgainsDESKTOP_SIZE = -223andEXTENDED_DESKTOP_SIZE = -308.SetEncodingswriter usessigned=Trueso negative pseudo-encodings serialize correctly when callers opt them in viaEncList.Video.readconverts the unsigned wire integer back to signed before theEnc(...)lookup. Existing raise-on-unknown-encoding behavior is preserved (silently skipping an unknown rect would desync the stream).Video.width/heightthrough a small_handle_desktop_resizehelper that only invalidates the framebuffer when the size actually changes (servers commonly echo the current size on connect).Client.screenshotre-requests on incomplete updates so callers don't deadlock when an unsolicited pseudo-encoding rect arrives mid-screenshot.Enc.default()now excludes pseudo-encodings (filtervalue > 0) with a docstring explaining the TigerVNC subscription quirk — see below.tests/test_desktop_size.pyadds 5 unit tests covering_handle_desktop_resizeno-op vs invalidate semantics andVideo.readparsing of DESKTOP_SIZE plus EDS rects (including multi-screen payloads).TigerVNC subscription quirk
If you advertise
ExtendedDesktopSizeinSetEncodings, the TigerVNC build inaccetto/ubuntu-vnc-xfce-g3returns EDS-onlyFramebufferUpdateresponses (cnt=1, no pixel data) to everyFramebufferUpdateRequest, even withincremental=False. This effectively starves the screenshot path. The docstring onEnc.default()warns about this so users who want subscription-style resize notifications opt in deliberately:EncList() + Enc.EXTENDED_DESKTOP_SIZE.Verification
Tested against
accetto/ubuntu-vnc-xfce-g3and the existing pytest suite. Default-behavior screenshots and the new resize handling both work; the test suite passes unchanged.