wayl_surface_scale_explicit_width_height(): don’t assert width/height are valid for scale

This function is only called directly when scaling the mouse
pointer. The mouse pointer is never guaranteed to have a valid width
and height, so skip the width/height assertions for it.
This commit is contained in:
Daniel Eklöf 2023-07-29 08:18:00 +02:00
parent 1782474481
commit 764248bb0d
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F

View file

@ -2000,18 +2000,31 @@ wayl_roundtrip(struct wayland *wayl)
wayl_flush(wayl);
}
void
wayl_surface_scale_explicit_width_height(
static void
surface_scale_explicit_width_height(
const struct wl_window *win, const struct wayl_surface *surf,
int width, int height, float scale)
int width, int height, float scale, bool verify)
{
if (term_fractional_scaling(win->term)) {
#if defined(HAVE_FRACTIONAL_SCALE)
LOG_DBG("scaling by a factor of %.2f using fractional scaling "
"(width=%d, height=%d) ", scale, width, height);
xassert((int)roundf(scale * (int)roundf(width / scale)) == width);
xassert((int)roundf(scale * (int)roundf(height / scale)) == height);
if (verify) {
if ((int)roundf(scale * (int)roundf(width / scale)) != width) {
BUG("width=%d is not valid with scaling factor %.2f (%d != %d)",
width, scale,
(int)roundf(scale * (int)roundf(width / scale)),
width);
}
if ((int)roundf(scale * (int)roundf(height / scale)) != height) {
BUG("height=%d is not valid with scaling factor %.2f (%d != %d)",
height, scale,
(int)roundf(scale * (int)roundf(height / scale)),
height);
}
}
wl_surface_set_buffer_scale(surf->surf, 1);
wp_viewport_set_destination(
@ -2034,12 +2047,20 @@ wayl_surface_scale_explicit_width_height(
}
}
void
wayl_surface_scale_explicit_width_height(
const struct wl_window *win, const struct wayl_surface *surf,
int width, int height, float scale)
{
surface_scale_explicit_width_height(win, surf, width, height, scale, false);
}
void
wayl_surface_scale(const struct wl_window *win, const struct wayl_surface *surf,
const struct buffer *buf, float scale)
{
wayl_surface_scale_explicit_width_height(
win, surf, buf->width, buf->height, scale);
surface_scale_explicit_width_height(
win, surf, buf->width, buf->height, scale, true);
}
void