[PR #11680] [MERGED] Add snap-layouts support to the Terminal #28704

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

📋 Pull Request Information

Original PR: https://github.com/microsoft/terminal/pull/11680
Author: @zadjii-msft
Created: 11/3/2021
Status: Merged
Merged: 11/29/2021
Merged by: @undefined

Base: mainHead: dev/migrie/nc-titlebar-chswan


📝 Commits (10+)

📊 Changes

11 files changed (+456 additions, -55 deletions)

View changed files

📝 .github/actions/spelling/allow/apis.txt (+7 -0)
📝 src/cascadia/TerminalApp/MinMaxCloseControl.cpp (+149 -7)
📝 src/cascadia/TerminalApp/MinMaxCloseControl.h (+8 -3)
📝 src/cascadia/TerminalApp/MinMaxCloseControl.idl (+4 -0)
📝 src/cascadia/TerminalApp/MinMaxCloseControl.xaml (+13 -3)
📝 src/cascadia/TerminalApp/Resources/en-US/Resources.resw (+6 -0)
📝 src/cascadia/TerminalApp/TitlebarControl.cpp (+53 -2)
📝 src/cascadia/TerminalApp/TitlebarControl.h (+6 -6)
📝 src/cascadia/TerminalApp/TitlebarControl.idl (+14 -0)
📝 src/cascadia/WindowsTerminal/NonClientIslandWindow.cpp (+194 -34)
📝 src/cascadia/WindowsTerminal/NonClientIslandWindow.h (+2 -0)

📄 Description

Adds snap layout support to the Terminal's maximize button. This PR is
full of BODGY, so brace yourselves.

Big thanks to Chris Swan in #11134 for building the prototype.
I don't believe this solves #8795, because XAML islands can't get
nchittest messages

  • The window procedure for the drag bar forwards clicks on its client
    area to its parent as non-client clicks.
  • BODGY: It also manually handles the caption buttons. They exist in
    the titlebar, and work reasonably well with just XAML, if the drag bar
    isn't covering them.
  • However, to get snap layout support, we need to actually return
    HTMAXBUTTON where the maximize button is. If the drag bar doesn't
    cover the caption buttons, then the core input site (which takes up
    the entirety of the XAML island) will steal the WM_NCHITTEST before
    we get a chance to handle it.
  • So, the drag bar covers the caption buttons, and manually handles
    hovering and pressing them when needed. This gives the impression that
    they're getting input as they normally would, even if they're not
    really getting input via XAML.
  • We also need to manually display the button tooltips now, because XAML
    doesn't know when they've been hovered for long enough. Hence, the
    _displayToolTip ThrottledFuncTrailing

Validation

Minimized, maximized, restored down, hovered the buttons slowly, moved
the mouse over them quickly, they feel the same as before. But now with
snap layouts appearing.

TODO!

  • I'm working on getting the ToolTips on the caption buttons back. Alas, I needed a demo of this today, so I'll fix that tomorrow morning.
  • mild concern: I should probably test Win 10 to make sure there wasn't weird changes to the message loop in win11 that means this is broken on win10.
  • I think I used the wrong issue number for tons of my comments throughout this PR. Double check that. Should be #9443, not #9447.

Closes #9443
I thought this took care of #8587 as a bonus, because I was here, and the fix is now trivial, but looking at the latest commit that regressed.

Co-authored-by: Chris Swan chswan@microsoft.com


🔄 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/11680 **Author:** [@zadjii-msft](https://github.com/zadjii-msft) **Created:** 11/3/2021 **Status:** ✅ Merged **Merged:** 11/29/2021 **Merged by:** [@undefined](undefined) **Base:** `main` ← **Head:** `dev/migrie/nc-titlebar-chswan` --- ### 📝 Commits (10+) - [`04145d4`](https://github.com/microsoft/terminal/commit/04145d4fe01492590045690d4c861bc869e387bc) seems to work okay - [`5fdef42`](https://github.com/microsoft/terminal/commit/5fdef429a895e4e7bb5ab01b3f55f3f7c423731f) Merge branch 'pull/11134' into dev/migrie/nc-titlebar-chswan - [`6c9b399`](https://github.com/microsoft/terminal/commit/6c9b3990480d96469b08b741fc36ac8b5c6d93a2) some cleanup. Try only hovering the actually hovered button - [`487edb9`](https://github.com/microsoft/terminal/commit/487edb90719b0d06e2e501753916811d37837b2a) this is surprisingly close. Doesn't handle the mouse-exit-from-window case, but otherwize :primo: - [`be38330`](https://github.com/microsoft/terminal/commit/be38330ddf102b212750511e19b111e732280669) Do the maximize/restore thing - [`939177b`](https://github.com/microsoft/terminal/commit/939177bdabdcc8c6e98da85ef28c9238e105ae11) This is closer to releasing the buttons when we're not over them, but moving the mouse fast still leaves them hovered. - [`d32fac4`](https://github.com/microsoft/terminal/commit/d32fac4d3f2def1fbd7740c33454b4f8c5343301) Same deal, this didn't work either - [`deb494f`](https://github.com/microsoft/terminal/commit/deb494f6ef77b86ca328c2250bed62e666385552) weird, TME_LEAVE | TME_NONCLIENT was actually vital to doing this right. Just TME_LEAVE did not work, it would send the leave when really it should have been sending hovers - [`0ef8673`](https://github.com/microsoft/terminal/commit/0ef867319dc29c970402db86bf34abd11d0f57d2) tons of cleanup - [`1915a06`](https://github.com/microsoft/terminal/commit/1915a06f6e6a15faef045d0508c21dc124f40c79) fixes #8587 ### 📊 Changes **11 files changed** (+456 additions, -55 deletions) <details> <summary>View changed files</summary> 📝 `.github/actions/spelling/allow/apis.txt` (+7 -0) 📝 `src/cascadia/TerminalApp/MinMaxCloseControl.cpp` (+149 -7) 📝 `src/cascadia/TerminalApp/MinMaxCloseControl.h` (+8 -3) 📝 `src/cascadia/TerminalApp/MinMaxCloseControl.idl` (+4 -0) 📝 `src/cascadia/TerminalApp/MinMaxCloseControl.xaml` (+13 -3) 📝 `src/cascadia/TerminalApp/Resources/en-US/Resources.resw` (+6 -0) 📝 `src/cascadia/TerminalApp/TitlebarControl.cpp` (+53 -2) 📝 `src/cascadia/TerminalApp/TitlebarControl.h` (+6 -6) 📝 `src/cascadia/TerminalApp/TitlebarControl.idl` (+14 -0) 📝 `src/cascadia/WindowsTerminal/NonClientIslandWindow.cpp` (+194 -34) 📝 `src/cascadia/WindowsTerminal/NonClientIslandWindow.h` (+2 -0) </details> ### 📄 Description Adds snap layout support to the Terminal's maximize button. This PR is full of BODGY, so brace yourselves. Big thanks to Chris Swan in #11134 for building the prototype. I don't believe this solves #8795, because XAML islands can't get nchittest messages - The window procedure for the drag bar forwards clicks on its client area to its parent as non-client clicks. - BODGY: It also _manually_ handles the caption buttons. They exist in the titlebar, and work reasonably well with just XAML, if the drag bar isn't covering them. - However, to get snap layout support, we need to actually return `HTMAXBUTTON` where the maximize button is. If the drag bar doesn't cover the caption buttons, then the core input site (which takes up the entirety of the XAML island) will steal the `WM_NCHITTEST` before we get a chance to handle it. - So, the drag bar covers the caption buttons, and manually handles hovering and pressing them when needed. This gives the impression that they're getting input as they normally would, even if they're not _really_ getting input via XAML. - We also need to manually display the button tooltips now, because XAML doesn't know when they've been hovered for long enough. Hence, the `_displayToolTip` `ThrottledFuncTrailing` ## Validation Minimized, maximized, restored down, hovered the buttons slowly, moved the mouse over them quickly, they feel the same as before. But now with snap layouts appearing. ## TODO! * [x] I'm working on getting the ToolTips on the caption buttons back. Alas, I needed a demo of this _today_, so I'll fix that tomorrow morning. * [x] mild concern: I should probably test Win 10 to make sure there wasn't weird changes to the message loop in win11 that means this is broken on win10. * [x] I think I used the wrong issue number for tons of my comments throughout this PR. Double check that. Should be #9443, not #9447. Closes #9443 I thought this took care of #8587 ~as a bonus, because I was here, and the fix is _now_ trivial~, but looking at the latest commit that regressed. Co-authored-by: Chris Swan <chswan@microsoft.com> --- <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:30:15 +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#28704