Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix UIA RangeFromPoint API #17695

Merged
merged 4 commits into from
Aug 20, 2024
Merged

Fix UIA RangeFromPoint API #17695

merged 4 commits into from
Aug 20, 2024

Conversation

carlos-zamora
Copy link
Member

Summary of the Pull Request

Fixes the RangeFromPoint API such that we're now properly locking when we attempt to retrieve the viewport data. This also corrects the conversion from UiaPoint (screen position) to buffer coordinates (buffer cell).

Closes #17579

Detailed Description of the Pull Request / Additional comments

  • UiaTextRangeBase::Initialize(UiaPoint):
    • reordered logic to clamp to client area first, then begin conversion to buffer coordinates
    • properly lock when retrieving the viewport data
  • updated _TranslatePointToScreen and _TranslatePointFromScreen to use & instead of *
    • we weren't properly updating the parameter before
  • TermControlUiaTextRange::_TranslatePointFromScreen()
    • includeOffsets was basically copied over from _TranslatePointToScreen. The math itself was straight up wrong since we had to do it backwards.

Validation Steps Performed

✅ Moved WT to top-left of monitor, then used inspect.exe to call RangeFromPoint API when mouse cursor is on top-left buffer cell (also meticulously stepped through the two functions ensuring everything was correct).

@microsoft-github-policy-service microsoft-github-policy-service bot added Issue-Bug It either shouldn't be doing this or needs an investigation. Area-Accessibility Issues related to accessibility Product-Terminal The new Windows Terminal. labels Aug 9, 2024
{
ScreenToClient(_getWindowHandle(), screenPoint->as_win32_point());
ScreenToClient(_getWindowHandle(), screenPoint.as_win32_point());
Copy link
Member

Choose a reason for hiding this comment

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

@lhecker this weirds me out - I think we are writing through the return value of as_win32_point? Is that safe?

Copy link
Member

Choose a reason for hiding this comment

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

It's definitely less than 3.6 roentgen.

Copy link
Member

@DHowett DHowett left a comment

Choose a reason for hiding this comment

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

(reversion)

@microsoft-github-policy-service microsoft-github-policy-service bot added the Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something label Aug 16, 2024
@microsoft-github-policy-service microsoft-github-policy-service bot removed the Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something label Aug 20, 2024
@DHowett DHowett merged commit 7b39d24 into main Aug 20, 2024
20 checks passed
@DHowett DHowett deleted the dev/cazamor/a11y/fix-rangefrompoint branch August 20, 2024 22:58
DHowett pushed a commit that referenced this pull request Aug 21, 2024
## Summary of the Pull Request
Fixes the `RangeFromPoint` API such that we're now properly locking when
we attempt to retrieve the viewport data. This also corrects the
conversion from `UiaPoint` (screen position) to buffer coordinates
(buffer cell).

Closes #17579

## Detailed Description of the Pull Request / Additional comments
- `UiaTextRangeBase::Initialize(UiaPoint)`:
- reordered logic to clamp to client area first, then begin conversion
to buffer coordinates
   - properly lock when retrieving the viewport data
- updated `_TranslatePointToScreen` and `_TranslatePointFromScreen` to
use `&` instead of `*`
   - we weren't properly updating the parameter before
- `TermControlUiaTextRange::_TranslatePointFromScreen()`
- `includeOffsets` was basically copied over from
`_TranslatePointToScreen`. The math itself was straight up wrong since
we had to do it backwards.

## Validation Steps Performed
✅ Moved WT to top-left of monitor, then used inspect.exe to call
`RangeFromPoint` API when mouse cursor is on top-left buffer cell (also
meticulously stepped through the two functions ensuring everything was
correct).

(cherry picked from commit 7b39d24)
Service-Card-Id: PVTI_lADOAF3p4s4AmhmszgSC930 PVTI_lADOAF3p4s4AmhmszgSCpCs
Service-Version: 1.21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Accessibility Issues related to accessibility Issue-Bug It either shouldn't be doing this or needs an investigation. Product-Terminal The new Windows Terminal.
Projects
Status: To Cherry Pick
Development

Successfully merging this pull request may close these issues.

RangeFromPoint and ExpandToEnclosingUnit freezes terminal
3 participants