fix Wayland fractional scaling on Linux#1144
Conversation
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
|
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? |
|
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. |
|
@kdroidFilter I just missed updating my test results. |
|
@mmaher88 can you check with my module https://nucleusframework.dev/runtime/linux-hidpi/ ? |
|
@kdroidFilter will definitely do this once am home today. |
|
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. |
|
@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. |
Summary
wp_fractional_scale_v1Wayland protocol, so it reports scale=1.0 and DPI=96 regardless of compositor settingsDetection methods (in order)
QT_SCALE_FACTOR,GDK_SCALE)Xft.dpivia xrdb (most portable, works across DEs via XWayland)[Xwayland] Scale(no subprocess needed)hyprctl monitorsswaymsg -t get_outputsSafety
Tested on
Fixes #291, #778
Test plan