[PR #5485] [MERGED] Replace the HRGN-based titlebar cutout with an overlay window #26336

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

📋 Pull Request Information

Original PR: https://github.com/microsoft/terminal/pull/5485
Author: @DHowett-MSFT
Created: 4/23/2020
Status: Merged
Merged: 4/24/2020
Merged by: @DHowett-MSFT

Base: masterHead: dev/duhowett/kill_hrgn_4778


📝 Commits (10+)

📊 Changes

6 files changed (+198 additions, -79 deletions)

View changed files

📝 .github/actions/spell-check/dictionary/apis.txt (+5 -1)
📝 .github/actions/spell-check/whitelist/whitelist.txt (+0 -4)
📝 src/cascadia/TerminalApp/App.xaml (+0 -6)
📝 src/cascadia/WindowsTerminal/IslandWindow.h (+1 -1)
📝 src/cascadia/WindowsTerminal/NonClientIslandWindow.cpp (+183 -64)
📝 src/cascadia/WindowsTerminal/NonClientIslandWindow.h (+9 -3)

📄 Description

Copying the description from the inimitable @greg904 in #4778.

Summary of the Pull Request

My understanding is that the XAML framework uses another way of getting mouse input that doesn't work with WM_SYSCOMMAND with SC_MOVE. It looks like it "steals" our mouse messages like WM_LBUTTONDOWN.

Before, we were cutting (with HRGNs) the drag bar part of the XAML islands window in order to catch mouse messages and be able to implement the drag bar that can move the window. However this "cut" doesn't only apply to input (mouse messages) but also to the graphics so we had to paint behind with the same color as the drag bar using GDI to hide the fact that we were cutting the window.

The main issue with this is that we have to replicate exactly the rendering on the XAML drag bar using GDI and this is bad because:

  1. it's hard to keep track of the right color: if a dialog is open, it will cover the whole window including the drag bar with a transparent white layer and it's hard to keep track of those things.
  2. we can't do acrylic with GDI

So I found another method, which is to instead put a "drag window" exactly where the drag bar is, but on top of the XAML islands window (in Z order). I've found that this lets us receive the WM_LBUTTONDOWN messages.

PR Checklist

  • Closes #4744. Closes #2100. Closes #4778 (superseded.)
  • CLA signed
  • I've discussed this with core contributors already. If not checked, I'm ready to accept this work might be rejected in favor of a different grand plan. Issue number where discussion took place: #4744

Detailed Description of the Pull Request / Additional comments

Picture's worth a thousand words.

Available with this PR:
image

Available after version 1, if we so desire:

image

Validation Steps Performed

DH: Tested manually in all configurations (debug, release) with snap, drag, move, double-click and double-click on the resize handle. Tested at 200% scale.

  • Need to test DPI transitions still.

🔄 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/5485 **Author:** [@DHowett-MSFT](https://github.com/DHowett-MSFT) **Created:** 4/23/2020 **Status:** ✅ Merged **Merged:** 4/24/2020 **Merged by:** [@DHowett-MSFT](https://github.com/DHowett-MSFT) **Base:** `master` ← **Head:** `dev/duhowett/kill_hrgn_4778` --- ### 📝 Commits (10+) - [`aa8b29f`](https://github.com/microsoft/terminal/commit/aa8b29f85413080a1809af20983e4df652c13270) Kill HRGN - [`c03a1b8`](https://github.com/microsoft/terminal/commit/c03a1b8409a4fea78e7868d8324652f7d3884be0) Update doc - [`d78ebaa`](https://github.com/microsoft/terminal/commit/d78ebaa1e5ecc23d4d4b5b85617ffbb6e21b1e30) Fix artifacts on 1px top border - [`bdb7f31`](https://github.com/microsoft/terminal/commit/bdb7f312c1ecf1adcadd45b6d368b2793bd1acaf) Fix maximize - [`b6e4e34`](https://github.com/microsoft/terminal/commit/b6e4e34d08dfb6cb589aa3c3f14e5ba859176e28) Recreate the drag window on resize to fix input issues (this is hacky!) - [`717c695`](https://github.com/microsoft/terminal/commit/717c69519602ee3a41091b602e22a95bba8ddc0f) Polish - [`cf1aee4`](https://github.com/microsoft/terminal/commit/cf1aee4aa42f7003a78f6b00994f92e4b0d626dc) Merge branch 'master' of https://github.com/microsoft/terminal into kill-hrgn - [`ca43113`](https://github.com/microsoft/terminal/commit/ca4311330deadeda11f40c2ae19dc8d3b68d5b02) Merge branch 'master' of https://github.com/microsoft/terminal into kill-hrgn - [`c5577e4`](https://github.com/microsoft/terminal/commit/c5577e4a387d46a12e095b5052bab41f7e0c3cbf) Add WM_PAINT handling back to hide system min/max controls and black background during resize - [`f30b8d5`](https://github.com/microsoft/terminal/commit/f30b8d5ae13d2c96196bc22b82f3a38abfd41149) oops ### 📊 Changes **6 files changed** (+198 additions, -79 deletions) <details> <summary>View changed files</summary> 📝 `.github/actions/spell-check/dictionary/apis.txt` (+5 -1) 📝 `.github/actions/spell-check/whitelist/whitelist.txt` (+0 -4) 📝 `src/cascadia/TerminalApp/App.xaml` (+0 -6) 📝 `src/cascadia/WindowsTerminal/IslandWindow.h` (+1 -1) 📝 `src/cascadia/WindowsTerminal/NonClientIslandWindow.cpp` (+183 -64) 📝 `src/cascadia/WindowsTerminal/NonClientIslandWindow.h` (+9 -3) </details> ### 📄 Description Copying the description from the inimitable @greg904 in #4778. ## Summary of the Pull Request My understanding is that the XAML framework uses another way of getting mouse input that doesn't work with `WM_SYSCOMMAND` with `SC_MOVE`. It looks like it "steals" our mouse messages like `WM_LBUTTONDOWN`. Before, we were cutting (with `HRGN`s) the drag bar part of the XAML islands window in order to catch mouse messages and be able to implement the drag bar that can move the window. However this "cut" doesn't only apply to input (mouse messages) but also to the graphics so we had to paint behind with the same color as the drag bar using GDI to hide the fact that we were cutting the window. The main issue with this is that we have to replicate exactly the rendering on the XAML drag bar using GDI and this is bad because: 1. it's hard to keep track of the right color: if a dialog is open, it will cover the whole window including the drag bar with a transparent white layer and it's hard to keep track of those things. 2. we can't do acrylic with GDI So I found another method, which is to instead put a "drag window" exactly where the drag bar is, but on top of the XAML islands window (in Z order). I've found that this lets us receive the `WM_LBUTTONDOWN` messages. ## PR Checklist * [x] Closes #4744. Closes #2100. Closes #4778 (superseded.) * [x] CLA signed * [x] I've discussed this with core contributors already. If not checked, I'm ready to accept this work might be rejected in favor of a different grand plan. Issue number where discussion took place: #4744 ## Detailed Description of the Pull Request / Additional comments Picture's worth a thousand words. Available with this PR: ![image](https://user-images.githubusercontent.com/14316954/80064158-43087f00-84ec-11ea-9bdc-4efa1c518808.png) Available after version 1, _if we so desire_: ![image](https://user-images.githubusercontent.com/14316954/80064177-4dc31400-84ec-11ea-908e-7eaab3e4939c.png) ## Validation Steps Performed DH: Tested manually in all configurations (debug, release) with snap, drag, move, double-click and double-click on the resize handle. Tested at 200% scale. * [x] Need to test DPI transitions still. --- <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:15:25 +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#26336