[PR #1948] [MERGED] Enable dragging with the entire titlebar #24727

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

📋 Pull Request Information

Original PR: https://github.com/microsoft/terminal/pull/1948
Author: @zadjii-msft
Created: 7/12/2019
Status: Merged
Merged: 7/18/2019
Merged by: @zadjii-msft

Base: masterHead: dev/migrie/f/newtab-btn-float-left


📝 Commits (10+)

  • 15a1f48 This definitely works for getting shadow, pointy corners back
  • 0bc9969 The window style was not important
  • bf239b6 Still getting a black xaml islands area (the HRGN) when we switch to high DPI
  • 22e1023 I don't know if this affects anything.
  • aad9f56 heyo this works.
  • 5fd4191 Add more comments and cleanup
  • b02d9eb Merge branch 'dev/migrie/f/1625-less-round-more-shadow' into dev/migrie/f/newtab-btn-float-left
  • 5c50804 Try making the button RightCustomContent
  • 10bcf6e * Make the MinMaxClose's drag bar's min size the same as a caption button
  • ea1298e Create a TitlebarControl

📊 Changes

27 files changed (+608 additions, -188 deletions)

View changed files

📝 src/cascadia/TerminalApp/App.cpp (+39 -35)
📝 src/cascadia/TerminalApp/App.h (+4 -7)
📝 src/cascadia/TerminalApp/App.idl (+4 -4)
📝 src/cascadia/TerminalApp/MinMaxCloseControl.cpp (+22 -41)
📝 src/cascadia/TerminalApp/MinMaxCloseControl.h (+15 -10)
📝 src/cascadia/TerminalApp/MinMaxCloseControl.idl (+10 -6)
📝 src/cascadia/TerminalApp/MinMaxCloseControl.xaml (+6 -10)
src/cascadia/TerminalApp/TabRowControl.cpp (+26 -0)
src/cascadia/TerminalApp/TabRowControl.h (+25 -0)
src/cascadia/TerminalApp/TabRowControl.idl (+12 -0)
src/cascadia/TerminalApp/TabRowControl.xaml (+31 -0)
📝 src/cascadia/TerminalApp/TerminalApp.vcxproj (+2 -0)
📝 src/cascadia/TerminalApp/TerminalPage.cpp (+0 -9)
📝 src/cascadia/TerminalApp/TerminalPage.h (+0 -2)
📝 src/cascadia/TerminalApp/TerminalPage.idl (+1 -2)
📝 src/cascadia/TerminalApp/TerminalPage.xaml (+2 -28)
src/cascadia/TerminalApp/TitlebarControl.cpp (+89 -0)
src/cascadia/TerminalApp/TitlebarControl.h (+41 -0)
src/cascadia/TerminalApp/TitlebarControl.idl (+13 -0)
src/cascadia/TerminalApp/TitlebarControl.xaml (+45 -0)

...and 7 more files

📄 Description

Summary of the Pull Request

If a picture is worth 1000 words, then this is 15000 words/second like 18000 words (getting a gif below 10MB was harder than I thought)

dragging-window-004

References

This is a bunch of the work in #1625 and #1375.

PR Checklist

Detailed Description of the Pull Request / Additional comments

This is done with a major change to the NonClientIslandWindow, and the MinMaxControl. I've introduced a new XAML control, the TitlebarControl. The TitlebarControl consists of three parts - Content, Drag Area, and MinMaxControl. The MinMaxControl is now owned by the TitlebarControl, and it does pretty much nothing on it's own. All the hwnd handling has moved up to the TitlebarControl. The MinMaxControl now exists simply as a control with caption buttons.

Instead of the App owning the MinMaxControl, and the titlebar existing as part of the TerminalPage, the TitlebarControl is now owned by the NonClientIslandWindow. The NonClientIslandWindow will initialize it's own UI consisting of a titlebar row and a content row. It'll place a TitlebarControl instance in its titlebar row. It'll also ask the App for content to place in both the client area and the titlebar. When the app is resized, or the titlebar content is resized, the NonClientIslandWindow will update its drag area. The NonClientIslandWindow can also communicate directly with the TitlebarControl, without needing to go through the App to do so. In the future, This should make future windowing-related bugs easier to fix.

TODOs

  • There's definitely a bug with the bottom margin. A single pixel of your accent color will appear at the bottom of the window. With different MARGINs passed to DwmExtendframIntoClientArea, the amount changes. This regressed between 1905852 and 96c5da2. I want to track this down before we check this in.
    • I was able to fix this. We need to not paint the entirety of the root window. As long as it's not all painted, then the border won't be drawn. Click "details" to see my ramblings as I debugged this.
  • Definitely also regressed after 60a444c 7b8cf10 b9cc819 0219781 02e8389 (wait there's only f4e02d8 between those two??)
  • Oh no, it's broken in master. Must've regressed in f4e02d8, thank god I have that branch locally still.
  • It's fine in 9040940, which was the last commit in that PR before merging into master. I'll bisect from there to f4e02d8, we'll see where this regressed
    • 122f0de: ✔ (Just the TerminalPage changes)
    • 122f0de + 5fd4191: ✔ (TerminalPage + Most of the NC painting but not the whole titlebar thing)
    • Okay, so 9040940, where I paint the entire titlebar, is what broke it. That's definitely the commit that breaks it.
    • 9040940 + 122f0de: (Fix the NC painting, paint the entire titlebar + TerminalPage)
    • 9040940 + 60a444c: Well this was surprising
  • This is actually related to how GDI blends with the nonclient area. @Dhowett-msft was seeing this previously when trying to paint our caption buttons himself. You won't see this bug in light mode, but in dark mode, where the color is #000000, the window frame bleeds through entirely. For example, I have a bright cyan accent color. If I change the backgroundColor to #ff00000, then the single pixel at the bottom will appear almost white:
    image
  • This should probably wait for @cinnamon-msft's #1934, so that the UI is more complete. Merging will be painful.
  • I'm self-blocking this till #1164 gets in. Merging will be a pain.

🔄 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/1948 **Author:** [@zadjii-msft](https://github.com/zadjii-msft) **Created:** 7/12/2019 **Status:** ✅ Merged **Merged:** 7/18/2019 **Merged by:** [@zadjii-msft](https://github.com/zadjii-msft) **Base:** `master` ← **Head:** `dev/migrie/f/newtab-btn-float-left` --- ### 📝 Commits (10+) - [`15a1f48`](https://github.com/microsoft/terminal/commit/15a1f482548db10cf49a0702b6e8b912241596e8) This definitely works for getting shadow, pointy corners back - [`0bc9969`](https://github.com/microsoft/terminal/commit/0bc9969361c3d583cf0ab34d2f7e95d4aafbf347) The window style was _not_ important - [`bf239b6`](https://github.com/microsoft/terminal/commit/bf239b6de055fa2719367529590264443bc9a0b4) Still getting a black xaml islands area (the HRGN) when we switch to high DPI - [`22e1023`](https://github.com/microsoft/terminal/commit/22e102386b29c537acff8f95d8606255dd7d1288) I don't know if this affects anything. - [`aad9f56`](https://github.com/microsoft/terminal/commit/aad9f56d83cf2a25fcea680016797a6f982d6cc5) heyo this works. - [`5fd4191`](https://github.com/microsoft/terminal/commit/5fd41919e94e3e9b14836c29eaab4751f9bffa03) Add more comments and cleanup - [`b02d9eb`](https://github.com/microsoft/terminal/commit/b02d9eb6d24e2aea7e2bf15267f75d9252817a40) Merge branch 'dev/migrie/f/1625-less-round-more-shadow' into dev/migrie/f/newtab-btn-float-left - [`5c50804`](https://github.com/microsoft/terminal/commit/5c50804e7f738e0e6ee64f9faceef3462db8b0eb) Try making the button RightCustomContent - [`10bcf6e`](https://github.com/microsoft/terminal/commit/10bcf6ea5293c36803182bca48567133281a5ac0) * Make the MinMaxClose's drag bar's min size the same as a caption button - [`ea1298e`](https://github.com/microsoft/terminal/commit/ea1298eed9f68f3b2fb885b43eac9ad36a5f2f88) Create a TitlebarControl ### 📊 Changes **27 files changed** (+608 additions, -188 deletions) <details> <summary>View changed files</summary> 📝 `src/cascadia/TerminalApp/App.cpp` (+39 -35) 📝 `src/cascadia/TerminalApp/App.h` (+4 -7) 📝 `src/cascadia/TerminalApp/App.idl` (+4 -4) 📝 `src/cascadia/TerminalApp/MinMaxCloseControl.cpp` (+22 -41) 📝 `src/cascadia/TerminalApp/MinMaxCloseControl.h` (+15 -10) 📝 `src/cascadia/TerminalApp/MinMaxCloseControl.idl` (+10 -6) 📝 `src/cascadia/TerminalApp/MinMaxCloseControl.xaml` (+6 -10) ➕ `src/cascadia/TerminalApp/TabRowControl.cpp` (+26 -0) ➕ `src/cascadia/TerminalApp/TabRowControl.h` (+25 -0) ➕ `src/cascadia/TerminalApp/TabRowControl.idl` (+12 -0) ➕ `src/cascadia/TerminalApp/TabRowControl.xaml` (+31 -0) 📝 `src/cascadia/TerminalApp/TerminalApp.vcxproj` (+2 -0) 📝 `src/cascadia/TerminalApp/TerminalPage.cpp` (+0 -9) 📝 `src/cascadia/TerminalApp/TerminalPage.h` (+0 -2) 📝 `src/cascadia/TerminalApp/TerminalPage.idl` (+1 -2) 📝 `src/cascadia/TerminalApp/TerminalPage.xaml` (+2 -28) ➕ `src/cascadia/TerminalApp/TitlebarControl.cpp` (+89 -0) ➕ `src/cascadia/TerminalApp/TitlebarControl.h` (+41 -0) ➕ `src/cascadia/TerminalApp/TitlebarControl.idl` (+13 -0) ➕ `src/cascadia/TerminalApp/TitlebarControl.xaml` (+45 -0) _...and 7 more files_ </details> ### 📄 Description <!-- Enter a brief description/summary of your PR here. What does it fix/what does it change/how was it tested (even manually, if necessary)? --> ## Summary of the Pull Request If a picture is worth 1000 words, then this is ~~15000 words/second~~ like 18000 words (getting a gif below 10MB was harder than I thought) ![dragging-window-004](https://user-images.githubusercontent.com/18356694/61157912-0c152f80-a4bd-11e9-9ad3-2d85f4c6de3a.gif) <!-- Other than the issue solved, is this relevant to any other issues/existing PRs? --> ## References This is a bunch of the work in #1625 and #1375. <!-- Please review the items on the PR checklist before submitting--> ## PR Checklist * [x] Closes #564 <!-- Provide a more detailed description of the PR, other things fixed or any additional comments/features here --> ## Detailed Description of the Pull Request / Additional comments This is done with a major change to the `NonClientIslandWindow`, and the `MinMaxControl`. I've introduced a new XAML control, the `TitlebarControl`. The `TitlebarControl` consists of three parts - Content, Drag Area, and `MinMaxControl`. The `MinMaxControl` is now owned by the `TitlebarControl`, and it does pretty much nothing on it's own. All the hwnd handling has moved up to the `TitlebarControl`. The `MinMaxControl` now exists simply as a control with caption buttons. Instead of the ``App`` owning the `MinMaxControl`, and the titlebar existing as part of the TerminalPage, the `TitlebarControl` is now owned by the `NonClientIslandWindow`. The `NonClientIslandWindow` will initialize it's own UI consisting of a titlebar row and a content row. It'll place a `TitlebarControl` instance in its titlebar row. It'll also ask the `App` for content to place in both the client area and the titlebar. When the app is resized, or the titlebar content is resized, the `NonClientIslandWindow` will update its drag area. The `NonClientIslandWindow` can also communicate directly with the `TitlebarControl`, without needing to go through the `App` to do so. In the future, This should make future windowing-related bugs easier to fix. ### TODOs * [x] There's definitely a bug with the bottom margin. A single pixel of your accent color will appear at the bottom of the window. With different `MARGIN`s passed to `DwmExtendframIntoClientArea`, the amount changes. This regressed between 1905852 and 96c5da2. I want to track this down before we check this in. - I was able to fix this. We need to _not_ paint the _entirety_ of the root window. As long as it's not _all_ painted, then the border won't be drawn. Click "details" to see my ramblings as I debugged this. <details> - Definitely also regressed after ~~60a444c~~ ~~7b8cf10~~ ~~b9cc819~~ ~~0219781~~ 02e8389 (wait there's only f4e02d8 between those two??) - Oh no, it's broken in master. Must've regressed in f4e02d8, thank god I have that branch locally still. - It's fine in 9040940, which was the last commit in that PR before merging into master. I'll bisect from there to f4e02d8, we'll see where this regressed - 122f0de: ✔ (Just the TerminalPage changes) - 122f0de + 5fd4191: ✔ (TerminalPage + Most of the NC painting but not the whole titlebar thing) - Okay, so 9040940, where I paint the _entire_ titlebar, is what broke it. That's _definitely_ the commit that breaks it. - 9040940 + 122f0de: ❌ (Fix the NC painting, paint the entire titlebar + TerminalPage) - 9040940 + 60a444c: ❌ Well this was surprising - This is actually related to how GDI blends with the nonclient area. @Dhowett-msft was seeing this previously when trying to paint our caption buttons himself. You won't see this bug in light mode, but in dark mode, where the color is `#000000`, the window frame bleeds through entirely. For example, I have a bright cyan accent color. If I change the `backgroundColor` to `#ff00000`, then the single pixel at the bottom will appear almost white: ![image](https://user-images.githubusercontent.com/18356694/61217120-a7342200-a6d4-11e9-9321-c482baf70f8e.png) </details> * [x] This should probably wait for @cinnamon-msft's #1934, so that the UI is more complete. Merging will be painful. * [x] I'm self-blocking this till #1164 gets in. Merging will be a pain. --- <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:05:00 +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#24727