Skip to content

Adding boundary security in Current coordinates setter#20067

Merged
seanbudd merged 2 commits into
nvaccess:masterfrom
France-Travail:fix/ScreenBoundaries
May 6, 2026
Merged

Adding boundary security in Current coordinates setter#20067
seanbudd merged 2 commits into
nvaccess:masterfrom
France-Travail:fix/ScreenBoundaries

Conversation

@Boumtchack
Copy link
Copy Markdown
Contributor

@Boumtchack Boumtchack commented May 6, 2026

Link to issue number:

fix #19878

Summary of the issue:

The magnifier could receive focus coordinates outside the screen boundaries, which allowed the magnified view to drift beyond the visible area depending on the mode.

Description of user facing changes:

The magnifier now stays within screen boundaries at all times, in both normal mode and true center mode. This makes the visible behavior more stable and prevents off-screen overflow.

Description of developer facing changes:

Automatic boundary protection was added through a currentCoordinates property that clamps coordinates on every assignment. The main magnifier lifecycle paths and pan logic now use this property, which centralizes validation and removes unsafe direct coordinate handling.

Description of development approach:

I isolated the nearest control point for magnifier coordinates, then added reusable clamping logic based on the existing screen limit calculation.

Testing strategy:

Unit

Known issues with pull request:

Code Review Checklist:

  • Documentation:
    • Change log entry
    • User Documentation
    • Developer / Technical Documentation
    • Context sensitive help for GUI changes
  • Testing:
    • Unit tests
    • System (end to end) tests
    • Manual testing
  • UX of all users considered:
    • Speech
    • Braille
    • Low Vision
    • Different web browsers
    • Localization in other languages / culture than English
  • API is compatible with existing add-ons.
  • Security precautions taken.

@Boumtchack Boumtchack marked this pull request as ready for review May 6, 2026 12:34
@Boumtchack Boumtchack requested a review from a team as a code owner May 6, 2026 12:34
@Boumtchack Boumtchack requested review from Copilot and seanbudd May 6, 2026 12:34
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses issue #19878 by centralizing magnifier coordinate validation so that focus / pan coordinates are clamped to screen limits, preventing the magnified view from drifting into off-screen/black regions.

Changes:

  • Added a currentCoordinates property on Magnifier that clamps coordinates on assignment via _clampCoordinates.
  • Updated key magnifier lifecycle paths (_startMagnifier, _updateMagnifier, _pan) and unit tests to use currentCoordinates instead of direct _currentCoordinates assignment.
  • Added unit tests to exercise coordinate clamping behavior.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
source/_magnifier/magnifier.py Introduces coordinate clamping via currentCoordinates and routes lifecycle/pan updates through it.
tests/unit/test_magnifier/test_magnifier.py Updates existing tests for the new property and adds new tests for clamping behavior.

Comment thread source/_magnifier/magnifier.py
Comment thread source/_magnifier/magnifier.py
Comment thread tests/unit/test_magnifier/test_magnifier.py
Copy link
Copy Markdown
Member

@seanbudd seanbudd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @Boumtchack

@seanbudd seanbudd merged commit 364c109 into nvaccess:master May 6, 2026
61 of 73 checks passed
@github-actions github-actions Bot added this to the 2026.2 milestone May 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Magnifier: Screen turns black in VS Code due to lack of screen boundary protection when acquiring coordinates

3 participants