aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Ser <contact@emersion.fr>2022-05-07 10:28:05 +0200
committerIsaac Freund <mail@isaacfreund.com>2022-06-01 12:56:42 +0000
commit18595000f3a21502fd60bf213122859cc348f9af (patch)
treef6e1b54df88a47e14ab2525a9d2b3e66a4f8b194
parent1284f85da4ee9345af31d239a2e451c4066e710b (diff)
downloadwlroots-18595000f3a21502fd60bf213122859cc348f9af.tar.xz
compositor: send WL_SURFACE_ERROR_INVALID_SIZE for non-cursor surfaces
See the discussion at [1]: there's no easy way to fix libwayland-cursor without a new API. Sending the error for other roles will prevent the same client bug from appearing elsewhere. [1]: https://gitlab.freedesktop.org/wayland/wayland/-/issues/194
-rw-r--r--types/wlr_compositor.c19
1 files changed, 14 insertions, 5 deletions
diff --git a/types/wlr_compositor.c b/types/wlr_compositor.c
index 1e86e9e7..8b84a643 100644
--- a/types/wlr_compositor.c
+++ b/types/wlr_compositor.c
@@ -176,12 +176,21 @@ static void surface_finalize_pending(struct wlr_surface *surface) {
if (!pending->viewport.has_src &&
(pending->buffer_width % pending->scale != 0 ||
pending->buffer_height % pending->scale != 0)) {
- // TODO: send WL_SURFACE_ERROR_INVALID_SIZE error once this issue is
- // resolved:
+ // TODO: send WL_SURFACE_ERROR_INVALID_SIZE error to cursor surfaces
+ // once this issue is resolved:
// https://gitlab.freedesktop.org/wayland/wayland/-/issues/194
- wlr_log(WLR_DEBUG, "Client bug: submitted a buffer whose size (%dx%d) "
- "is not divisible by scale (%d)", pending->buffer_width,
- pending->buffer_height, pending->scale);
+ if (!surface->role
+ || strcmp(surface->role->name, "wl_pointer-cursor") == 0
+ || strcmp(surface->role->name, "wp_tablet_tool-cursor") == 0) {
+ wlr_log(WLR_DEBUG, "Client bug: submitted a buffer whose size (%dx%d) "
+ "is not divisible by scale (%d)", pending->buffer_width,
+ pending->buffer_height, pending->scale);
+ } else {
+ wl_resource_post_error(surface->resource,
+ WL_SURFACE_ERROR_INVALID_SIZE,
+ "Buffer size (%dx%d) is not divisible by scale (%d)",
+ pending->buffer_width, pending->buffer_height, pending->scale);
+ }
}
if (pending->viewport.has_dst) {