Repository navigation
Conversation
|
For more information on signing commits, see GitHub's documentation on Telling Git about your signing key. |
94454e1 to
9ea0694
Compare
|
Suggestion:For better robustness, when UnhookWindowsHookEx fails, we should verify whether the error code is ERROR_INVALID_HOOK_HANDLE. |
codebytere
left a comment
There was a problem hiding this comment.
Thanks for working on this! Once we handle ERROR_INVALID_HOOK_HANDLE we should be able to move this forward.
9ea0694 to
bf1f2b7
Compare
|
Handled |
|
@officialasishkumar commits need to be signed |
bf1f2b7 to
ae8ad98
Compare
|
@officialasishkumar can you rebase your PR with the latest from main? Hopefully that will clear the failing Windows arm64 test. |
ae8ad98 to
53cbf2b
Compare
|
Rebased on latest main and pushed (53cbf2b). |
|
@officialasishkumar please fix unsigned commits |
NativeWindowViews::SetForwardMouseMessages() installs a low-level mouse hook when mouse forwarding begins and unhooks it once no window needs forwarding. The previous code reset the shared `mouse_hook_` handle to `nullptr` unconditionally after calling UnhookWindowsHookEx, even when the unhook call failed. When unhooking fails, the hook is still installed in the system. Because `mouse_hook_` is nulled out anyway, the next call to SetForwardMouseMessages(true) evaluates `if (!mouse_hook_)` as true and installs a second, duplicate hook via SetWindowsHookEx, so every mouse message is processed by MouseHookProc multiple times. Check the return value of UnhookWindowsHookEx and only null the handle on success. When the call fails, leave `mouse_hook_` pointing at the existing hook so the next activation reuses it rather than stacking a new one on top, and log the failure via PLOG to surface the underlying Windows error. Fixes: electron#51064 Signed-off-by: Asish Kumar <[email protected]>
Signed-off-by: Asish Kumar <[email protected]>
53cbf2b to
b55cf38
Compare
|
Signed the commits and force-pushed b55cf38; the signed-commit check is passing now. |
|
Release Notes Persisted
|
|
I have automatically backported this PR to "42-x-y", please check out #51418 |
|
I have automatically backported this PR to "41-x-y", please check out #51419 |
Description of Change
NativeWindowViews::SetForwardMouseMessages()installs a low-level mouse hook viaSetWindowsHookEx(WH_MOUSE_LL, ...)when mouse forwarding begins, and unhooks it once no window needs forwarding. The previous code reset the sharedmouse_hook_handle tonullptrunconditionally after callingUnhookWindowsHookEx, even when the unhook call failed:Per the UnhookWindowsHookEx documentation, a failure (
FALSEreturn) means the hook is still installed in the system. Becausemouse_hook_was nulled out regardless, the next call toSetForwardMouseMessages(true)would evaluateif (!mouse_hook_)as true and install a second hook viaSetWindowsHookEx, leading to duplicateMouseHookProcinvocations for every mouse message.This PR checks the return value of
UnhookWindowsHookExand only nullsmouse_hook_on success. When the call fails, the handle is left pointing at the still-installed hook so the next activation reuses it instead of stacking a new one on top, and the failure is logged viaPLOG(WARNING)to surface the underlying Windows error.Fixes #51064
Checklist
Release Notes
Notes: Fixed an issue on Windows where a transient
UnhookWindowsHookExfailure insetIgnoreMouseEvents(true, { forward: true })teardown could cause duplicate low-level mouse hooks to be installed on the next activation.