[PR #4748] [CLOSED] TermControl: rework input and focus handling #25925

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

📋 Pull Request Information

Original PR: https://github.com/microsoft/terminal/pull/4748
Author: @DHowett-MSFT
Created: 2/28/2020
Status: Closed

Base: masterHead: dev/duhowett/be_my_input_sink


📝 Commits (3)

  • bfdce8f TermControl: rework input and focus handling
  • ec22e43 Merge remote-tracking branch 'origin/master' into dev/duhowett/be_my_input_sink
  • 8881ce1 Merge remote-tracking branch 'origin/master' into dev/duhowett/be_my_input_sink

📊 Changes

7 files changed (+55 additions, -80 deletions)

View changed files

📝 src/cascadia/TerminalControl/SearchBoxControl.cpp (+7 -27)
📝 src/cascadia/TerminalControl/SearchBoxControl.h (+2 -3)
📝 src/cascadia/TerminalControl/SearchBoxControl.idl (+0 -2)
📝 src/cascadia/TerminalControl/SearchBoxControl.xaml (+2 -2)
📝 src/cascadia/TerminalControl/TermControl.cpp (+22 -29)
📝 src/cascadia/TerminalControl/TermControl.h (+2 -3)
📝 src/cascadia/TerminalControl/TermControl.xaml (+20 -14)

📄 Description

This commit changes how we handle focus and tabstop-ness in TermControl
and its descendent controls.

The root of the issue that #4031 set out to investigate is that
TermControl hosts a bunch of other controls, but it's using event
tunneling to get first dibs on every bit of keyboard input sent its way
-- even for things that live inside it. This required us to hack around
and detemrine whether the input was intended for someone else before
eventually ignoring it or using it.

I believe the correct thing for us to do is to direct user keyboard
input to a control that lives logically "inside" the terminal surface
and have that control hold focus and process keyboard events.

Herein, we introduce an empty and invisible UserControl to hold focus
inside the terminal surface. Everything I've tested works great here.

It's important to note that the UserControl is invisible. Unfortunately,
this means that it can't receive mouse input. Its parent, the
SwapChainPanel acting as the terminal surface, can.

I've gone through and unmarked things that should not show up in the
tabstop list and changed the focus parameters for things that should.

Doing this lets us kill TermControl's dependency on all private details
in SearchBoxControl, including the bit where we could ask "do you think
you should be focused?", by letting Xaml handle focus. We now listen to
more focus events and funnel focus where we think it belongs. For
SearchBoxControl, that means we focus the text field and continue to
select all the text in it when the SearchBoxControl gets focus.

Fixes #4031.
This is an alternative solution to #4723, so I reverted that fix.

PR Checklist


🔄 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/4748 **Author:** [@DHowett-MSFT](https://github.com/DHowett-MSFT) **Created:** 2/28/2020 **Status:** ❌ Closed **Base:** `master` ← **Head:** `dev/duhowett/be_my_input_sink` --- ### 📝 Commits (3) - [`bfdce8f`](https://github.com/microsoft/terminal/commit/bfdce8ff837256522e0175536e036adf2b7d3b96) TermControl: rework input and focus handling - [`ec22e43`](https://github.com/microsoft/terminal/commit/ec22e43743ee9ea5fdb5bed7343e80bc9769fb8b) Merge remote-tracking branch 'origin/master' into dev/duhowett/be_my_input_sink - [`8881ce1`](https://github.com/microsoft/terminal/commit/8881ce15f01a12ff54635f47b031382e4c8571b5) Merge remote-tracking branch 'origin/master' into dev/duhowett/be_my_input_sink ### 📊 Changes **7 files changed** (+55 additions, -80 deletions) <details> <summary>View changed files</summary> 📝 `src/cascadia/TerminalControl/SearchBoxControl.cpp` (+7 -27) 📝 `src/cascadia/TerminalControl/SearchBoxControl.h` (+2 -3) 📝 `src/cascadia/TerminalControl/SearchBoxControl.idl` (+0 -2) 📝 `src/cascadia/TerminalControl/SearchBoxControl.xaml` (+2 -2) 📝 `src/cascadia/TerminalControl/TermControl.cpp` (+22 -29) 📝 `src/cascadia/TerminalControl/TermControl.h` (+2 -3) 📝 `src/cascadia/TerminalControl/TermControl.xaml` (+20 -14) </details> ### 📄 Description This commit changes how we handle focus and tabstop-ness in TermControl and its descendent controls. The root of the issue that #4031 set out to investigate is that TermControl hosts a bunch of other controls, but it's using event tunneling to get first dibs on every bit of keyboard input sent its way -- even for things that live inside it. This required us to hack around and detemrine whether the input was intended for someone else before eventually ignoring it or using it. I believe the _correct_ thing for us to do is to direct user keyboard input to a control that lives logically "inside" the terminal surface and have that control hold focus and process keyboard events. Herein, we introduce an empty and invisible UserControl to hold focus inside the terminal surface. Everything I've tested works great here. It's important to note that the UserControl is invisible. Unfortunately, this means that it can't receive **mouse** input. Its parent, the SwapChainPanel acting as the terminal surface, can. I've gone through and unmarked things that should not show up in the tabstop list and changed the focus parameters for things that should. Doing this lets us kill TermControl's dependency on all private details in SearchBoxControl, including the bit where we could ask "do you think you should be focused?", by letting Xaml handle focus. We now listen to more focus events and funnel focus where we think it belongs. For SearchBoxControl, that means we focus the text field and continue to select all the text in it when the SearchBoxControl gets focus. Fixes #4031. This is an alternative solution to #4723, so I reverted that fix. ## PR Checklist * [x] Closes #4031 * [x] CLA signed * [x] I've discussed this with core contributors already. --- <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:12:40 +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#25925