Scale classic UI XCB theme metrics with DPI - #1620
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (9)
🚧 Files skipped from review as they are similar to previous changes (7)
📝 WalkthroughWalkthroughThis PR adds DPI-based metric scaling to the classic UI. It introduces ChangesDPI Metric Scaling
Estimated code review effort: 4 (Complex) | ~60 minutes Sequence Diagram(s)sequenceDiagram
participant XCBInputWindow
participant InputWindow
participant Theme
XCBInputWindow->>XCBInputWindow: derive metricScale from DPI
XCBInputWindow->>InputWindow: apply metricScale to layout and painting
InputWindow->>Theme: paint(config, targetScale)
Theme->>Theme: scale margins, tiles, and overlays
Theme-->>InputWindow: render scaled output
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ 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: 6
🤖 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 `@src/ui/classic/inputwindow.cpp`:
- Around line 677-680: The Yoga layout calculation for button width combines the
individual action dimensions without rounding, while the paint path rounds each
action's width individually using roundedScaledMetric. At fractional scales,
this divergence causes the next button to extend beyond buttonNode_. Ensure that
when summing the individual widths (prevWidth and nextWidth, obtained from
roundedScaledMetric) in the Yoga path, the combined result is also rounded so it
matches the total width painted by the individual rounded action widths.
In `@src/ui/classic/theme.cpp`:
- Around line 787-845: The overlay clipping and containment calculations around
clipRect and rect currently truncate scaled fractional values through
fcitx::Rect::setPosition/setSize. Keep overlayClipMarginLeft, clipWidth,
overlayWidth, overlayHeight, x, and y in floating-point geometry for
intersection and contains checks, converting to integer Rect coordinates only
for the final rendering operation.
- Around line 334-342: Update the auto-size assignments in the height/width
calculation to round the scaled metric plus margins using the existing
roundedScaledMetric or equivalent std::lround conversion, rather than implicitly
truncating the double result when assigning to int. Preserve the current
fallback conditions and dimension components.
In `@src/ui/classic/xcbinputwindow.cpp`:
- Line 171: Update XCBInputWindow::calculatePositionX and calculatePositionY to
scale each shadowMargin value through roundedScaledMetric using metricScale()
before subtracting it, covering left, right, top, and bottom margins while
preserving the existing positioning logic.
- Around line 211-213: Update the mask/blur-region refresh logic around
parent_->theme().mask() to also track the applied metricScale() (or equivalent
DPI value). Rebuild and reapply the blur property whenever that scale changes,
even when width and height remain unchanged, while preserving the existing
size-change behavior.
In `@src/ui/classic/xcbmenu.cpp`:
- Around line 505-517: In the item.region_ setSize call, replace the second
vertical margin contribution with highlightMargin.marginBottom instead of
repeating highlightMargin.marginTop, while leaving the width and top-margin
calculation unchanged.
🪄 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: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 7a2773dc-d548-48c7-b46f-1b837bc93a42
📒 Files selected for processing (9)
src/ui/classic/common.hsrc/ui/classic/inputwindow.cppsrc/ui/classic/inputwindow.hsrc/ui/classic/theme.cppsrc/ui/classic/theme.hsrc/ui/classic/xcbinputwindow.cppsrc/ui/classic/xcbinputwindow.hsrc/ui/classic/xcbmenu.cppsrc/ui/classic/xcbmenu.h
|
Updated the PR to address the review comments:
|
|
The change could mostly be minimized to xcb part if you just simply downscale the X11 event coordinates and it shall be similar to wayland model. |
This improves HiDPI support in the classic UI XCB path.
Theme margins, overlays, action images, input window layout metrics, menu spacing, menu icons, separators, click regions, blur regions, and masks are now scaled with the current DPI.
This keeps the input window and XCB menu visually consistent on high-DPI displays instead of mixing scaled text with unscaled theme metrics.
Comparison on my KDE Wayland 175% scale setting, with Xft.dpi: 168 for Xwayland:

Wayland:
Xwayland, before this fix:

Xwayland, after this fix:

Summary by CodeRabbit