[PR #5609] [MERGED] Adjust TSFInputControl alignment #26389

Open
opened 2026-01-31 09:15:45 +00:00 by claunia · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/microsoft/terminal/pull/5609
Author: @leonMSFT
Created: 4/28/2020
Status: Merged
Merged: 4/28/2020
Merged by: @undefined

Base: masterHead: dev/lelian/tsfbugaroos


📝 Commits (3)

  • e1737c4 i think this is right
  • e59a1db uh i forgot what is in this commit
  • ca78b64 trying to make muh comments as clear as possible

📊 Changes

2 files changed (+26 additions, -8 deletions)

View changed files

📝 src/cascadia/TerminalControl/TSFInputControl.cpp (+25 -8)
📝 src/cascadia/TerminalControl/TSFInputControl.h (+1 -0)

📄 Description

This PR fixes a couple of issues with TSFInputControl alignment:

  1. The emoji picker IME in particular would show up overlapping the
    current buffer row because I stupidly didn't realize that
    TextBlock.ActualHeight is 0 right after initialization and before
    it has any text. So, the emoji picker will show up on the bottom of
    the 0 height TextBlock, which overlaps the current buffer row. This
    isn't a problem with CJK because inputting text causes the IME to
    show up, so by the time the IME shows up, the TextBlock has text and
    accordingly has a height.
  2. It turns out the emoji picker IME doesn't follow the TextBlock
    bottom, unlike Chinese and Japanese IME, so if a user were to compose
    near the edge of the screen and let the TextBlock start line
    wrapping, the emoji IME doesn't follow the bottom of the TextBlock
    as it grows. This means that the TextBlock position doesn't update
    in the middle of composition, and the LayoutRequested event that it
    fires at the beginning of composition is the only chance we get to
    tell the emoji IME where to place itself. It turns out when we reset
    TextBlock.Text, the ActualHeight doesn't get immediately reset back
    to the min size. So if a user were to bring up the emoji IME before
    ActualHeight is reset, the IME will show up way below the current
    buffer row.
  3. We don't currently TryRedrawCanvas when the window position changes
    (resizing, dragging the window around), so sometimes dragging or
    resizing the Terminal doesn't update the position of the IME. Ideally
    it should be listening to some "window position changed" event, but
    alas we don't have that and it would be much harder than this
    incoming fix. We'll just track the window bounds as part of
    TryRedrawCanvas and redraw if it changes. For the most part, this
    will allow the IME to update to where the new window position is, but
    it'll only be called if we receive a LayoutRequested event.

PR Checklist

Validation Steps Performed

I play with it for quite a bit.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/microsoft/terminal/pull/5609 **Author:** [@leonMSFT](https://github.com/leonMSFT) **Created:** 4/28/2020 **Status:** ✅ Merged **Merged:** 4/28/2020 **Merged by:** [@undefined](undefined) **Base:** `master` ← **Head:** `dev/lelian/tsfbugaroos` --- ### 📝 Commits (3) - [`e1737c4`](https://github.com/microsoft/terminal/commit/e1737c45614726d0f1e9ce3d0dbb7d58e9f5ce3e) i think this is right - [`e59a1db`](https://github.com/microsoft/terminal/commit/e59a1dbde8e55317b863af7b24b174f479f0fc73) uh i forgot what is in this commit - [`ca78b64`](https://github.com/microsoft/terminal/commit/ca78b64ce392cc4a4eaf1cab32a9f4026a367829) trying to make muh comments as clear as possible ### 📊 Changes **2 files changed** (+26 additions, -8 deletions) <details> <summary>View changed files</summary> 📝 `src/cascadia/TerminalControl/TSFInputControl.cpp` (+25 -8) 📝 `src/cascadia/TerminalControl/TSFInputControl.h` (+1 -0) </details> ### 📄 Description This PR fixes a couple of issues with TSFInputControl alignment: 1. The emoji picker IME in particular would show up overlapping the current buffer row because I stupidly didn't realize that `TextBlock.ActualHeight` is 0 right after initialization and before it has any text. So, the emoji picker will show up on the bottom of the 0 height TextBlock, which overlaps the current buffer row. This isn't a problem with CJK because inputting text _causes_ the IME to show up, so by the time the IME shows up, the TextBlock has text and accordingly has a height. 2. It turns out the emoji picker IME doesn't follow the `TextBlock` bottom, unlike Chinese and Japanese IME, so if a user were to compose near the edge of the screen and let the `TextBlock` start line wrapping, the emoji IME doesn't follow the bottom of the `TextBlock` as it grows. This means that the `TextBlock` position doesn't update in the middle of composition, and the `LayoutRequested` event that it fires at the beginning of composition is the only chance we get to tell the emoji IME where to place itself. It turns out when we reset `TextBlock.Text`, the ActualHeight doesn't get immediately reset back to the min size. So if a user were to bring up the emoji IME before `ActualHeight` is reset, the IME will show up way below the current buffer row. 3. We don't currently `TryRedrawCanvas` when the window position changes (resizing, dragging the window around), so sometimes dragging or resizing the Terminal doesn't update the position of the IME. Ideally it should be listening to some "window position changed" event, but alas we don't have that and it would be much harder than this incoming fix. We'll just track the window bounds as part of `TryRedrawCanvas` and redraw if it changes. For the most part, this will allow the IME to update to where the new window position is, but it'll only be called if we receive a `LayoutRequested` event. ## PR Checklist * [x] Closes #5470 * [x] CLA signed. * [x] Tests added/passed ## Validation Steps Performed I play with it for quite a bit. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
claunia added the pull-request label 2026-01-31 09:15:45 +00:00
Sign in to join this conversation.
No Label pull-request
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#26389