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

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

Original Pull Request: https://github.com/microsoft/terminal/pull/5485

State: closed
Merged: Yes


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.
**Original Pull Request:** https://github.com/microsoft/terminal/pull/5485 **State:** closed **Merged:** Yes --- 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.
claunia added the pull-request label 2026-01-31 09:15:27 +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#26341