Minor code pruning

* dmabuf.c (struct _BufferParams): Prune unused code.
* shm.c (CreateBuffer): Fix offset checks.
* xdg_toplevel.c (SetAppId): Don't allow setting the app ID on a
mapped surface.
This commit is contained in:
oldosfan 2022-09-15 07:04:20 +00:00
parent 007ba43dba
commit 266c3e5c1e
3 changed files with 11 additions and 7 deletions

View file

@ -102,9 +102,6 @@ struct _BufferParams
/* The width and height of the buffer that will be created. */ /* The width and height of the buffer that will be created. */
int width, height; int width, height;
/* The buffer ID that will be used to create the buffer. */
uint32_t buffer_id;
/* The DRM format. */ /* The DRM format. */
uint32_t drm_format; uint32_t drm_format;
}; };

10
shm.c
View file

@ -263,17 +263,18 @@ CreateBuffer (struct wl_client *client, struct wl_resource *resource,
if (!depth) if (!depth)
{ {
wl_resource_post_error (resource, WL_SHM_ERROR_INVALID_FORMAT, wl_resource_post_error (resource, WL_SHM_ERROR_INVALID_FORMAT,
"The specified format is not supported"); "the specified format is not supported");
return; return;
} }
pool = wl_resource_get_user_data (resource); pool = wl_resource_get_user_data (resource);
if (pool->size < offset || stride != width * 4 if (pool->size < offset || stride != width * 4
|| offset + stride * height > pool->size) || offset + stride * height > pool->size
|| offset < 0)
{ {
wl_resource_post_error (resource, WL_SHM_ERROR_INVALID_STRIDE, wl_resource_post_error (resource, WL_SHM_ERROR_INVALID_STRIDE,
"Invalid offset or stride, or pool too small"); "invalid offset or stride, or pool too small");
return; return;
} }
@ -288,7 +289,8 @@ CreateBuffer (struct wl_client *client, struct wl_resource *resource,
{ {
/* X doesn't support smaller drawables. */ /* X doesn't support smaller drawables. */
wl_resource_post_error (resource, WL_SHM_ERROR_INVALID_STRIDE, wl_resource_post_error (resource, WL_SHM_ERROR_INVALID_STRIDE,
"Invalid size, X server does not support zero-width drawables"); "invalid size, this server does not support"
" zero-width drawables");
return; return;
} }

View file

@ -1622,6 +1622,11 @@ SetAppId (struct wl_client *client, struct wl_resource *resource,
if (!toplevel->role) if (!toplevel->role)
return; return;
if (toplevel->state & StateIsMapped)
/* The toplevel is already mapped. Setting class hints in this
situation is not possible under X. */
return;
class_hints.res_name = (char *) app_id; class_hints.res_name = (char *) app_id;
class_hints.res_class = (char *) app_id; class_hints.res_class = (char *) app_id;