muhammadwahid
New member
WebView2 issue
I’ve investigated the issue where the right-click context menu does not open at the correct position, and I’ve identified the root cause.
The problem is caused by DPI scaling differences between the coordinates provided by the internal browser engine and the coordinates used by the native application window.
The internal Chromium-based browser used by ExeOutput provides mouse coordinates (clientX / clientY) in CSS pixels.
However, the native Windows API functions used to display context menus expect coordinates in physical (device) pixels.
When the system uses DPI scaling (e.g., 125%, 150%, 175%), these two coordinate systems no longer match.
As a result, the context menu appears offset from the cursor location.
The solution is to apply the current DPI scale factor (window.devicePixelRatio) and convert the CSS-pixel coordinates to physical pixels before displaying the context menu.
This explains the incorrect context-menu positioning and provides a clear path to fix it.
I’ve investigated the issue where the right-click context menu does not open at the correct position, and I’ve identified the root cause.
The problem is caused by DPI scaling differences between the coordinates provided by the internal browser engine and the coordinates used by the native application window.
The internal Chromium-based browser used by ExeOutput provides mouse coordinates (clientX / clientY) in CSS pixels.
However, the native Windows API functions used to display context menus expect coordinates in physical (device) pixels.
When the system uses DPI scaling (e.g., 125%, 150%, 175%), these two coordinate systems no longer match.
As a result, the context menu appears offset from the cursor location.
The solution is to apply the current DPI scale factor (window.devicePixelRatio) and convert the CSS-pixel coordinates to physical pixels before displaying the context menu.
This explains the incorrect context-menu positioning and provides a clear path to fix it.