diff options
-rw-r--r-- | src/scanner.c | 7 | ||||
-rw-r--r-- | src/wayland-server.c | 64 | ||||
-rw-r--r-- | src/wayland-server.h | 5 | ||||
-rw-r--r-- | src/wayland-shm.c | 39 |
4 files changed, 58 insertions, 57 deletions
diff --git a/src/scanner.c b/src/scanner.c index d6e8969..2e53e4e 100644 --- a/src/scanner.c +++ b/src/scanner.c @@ -514,9 +514,10 @@ emit_structs(struct wl_list *message_list, struct interface *interface) n = strlen(m->name) + 17; if (is_interface) { - printf("struct wl_client *client,\n" - "%sstruct wl_resource *resource", - indent(n)); + printf("struct wl_resource *resource,\n" + "%sstruct %s *%s", + indent(n), + interface->name, interface->name); } else { printf("void *data,\n"), printf("%sstruct %s *%s", diff --git a/src/wayland-server.c b/src/wayland-server.c index 06c1acc..2085c30 100644 --- a/src/wayland-server.c +++ b/src/wayland-server.c @@ -108,8 +108,8 @@ wl_resource_post_event(struct wl_resource *resource, uint32_t opcode, ...) } WL_EXPORT void -wl_client_post_error(struct wl_client *client, struct wl_object *object, - uint32_t code, const char *msg, ...) +wl_resource_post_error(struct wl_resource *resource, + uint32_t code, const char *msg, ...) { char buffer[128]; va_list ap; @@ -118,8 +118,9 @@ wl_client_post_error(struct wl_client *client, struct wl_object *object, vsnprintf(buffer, sizeof buffer, msg, ap); va_end(ap); - wl_resource_post_event(client->display_resource, - WL_DISPLAY_ERROR, object, code, buffer); + wl_resource_post_event(resource->client->display_resource, + WL_DISPLAY_ERROR, + &resource->object, code, buffer); } static int @@ -155,9 +156,9 @@ wl_client_connection_data(int fd, uint32_t mask, void *data) resource = wl_map_lookup(&client->objects, p[0]); if (resource == NULL) { - wl_client_post_error(client, &resource->object, - WL_DISPLAY_ERROR_INVALID_OBJECT, - "invalid object %d", p[0]); + wl_resource_post_error(resource, + WL_DISPLAY_ERROR_INVALID_OBJECT, + "invalid object %d", p[0]); wl_connection_consume(connection, size); len -= size; continue; @@ -165,11 +166,11 @@ wl_client_connection_data(int fd, uint32_t mask, void *data) object = &resource->object; if (opcode >= object->interface->method_count) { - wl_client_post_error(client, &resource->object, - WL_DISPLAY_ERROR_INVALID_METHOD, - "invalid method %d, object %s@%d", - object->interface->name, - object->id, opcode); + wl_resource_post_error(resource, + WL_DISPLAY_ERROR_INVALID_METHOD, + "invalid method %d, object %s@%d", + object->interface->name, + object->id, opcode); wl_connection_consume(connection, size); len -= size; continue; @@ -181,12 +182,12 @@ wl_client_connection_data(int fd, uint32_t mask, void *data) len -= size; if (closure == NULL && errno == EINVAL) { - wl_client_post_error(client, &resource->object, - WL_DISPLAY_ERROR_INVALID_METHOD, - "invalid arguments for %s@%d.%s", - object->interface->name, - object->id, - message->name); + wl_resource_post_error(resource, + WL_DISPLAY_ERROR_INVALID_METHOD, + "invalid arguments for %s@%d.%s", + object->interface->name, + object->id, + message->name); continue; } else if (closure == NULL && errno == ENOMEM) { wl_client_post_no_memory(client); @@ -197,8 +198,8 @@ wl_client_connection_data(int fd, uint32_t mask, void *data) if (wl_debug) wl_closure_print(closure, object, false); - wl_closure_invoke(closure, object, - object->implementation[opcode], client); + wl_closure_invoke(closure, resource->data, + object->implementation[opcode], resource); wl_closure_destroy(closure); } @@ -287,8 +288,8 @@ wl_client_add_resource(struct wl_client *client, WL_EXPORT void wl_client_post_no_memory(struct wl_client *client) { - wl_client_post_error(client, &client->display_resource->object, - WL_DISPLAY_ERROR_NO_MEMORY, "no memory"); + wl_resource_post_error(client->display_resource, + WL_DISPLAY_ERROR_NO_MEMORY, "no memory"); } static void @@ -510,32 +511,31 @@ wl_input_device_update_grab(struct wl_input_device *device, } static void -display_bind(struct wl_client *client, - struct wl_resource *resource, uint32_t name, +display_bind(struct wl_resource *resource, + struct wl_display *display, uint32_t name, const char *interface, uint32_t version, uint32_t id) { struct wl_global *global; - struct wl_display *display = resource->data; wl_list_for_each(global, &display->global_list, link) if (global->name == name) break; if (&global->link == &display->global_list) - wl_client_post_error(client, &resource->object, - WL_DISPLAY_ERROR_INVALID_OBJECT, - "invalid global %d", name); + wl_resource_post_error(resource, + WL_DISPLAY_ERROR_INVALID_OBJECT, + "invalid global %d", name); else - global->bind(client, global->data, version, id); + global->bind(resource->client, global->data, version, id); } static void -display_sync(struct wl_client *client, - struct wl_resource *resource, uint32_t id) +display_sync(struct wl_resource *resource, + struct wl_display *display, uint32_t id) { struct wl_resource *callback; - callback = wl_client_add_object(client, + callback = wl_client_add_object(resource->client, &wl_callback_interface, NULL, id, NULL); wl_resource_post_event(callback, WL_CALLBACK_DONE, 0); wl_resource_destroy(callback, 0); diff --git a/src/wayland-server.h b/src/wayland-server.h index e5f1767..4688aee 100644 --- a/src/wayland-server.h +++ b/src/wayland-server.h @@ -98,8 +98,6 @@ void wl_display_remove_global(struct wl_display *display, struct wl_client *wl_client_create(struct wl_display *display, int fd); void wl_client_destroy(struct wl_client *client); -void wl_client_post_error(struct wl_client *client, struct wl_object *object, - uint32_t code, const char *msg, ...); void wl_client_post_no_memory(struct wl_client *client); void wl_client_flush(struct wl_client *client); @@ -227,6 +225,9 @@ struct wl_selection { }; void +wl_resource_post_error(struct wl_resource *resource, + uint32_t code, const char *msg, ...); +void wl_resource_post_event(struct wl_resource *resource, uint32_t opcode, ...); int diff --git a/src/wayland-shm.c b/src/wayland-shm.c index 0324168..6774bea 100644 --- a/src/wayland-shm.c +++ b/src/wayland-shm.c @@ -58,17 +58,18 @@ destroy_buffer(struct wl_resource *resource) } static void -shm_buffer_damage(struct wl_client *client, struct wl_resource *resource, +shm_buffer_damage(struct wl_resource *resource, struct wl_buffer *base, int32_t x, int32_t y, int32_t width, int32_t height) { - struct wl_shm_buffer *buffer = resource->data; + struct wl_shm_buffer *buffer = + container_of(base, struct wl_shm_buffer, buffer); buffer->shm->callbacks->buffer_damaged(&buffer->buffer, x, y, width, height); } static void -shm_buffer_destroy(struct wl_client *client, struct wl_resource *resource) +shm_buffer_destroy(struct wl_resource *resource, struct wl_buffer *buffer) { wl_resource_destroy(resource, 0); } @@ -113,27 +114,26 @@ wl_shm_buffer_init(struct wl_shm *shm, struct wl_client *client, uint32_t id, } static void -shm_create_buffer(struct wl_client *client, struct wl_resource *resource, +shm_create_buffer(struct wl_resource *resource, struct wl_shm *shm, uint32_t id, int fd, int32_t width, int32_t height, uint32_t stride, struct wl_visual *visual) { - struct wl_shm *shm = resource->data; struct wl_shm_buffer *buffer; void *data; if (!visual || visual->object.interface != &wl_visual_interface) { - wl_client_post_error(client, &resource->object, - WL_SHM_ERROR_INVALID_VISUAL, - "invalid visual"); + wl_resource_post_error(resource, + WL_SHM_ERROR_INVALID_VISUAL, + "invalid visual"); close(fd); return; } if (width < 0 || height < 0 || stride < width) { - wl_client_post_error(client, &resource->object, - WL_SHM_ERROR_INVALID_STRIDE, - "invalid width, height or stride (%dx%d, %u)", - width, height, stride); + wl_resource_post_error(resource, + WL_SHM_ERROR_INVALID_STRIDE, + "invalid width, height or stride (%dx%d, %u)", + width, height, stride); close(fd); return; } @@ -143,22 +143,21 @@ shm_create_buffer(struct wl_client *client, struct wl_resource *resource, close(fd); if (data == MAP_FAILED) { - wl_client_post_error(client, &resource->object, - WL_SHM_ERROR_INVALID_FD, - "failed mmap fd %d", fd); + wl_resource_post_error(resource, + WL_SHM_ERROR_INVALID_FD, + "failed mmap fd %d", fd); return; } - buffer = wl_shm_buffer_init(shm, client, id, - width, height, stride, visual, - data); + buffer = wl_shm_buffer_init(shm, resource->client, id, + width, height, stride, visual, data); if (buffer == NULL) { munmap(data, stride * height); - wl_client_post_no_memory(client); + wl_client_post_no_memory(resource->client); return; } - wl_client_add_resource(client, &buffer->buffer.resource); + wl_client_add_resource(resource->client, &buffer->buffer.resource); } const static struct wl_shm_interface shm_interface = { |