summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKristian Høgsberg <krh@bitplanet.net>2011-05-11 11:00:40 -0400
committerKristian Høgsberg <krh@bitplanet.net>2011-05-11 13:06:51 -0400
commit8834a0f22f36d7890691015ef93b3c77cf9b4bbb (patch)
tree54b218645ee275772afc577facbf2f21e694b4a3
parent1db05255728c7a9a7e1460acff0651f6f5ea3f4e (diff)
Define shm specific errors
We stop abusing the wl_display error codes for shm purposes.
-rw-r--r--protocol/wayland.xml6
-rw-r--r--wayland/wayland-shm.c25
2 files changed, 16 insertions, 15 deletions
diff --git a/protocol/wayland.xml b/protocol/wayland.xml
index aef8385..afeaf9e 100644
--- a/protocol/wayland.xml
+++ b/protocol/wayland.xml
@@ -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
diff --git a/wayland/wayland-shm.c b/wayland/wayland-shm.c
index 84441e2..8a15f4c 100644
--- a/wayland/wayland-shm.c
+++ b/wayland/wayland-shm.c
@@ -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;
}