Repository navigation
fix(display): correct Windows DPI scale step mapping - #1182
Conversation
|
No actionable comments were generated in the recent review.
|
| Layer / File(s) | Summary |
|---|---|
步进转换与单元测试 src/platform/windows/display_device/display_scale_steps.h, tests/unit/test_display_scale_steps.cpp, tests/CMakeLists.txt |
新增 12 项缩放百分比表、范围索引结构,以及相对值解码和百分比编码函数。新增测试,覆盖有效输入、无效输入和 int32_t 极值,并注册独立测试目标。 |
Windows 缩放读取与设置 src/platform/windows/display_device/windows_utils.cpp |
缩放详情读取改用 decode_range,并从百分比表填充当前、推荐和支持的缩放值。设置逻辑改用 relative_from_percent 计算相对推荐值;转换失败或目标百分比不受该显示器支持时返回不支持缩放错误。 |
Priority:
Estimated code review effort: 3 (Moderate) | ~20 minutes
Change: Bug fix
Suggested reviewers: yundi339
Merge Risk: 
Minimal · up to d2b83
-
No identified issue blocks merging this DPI scale mapping change.
Pre-merge checks: 
4 · 
1
-
Failed checks: 1 warning Passed checks: 4 passedFull details: Docstring Coverage
-
Explanation
Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 8 functions across 3 files. (1 skipped: 1 unsupported.)
Resolution
Write docstrings for the functions missing them to satisfy the coverage threshold.
-
Finishing Touches: 💡 1
-
📝 Generate docstrings: 💡
-
- Commit to this branch
- Create a new PR
🧪 Generate unit tests (beta)
-
- Commit to this branch
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
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 @coderabbitai help to get the list of available commands.
There was a problem hiding this comment.
🟢 Approval recommended
The focused mapping correction has direct regression coverage and no identified blocking issues, though Windows host compilation and live display validation remain unverified.
No open issues 🎉
What changed in this PR
Corrects Windows desktop DPI scaling so reported percentages and requested scale changes use the proper native step mapping.
Changes:
- Replaces the incorrect 16-entry mapping with the 12 supported desktop scaling steps.
- Shares bounds-checked, overflow-safe conversion helpers between the Windows GET and SET paths.
- Adds a standalone regression test target with explicit percentage expectations and invalid-range checks.
| File | Description |
|---|---|
tests/unit/test_display_scale_steps.cpp |
Tests native offsets, expected percentages, unsupported values, and overflow boundaries. |
tests/CMakeLists.txt |
Registers the standalone test target and excludes its source from the shared test suite. |
src/platform/windows/display_device/windows_utils.cpp |
Uses the shared helpers for reading and setting display scale. |
src/platform/windows/display_device/display_scale_steps.h |
Defines the corrected scale table and validated conversion helpers. |
Review effort: Balanced
## 改了啥呀 - 波形触觉卡片接入显隐、长按编辑、配置同步与备份恢复;旧配置沿用原来的显示行为。 - 码率只显示一个目标读数,请求中显示小型进度提示;读数固定在标题行,切换时不再推动整个菜单。手动请求串行并合并最新目标,关闭重开菜单共用连接内队列,旧回调不会覆盖新预览,失败响应不参与同值去重;请求总时限 15 秒。 - 显示缩放压成一行,使用主机提供的离散百分比并标出推荐值;仍在松手后提交,应用中忽略重复输入。 - 串流屏幕组合只提供主屏/副屏/仅此屏,摘要继续显示当前策略;完整设置页保留全部策略。 - 分辨率列表明确区分已保存项与当前未保存项,删除后不再伪装成保存成功的条目;显式空列表保持为空。低带宽开关合并进列表,旧开关与旧备份迁移为实际的 360p/480p 条目。 - 补齐中英俄繁体说明,DPI 触摸与手柄共用回调;清除旧开关、重复注入、冗余状态/转发方法、临时截图代码;分辨率备份场景并入既有测试,删除独立测试文件、重复断言和多余夹具。 ## 为啥要改 快速切码率会因读数增减一行推动整个菜单,迟到的请求也可能覆盖新选择;这些杂鱼状态现在有了明确的收敛顺序。删除分辨率只管理候选列表,保留当前串流参数,避免暗中改分辨率或重算手动码率。 主机 Windows DPI 映射另有索引错误,修复在 AlkaidLab/foundation-sunshine#1182 。客户端继续以主机返回的能力为准;真实 Windows 显示器上的缩放生效尚未验收。 ## 验证 - `:app:testNonRootDebugUnitTest`:1,037 项通过,覆盖码率请求交错、超时后返回旧值、慢速正文与 HTTPS 端口发现超时。 - 本地 Debug APK 与 instrumentation APK 构建通过;[最新 Android CI](https://github.com/qiin2333/moonlight-vplus/actions/runs/40176780082) 验证中。 - Android 15 模拟器 34 项本轮相关回归通过,包含显示卡片交互、手柄焦点导航、分辨率删除和备份恢复;另验收暗色主题、俄语、横屏及 300dp/130% 字体下的紧凑布局与单一码率读数。 - 主题色生成校验和 release 脚本测试通过。 - `git diff --check` 通过。
改了啥呀
GET/SET_DPI_SCALE的相对索引表恢复为实际的 12 个桌面缩放档位,移除误混入的120/140/160/180。display_scale_steps_unit_tests,直接断言 Windows 相对值与百分比的对应关系。为啥要改
原来的 16 档表会错读当前/推荐缩放,也会向 Windows 写入错误的相对档位。例如请求 150% 实际可能设置成 200%,再读回来却仍显示 150%。杂鱼错位读写互相掩护,普通 round-trip 测试抓不住。
正确表和索引语义可参照 Windows DPI scaling sample。
客户端联动:qiin2333/moonlight-vplus#757。
验证
clang++ -std=c++23 -Wall -Wextra -Werror -fsanitize=address,undefined -fno-omit-frame-pointer,直接编译生产 helper、GoogleTest 和新增测试并运行:4/4 通过。(-3,-1,8)必须得到推荐 175%、当前 150%、上限 500%;写入 150% 相对推荐 175% 必须为 -1。git diff --check origin/master...HEAD通过。ctest --test-dir build --output-on-failure的 34/34 个测试目标全部通过,包含本次内含 4 项回归用例的display_scale_steps_unit_tests。