MicrosoftEdge / MicrosoftEdge/WebView2Feedback

[Problem/Bug]: Mouse Position via mouseProc in C++ over embedded WebView2 not working

Open
#5,043 0 comments 0 reactions 1 assignee View on GitHub

@Badhri is already working on this.

Since Jan 16, 2025.

bug
Dominant language
PowerShell
Stars
526
Forks
67
PR merge metrics
No merged PRs in 30d

Description

What happened?

I have a Win32 window which contains a WebView2 browser instance. I now want to query the hosts mouse position to determine if it is over my window via a call to SetWindowsHookEx(WH_MOUSE, mouseProc, __module_handle, 0).

Inside of mouseProc, I have tried both GetClientRect and GetWindowRect to retrieve the Window's position and then checked the result against GetCursorPos. In the Case of GetClientRect I transformed the coordinates appropriately.

All of these function deliver the expected results except on my WebView2 Browser window where the mouseProc callback stops working after I move the mouse over the few pixels of invisible border around the window to inside the window.

Importance

Moderate. My app's user experience is affected, but still usable.

Runtime Channel

Stable release (WebView2 Runtime)

Runtime Version

131.0.2903.112

SDK Version

1.0.2739.15

Framework

Win32

Operating System

Windows 11

OS Version

22631.4751

Repro steps
  1. Use Win32 to create a window (size, position and the rest does not matter as long as its visible)
  2. Initiate a plain WebView2 Browser Instance
  3. Use SetWindowsHookEx(WH_MOUSE, mouseProc, __module_handle, 0) to register the mouseProc callback
  4. Use GetClientRect and GetCursorPos and print them to stdout
  5. Start the application and move the mouse cursor over the window

As soon as the mouse is over the WebView2 window the mouseProc Callback stops being called. The last recorded positon from GetCursorPos is the last pixel of the invisible border of the window.

Repros in Edge Browser

No, issue does not reproduce in the corresponding Edge version

Regression

No, this never worked

Last working version (if regression)

No response

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.