Adding boundary security in Current coordinates setter#20067
Merged
Conversation
Contributor
There was a problem hiding this comment.
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
currentCoordinatesproperty onMagnifierthat clamps coordinates on assignment via_clampCoordinates. - Updated key magnifier lifecycle paths (
_startMagnifier,_updateMagnifier,_pan) and unit tests to usecurrentCoordinatesinstead of direct_currentCoordinatesassignment. - 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. |
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:
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: