fix(cua-driver): add DPI awareness manifest for Windows - #1821
Conversation
Fixes coordinate offset when using 125%/150%/200% display scaling on Windows. Without the manifest, Windows treats the process as DPI-unaware and provides physical pixels instead of logical pixels, causing clicks to land at the wrong position. The manifest declares Per-Monitor V2 DPI awareness (same as cua-driver-uia), ensuring the process receives logical coordinates that match what the user sees on screen and what screenshot coordinates represent. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
|
Important Review skippedAuto incremental reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
📝 WalkthroughWalkthroughThe PR adds Windows DPI awareness support to the cua-driver crate by introducing a Windows application manifest, declaring the embed-resource build dependency, and configuring the build script to embed the manifest at compile time. ChangesWindows DPI Awareness Setup
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@libs/cua-driver/rust/crates/cua-driver/build.rs`:
- Line 16: The build script currently calls
embed_resource::compile("cua-driver.manifest", ...) which is wrong because
embed_resource::compile expects a Windows .rc resource script, not a raw
.manifest; create a resource script named cua-driver.rc containing the
RT_MANIFEST definition and reference to the XML manifest (e.g., "`#define`
RT_MANIFEST 24" and "1 RT_MANIFEST \"cua-driver.manifest\""), then update the
call to embed_resource::compile("cua-driver.rc", embed_resource::NONE) so the
manifest is embedded correctly by the embed_resource::compile function.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 406ee2f2-642b-4c02-b60b-bddcdd5a641c
📒 Files selected for processing (3)
libs/cua-driver/rust/crates/cua-driver/Cargo.tomllibs/cua-driver/rust/crates/cua-driver/build.rslibs/cua-driver/rust/crates/cua-driver/cua-driver.manifest
embed_resource::compile() expects a Windows resource script (.rc) that references the manifest via RT_MANIFEST, not the raw .manifest XML file. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Add high-DPI awareness support for Windows, enabling proper coordinate scaling and display clarity on high-resolution displays. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Fix critical bugs where logical and physical pixel coordinates were mismatched after adding DPI awareness manifest. **Fixes:** 1. screenshot_display_bytes: Scale logical GetSystemMetrics dimensions to physical pixels before BitBlt capture 2. screenshot_via_screen_region: Scale GetWindowRect logical coords to physical pixels for screen DC BitBlt 3. screenshot_window_bytes (occlusion path): Scale window dimensions to physical pixels for bitmap creation 4. get_screen_size: Update comments - GetSystemMetrics already returns logical pixels with permonitorv2, no double-scaling needed With permonitorv2 DPI awareness: - GetSystemMetrics/GetWindowRect return logical pixels (DPI-scaled) - BitBlt/CreateCompatibleBitmap work in physical device pixels - Conversion: physical = logical × (DPI / 96.0) These fixes ensure screenshots and coordinates work correctly at any DPI scaling (125%, 150%, 200%). Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
CI provided hash: sha256-1/dcdzoK8PC1ns1WyJY+QmWRMj7GKOXUpRO9zTPDbl4=
The embed-resource build dependency should only be included on Windows builds to avoid vendoring issues on Linux Nix builds.
CI provided hash: sha256-TezobhZKan2E087x8cECCqZS0lafEBAOd0Cx70BgP9w=
Summary
cua-driver.exeon WindowsProblem
Users reported that x/y coordinates were offset when running
cua-driver-rson Windows with 125% display scaling. This happened because Windows treats processes without a DPI manifest as DPI-unaware and provides physical pixels instead of logical pixels.Without the manifest:
cua-driver-uia.exeworker had the manifest, but the main daemon didn'tSolution
Added a Windows application manifest declaring Per-Monitor V2 DPI awareness (matching
cua-driver-uia.exe). This ensures:The manifest is embedded at build time via
embed-resourcecrate (Windows-only build dependency).Test plan
🤖 Generated with Claude Code
Summary by CodeRabbit