Skip to content

fix: a11y: magnifier: correct focal-point math and update focal point on zoom-in - #2533

Merged
Drakulix merged 4 commits into
pop-os:masterfrom
dra11y:fix-centered-and-onedge-movement
Jul 13, 2026
Merged

Drakulix merged 4 commits into
pop-os:masterfrom
dra11y:fix-centered-and-onedge-movement

Conversation

@tgrushka

@tgrushka tgrushka commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

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::Centered and OnEdge (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 Local coordinates in update_focal_point to eliminate local-global conversion confusion / issues.

  • ZoomState::update_focal_point

    • ZoomMovement::OnEdge branch - single code path rewrite - old two-branch logic caused jumping and unpredictability at high zoom. Fixes #2683, partially addresses #2688.

    • ZoomMovement::Centered branch - 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 - 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 Shell::trigger_zoom, call ZoomState::update_focal_point when level > 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.

    • If you are using an LLM, and do not fully understand the changes it is making to the code base, do not create a PR.
    • In our experience, AI generated code often results in overly complex code that lacks enough context for a proper fix or feature inclusion. This results in considerably longer code reviews. Due to this, AI authored or partially authored PRs may be closed without comment.
  • 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.

@Drakulix Drakulix left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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!

Comment thread src/shell/mod.rs Resolved
Comment thread src/shell/zoom.rs Resolved
@Drakulix
Drakulix requested a review from a team July 8, 2026 14:44
tgrushka added 3 commits July 8, 2026 14:48
…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).
@tgrushka
tgrushka force-pushed the fix-centered-and-onedge-movement branch from 39e1453 to ad6a00b Compare July 8, 2026 20:48
@leviport leviport self-assigned this Jul 9, 2026

@leviport leviport left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Seems to be working nicely. Thanks!

@leviport leviport removed their assignment Jul 9, 2026
@tgrushka

tgrushka commented Jul 10, 2026 •

Copy link
Copy Markdown
Contributor Author

Thanks for the reviews, @Drakulix and @leviport . Have I resolved the concerns and do you need anything else on this one? I just rebased and the clippy errors are in another module and unrelated to my changes. If the failing check is blocking, I can run clippy, if you want.

@Drakulix
Drakulix merged commit 0596cce into pop-os:master Jul 13, 2026
3 of 4 checks passed
@Drakulix

Copy link
Copy Markdown
Member

Have I resolved the concerns and do you need anything else on this one? I just rebased and the clippy errors are in another module and unrelated to my changes.

All good! Just needed to find the time to look into the code again. Thanks again :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

3 participants