mirror of
https://gitlab.freedesktop.org/wayland/wayland.git
synced 2025-11-02 09:01:39 -05:00
Define shm specific errors
We stop abusing the wl_display error codes for shm purposes.
This commit is contained in:
parent
1db0525572
commit
8834a0f22f
2 changed files with 16 additions and 15 deletions
|
|
@ -87,6 +87,12 @@
|
||||||
|
|
||||||
<!-- Shared memory support -->
|
<!-- Shared memory support -->
|
||||||
<interface name="wl_shm" version="1">
|
<interface name="wl_shm" version="1">
|
||||||
|
<enum name="error">
|
||||||
|
<entry name="invalid_visual" value="0"/>
|
||||||
|
<entry name="invalid_stride" value="1"/>
|
||||||
|
<entry name="invalid_fd" value="2"/>
|
||||||
|
</enum>
|
||||||
|
|
||||||
<!-- Transfer a shm buffer to the server. The allocated buffer
|
<!-- Transfer a shm buffer to the server. The allocated buffer
|
||||||
would include at least stride * height bytes starting at the
|
would include at least stride * height bytes starting at the
|
||||||
beginning of fd. The file descriptor is transferred over the
|
beginning of fd. The file descriptor is transferred over the
|
||||||
|
|
|
||||||
|
|
@ -117,24 +117,21 @@ shm_create_buffer(struct wl_client *client, struct wl_shm *shm,
|
||||||
uint32_t stride, struct wl_visual *visual)
|
uint32_t stride, struct wl_visual *visual)
|
||||||
{
|
{
|
||||||
struct wl_shm_buffer *buffer;
|
struct wl_shm_buffer *buffer;
|
||||||
struct wl_display *display = wl_client_get_display(client);
|
|
||||||
|
|
||||||
void *data;
|
void *data;
|
||||||
|
|
||||||
/* FIXME: Define a real exception event instead of abusing the
|
|
||||||
* display.invalid_object error */
|
|
||||||
if (visual->object.interface != &wl_visual_interface) {
|
if (visual->object.interface != &wl_visual_interface) {
|
||||||
wl_client_post_error(client, (struct wl_object *) display,
|
wl_client_post_error(client, &shm->object,
|
||||||
WL_DISPLAY_ERROR_INVALID_OBJECT,
|
WL_SHM_ERROR_INVALID_VISUAL,
|
||||||
"invalid visual in create_buffer\n");
|
"invalid visual");
|
||||||
close(fd);
|
close(fd);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (width < 0 || height < 0 || stride < width) {
|
if (width < 0 || height < 0 || stride < width) {
|
||||||
wl_client_post_error(client, (struct wl_object *) display,
|
wl_client_post_error(client, &shm->object,
|
||||||
WL_DISPLAY_ERROR_INVALID_OBJECT,
|
WL_SHM_ERROR_INVALID_STRIDE,
|
||||||
"invalid width, height or stride in create_buffer\n");
|
"invalid width, height or stride (%dx%d, %u)",
|
||||||
|
width, height, stride);
|
||||||
close(fd);
|
close(fd);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -144,11 +141,9 @@ shm_create_buffer(struct wl_client *client, struct wl_shm *shm,
|
||||||
|
|
||||||
close(fd);
|
close(fd);
|
||||||
if (data == MAP_FAILED) {
|
if (data == MAP_FAILED) {
|
||||||
/* FIXME: Define a real exception event instead of
|
wl_client_post_error(client, &shm->object,
|
||||||
* abusing this one */
|
WL_SHM_ERROR_INVALID_FD,
|
||||||
wl_client_post_error(client, (struct wl_object *) display,
|
"failed mmap fd %d", fd);
|
||||||
WL_DISPLAY_ERROR_INVALID_OBJECT,
|
|
||||||
"failed to create image for fd %d\n");
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue