Only restore braille on secure desktop exit, not on ordinary desktop switches#20550
Open
LeonarddeR wants to merge 2 commits into
Open
Only restore braille on secure desktop exit, not on ordinary desktop switches#20550LeonarddeR wants to merge 2 commits into
LeonarddeR wants to merge 2 commits into
Conversation
…switches (nvaccess#18810) BrailleHandler._onSecureDesktopStateChanged re-ran display detection (or re-set the configured display) whenever a desktop switch away from the secure desktop was reported. Ordinary desktop switches -- e.g. input desktop switches in a Remote Desktop session when focus moves between the session and the local machine -- are reported the same way, so a working braille display was repeatedly disconnected and re-detected. Only restore the display when it differs from the last requested one, i.e. when it was actually replaced by the secure desktop noBraille fallback (which does not update _lastRequestedDisplayName). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR refines NVDA’s braille secure-desktop handling to avoid unnecessary braille display teardown/re-detection on desktop switches that never entered the Secure Desktop (notably Remote Desktop session focus changes). It adjusts the restore path so it only runs when the current display differs from the last requested display, which is intended to indicate the Secure Desktop fallback was activated.
Changes:
- Guard braille “restore” behavior on
isSecureDesktop=Falseso ordinary desktop switches don’t re-run display selection/detection. - Add a user-facing changelog entry describing the reduced braille churn on non-secure desktop switches.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
source/braille/brailleHandler.py |
Adds an early-return guard to avoid restoring/re-detecting braille on ordinary desktop switches. |
user_docs/en/changes.md |
Documents the user-visible fix for braille churn on non-secure desktop switches (e.g. Remote Desktop focus changes). |
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.
Link to issue number:
Fixup for #18810
Summary of the issue:
Since #18810, NVDA frees the braille display when switching to the secure desktop and restores it
when returning to a user desktop. However, the restore branch also runs on desktop switches that
never entered the secure desktop. Moving input focus between a Remote Desktop session and the local
machine generates
EVENT_SYSTEM_DESKTOPSWITCHin the remote session, sobraille.handler._onSecureDesktopStateChangedis invoked withisSecureDesktop=Falseeven thoughthe secure desktop was never active. This re-runs braille display detection (or re-sets the
configured display), repeatedly disconnecting and re-detecting a working display. For remote braille
(e.g. RDAccess) each such switch causes a full channel teardown and re-handshake, so braille churns
on every alt+tab / focus change.
Description of user facing changes:
The braille display is no longer briefly disconnected and re-detected on desktop switches that do not
enter the secure desktop, such as switching between a Remote Desktop session and the local machine.
Description of developer facing changes:
None.
Description of development approach:
In
BrailleHandler._onSecureDesktopStateChanged, when returning to a user desktop(
isSecureDesktop=False), only restore the display when the current display differs from_lastRequestedDisplayName. Switching to the secure desktop replaces the display with thenoBraillefallback viasetDisplayByName(..., isFallback=True), which deliberately does not update_lastRequestedDisplayName. So a current display equal to_lastRequestedDisplayNamemeans thedisplay was never freed (an ordinary desktop switch) and there is nothing to restore. This covers
both automatic detection (where
_lastRequestedDisplayNameholds the detected driver name) and amanually configured display (where it equals the configured display). Entering the secure desktop is
unchanged, so the display is still freed there.
Testing strategy:
Manually tested in a Remote Desktop session with a braille display, switching focus between the
session and the local machine (alt+tab / Windows+D): the display is no longer repeatedly
disconnected and re-detected. Verified a genuine secure desktop transition (UAC prompt) still frees
and then restores the display.
Known issues with pull request:
autoScrollandmainBufferare still cleared at the top of_onSecureDesktopStateChangedon everyreported desktop switch, so an ordinary switch still briefly clears the braille buffer (no reconnect).
This is unchanged behaviour and could be addressed separately.
Code Review Checklist:
🤖 Generated with Claude Code