Add option to set Per-Game and Global Wine DPI value #915
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This topic was previously discussed in #900, and the ideas discussed there have now been implemented more broadly.
Overview
This PR adds an option to configure a Global and Per-Game Wine DPI scaling value. This option is available for configuration from Winecfg, but this PR exposes it on the SteamTinkerLaunch GUI on the Global Menu (Global Scale) and Game Menu (Per-Game Scale).
Effectively, this option allows for increasing the font size, and thus the rendering size of a given window under Wine. This option is useful when the text that an application may display is too small to be read comfortably, MO2 suffers from this in my experience and others' experienced as well (though it may be configurable from a theme). This option is also useful for people who are using fraction scaling on Wayland with a multi-monitor setup, and have unscaled monitors. In this scenario, this option complements KDE Plasma Wayland's now-default legacy application scaling setting, "Apply Scaling Themselves".
I implemented this option because I pretty much needed it when playing Oblivion with ModOrganizer 2, as not only was Oblivion's launcher rendered incorrectly on my displays (needed to bump the resolution to 3840x2160 once), so was the ModOrganizer 2 UI.
Implementation
The Wine DPI scaling can be configured from Winecfg, but for convenience we now exposed the option on the UI. To set the scaling value, we can write directly out to the current game prefix's registry. We write under
HKEY_CURRENT_USER\\Control Panel\\Desktop
to the keyLogPixels
, and write out the value in decimal (thereg
command can convert it to hexadecimal, which the registry actually stores).We write this value out on launch if the DPI scale value is enabled, however, we can't unset this. There is no good way to know when the DPI value should be updated without creating a messy system to track the previous preferences state and so on. Therefore, this value is applied permanently to the prefix, though a user is free to modify the value back. Just like with Winecfg, the user is expected to know how to tinker with this properly. We also offer ways to directly access Winecfg should the need arise through a checkbox on the Game Menu to launch Winecfg before game launch, as well as on the One-Time Run menu.
Future Work
In future, it may be worth exposing this option for third-party tools which have their own prefixes, such as MO2 and Vortex Mod Manager.
We should create a wiki page, perhaps a general section for limitations, workarounds, and tips when running under Wayland, as this option is useful as well in combination with Steam's lesser-known
STEAM_FORCE_DESKTOPUI_SCALING=1.5
value. There are also some funky Yad behaviours in this mode as well which are annoying but at the moment have no workarounds. The notes about how this DPI value is applied should also be documented on this wiki, as well as how to change these values back if a user is stuck.I wrote out a big PR description for this, and when I tried to create the PR, it disappeared into the aether. I have no idea where the PR went, but it's disappeared, and so too has my motivation to describe this feature in as much detail again 😓
TODO: