Repository navigation
feat(kvm): start Windows remote-desktop sessions on the primary monitor - #177
Merged
Merged
Conversation
The Windows KVM started every session on all monitors combined, so the first frames of each session and recording showed the whole virtual desktop until the console switched to one display. A new KVM now selects the primary monitor (numbered like the display location message) when the machine has more than one; single-monitor machines keep streaming "all" as before. A selection that no longer exists (unplugged monitor, unknown id) falls back to the same default instead of capturing a stale rectangle. "All" (0xFFFF) stays supported.
🦩 Flamingo Code ReviewNot reviewed yet. Reviews start when you ask, so the reviewer reads this pull request when it is ready, not when it is opened. When it is ready:
Or comment Updated 2026-10-12 21:15 UTC · workflow run |
denys-gif
approved these changes
Oct 13, 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.
Description
The Windows KVM started every remote-desktop session on all monitors combined (
SCREEN_SEL/SCREEN_SEL_TARGET= 0). The console switched to one display only after the display list arrived, so the first frames of every session and every recording showed the whole virtual desktop.A new KVM (fresh child process: new session, or re-spawn after a desktop switch) now selects the primary monitor (
MONITORINFOF_PRIMARY) on its first look at the displays, numbered like the display-location message (cmd 82) that the console reads. The first display list already reports it as selected, so the console has nothing to switch.Behaviour kept:
0xFFFFinMNG_KVM_SET_DISPLAY) still works; the UI does not offer it.New fallback: a selected display that no longer exists (unplugged, or an unknown id) now falls back to the primary instead of capturing the stale rectangle of the vanished monitor.
Improvements
kvm_default_display(): primary display index with several monitors (the first one if none is flagged), 0 with one.CheckDesktopSwitch: on the first display count of a KVM process, start on that display; when the enumerator cannot find the selected display, fall back to it.Safety / compatibility:
main): identifies the primary as the cmd-82 display at 0,0 and only switches when the agent is not on its target, so with this agent the start-of-session PAUSE / SET_DISPLAY / REFRESH round trip disappears; a technician's own pick is still re-applied after a reconnect or desktop switch. Older frontends see the primary selected and do not switch either.Testing:
-fsyntax-onlyofkvm.c: same diagnostics as master (MSVC-only__try).kvm.cagainst fake monitor layouts: 3 monitors with the primary enumerated second, switching, "all", unplug of the selected monitor, unknown id, unplug down to one monitor, single monitor, no primary flagged, input thread first, hot-plug. All pass on the branch; on master the start, fallback and no-primary cases fail. 7 mutations of the change are all caught.Known limits (unchanged from before):
DisplayInfoEnumProc(which applies a selection) counts only monitors named\\.\DISPLAY<n>, while cmd 82 and the new default count every monitor. On a machine with an oddly named display enumerated before the primary, the two numberings differ; explicit picks from the console already behave this way today.run/connect, testing only) runs the KVM as a thread that keeps its state, so only the first session of that process starts on the primary. OpenFrame installs the agent as a service (-install), where every session gets a fresh KVM process.Rollout: release a new meshagent version and bump
meshcentral.client.tag(0.0.29 on every environment today). The next release also carries #172.Task
ClickUp task: CU-17tkuw5v5zr [Mesh Agent] Windows: start every remote-screen session on the primary monitor
Change-Set: hotfix-win-kvm-primary-monitor
Change set
flamingo-stack/hotfix-win-kvm-primary-monitor: this pull request is the only one in it so far. Another pull request joins by naming this one in aDepends-Online, or by carrying the sameChange-Setline.Linked work
Linked by the
Depends-On/Change-Setlines in these descriptions; this block is maintained by the hub.