Skip to content

xwayland: hidpi support

Dario Nieuwenhuis requested to merge github/fork/Dirbaio/xwayland_hidpi into master

This PR adds hidpi support to xwayland, using the proposed X changes from xorg/xserver!432 .

Sway PR: https://github.com/swaywm/sway/pull/5090

A single, global scale factor is chosen. This scale factor is used for the entire X server, so all x11 apps are rendered at that same scale. wlroots will then scale rendered windows on outputs with scale different to the globa scale factor.

For optimal text rendering, the global scale factor should match the output's, but text is the correct size in all cases (no tiny/huge text on mismatches).

The xserver patches allow the Wayland compositor to control the global scale factor and change it on the fly via a X protocol extension. This is the main difference with the original xserver PR: that one automatically sets the scale factor to the max of the outputs' scales.

IMO having the scale factor configurable is the best choice, because the user can choose on which monitor the text is rendered best. For example: a 4K laptop (scale 2x) attached to a big 1080p external monitor (scale 1x) where the external monitor is the "main" display used for eg coding. The user will want the text to look best on the external monitor, so they'll set the global scale factor to 1.

To communicate the global scale factor to the apps, the X WM registers itself as the xsettings owner, and publishes the setting Gdk/WindowScalingFactor. The setting is updated on scaling factor change, triggering apps to dynamically re-render themselves at the new scale. This leads to a very seamless UX, but will conflict with the user's xsettings daemon if they're running any. In that case, what will happen is the user's daemon will override wlroots's, and if the user doesn't set Gdk/WindowScalingFactor correctly they'll get huge/tiny text. Update: the integrated xsettings is removed now, users must run their own xsettings daemon.

ToDo items:

  • Get the xserver patches upstream
  • The current code assumes the xserver extension is supported, it should fall back to forcing scale factor to 1 if it's not supported (eg user is running an old x server)
  • the code in xwm_xsettings_set is very ugly and inflexible.

Working apps:

  • VSCode (scroll wheel is 2x faster in 2x scale, but I think it's a vscode bug)
  • Firefox
  • Chromium
  • GNOME calculator (forcing it to x11 mode by unsetting WAYLAND_DISPLAY)
  • Nautilus (forcing it to x11 mode by unsetting WAYLAND_DISPLAY)

Not working apps:

  • Spotify: always renders at 1x, so it looks tiny. It doesn't seem to be following xsettings for some reason.
  • GIMP: same

Merge request reports

Loading