-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix display scaling on linux #9390
Comments
X11 does not support per display scaling. Any values you set in your system settings in your Wayland-powered DE are invisible to X11 apps. Technically nothing prevents DE authors from providing per-display DPI information to X11 apps, but they deliberately choose not to. Avalonia currently has the same behavior as Qt5 in automatic DPI mode which is DPI detection based on display EDID with an environment variable override. EDID information is incorrect with XWayland. TL;DR: Wait for a Wayland backend to be ready or switch to pure X11 session |
You are running a Wayland session. Your Qt app is running with Wayland support. |
@kekekeks Why do you think that it is Wayland session? @timunie Behavior is wrong on both Wayland and x11. In initital post Wayland is present only in Gnome. |
@HermanKirshin I think you are right 👍 |
Made some important refactorings in scale factor detection algorithm https://github.com/HermanKirshin/LinuxDisplayScale |
After taking a look at heuristics in your repo, I'm not sure we can use those. We might just follow what Qt6 does, which is just reading |
That would be not perfect but good enough, because It will work on Gnome+Wayland but unlike KDE will not respect mixed monitor settings It will not respect system settings on MATE, XFCE, LXQt and some others, but I think they are not frequent choice for HiDpi configurations. It will work same way both on real and virtual machines. So I think reading Xft.dpi is way more better approach than current magic with EDID, because unlike EDID it at least works and moreover - it will handle correctly at least half of cases. |
And why trying to also read values from libgtk is not an option? |
Attempting to use GTK from the UI thread will break our native dialogs since they require a separate GTK-powered event loop on a background thread. |
But calling it using GtkInteropHelper.RunOnGLibThread with preceding XInitThreads works fine and does not break native dialogs |
Any update on this ? |
Any updates? |
Avalonia currently reads Xft.dpi value from XRDB, which is the only thing we can do since WM/DE authors simply refuse to provide accurate per-monitor scaling information for X11 apps. Avalonia also respects QT environment variables (QT_SCREEN_SCALE_FACTOR/QT_AUTO_SCREEN_SCALE_FACTOR) for configuring per-monitor scaling, so if you set such envs in /etc/profile those should work. |
Is this something which needs to be programmed into each application? I've tried a few things to get Scarab to scale, but none of these seem to work:
|
@l0b0 Have you tried:
|
Sets `AVALONIA_GLOBAL_SCALE_FACTOR` to the GNOME desktop scaling factor based on <AvaloniaUI/Avalonia#9390 (comment)>.
Sets `AVALONIA_GLOBAL_SCALE_FACTOR` to the GNOME desktop scaling factor based on <AvaloniaUI/Avalonia#9390 (comment)>, falling back to the X FreeType DPI setting if the former is not available.
Sets `AVALONIA_GLOBAL_SCALE_FACTOR` to the GNOME desktop scaling factor based on <AvaloniaUI/Avalonia#9390 (comment)>, falling back to the X FreeType DPI setting if the former is not available.
Sets `AVALONIA_GLOBAL_SCALE_FACTOR` to the GNOME desktop scaling factor based on <AvaloniaUI/Avalonia#9390 (comment)>, falling back to the X FreeType DPI setting if the former is not available. Does not include `gsettings` and `xrdb` in build inputs, since these should be available on the relevant platforms. Bash does not support decimal/floating point arithmetic, so this *does* include `bc` in the runtime dependencies.
Sets `AVALONIA_GLOBAL_SCALE_FACTOR` to the GNOME desktop scaling factor based on <AvaloniaUI/Avalonia#9390 (comment)>, falling back to the X FreeType DPI setting if the former is not available. Does not include `gsettings` and `xrdb` in build inputs, since these should be available on the relevant platforms. Bash does not support decimal/floating point arithmetic, so this *does* include `bc` in the runtime dependencies.
Sets `AVALONIA_GLOBAL_SCALE_FACTOR` to the GNOME desktop scaling factor based on <AvaloniaUI/Avalonia#9390 (comment)>, falling back to the X FreeType DPI setting if the former is not available. Does not include `gsettings` and `xrdb` in build inputs, since these should be available on the relevant platforms. Bash does not support decimal/floating point arithmetic, so this *does* include `bc` in the runtime dependencies.
Sets `AVALONIA_GLOBAL_SCALE_FACTOR` to the GNOME desktop scaling factor based on <AvaloniaUI/Avalonia#9390 (comment)>, falling back to the X FreeType DPI setting if the former is not available. Does not include `gsettings` and `xrdb` in build inputs, since these should be available on the relevant platforms. Bash does not support decimal/floating point arithmetic, so this *does* include `bc` in the runtime dependencies.
Sets `AVALONIA_GLOBAL_SCALE_FACTOR` to the GNOME desktop scaling factor based on <AvaloniaUI/Avalonia#9390 (comment)>, falling back to the X FreeType DPI setting if the former is not available. Does not include `gsettings` and `xrdb` in build inputs, since these should be available on the relevant platforms. Bash does not support decimal/floating point arithmetic, so this *does* include `bc` in the runtime dependencies.
Related to #4826
I have tested how application is displayed in 7 different desktop environments on real hardware with multiple monitors (combination of high-dpi and low-dpi), some of them cover 90% of cases I think. Here are the results:
Default Avalonia behavior:
Always rendered in 100%
incorrect (Scale settings does not affect, looks too small on HiDpi displays)
always rendered 200% on HiDpi display and 100% on LowDpi display
incorrect, displays may be configured to 150% and app will be bigger than expected, and on low dpi smaller than expected.
on virtual machine always rendered 100% because virtual monitor does not report physical size and HiDpi detection logic fails
if all monitors set to 100% then rendered 200% on HiDpi monitor and 100% on LoDpi monitor
incorrect, HiDpi may be configured to 100 or 150 and app will be bigger than expected, and on low dpi smaller than expected.
Configure HiDpi to 125% and LoDpi to 100% then displayed on HiDpi in 62% and on LoDpi in 50%
Configure HiDpi to 100% and LoDpi to 200% then displayed on HiDpi in 50% and on LoDpi in 100%
incorrect, app looks even smaller while all other apps are displayed correctly (unlike XFCE where everything looks weird)
I have looked into X11Screens code, ant it does very strange things.
Conclusion - looks like there is NO linux setups where avalonia apps are scaled correctly, while majority of up-to-date apps are displayed as expected respecting scale factors from system settings.
Missing such fundamental feature is a serious flaw, because most other UI frameworks are capable to do it. If they can, why we cannot? It is possible to get with high probability correct values from system, that will cover majority of cases, here is some prototype:
https://github.com/HermanKirshin/LinuxDisplayScale/blob/main/Program.cs
Currently I use this to setup AVALONIA_SCREEN_SCALE_FACTORS before calling AppBuilder
Also here is some investigation summary about desktop environments https://github.com/HermanKirshin/LinuxDisplayScale/blob/main/linux_scale_info.txt
The text was updated successfully, but these errors were encountered: