UI scaling issues when physical and logical screen resolutions differ on Linux

Martin Fox martin at martinfox.com
Wed Feb 21 22:06:58 UTC 2024


Christopher,

I’ve entered a bug to track this. See https://bugs.openjdk.org/browse/JDK-8326428

JavaFX added support for scaling-factor back in 2016 to address an issue with Ubuntu 16. Since then I suspect that setting has fallen into disuse. I know that it’s not set in Ubuntu/Kubuntu 22 but I can’t easily test earlier releases. My hunch is that on most distros it is set to 0 which would allow JavaFX to compute the correct UI scale.

Until recently KDE did not mess with this setting but that changed with version 5.27.8 which was released in the middle of last year. According to the commit message KDE started setting scaling-factor to make apps like IntelliJ IDE behave better. But this means the value is sure to be incorrect when the real scaling is fractional.

I suspect JavaFX should probably be ignoring this setting. Until we can sort this out the only work-around is to set the scaling-factor to 0 yourself to undo what KDE did or use the glass.gtk.uiScale override.

Martin

> On Feb 20, 2024, at 8:57 PM, Christopher Schnick <crschnick at xpipe.io> wrote:
> 
> So I tested this on my Asahi Fedora Linux KDE setup. So you were right about the scaling-factor being set to 1, but I'm still a little bit confused about this situation.
> 
> If I go into the KDE settings, and change the display scaling to 150% for example, other (native) applications somehow get scaled appropriately. However, the scaling-factor property in gsettings is an integer and gets rounded down. So if I set display scaling to 150% in the settings, it will still get rounded down to one, leading to a wrong scaling for JavaFX applications. I would argue that JavaFX applications not scaling correctly on KDE systems is not a small issue as it makes some applications unusable unless the developer add support for custom scaling explicitly. So I have two questions:
> - Is the default dpi calculation also error prone? If not, why not always use the manual calculation on KDE systems
> - Are there better alternatives to the gsettings scaling-factor? Something like org.gnome.desktop.interface text-scaling-factor
> 
> On 16/02/2024 21:31, Martin Fox wrote:
>> Hi Christopher,
>> 
>> This may be a side-effect of using KDE. To determine the UI scale the JavaFX code consults the “scaling-factor” setting in the “org.gnome.desktop.interface” schema. You can check this on the command line:
>> 
>> 	gsettings get org.gnome.desktop.interface scaling-factor
>> 
>> This should be 0 so JavaFX can compute the scale itself. If it’s greater than 0 that’s the value JavaFX will use for the UI scale.
>> 
>> It appears that a KDE install can set this value to 1. In my case I started with the ARM version of Ubuntu server and then installed KDE (kubuntu-desktop) and afterward the scaling-factor was 1. This doesn’t happen when installing the standard GNOME desktop.
>> 
>> Martin
>> 
>>> On Feb 13, 2024, at 2:13 AM, Christopher Schnick <crschnick at xpipe.io> <mailto:crschnick at xpipe.io> wrote:
>>> 
>>> Hello,
>>> 
>>> several users of our JavaFX applications have reported that the UI scale is too small when the physical and logical screen resolutions differ on Linux. For example in this case
>>> 
>>> <Screenshot_20240125_115224(1).png>
>>> 
>>> there is an implicit scaling factor of 150% included as the monitor is a 4k display but is using a lowered resolution of 2560x1440. This is then further stretched as the OS resolution is 1920x1080, but the main problem is that the 150% factor is somehow not getting picked up and JavaFX is treating this as a 4k display, thus making everything too small. For now these users can use -Dglass.gtk.uiScale=1.5 but that is not a nice solution to this problem.
>>> 
>>> Best
>>> Christopher Schnick
>>> 
>> 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/openjfx-dev/attachments/20240221/9354bc90/attachment.htm>


More information about the openjfx-dev mailing list