Skip to content

wpf: use the new TSF implementation #18861

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

Merged
merged 3 commits into from
May 2, 2025
Merged

wpf: use the new TSF implementation #18861

merged 3 commits into from
May 2, 2025

Conversation

DHowett
Copy link
Member

@DHowett DHowett commented May 1, 2025

This fixes two issues in the WPF terminal control:

  • The emoji picker and other IME candidate windows didn't show up in the right place
  • Submitting an emoji via the emoji picker would result in two win32 input mode events with a VK of 65535 and the surrogate pair halves.

I am not sure I did the right thing with the thread TSF handle...

DHowett added 2 commits April 30, 2025 21:23
This fixes two issues in the WPF terminal control:
- The emoji picker and other IME candidate windows didn't show up in the
  right place
- Submitting an emoji via the emoji picker would result in two win32
  input mode events with a VK of 65535 and the surrogate pair halves.

I am not sure I did the right thing with the thread TSF handle...
Comment on lines 67 to 72
fontSize = _terminal->_actualFont.GetSize();
}
POINT ptSuggestion = {
.x = cursorPos.x * fontSize.width,
.y = cursorPos.y * fontSize.height,
};
Copy link
Member

Choose a reason for hiding this comment

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

The _actualFont.GetSize() is in pixel?

Comment on lines 125 to 126
Microsoft::Console::TSF::Handle _tsfHandle;
TsfDataProvider _tsfDataProvider;
Copy link
Member

Choose a reason for hiding this comment

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

The destruction order is wrong here. You need to destroy the Handle first, since the TsfDataProvider doesn't properly implement AddRef/Release. I think this is worth commenting as well.

Copy link
Member

Choose a reason for hiding this comment

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

(Dustin showed me that Teardown does it in the right order.)

@@ -171,7 +243,8 @@ HwndTerminal::HwndTerminal(HWND parentHwnd) noexcept :
_uiaProvider{ nullptr },
_currentDpi{ USER_DEFAULT_SCREEN_DPI },
_pfnWriteCallback{ nullptr },
_multiClickTime{ 500 } // this will be overwritten by the windows system double-click time
_multiClickTime{ 500 }, // this will be overwritten by the windows system double-click time
_tsfDataProvider{ this }
Copy link
Member

Choose a reason for hiding this comment

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

FWIW I believe you can also use { this } in the header.

@@ -242,6 +315,11 @@ try
{
// As a rule, detach resources from the Terminal before shutting them down.
// This ensures that teardown is reentrant.
if (_tsfHandle)
{
_tsfHandle.Unfocus(&_tsfDataProvider);
Copy link
Member

Choose a reason for hiding this comment

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

I believe you don't need to unfocus during teardown. Re-reading its implementation shows that it is primarily concerned with clearing the pending compositions out of the renderer.

@DHowett DHowett merged commit 06f736b into main May 2, 2025
19 checks passed
@DHowett DHowett deleted the dev/duhowett/wpf-tsf branch May 2, 2025 23:30
@github-project-automation github-project-automation bot moved this to To Cherry Pick in 1.23 Servicing Pipeline May 2, 2025
@github-project-automation github-project-automation bot moved this to To Cherry Pick in 1.22 Servicing Pipeline May 2, 2025
@DHowett DHowett moved this from To Cherry Pick to Cherry Picked in 1.22 Servicing Pipeline May 5, 2025
@DHowett DHowett moved this from To Cherry Pick to Cherry Picked in 1.23 Servicing Pipeline May 5, 2025
DHowett added a commit that referenced this pull request May 5, 2025
This fixes two issues in the WPF terminal control:
- The emoji picker and other IME candidate windows didn't show up in the
right place
- Submitting an emoji via the emoji picker would result in two win32
input mode events with a VK of 65535 and the surrogate pair halves.

I am not sure I did the right thing with the thread TSF handle...

(cherry picked from commit 06f736b)
Service-Card-Id: PVTI_lADOAF3p4s4AxadtzgZ-Sw0
Service-Version: 1.23
DHowett added a commit that referenced this pull request May 5, 2025
This fixes two issues in the WPF terminal control:
- The emoji picker and other IME candidate windows didn't show up in the
right place
- Submitting an emoji via the emoji picker would result in two win32
input mode events with a VK of 65535 and the surrogate pair halves.

I am not sure I did the right thing with the thread TSF handle...

(cherry picked from commit 06f736b)
Service-Card-Id: PVTI_lADOAF3p4s4AmhmQzgZ-Sw4
Service-Version: 1.22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Cherry Picked
Status: Cherry Picked
Development

Successfully merging this pull request may close these issues.

2 participants