diff options
| author | Daniel Eklöf <daniel@ekloef.se> | 2023-07-29 06:18:00 +0000 |
|---|---|---|
| committer | Daniel Eklöf <daniel@ekloef.se> | 2023-07-29 06:18:00 +0000 |
| commit | 764248bb0d846f65c20931024c1f4adca57aae29 (patch) | |
| tree | b02ae4e5a876f2931537be510e98b2557ef117a9 | |
| parent | fractional scaling: another round(!) of rounding fixes (diff) | |
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.
| -rw-r--r-- | wayland.c | 35 |
1 files changed, 28 insertions, 7 deletions
@@ -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( @@ -2035,11 +2048,19 @@ 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 |
