Repository navigation
Serve a screen to VNC clients with gliff-server --vnc - #133
Open
avillagran wants to merge 9 commits into
Open
avillagran wants to merge 9 commits into
avillagran wants to merge 9 commits into
Conversation
A headless output always went where Hyprland found room. --position puts it right, left, above or below this machine's screens, and --align lines it up with their top or left edges (start), their middles, or their bottom or right edges (end). The position is worked out from the other screens' layout each time the output's mode is set, so a resize keeps it in place beside them.
The position comes from the output's logical size, which resize computed with the requested scale. When Hyprland applies a rounded scale instead, place the output again at that scale, so it still meets the other screens on the chosen side and lines up as asked.
Hyprland places a screen whose position is `auto`, as Omarchy's default configuration does, after every screen with a fixed one. A fixed position for the headless output therefore pushed such a screen aside: on a laptop asked for `--position right`, the laptop screen moved right of the new output. When placing the output moves another screen, the placement goes to Hyprland's `auto-right`, `auto-center-right` and related positions instead. They line up at the start or the center of a side, so `--align end` is centered there, with a warning.
CaptureConfig::paint_cursors asks the compositor to draw cursors onto the captured frames (ext-image-copy-capture's paint_cursors option), for a viewer that cannot draw a cursor of its own. It is off by default, so the gliff session, which sends the cursor separately, is unchanged.
gliff-vnc holds the RFB protocol for serving a Hyprland output to VNC clients, kept apart from any I/O beyond the stream it is given so each part can be tested on its own: - the handshake for RFB 3.3, 3.7 and 3.8, with VNC Authentication (DES challenge-response, checked against OpenSSL) or none; - every pixel format a client may ask for: 8, 16 and 32-bit true colour in either byte order, and 8-bit colour maps, which get a 3-3-2 map; - the Raw, Hextile and ZRLE encodings, decoded back in the tests by a separate decoder over desktop-like and random pictures; - which 16x16 tiles changed since the client was last sent them; - a keymap of the server's own on which each keysym a client sends has a key, with modifiers kept as modifiers and keys reused least recently typed first, so any character can be typed whatever the local layout.
`gliff-server --vnc ADDR --headless --size WxH` adds a screen of that size beside the others (`--scale`, `--position` and `--align` as for a gliff session) and serves it to VNC clients until stopped, so a device with any VNC viewer, however old, becomes one more screen of this machine. `--output` serves an existing screen instead. The screen lives as long as the server: a client that sleeps or drops comes back to the same windows. One client is served at a time, and one that logs in takes over from the previous one; a wrong password waits two seconds before it is refused. A password is required, from --vnc-password-file or GLIFF_VNC_PASSWORD, unless --vnc-no-password says otherwise. Frames are captured with the cursor painted in, only while a client is connected, and only once the screen changes; a client's first update waits for a frame newer than its connection. Updates carry the tiles that changed. Key events type keysyms through gliff-vnc's keymap, and pointer events move, click and scroll on that screen. setup_output now takes the mode to start in, so the VNC screen starts at its size and scale, and places the output again when Hyprland rounds the scale. SIGINT, SIGTERM and SIGHUP give the screen back.
A config reload drops the monitor rule that set a headless output's mode, and Omarchy reloads when a monitor comes or goes, which left a tablet's 1024x720 screen at 1920x1080 scale 2. The VNC server checks the mode every two seconds and sets it back.
[High impact] The latest change appears safe to merge and fixes clicks during temporary headless screen resizes. SummaryThis PR adds
Reviews (3) · Last reviewed commit: "Keep the pointer on the screen the viewe..." · Reviewed by Greptile |
- Updates go to a writer task per client through a queue of four, each write with a 10-second limit; a client that stops reading is dropped instead of blocking logins, frames and shutdown. Client messages are read ahead through a bounded queue, so reading waits instead of growing without end. - A client's reader and writer tasks stop when it is dropped or replaced. - The client's version line is read as bytes, so a line that is not ASCII is refused instead of panicking, and a login slot is given back by a guard however the login ends. - SetEncodings changes only the encoding: the encoder, and the ZRLE stream that runs for the whole connection, stay. - A headless screen keeps the mode it was made with as the one to restore after a reload; frames of another size no longer replace it. - --scale takes a finite value from 0.5 to 4.
Author
|
All six findings are addressed in 3f1d7d3: stalled clients, malformed version lines and login slots, the headless mode across reloads, the ZRLE stream across SetEncodings, --scale validation, and reader/writer tasks stopped with their client. scripts/check.sh passes (307 tests), with new tests for the non-ASCII version line, the login slot guard and the scale range. |
avillagran
added a commit
to avillagran/gliff
that referenced
this pull request
Nov 11, 2026
The headless screen's requested mode stays apart, but the pointer's extent now follows the frame size, so clicks land where the viewer sees them during the moment a reload holds the screen at another size.
avillagran
added a commit
to avillagran/gliff
that referenced
this pull request
Nov 11, 2026
avillagran
added a commit
to avillagran/gliff
that referenced
this pull request
Nov 12, 2026
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 problem
An old tablet or laptop is a perfectly good extra screen, but it cannot run gliff. Almost every device can run a VNC viewer, though.
What this adds
gliff-server --vnc ADDR --headless --size WxHadds a screen of that size beside the others and serves it to VNC clients until it is stopped.--scale,--positionand--alignwork as they do for a gliff session.--output NAMEserves an existing screen instead of a new one.gliff-vnc, holds the protocol and does no I/O beyond the stream it is given, so each part is tested on its own:CaptureConfig::paint_cursorsasks the compositor to draw the cursor into the frames, for viewers that cannot draw one. It is off by default, so gliff's own sessions are unchanged. Frames are captured only while a client is connected and only when the screen changes.setup_outputtakes the mode to start in, so the VNC screen starts at its own size and scale.Screenshots
Taken from a test laptop running Hyprland.
The server starting a 1024x768 screen on the right of the laptop's own and serving it on 127.0.0.1:5906. This run uses
--vnc-no-passwordfor the shot, which the server warns about.That screen in TigerVNC's viewer, with a terminal opened on it.
Security
--vnc-password-fileorGLIFF_VNC_PASSWORD, unless--vnc-no-passwordis given.docs/vnc.mdsays plainly that VNC Authentication uses only the first 8 characters of the password and does not encrypt the session. It advises keeping the port to your own devices or behind an ssh tunnel.Testing
scripts/check.shpasses, with the protocol tests ingliff-vnc. Eight combinations of protocol version, encoding and pixel format decode back pixel for pixel: 786,432 of 786,432 pixels match.Hola ñandú AÉ!? 123 ~/{x}andacción €came out as typed.--output eDP-1served the built-in screen.