Skip to content

fix Wayland fractional scaling on Linux#1144

Open
mmaher88 wants to merge 1 commit into
amir1376:masterfrom
mmaher88:pr/wayland-scaling-fix
Open

fix Wayland fractional scaling on Linux#1144
mmaher88 wants to merge 1 commit into
amir1376:masterfrom
mmaher88:pr/wayland-scaling-fix

Conversation

@mmaher88

@mmaher88 mmaher88 commented Mar 16, 2026

Copy link
Copy Markdown

Summary

  • Fix UI rendering at 1x on HiDPI Wayland displays (appears tiny/unscaled)
  • Java AWT doesn't support the wp_fractional_scale_v1 Wayland protocol, so it reports scale=1.0 and DPI=96 regardless of compositor settings
  • Auto-detect real display scale from the OS when AWT fails, using multiple fallback methods

Detection methods (in order)

  1. Environment variables (QT_SCALE_FACTOR, GDK_SCALE)
  2. Xft.dpi via xrdb (most portable, works across DEs via XWayland)
  3. KDE kwinrc [Xwayland] Scale (no subprocess needed)
  4. Hyprland via hyprctl monitors
  5. Sway via swaymsg -t get_outputs

Safety

  • Only activates on Linux + Wayland + AWT reporting scale=1.0
  • If AWT already reports correct scaling (e.g. future JVM fix), the workaround is skipped (no double-scaling)
  • Result is cached (detected once at startup)

Tested on

  • CachyOS (Arch-based), KDE Plasma 6, Wayland, 4K display at 1.7x fractional scaling
  • NVIDIA RTX 2080 Ti

Fixes #291, #778

Test plan

  • Test on KDE Wayland with fractional scaling
  • Test on Hyprland with fractional scaling
  • Test on X11 (should have no effect)
  • Test on Wayland without fractional scaling (should have no effect)

Java AWT doesn't support the wp_fractional_scale_v1 Wayland protocol,
so it always reports scale=1.0 and DPI=96 regardless of the compositor's
actual setting. This causes the UI to render at 1x on HiDPI displays.

Auto-detect the real display scale from the OS when AWT fails:
- Environment variables (QT_SCALE_FACTOR, GDK_SCALE)
- Xft.dpi via xrdb (most portable, works across DEs via XWayland)
- KDE kwinrc [Xwayland] Scale (no subprocess needed)
- Hyprland via hyprctl
- Sway via swaymsg

Includes a guard against double-scaling: if AWT already reports scale>1,
the workaround is skipped, so this is safe if the JVM fixes the issue
in a future version.

Fixes amir1376#291, amir1376#778
@kdroidFilter

Copy link
Copy Markdown
Contributor

The best solution is to use the jbr, if you can't you can use my module https://nucleus.kdroidfilter.com/runtime/linux-hidpi/

@amir1376

Copy link
Copy Markdown
Owner

The best solution is to use the jbr, if you can't you can use my module https://nucleus.kdroidfilter.com/runtime/linux-hidpi/

I'm already using JBR-21 (JBRSDK), does it requires extra configuration in the code?

@kdroidFilter

kdroidFilter commented Apr 18, 2026

Copy link
Copy Markdown
Contributor

I therefore think it's not a real problem; besides, the author himself hasn't tested his solution with fractional scaling. JBR handles that very well. I suggest closing this pr.

@mmaher88

Copy link
Copy Markdown
Author

@kdroidFilter I just missed updating my test results.
I did have issues with fractional scaling on a 4k monitor and this did solve it.
Before that the app was using 1x scaling regardless of what scaling setting is the display config set to.

@kdroidFilter

Copy link
Copy Markdown
Contributor

@mmaher88 can you check with my module https://nucleusframework.dev/runtime/linux-hidpi/ ?

@mmaher88

Copy link
Copy Markdown
Author

@kdroidFilter will definitely do this once am home today.

@amir1376

Copy link
Copy Markdown
Owner

Hi @mmaher88, thank you for creating this PR.

As @kdroidFilter mentioned, since I’m already using JBR, it seems that JBR might already address this issue - though I’m not yet sure how exactly.

The last time I tested the app on Linux, UI scaling wasn’t fixed, so it’s possible that additional configuration or code on my side is needed to enable it.

I’ll keep this PR open until I can confirm whether JBR fully resolves the problem or not.

@kdroidFilter

Copy link
Copy Markdown
Contributor

@amir1376 Yes, this needs to be verified end-to-end, especially since, as I understand it, the issues he mentioned are rendering problems with Nvidia GPUs that crash with hardware acceleration, this has nothing to do with scaling problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Arch Linux app black

3 participants