Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to set Per-Game and Global Wine DPI value #915

Merged
merged 5 commits into from
Sep 23, 2023
Merged

Conversation

sonic2kk
Copy link
Owner

@sonic2kk sonic2kk commented Sep 23, 2023

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 key LogPixels, and write out the value in decimal (the reg 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:

  • More testing to ensure Global Scale applies properly
  • More testing to ensure Per-Game Scale applies and overrides Global Scale
  • More testing to ensure this setting is only applied when the settings are enabled
  • Update wiki with information about this, including that this may not work as expected with all applications depending on how the deal with reported DPI
  • Update langfiles

@sonic2kk
Copy link
Owner Author

sonic2kk commented Sep 23, 2023

Untested, but this option may not work for Vortex. We may need to pass the argument `--force-device-scale-factor= to the executable independent of this scale factor.

This --force-device-scale-factor argument is used for Electron applications. It is generally only needed for very old native Linux Electron applications, or Electron applications running under Wine (such as Cookie Clicker or Vortex Mod Manager).

@sonic2kk
Copy link
Owner Author

A comprehensive wiki page covering scaling options for various different applications, toolkits, Wine, and SteamTinkerLaunch itself has been created: HiDPI Scaling wiki page.

@sonic2kk
Copy link
Owner Author

This all appears to be working in testing. Per-Game Scale overrides Global Scale correctly, and each option works individually. When the Global Scale is disabled, and a new game is launched, it will not pass any DPI scaling.

Probably this is ready to merge after some more testing, and a langfile update.

@sonic2kk
Copy link
Owner Author

Apparently I was setting USEGLOBALWINEDPI to DEFWINEDPI by default, this is what I get for copypasting...

This didn't seem to cause issues, as I guess any value not 0 or 1 was defaulting to 0, since this option was off by default in my testing.

@sonic2kk
Copy link
Owner Author

Shellcheck is good, testing is good, I think this is ready!

@sonic2kk sonic2kk merged commit 7c94883 into master Sep 23, 2023
@sonic2kk sonic2kk deleted the set-wine-dpi branch September 24, 2023 20:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant