[mutter] wayland/surface: Implement WL_SURFACE_ERROR_INVALID_SIZE check



commit ab17c98c947aa9a53eecf27d7242c18c5dccbbfc
Author: Robert Mader <robert mader posteo de>
Date:   Thu Dec 30 03:41:07 2021 +0100

    wayland/surface: Implement WL_SURFACE_ERROR_INVALID_SIZE check
    
    From the spec:
    > This means that at commit time the supplied buffer size must be
    > an integer multiple of the buffer_scale. If that's not the case,
    > an invalid_size error is sent.
    
    Closes https://gitlab.gnome.org/GNOME/mutter/-/issues/1938
    
    Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2188>

 src/wayland/meta-wayland-surface.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
---
diff --git a/src/wayland/meta-wayland-surface.c b/src/wayland/meta-wayland-surface.c
index 5bd0d684d5..1032c4a78c 100644
--- a/src/wayland/meta-wayland-surface.c
+++ b/src/wayland/meta-wayland-surface.c
@@ -787,6 +787,17 @@ meta_wayland_surface_apply_state (MetaWaylandSurface      *surface,
   if (state->scale > 0)
     surface->scale = state->scale;
 
+  if ((get_buffer_width (surface) % surface->scale != 0) ||
+      (get_buffer_height (surface) % surface->scale != 0))
+    {
+      wl_resource_post_error (surface->resource, WL_SURFACE_ERROR_INVALID_SIZE,
+                              "Buffer size (%dx%d) must be an integer multiple "
+                              "of the buffer_scale (%d)",
+                              get_buffer_width (surface),
+                              get_buffer_height (surface), surface->scale);
+      goto cleanup;
+    }
+
   if (state->has_new_buffer_transform)
     surface->buffer_transform = state->buffer_transform;
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]