mirror of
https://github.com/godotengine/godot.git
synced 2026-01-03 18:11:19 +03:00
Wayland: Workaround API limitation in screen/UI scale logic
Mainly, this fixes auto UI scaling with _single-monitor_ fractional setups (see the comment in `display_server_wayland.cpp` for more info). This is the result of a bunch of current limitations, mainly the fact that the UI scale is static (it's probed at startup) and the fact that Wayland exposes fractional scales only at the window-level, by design. The `screen_get_scale` special case should help in 99% of cases, while the auto UI scale part will unfortunately only help with single-screen situations, as multi-screen fractional scaling requires dynamic UI scale changing.
This commit is contained in:
@@ -1540,6 +1540,19 @@ String EditorSettings::get_editor_layouts_config() const {
|
||||
float EditorSettings::get_auto_display_scale() const {
|
||||
#ifdef LINUXBSD_ENABLED
|
||||
if (DisplayServer::get_singleton()->get_name() == "Wayland") {
|
||||
float main_window_scale = DisplayServer::get_singleton()->screen_get_scale(DisplayServer::SCREEN_OF_MAIN_WINDOW);
|
||||
|
||||
if (DisplayServer::get_singleton()->get_screen_count() == 1 || Math::fract(main_window_scale) != 0) {
|
||||
// If we have a single screen or the screen of the window is fractional, all
|
||||
// bets are off. At this point, let's just return the current's window scale,
|
||||
// which is special-cased to the scale of `SCREEN_OF_MAIN_WINDOW`.
|
||||
return main_window_scale;
|
||||
}
|
||||
|
||||
// If the above branch didn't fire, fractional scaling isn't going to work
|
||||
// properly anyways (we're need the ability to change the UI scale at runtime).
|
||||
// At this point it's more convenient to "supersample" like we do with other
|
||||
// platforms, hoping that the user is only using integer-scaled screens.
|
||||
return DisplayServer::get_singleton()->screen_get_max_scale();
|
||||
}
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user