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

Add support for renaming windows #9662

Merged
55 commits merged into from
Apr 2, 2021
Merged

Add support for renaming windows #9662

55 commits merged into from
Apr 2, 2021

Conversation

zadjii-msft
Copy link
Member

@zadjii-msft zadjii-msft commented Mar 30, 2021

Summary of the Pull Request

This PR adds support for renaming windows.

window-renaming-000
window-renaming-001

It does so through two new actions:

  • renameWindow takes a name parameter, and attempts to set the window's name
    to the provided name. This is useful if you always want to hit F3
    and rename a window to "foo" (READ: probably not that useful)
  • openWindowRenamer is more interesting: it opens a TeachingTip with a
    TextBox. When the user hits Ok, it'll request a rename for the provided
    value. This lets the user pick a new name for the window at runtime.

In both cases, if there's already a window with that name, then the monarch will
reject the rename, and pop a Toast in the window informing the user that the
rename failed. Nifty!

References

PR Checklist

Detailed Description of the Pull Request / Additional comments

I'm sending this PR while finishing up the tests. I figured I'll have time to sneak them in before I get the necessary reviews.

PAIN: We can't immediately focus the textbox in the TeachingTip. It's
not technically focusable until it is opened. However, it doesn't
provide an even tto tell us when it is opened. That's tracked in
microsoft/microsoft-ui-xaml#1607. So for now, the user needs to
click on the text box manually.
We're also not using a ContentDialog for this, because in Xaml
Islands a text box in a ContentDialog won't recieve any keypresses.
Fun!

Validation Steps Performed

I've been playing with

        { "keys": "f1", "command": "identifyWindow" },
        { "keys": "f2", "command": "identifyWindows" },
        { "keys": "f3", "command": "openWindowRenamer" },
        { "keys": "f4", "command": { "action": "renameWindow", "name": "foo" } },
        { "keys": "f5", "command": { "action": "renameWindow", "name": "bar" } },

and they seem to work as expected

  The history of this had gotten way, way too long. It included everything since I started working on this
  WE LIVE IN A MAD WORLD. Teaching tips are exactly the UI we want, but they
  just don't fucking work man. WE want them to light dismiss, but if the window
  is inactive, and you have ILDE=true, then the tip immediately dismisses
  itself. So inactive windows need to not enable light dismiss.

  ALSO we need inactive windows to not focus something when the tip dismisses
  itself. Like, focus was _nowhere_ when we started. We need to toss the focus
  back to _nowhere_.
(cherry picked from commit aa51c07)
(cherry picked from commit fa26f7f)
…dows-3

# Conflicts:
#	src/cascadia/Remoting/FindTargetWindowArgs.h
#	src/cascadia/Remoting/ProposeCommandlineResult.h
  add a test, and add liberal comments.
…Windows

# Conflicts:
#	src/cascadia/Remoting/WindowManager.cpp
#	src/cascadia/TerminalApp/Resources/en-US/Resources.resw
…windows

# Conflicts:
#	src/cascadia/TerminalApp/Resources/en-US/Resources.resw
#	src/cascadia/TerminalApp/TerminalPage.cpp
#	src/cascadia/TerminalApp/TerminalPage.h
#	src/cascadia/WindowsTerminal/AppHost.cpp
doc/cascadia/profiles.schema.json Outdated Show resolved Hide resolved
src/cascadia/Remoting/Monarch.cpp Show resolved Hide resolved
src/cascadia/TerminalApp/Resources/en-US/Resources.resw Outdated Show resolved Hide resolved
src/cascadia/TerminalApp/Resources/en-US/Resources.resw Outdated Show resolved Hide resolved
src/cascadia/TerminalApp/TerminalPage.xaml Outdated Show resolved Hide resolved
src/cascadia/TerminalApp/TerminalPage.xaml Show resolved Hide resolved
src/cascadia/TerminalApp/TerminalPage.xaml Show resolved Hide resolved
src/cascadia/TerminalApp/TerminalPage.xaml Outdated Show resolved Hide resolved
tools/README.md Show resolved Hide resolved
@zadjii-msft zadjii-msft added the AutoMerge Marked for automatic merge by the bot when requirements are met label Apr 2, 2021
@ghost
Copy link

ghost commented Apr 2, 2021

Hello @zadjii-msft!

Because this pull request has the AutoMerge label, I will be glad to assist with helping to merge this pull request once all check-in policies pass.

p.s. you can customize the way I help with merging this pull request, such as holding this pull request until a specific person approves. Simply @mention me (@msftbot) and give me an instruction to get started! Learn more here.

@ghost ghost merged commit fb597ed into main Apr 2, 2021
@ghost ghost deleted the dev/migrie/f/rename-windows branch April 2, 2021 16:00
ghost pushed a commit that referenced this pull request Apr 6, 2021
## Summary of the Pull Request

In exactly the same fashion as the tab renamer, handle <kbd>Enter</kbd> for committing the rename, and <kbd>Escape</kbd> for dismissing the rename.

## References
* Added in #9662

## PR Checklist
* [x] Closes #9720
* [x] I work here
* [n/a] Tests added/passed
* [n/a] Requires documentation to be updated

## Validation Steps Performed
Played with it - this feels good.
ghost pushed a commit that referenced this pull request Apr 7, 2021
## Summary of the Pull Request

Huh, I guess I missed making the window renamer light-dismissable. This is a oneline fix for that.

Light dismissing is treated as a _cancel_, not as a commit. 

## References
* Added in #9662

## PR Checklist
* [x] Closes #9718 
* [x] I work here
* [n/a] Tests added/passed
* [n/a] Requires documentation to be updated

## Validation Steps Performed

This feels right.
ghost pushed a commit that referenced this pull request Apr 7, 2021
## Summary of the Pull Request

Make sure that the window renamer and other toasts follow the requested app theme. We accomplish this by doing something similar to what we do with ContentDialogs. Since TeachingTips aren't in the same XAML root, we have to traverse the entire tree upwards setting RequestedTheme. If we don't, then we'll update the background color of the TeachingTip, but not the text inside it. 

## References
* Added in #9662 and #9523 

## PR Checklist
* [x] Closes #9717
* [x] I work here
* [n/a] Tests added/passed
* [n/a] Requires documentation to be updated

## Validation Steps Performed
Tested with system theme light & dark, and `theme` set to `light, dark, and unset, and verified that they worked as expected.
@ghost
Copy link

ghost commented Apr 14, 2021

🎉Windows Terminal Preview v1.8.1032.0 has been released which incorporates this pull request.:tada:

Handy links:

ghost pushed a commit that referenced this pull request Apr 14, 2021
## Summary of the Pull Request

Clearly, I didn't run these tests on my last commit where I made the toasts lazy-load.

## References
* broken in in #9662
* 
## PR Checklist
* [x] Closes #9769
* [x] I work here
* [x] Tests added/passed
* [n/a] Requires documentation to be updated

## Detailed Description of the Pull Request / Additional comments

For whatever reason, these tests are unhappy running back to back, but are just fine running isolated.
mpela81 pushed a commit to mpela81/terminal that referenced this pull request Apr 17, 2021
## Summary of the Pull Request

Clearly, I didn't run these tests on my last commit where I made the toasts lazy-load.

## References
* broken in in microsoft#9662
* 
## PR Checklist
* [x] Closes microsoft#9769
* [x] I work here
* [x] Tests added/passed
* [n/a] Requires documentation to be updated

## Detailed Description of the Pull Request / Additional comments

For whatever reason, these tests are unhappy running back to back, but are just fine running isolated.
ghost pushed a commit that referenced this pull request Apr 22, 2021
I added a `RenameSucceededText` property to the `TerminalPage` which returns the
formatted message `Successfully renamed window to "{WindowNameForDisplay()}"`

This _doesn't_ pop the dialog when you `wt -w foo` for the first time. Only
_subsequent_ renames.

## References
* Added in #9662
* Closes #9804
DHowett pushed a commit that referenced this pull request May 14, 2021
I added a `RenameSucceededText` property to the `TerminalPage` which returns the
formatted message `Successfully renamed window to "{WindowNameForDisplay()}"`

This _doesn't_ pop the dialog when you `wt -w foo` for the first time. Only
_subsequent_ renames.

## References
* Added in #9662
* Closes #9804

(cherry picked from commit aa54de1)
ghost pushed a commit that referenced this pull request Mar 31, 2022
Does what it says on the tin. This is maximal BODGE. 

`TeachingTip` doesn't provide an `Opened` event.
(microsoft/microsoft-ui-xaml#1607). But we
want to focus the renamer text box when it's opened. We can't do that
immediately, the TextBox technically isn't in the visual tree yet. We
have to wait for it to get added some time after we call IsOpen. How do
we do that reliably? Usually, for this kind of thing, we'd just use a
one-off LayoutUpdated event, as a notification that the TextBox was
added to the tree. HOWEVER:
* The _first_ time this is fired, when the box is _first_ opened,
  yeeting focus doesn't work on the first LayoutUpdated. It does work on
  the second LayoutUpdated. Okay, so we'll wait for two LayoutUpdated
  events, and focus on the second.
* On subsequent opens: We only ever get a single LayoutUpdated. Period.
  But, you can successfully focus it on that LayoutUpdated.

So, we'll keep track of how many LayoutUpdated's we've _ever_ gotten. If
we've had at least 2, then we can focus the text box.

We're also not using a ContentDialog for this, because in Xaml Islands a
text box in a ContentDialog won't receive _any_ keypresses. Fun!


## References
* microsoft/microsoft-ui-xaml#1607
* microsoft/microsoft-ui-xaml#6910
* microsoft/microsoft-ui-xaml#3257
* #9662

## PR Checklist
* [x] Will close out #12021, but that's an a11y bug that needs secondary
  validation
* [x] Closes #11322
* [x] I work here
* [x] Tests added/passed
* [n/a] Requires documentation to be updated

## Validation Steps Performed

Tested manually
DHowett pushed a commit that referenced this pull request Mar 31, 2022
Does what it says on the tin. This is maximal BODGE.

`TeachingTip` doesn't provide an `Opened` event.
(microsoft/microsoft-ui-xaml#1607). But we
want to focus the renamer text box when it's opened. We can't do that
immediately, the TextBox technically isn't in the visual tree yet. We
have to wait for it to get added some time after we call IsOpen. How do
we do that reliably? Usually, for this kind of thing, we'd just use a
one-off LayoutUpdated event, as a notification that the TextBox was
added to the tree. HOWEVER:
* The _first_ time this is fired, when the box is _first_ opened,
  yeeting focus doesn't work on the first LayoutUpdated. It does work on
  the second LayoutUpdated. Okay, so we'll wait for two LayoutUpdated
  events, and focus on the second.
* On subsequent opens: We only ever get a single LayoutUpdated. Period.
  But, you can successfully focus it on that LayoutUpdated.

So, we'll keep track of how many LayoutUpdated's we've _ever_ gotten. If
we've had at least 2, then we can focus the text box.

We're also not using a ContentDialog for this, because in Xaml Islands a
text box in a ContentDialog won't receive _any_ keypresses. Fun!

## References
* microsoft/microsoft-ui-xaml#1607
* microsoft/microsoft-ui-xaml#6910
* microsoft/microsoft-ui-xaml#3257
* #9662

## PR Checklist
* [x] Will close out #12021, but that's an a11y bug that needs secondary
  validation
* [x] Closes #11322
* [x] I work here
* [x] Tests added/passed
* [n/a] Requires documentation to be updated

## Validation Steps Performed

Tested manually

(cherry picked from commit b57fe85)
Service-Card-Id: 79978834
Service-Version: 1.13
DHowett pushed a commit that referenced this pull request Mar 31, 2022
Does what it says on the tin. This is maximal BODGE.

`TeachingTip` doesn't provide an `Opened` event.
(microsoft/microsoft-ui-xaml#1607). But we
want to focus the renamer text box when it's opened. We can't do that
immediately, the TextBox technically isn't in the visual tree yet. We
have to wait for it to get added some time after we call IsOpen. How do
we do that reliably? Usually, for this kind of thing, we'd just use a
one-off LayoutUpdated event, as a notification that the TextBox was
added to the tree. HOWEVER:
* The _first_ time this is fired, when the box is _first_ opened,
  yeeting focus doesn't work on the first LayoutUpdated. It does work on
  the second LayoutUpdated. Okay, so we'll wait for two LayoutUpdated
  events, and focus on the second.
* On subsequent opens: We only ever get a single LayoutUpdated. Period.
  But, you can successfully focus it on that LayoutUpdated.

So, we'll keep track of how many LayoutUpdated's we've _ever_ gotten. If
we've had at least 2, then we can focus the text box.

We're also not using a ContentDialog for this, because in Xaml Islands a
text box in a ContentDialog won't receive _any_ keypresses. Fun!

## References
* microsoft/microsoft-ui-xaml#1607
* microsoft/microsoft-ui-xaml#6910
* microsoft/microsoft-ui-xaml#3257
* #9662

## PR Checklist
* [x] Will close out #12021, but that's an a11y bug that needs secondary
  validation
* [x] Closes #11322
* [x] I work here
* [x] Tests added/passed
* [n/a] Requires documentation to be updated

## Validation Steps Performed

Tested manually

(cherry picked from commit b57fe85)
Service-Card-Id: 79978833
Service-Version: 1.12
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
AutoMerge Marked for automatic merge by the bot when requirements are met
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants