[client] wayland: improve fractional scale handling

Currently, we scale the desktop up to the next largest integer, and rely on
the wayland compositor to scale it back down to the correct size.
This is obviously undesirable.

In this commit, we attempt to detect the actual fractional scaling by finding
the current active mode in wl_output, and dividing it by the logical screen
size reported by xdg_output, taking into consideration screen rotation.

We then use wp_viewporter to set the exact buffer and viewport sizes if
fractional scaling is needed.
This commit is contained in:
Quantum
2021-07-31 21:56:47 -04:00
committed by Geoffrey McRae
parent 3baed05728
commit b3ca872cef
6 changed files with 152 additions and 19 deletions

View File

@@ -33,12 +33,12 @@
void waylandWindowUpdateScale(void)
{
int32_t maxScale = 0;
wl_fixed_t maxScale = 0;
struct SurfaceOutput * node;
wl_list_for_each(node, &wlWm.surfaceOutputs, link)
{
int32_t scale = waylandOutputGetScale(node->output);
wl_fixed_t scale = waylandOutputGetScale(node->output);
if (scale > maxScale)
maxScale = scale;
}
@@ -46,6 +46,7 @@ void waylandWindowUpdateScale(void)
if (maxScale)
{
wlWm.scale = maxScale;
wlWm.fractionalScale = wl_fixed_from_int(wl_fixed_to_int(maxScale)) != maxScale;
wlWm.needsResize = true;
}
}
@@ -77,7 +78,7 @@ static const struct wl_surface_listener wlSurfaceListener = {
bool waylandWindowInit(const char * title, bool fullscreen, bool maximize, bool borderless)
{
wlWm.scale = 1;
wlWm.scale = wl_fixed_from_int(1);
if (!wlWm.compositor)
{