Fix #105895: UI scaled down with 125% fractional scaling on Wayland
The DPI returned by the GHOST/Wayland didn't account the buffer being rendered at a higher (non-fractional) resolution, then scaled down. This caused the software cursor and UI to rendered very small. A fractional scale of 101% would show the UI just over 50% of the size (making the UI to be close to half the scale it should have been). Resolve by accounting for down-scaling of the buffer to it's fractional size.
This commit is contained in:
@@ -1188,9 +1188,25 @@ uint16_t GHOST_WindowWayland::getDPIHint()
|
||||
/* No need to lock `server_mutex`
|
||||
* (`outputs_changed_update_scale` never changes values in a non-main thread). */
|
||||
|
||||
const wl_fixed_t scale_fractional = window_->scale_fractional;
|
||||
GHOST_ASSERT(wl_fixed_from_int(window_->scale) >= scale_fractional,
|
||||
"Fractional scale should always be less than the fixed scale.");
|
||||
|
||||
/* Using the physical DPI will cause wrong scaling of the UI
|
||||
* use a multiplier for the default DPI as a workaround. */
|
||||
return wl_fixed_to_int(window_->scale_fractional * base_dpi);
|
||||
if (wl_fixed_from_int(window_->scale) == scale_fractional || window_->scale <= 1) {
|
||||
/* No fractional scaling. */
|
||||
return window_->scale * base_dpi;
|
||||
}
|
||||
const int scale_ceil = window_->scale;
|
||||
const int scale_floor = scale_ceil - 1;
|
||||
const wl_fixed_t scale_fractional_final = wl_fixed_to_int(
|
||||
scale_fractional *
|
||||
/* Compensate for the buffer being rendered at `window_->scale`,
|
||||
* then scaled down fractionally. */
|
||||
(wl_fixed_from_int(1) + ((wl_fixed_from_int(scale_ceil) - scale_fractional) / scale_floor)));
|
||||
|
||||
return wl_fixed_to_int(scale_fractional_final * base_dpi);
|
||||
}
|
||||
|
||||
GHOST_TSuccess GHOST_WindowWayland::setWindowCursorVisibility(bool visible)
|
||||
|
||||
Reference in New Issue
Block a user