summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/scanner.c7
-rw-r--r--src/wayland-server.c64
-rw-r--r--src/wayland-server.h5
-rw-r--r--src/wayland-shm.c39
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, ...);