You are here

Kwin Wayland High DPI Support

The current world of high DPI works fine when dealing with a single montior and only dealing with modern apps.
but it breaks down with multiple monitors.

What we want to see:

What we need to render:

As well as windows being spread across outputs, we also want the following features to work:

  • Legacy applications to still be readable and usable
  • Mouse speed to be consistent
  • Screenshots to be consistent across screens
  • All toolkits behaving the same through a common protocol

Handling scaling is part of the core wayland protocol and, with some changes in kwin, solves all of these problems.

The system

The system is a bit counter-intuitive, yet at the same time very simple; instead of clients having bigger windows and adjusting all the
input and positioning, we pretend everything is normal DPI and kwin just renders the entire screen at twice the size.
Clients, then provide textures (pictures of their window contents) that are twice the resolution of their window size.

This covers all possible cases:
- we render a 1x window on a 2x screen:
Because kwin scales up all the rendering, the window is shown twice the size, and therefore readable, albeit at standard resolution.

- we render a 2x window on a 1x screen:
The window texture will be downsampled to be the right size.

- we render a 2x window on a 2x screen:
Kwin scales up all the output, so we draw the window at twice the size. However, because the texture is twice as detailed this cancels out
and we end up showing it at the native drawn resolution giving us the high DPI detail.

The changes in KWin are not about adding explicit resizing or input redirection anywhere; but instead about decoupling the assumption between the size of a window or monitor, and its actual resolution.

What changes for app developers?

Nothing.

When?

All the kwin code changes landed in time for Plasma 5.10, but dynamically changing the screen scale exposed some problems elsewhere in the stack. Thefore the main UI has been disabled till hopefully Plasma 5.11. This also allows us to expand our testing with users that want to manually edit their kscreen config and opt-in.

What about fractional scaling?

Despite Qt having quite good fractional scaling support, the wayland protocol limits itself to integers. This is in the very core protocol and somewhat hard to avoid. However, there's technically nothing stopping kwin from scaling to a different size than it tells the client to scale at...So it's something we can revisit later.

Tags: