-
Notifications
You must be signed in to change notification settings - Fork 16.2k
fix: hover state bug when BrowserWindow is not resizable #29721
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
Conversation
💖 Thanks for opening this pull request! 💖 We use semantic commit messages to streamline the release process. Before your pull request can be merged, you should update your pull request title to start with a semantic prefix. Examples of commit messages with semantic prefixes:
Things that will help get your PR across the finish line:
We get a lot of pull requests on this repo, so please be patient and we will get back to you as soon as we can. |
3f459f5
to
260d369
Compare
我英文不太好,尝试解释一下 bug 产生的细节: 经研究发现:
当 resizable 设置为 false 时,鼠标经过窗口边缘时(窗口边缘设置为5个像素[kResizeInsideBoundsSize]), 调用 这会导致 Windows 误以为鼠标离开了窗口区域,从而向窗口发送了一个 WM_MOUSELEAVE 事件,实际上鼠标依然在窗口内。 chromium 在 LRESULT LegacyRenderWidgetHostHWND::OnMouseLeave(UINT message,
WPARAM w_param,
LPARAM l_param) {
mouse_tracking_enabled_ = false;
LRESULT ret = 0;
HWND capture_window = ::GetCapture();
if ((capture_window != GetParent()) && GetWindowEventTarget(GetParent())) {
// We should send a WM_MOUSELEAVE to the parent window only if the mouse
// has moved outside the bounds of the parent.
POINT cursor_pos;
::GetCursorPos(&cursor_pos);
// WindowFromPoint returns the top-most HWND. As hwnd() may not
// respond with HTTRANSPARENT to a WM_NCHITTEST message,
// it may be returned.
HWND window_from_point = ::WindowFromPoint(cursor_pos);
if (window_from_point != GetParent() &&
(capture_window || window_from_point != hwnd())) {
bool msg_handled = false;
ret = GetWindowEventTarget(GetParent())->HandleMouseMessage(
message, w_param, l_param, &msg_handled);
SetMsgHandled(msg_handled);
}
}
return ret;
} 此时因为 WM_NCHITTEST 返回了 HTBORDER,因此虽然触发了 WM_MOUSELEAVE,但是鼠标仍然在窗口内部。 所以会导致 所以当 BrowserWindow 的 resizable 属性设置为 false 时,NCHitTest 应该返回 HTCLIENT,这样才能让 Windows 在鼠标真正离开窗口时触发 WM_MOUSELEAVE,解决 hover 状态清除不掉的问题。 |
I am a new comer as an electron contributor, can anyone tell me why the linux build failed please ? I haven't comitted any code associated with linux |
Our CI is not very stable recently and I think the failure is not related to this PR. |
OK, thank you for the reply 😄 |
Congrats on merging your first pull request! 🎉🎉🎉 |
Release Notes Persisted
|
I have automatically backported this PR to "12-x-y", please check out #29799 |
I have automatically backported this PR to "13-x-y", please check out #29800 |
I have automatically backported this PR to "14-x-y", please check out #29801 |
…resizable (electron#611) (electron#29721)" This reverts commit e54667e. Around allows interactions within the non-client region so that the floating window allows dragging. This also affects modals which are not resizable.
Fix bug : when BrowserWindow is not resizable, the hover state of DOM element may not be cleared.
#611
Notes: fix hover state not clear bug when BrowserWindow is not resizable