Repository navigation
fix: a11y: magnifier: correct focal-point math and update focal point on zoom-in - #2533
Merged
Merged
Conversation
Drakulix
reviewed
Jul 8, 2026
Drakulix
left a comment
Member
There was a problem hiding this comment.
Code wise this looks good, just a couple of nitpicks. Obviously this will need to go through QA first, but thanks a lot for working on this!
…fresh focal point at zoom-in - I used AI to assist in research of the focal point computation formulae for OnEdge and Centered modes. - I used the formulas found in [KDE's zoom magnifier](https://invent.kde.org/plasma/kwin/-/blob/master/src/plugins/zoom/zoom.cpp) and converted them to Rust and the COSMIC focal point system. - Remove unnecessary focal-point precomputation in `OutputZoomState::new`, because it is now updated on first zoom in anyway. - Do focal point computation in Local coordinates in update_focal_point to eliminate local-global conversion confusion/ issues. - ZoomMovement::OnEdge - single code path rewrite - old two-branch logic caused jumping and unpredictability at high zoom. Fixes [pop-os#2683](pop-os/cosmic-epoch#2683), partially addresses [pop-os#2688](pop-os/cosmic-epoch#2688). - ZoomMovement::Centered - translation/clamp/invert - prevents "blow up" of calculation at zoom level > 2.0 that caused cursor to disappear off bottom right of screen. Fixes [pop-os#1503](pop-os#1503). - `is_level_change` - sets `previous_point` so that `animating_focal_point` interpolates instead of jumping. Still room for improvement (needs focal point recomputation per-frame during animation to prevent "boomerang" feel), but this is still an improvement over jumping. - In `trigger_zoom`, call `update_focal_point` when `level > 1.0` - overlaps proposal in [pop-os#1859](pop-os#1859) + the level gate to prevent stale focal point on zoom in. Fixes [pop-os#2511](pop-os#2511) and [pop-os#1883](pop-os/cosmic-epoch#1883). Partially addresses [pop-os#1420](pop-os#1420) (item 1 only).
…Movement::Centered
tgrushka
force-pushed
the
fix-centered-and-onedge-movement
branch
from
July 8, 2026 20:48
39e1453 to
ad6a00b
Compare
leviport
approved these changes
Jul 9, 2026
leviport
left a comment
Member
There was a problem hiding this comment.
Seems to be working nicely. Thanks!
Contributor
Author
Drakulix
approved these changes
Jul 13, 2026
Member
All good! Just needed to find the time to look into the code again. Thanks again :) |
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.
Happy Disability Pride Month!
I am celebrating this occasion as a legally blind contributor to help improve the magnifier for the COSMIC user community.
Feedback and suggestions for revisions welcome.
Summary
This PR corrects the focal-point math in
ZoomMovement::CenteredandOnEdge(which broke and caused jumping at high zoom levels) and refreshes the stale focal point on zoom in.Use of AI / references
I used AI to assist in research of the focal point computation formulae for OnEdge and Centered modes.
I co-wrote the final formulas with AI assistance and my corrections. I tested the formulas.
I used the formulas found in KDE's zoom magnifier - link directly to zoom.cpp and converted them to Rust and the COSMIC focal point system.
Changes
Remove unnecessary focal point precomputation in
OutputZoomState::new, because it is now updated on first zoom in anyway.Do focal point computation in
Localcoordinates inupdate_focal_pointto eliminate local-global conversion confusion / issues.ZoomState::update_focal_pointZoomMovement::OnEdgebranch - single code path rewrite - old two-branch logic caused jumping and unpredictability at high zoom. Fixes #2683, partially addresses #2688.ZoomMovement::Centeredbranch - translation/clamp/invert - prevents "blow up" of calculation at zoom level > 2.0 that caused cursor to disappear off bottom right of screen. Fixes #1503.is_level_change- setsprevious_pointso thatanimating_focal_pointinterpolates instead of jumping. Still room for improvement (needs focal point recomputation per-frame during animation to prevent "boomerang" feel), but this is still an improvement over jumping.In
Shell::trigger_zoom, callZoomState::update_focal_pointwhenlevel > 1.0- overlaps proposal in #1859 + the level gate to prevent stale focal point on zoom in. Fixes #2511 and #1883. Partially addresses #1420 (item 1 only).I have disclosed use of any AI generated code in my commit messages.
I understand these changes in full and will be able to respond to review comments.
My change is accurately described in the commit message.
My contribution is tested and working as described.
I have read the Developer Certificate of Origin and certify my contribution under its conditions.