The standard way to determine the user interface scaling factor on Linux is to 
consult the reported monitor DPI and divide by 96 (which is also the way it's 
done on Windows). This allows the scaling factor to vary per-monitor and also 
achieve fractional values.

Before this became the standard the Gnome toolkit communicated the scaling 
factor using the "GDK_SCALE" environment variable or the 
"org.gnome.desktop.interface" "scaling-factor" gsetting. These were always 
integer values (no fractional scaling) and applied to all monitors. They became 
the de-facto way of communicating the scaling factor and were picked  by 
various toolkits including JavaFX. They are now obsolete within Gnome.

JavaFX will compute correct per-monitor scaling factors if GDK_SCALE and 
"scaling-factor" aren't set. Gnome no longer sets these but unfortunately the 
KDE desktop does in an attempt to get certain apps to scale (one bug report 
specifically called out IntelliJ). In KDE for Ubuntu 24 the "scaling-factor" is 
always set to the floor of the actual scaling factor which is preventing JavaFX 
from computing fractional scales. Either setting will prevent JavaFX from 
computing per-monitor scales.

This PR changes the priority of the ui scale tests. As always, the JavaFX 
"glass.gtk.uiScale" setting takes precedence. If that's not set the system uses 
the scaling computed based on the monitor DPI. It only consults the legacy 
settings if the reported DPI is 96.

Ignoring GDK_SCALE is problematic since there are certainly users who use this 
as a convenient way to influence JavaFX (if only to work around this bug). If 
we want to provide an environment variable for them we should create our own 
and not rely on the legacy variables of other toolkits.

-------------

Commit messages:
 - Prioritize DPI-based scaling factor over legacy global variables

Changes: https://git.openjdk.org/jfx/pull/1994/files
  Webrev: https://webrevs.openjdk.org/?repo=jfx&pr=1994&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8326428
  Stats: 20 lines in 1 file changed: 8 ins; 0 del; 12 mod
  Patch: https://git.openjdk.org/jfx/pull/1994.diff
  Fetch: git fetch https://git.openjdk.org/jfx.git pull/1994/head:pull/1994

PR: https://git.openjdk.org/jfx/pull/1994

Reply via email to