Define shm specific errors

We stop abusing the wl_display error codes for shm purposes.
This commit is contained in:
Kristian Høgsberg 2011-05-11 11:00:40 -04:00
parent 1db0525572
commit 8834a0f22f
2 changed files with 16 additions and 15 deletions

View file

@ -87,6 +87,12 @@
<!-- Shared memory support -->
<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
would include at least stride * height bytes starting at the
beginning of fd. The file descriptor is transferred over the

View file

@ -117,24 +117,21 @@ shm_create_buffer(struct wl_client *client, struct wl_shm *shm,
uint32_t stride, struct wl_visual *visual)
{
struct wl_shm_buffer *buffer;
struct wl_display *display = wl_client_get_display(client);
void *data;
/* FIXME: Define a real exception event instead of abusing the
* display.invalid_object error */
if (visual->object.interface != &wl_visual_interface) {
wl_client_post_error(client, (struct wl_object *) display,
WL_DISPLAY_ERROR_INVALID_OBJECT,
"invalid visual in create_buffer\n");
wl_client_post_error(client, &shm->object,
WL_SHM_ERROR_INVALID_VISUAL,
"invalid visual");
close(fd);
return;
}
if (width < 0 || height < 0 || stride < width) {
wl_client_post_error(client, (struct wl_object *) display,
WL_DISPLAY_ERROR_INVALID_OBJECT,
"invalid width, height or stride in create_buffer\n");
wl_client_post_error(client, &shm->object,
WL_SHM_ERROR_INVALID_STRIDE,
"invalid width, height or stride (%dx%d, %u)",
width, height, stride);
close(fd);
return;
}
@ -144,11 +141,9 @@ shm_create_buffer(struct wl_client *client, struct wl_shm *shm,
close(fd);
if (data == MAP_FAILED) {
/* FIXME: Define a real exception event instead of
* abusing this one */
wl_client_post_error(client, (struct wl_object *) display,
WL_DISPLAY_ERROR_INVALID_OBJECT,
"failed to create image for fd %d\n");
wl_client_post_error(client, &shm->object,
WL_SHM_ERROR_INVALID_FD,
"failed mmap fd %d", fd);
return;
}