[PR #4778] Kill HRGN #25937

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

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

State: closed
Merged: No


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 makes us receive the WM_LBUTTONDOWN messages. That window has to have the WS_EX_LAYERED style and I don't know why. Also we have to recreate the window on every resize (see comments).

References

PR Checklist

  • Closes #4744. Closes #2100.
  • CLA signed. If not, go over here and sign the CLA
  • 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

Validation Steps Performed

**Original Pull Request:** https://github.com/microsoft/terminal/pull/4778 **State:** closed **Merged:** No --- ## 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 makes us receive the `WM_LBUTTONDOWN` messages. That window has to have the `WS_EX_LAYERED` style and I don't know why. Also we have to recreate the window on every resize (see comments). ## References ## PR Checklist * [x] Closes #4744. Closes #2100. * [x] CLA signed. If not, go over [here](https://cla.opensource.microsoft.com/microsoft/Terminal) and sign the CLA * [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 ## Validation Steps Performed
claunia added the pull-request label 2026-01-31 09:12:48 +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#25937