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

Raise ShortcutActions with the sender (tab, control) context #15773

Merged
merged 14 commits into from Aug 24, 2023

Conversation

zadjii-msft
Copy link
Member

@zadjii-msft zadjii-msft commented Jul 27, 2023

This PR's goal is to allow something like a Tab to raise a ShortcutAction, by saying "this action should be performed on ME". We've had a whole category of these issues in the past:

So, this tries to remove a bit of that footgun. This probably isn't the final form of what this refactor might look like, but the code is certainly better than before.

Basically, there's a few bits:

  • ShortcutActionDispatch.DoAction now takes a sender, which can be anything.
  • Most actions that use a "Get the focused thing then do something to it" are changed to "If there was a sender, let's use that - otherwise, we'll use the focused thing".
  • TerminalTab was largely refactored to use this, instead of making requests to the TerminalPage to just do a thing to it.

I've got a few TODO!s left, but wanted to get initial feedback.

  • TerminalPage::_HandleTogglePaneZoom
  • TerminalPage::_HandleFocusPane
  • TerminalPage::_MoveTab

Closes #15734

@microsoft-github-policy-service microsoft-github-policy-service bot added Issue-Bug It either shouldn't be doing this or needs an investigation. Area-User Interface Issues pertaining to the user interface of the Console or Terminal Product-Terminal The new Windows Terminal. labels Jul 27, 2023
@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@zadjii-msft zadjii-msft marked this pull request as ready for review August 2, 2023 22:03
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.

Third thought about using actions: actually, I like it even more than I expected. It removes the handlers dance from Page.

src/cascadia/TerminalApp/TerminalPage.cpp Outdated Show resolved Hide resolved
src/cascadia/TerminalApp/TerminalPage.cpp Show resolved Hide resolved
src/cascadia/TerminalApp/TerminalTab.cpp Show resolved Hide resolved
src/cascadia/TerminalApp/TerminalTab.cpp Outdated Show resolved Hide resolved
src/cascadia/TerminalApp/TerminalTab.cpp Outdated Show resolved Hide resolved
Comment on lines +534 to +535
winrt::Microsoft::Terminal::Control::TermControl _senderOrActiveControl(const winrt::Windows::Foundation::IInspectable& sender);
winrt::com_ptr<TerminalTab> _senderOrFocusedTab(const IInspectable& sender);
Copy link
Member

Choose a reason for hiding this comment

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

For the future: technically, we might want the concept of a "stack" of senders. A message coming from a control has an associated pane and tab and eventually, window. Those things might matter to different recipients, or different action types.

Copy link
Member

@lhecker lhecker left a comment

Choose a reason for hiding this comment

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

Exactly what Dustin said. LGTM though.

@zadjii-msft zadjii-msft merged commit 30eb9ee into main Aug 24, 2023
17 checks passed
@zadjii-msft zadjii-msft deleted the dev/migrie/f/action-dispatch-with-sender branch August 24, 2023 15:31
@DHowett DHowett added this to To Cherry Pick in 1.18 Servicing Pipeline via automation Sep 6, 2023
@DHowett DHowett moved this from To Cherry Pick to Cherry Picked in 1.18 Servicing Pipeline Sep 22, 2023
DHowett pushed a commit that referenced this pull request Sep 22, 2023
This PR's goal is to allow something like a `Tab` to raise a
ShortcutAction, by saying "this action should be performed on ME". We've
had a whole category of these issues in the past:

* #15734
* #15760
* #13579
* #13942
* #13942
* Heck even dating back to #10832

So, this tries to remove a bit of that footgun. This probably isn't the
_final_ form of what this refactor might look like, but the code is
certainly better than before.

Basically, there's a few bits:

* `ShortcutActionDispatch.DoAction` now takes a `sender`, which can be
_anything_.
* Most actions that use a "Get the focused _thing_ then do something to
it" are changed to "If there was a sender, let's use that - otherwise,
we'll use the focused _thing_".
* TerminalTab was largely refactored to use this, instead of making
requests to the `TerminalPage` to just do a thing to it.

I've got a few TODO!s left, but wanted to get initial feedback.
* [x] `TerminalPage::_HandleTogglePaneZoom`
* [x] `TerminalPage::_HandleFocusPane`
* [x] `TerminalPage::_MoveTab`

Closes #15734

(cherry picked from commit 30eb9ee)
Service-Card-Id: 90438493
Service-Version: 1.18
@DHowett DHowett moved this from Cherry Picked to Validated in 1.18 Servicing Pipeline Oct 3, 2023
@DHowett DHowett moved this from Validated to Shipped in 1.18 Servicing Pipeline Oct 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-User Interface Issues pertaining to the user interface of the Console or Terminal Issue-Bug It either shouldn't be doing this or needs an investigation. Product-Terminal The new Windows Terminal. zBugBash-Consider
Projects
Development

Successfully merging this pull request may close these issues.

"Move Tab to New Window" context menu item uses focused tab
3 participants