-
Notifications
You must be signed in to change notification settings - Fork 8.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Kill HRGN #4778
Kill HRGN #4778
Conversation
!!!! |
It works but I wouldn't be that happy about it because it's very hacky:
It's just to give an idea of the idea because I had already wrote this code but I'll let you judge if it's worth accepting or if it's too hacky. |
I mean, I really like this. I'm certainly always hesitant about changes to our window, so I'd want to keep a careful eye on this, but just playing with this, it doesn't seem like anything else has regressed. I'm definitely curious about why we need to remake a new |
Would this also probably fix #4166 (by virtue of just not having a grab bar at all)? @DHowett-MSFT and I spoke about it, and if it doesn't end up working, and creates more issues that are less solvable, it's easy enough to revert before 1.0. I've played with this and I honestly don't think it's bad. @greg904 If you're okay with this going in, I think we're okay with this change. |
It doesn't fix #4166. Now the big gray rectangle that covers the min/max controls is "invisible" when the bug happens but it's still "there" and catches mouse input:
OK, I'm OK. |
Sorry I've explained the problem badly. The problem is that when I resize the window with |
I'd prefer we preserve the color -- it's more uniform-looking 😄 |
I absolutely love that this lets us hit test even over the tab bar and do, largely, whatever the heck we want. In the future, we could even make it ask XAML "what is underneath the cursor" before doing anything. I am so excited about this. |
Ok. I will do this later when I have time. BTW, note that if I use the title bar color then we will get #2100 but instead of title bar it will be the background color while resizing.
I'm not sure that this is true. Right now, either the XAML islands window receives the input either it's the "drag window" that is put on top of the drag bar. Maybe you got that impression from the fact that I said this originally:
Unfortunately I was not able to replicate the behavior from Another mystery is that for UWP apps, this Basically, the more I try to understand how this thing works, the weirder it gets everytime 😆. |
Nah, I was being more wishful/hopeful 😄 like, if we could get input on the drag bar window we could push it down into Xaml land ourselves, or some-other-how reflect it into the input queue. That's a problem for future-us. |
done |
The root cause of #2100 causes two bugs:
This fixes the first issue but not the second. I don't think that this is really important because when this is fixed: microsoft/microsoft-ui-xaml#759, we will be able to get rid of this workaround and this issue will go away. So I don't think it's necessary to open a new issue for this small thing. |
@msftbot make sure @zadjii-msft and @DHowett-MSFT sign off |
## Summary of the Pull Request Pretty straightforward. When we get a `WM_DISPLAYCHANGE`, that means the display's DPI changed. When that happens, resize the drag bar, so that it'll reflect the new scaling. Unblocks #4778 Closes #4166 ## Validation Man I've changed the DPI of my displays so many times in the last 30 minutes. I dragged the window across a bunch of DPI boundaries too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, I had a go at testing this. I like it! Couple bits of feedback.
- I bet there's a way to get it working without having to recreate the
window every time. - I tried briefly to do the resizing thing, and yeah -- I was having
some Z order issues and couldn't even get the window to reliably paint
(i tried making it red so that i could see what was happening)- Weirdly, adding a WM_PAINT handler made the window totally
hit-testable even when it was resized... perhaps there's something
interesting here?
- Weirdly, adding a WM_PAINT handler made the window totally
- The drag region is still hit testable when the application has been
fullscreened; maybe we should suppress it? - It doesn't feel incorrect; the window can be interacted with just like
normal. - Should we be trying to get the WM_NC events inside this window
instead of tunneling normal events through to the parent window as NC
events? I'm not sure on this one at all. 😄
This pull request has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 7 days. It will be closed if no further activity occurs within 7 days of this comment. |
I hope too. I have not found a way to do it unfortunately.
I have tried adding a WM_PAINT handler in the drag window that does: case WM_PAINT:
{
PAINTSTRUCT ps;
BeginPaint(window, &ps);
EndPaint(window, &ps);
return 0;
} And using But it doesn't work.
Fixed in c375958.
Yes.
I think that in the drag window proc, either:
But I think that in all cases, we have to tunnel something to the parent window: initially, I tried to send WM_SYSCOMMAND events with SC_MOVE to the drag bar window and what happened was that when I clicked on the drag bar, it would drag the drag bar instead of the whole window. So I made it send the message to the parent window instead. I'm no expert at this. |
Wow so now (maybe before too?) the drag bar is broken in Release mode but works in Debug. This is bad. I don't know why. |
BTW I'm not sure how to use the spell checker bot. I ran the command to accept the changes but it created the |
@greg904 The filename it suggests is not specific to this project (it's based on a git sha) -- When there's only one file, it just suggests that file, but when there are multiple, it doesn't really know which to pick. It would be better if you picked one of the existing files. A future run of the checker (when you merge again) would include a bit better advice. You could put your changes into the whitelist file, or maybe the api file (when it arrives). Or wherever a reviewer suggests. |
@greg904 I love this pull request so much that I pulled it into a testing branch over here on our repo and made a couple changes. I got it working without recreating the window, in both debug and release mode. I'm going to submit a pull request from that branch and you will, of course, get full credit on the merge. :) |
Ok so I should probably close this PR then. It's cool that you found a way to make it work. When I saw that it didn't work in Release mode I was mad 🤣, I thought it was going to be impossible to debug because I don't even understand how some parts of the code I wrote work. |
Also known as "Kill HRGN II: Kills Regions Dead (#5485)" Copying the description from @greg904 in #4778. --- 8< --- 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. --- >8 --- Dustin's notes: I've based this on the implementation of the input sink window in the UWP application frame host. Tested manually in all configurations (debug, release) with snap, drag, move, double-click and double-click on the resize handle. Tested at 200% scale. Closes #4744 Closes #2100 Closes #4778 (superseded.)
🎉This issue was addressed in #5485, which has now been successfully released as Handy links: |
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
withSC_MOVE
. It looks like it "steals" our mouse messages likeWM_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:
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 theWS_EX_LAYERED
style and I don't know why. Also we have to recreate the window on every resize (see comments).References
PR Checklist
HRGN
for the titlebar #4744. Closes When a dialog is open, the titlebar is the wrong color #2100.HRGN
for the titlebar #4744Detailed Description of the Pull Request / Additional comments
Validation Steps Performed