fix(windows): make portal geometry per-monitor DPI aware - #1
Open
s-qin wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
fix(windows): make portal geometry per-monitor DPI aware
Problem
OpenSpan mixed logical and physical coordinates on mixed-DPI Windows displays.
Reproduction
Real physical desktop: left monitor 1600x2560, PRIMARY 1920x1080, right monitor 2560x1600.
OpenSpan before the fix enumerated:
800x1280 / 1536x864 (PRIMARY) / 1280x800— DPI-virtualized logical values.Observed effect: the portal captured the mouse before the physical screen edge — premature capture while the cursor was still above the true bottom edge of the PRIMARY monitor.
Root cause
No Windows OpenSpan process ever declared DPI awareness. The GUI / setup / portal processes ran as DPI-unaware (or system-aware), so monitor rectangles (
GetMonitorInfoWinwin/openspan_setup.py), the portal edge geometry (written intoopenspan_config.jsonby the GUI) and low-level-hook cursor coordinates ended up in DPI-virtualized coordinate spaces (e.g. primary reported 1536x864 instead of 1920x1080). Portal edges were therefore crossed early.Fix
win/dpi_aware.py: declares per-monitor DPI awareness V2 first (SetProcessDpiAwarenessContext(DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2)), with fallbacks (shcoreSetProcessDpiAwareness(PROCESS_PER_MONITOR_DPI_AWARE), then user32SetProcessDPIAware), and reports the awareness actually in force viaGetProcessDpiAwareness.openspan_setup.py(GUI + setup role),openspan_portal.py,openspan_launcher.py.Validation
Manually tested on real hardware (mixed-DPI, three displays):
1600x2560 / 1920x1080 (PRIMARY) / 2560x1600No CI pipeline configured in this repository (no .github/workflows); static checks passed (python -m py_compile, git diff --check).