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
fix: WCO window hover on window controls on Windows #32672
Conversation
I'm working on upstreaming this, either as-is or as a small refactor. Either way and whether it gets accepted there or not, I think it would be a good idea to land this as a patch for now rather than when it finds its way in through the roll! |
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.
Excellent fix!
Is it possible to signal the handling of this mouse event at |
Good catch! I know the Also I just realized when I cleaned up the patch I broke the condition 😅 (should be |
@deepak1556 That works! It took me a minute to figure out, but as long as we do it after |
aee4040
to
6e9a0b0
Compare
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.
👍
Co-authored-by: Robo <hop2deep@gmail.com>
Release Notes Persisted
|
I have automatically backported this PR to "14-x-y", please check out #32716 |
I have automatically backported this PR to "15-x-y", please check out #32717 |
I have automatically backported this PR to "17-x-y", please check out #32719 |
I have automatically backported this PR to "16-x-y", please check out #32720 |
/trop run backport-to 18-x-y |
The backport process for this PR has been manually initiated - sending your PR to |
I have automatically backported this PR to "18-x-y", please check out #32723 |
Description of Change
This adds a patch to Chromium that marks non-client mouse hover events as handled so they don't get redispatched to the default OS event handler (which is currently immediately "stealing" the mouse every time it moves).
Currently, on Windows with WCO-enabled windows, Win API mouse messages first find their way to
LegacyRenderWidgetHostHWND::OnMouseRange
which, for non-client mouse moved events, will both handle the event normally (throughHWNDMessageHandler::HandleMouseMessage
which eventually bubbles down toWidget::OnMouseEvent
) as well as redispatch the original message back to the OS default window procedure (via the Win APIDefWndProc
) on the real window handle, depending on some conditions.Calling
DefWndProc
after we process a non-client area mouse move message seems to cause issues where the system will immediately send a non-client mouse exit message to the real window (HWNDMessageHandler
directly this time, which again flows down toWidget::OnMouseEvent
) which makes it think the mouse is no longer hovering over the non-client area.To avoid this, an event should be marked as handled meaning
LegacyRenderWidgetHostHWND
will no longer forward the message toDefWndProc
. Note that this is how many other mouse events behave in that method, but not hovers currently.The only open question I haven't figured out is why
DefWndProc
is taking aWM_NCMOUSEMOVE
message fromLegacyRenderHostHWND
called onHWNDMessageHandler
's window handle and then sending aWM_NCMOUSELEAVE
message (take note: move changed to leave) when it invokesHWNDMessageHandler
'sWndProc
. My current thought is that we tell the system that the client area covers the full window (i.e. the window has no frame) but also indicate that the mouse is sometimes in non-client area via hit testing (which we have to do to get Snap Assist) and this sort of inconsistency might trickDefWndProc
into the behavior we're seeing. Not really sure if it's worth confirming though so it might just stay a hypothesis.In theory this shouldn't affect anything but WCO windows as usually the
LegacyRenderWidgetHostHWND
doesn't cover any non-client area, so I deduce that all other kinds of windows will never send theLegacyRenderWidgetHostHWND
a non-client mouse message in practice.Fixes #32360.
Checklist
npm test
passesRelease Notes
Notes: Fix effect when hovering over window controls on Windows in a WCO-enabled window.