wayland: surface_scale_explicit_width_height(): dont assert width/height are valid for scale, take 2

764248bb0d modified
wayl_surface_scale_explicit_width_height() to not assert the surface
size is valid for the given scaling factor. This, since that function
is only used when scaling a mouse pointer surface.

However, that commit only updated the code path run when fractional
scaling is available (i.e. when the compositor implements the
fractional-scale-v1 protocol).

The legacy code path, that does integer scaling, was still asserting
the surface width/height were divisible with the scaling factor.

For the same reasons this isn't true with fractional scaling
available, it's not true with integer scaling. Fix by skipping the
assertions.

This patch also converts the assertions to more verbose BUG() calls,
that prints more information on the numbers involved.

Closes #1573
This commit is contained in:
Daniel Eklöf 2024-01-09 16:47:41 +01:00
parent 0ca4633898
commit a2283c8229
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F
2 changed files with 16 additions and 3 deletions

View file

@ -77,8 +77,12 @@
* config: improved validation of color values.
* config: double close of file descriptor, resulting in a chain of
errors ultimately leading to a startup failure ([#1531][1531]).
* Crash when using a desktop scaling factor > 1, on compositors that
implements neither the `fractional-scale-v1`, nor the
`cursor-shape-v1` Wayland protocols ([#1573][1573]).
[1531]: https://codeberg.org/dnkl/foot/issues/1531
[1573]: https://codeberg.org/dnkl/foot/issues/1573
### Security

View file

@ -2024,10 +2024,19 @@ surface_scale_explicit_width_height(
"(width=%d, height=%d)", scale, width, height);
xassert(scale == floorf(scale));
const int iscale = (int)floorf(scale);
xassert(width % iscale == 0);
xassert(height % iscale == 0);
if (verify) {
if (width % iscale != 0) {
BUG("width=%d is not valid with scaling factor %.2f (%d %% %d != 0)",
width, scale, width, iscale);
}
if (height % iscale != 0) {
BUG("height=%d is not valid with scaling factor %.2f (%d %% %d != 0)",
height, scale, height, iscale);
}
}
wl_surface_set_buffer_scale(surf->surf, iscale);
}