shell_create_drag(struct wl_client *client,
struct wl_shell *shell, uint32_t id)
{
- struct wl_display *display = wl_client_get_display(client);
struct wl_drag *drag;
drag = malloc(sizeof *drag);
if (drag == NULL) {
- wl_client_post_event(client,
- (struct wl_object *) display,
- WL_DISPLAY_NO_MEMORY);
+ wl_client_post_no_memory(client);
return;
}
surface = wlsc_surface_create(ec, NULL, 0, 0, 0, 0);
if (surface == NULL) {
- wl_client_post_event(client,
- (struct wl_object *) ec->wl_display,
- WL_DISPLAY_NO_MEMORY);
+ wl_client_post_no_memory(client);
return;
}
if (surface &&
(!drag->pointer_focus ||
drag->pointer_focus->client != surface->base.client)) {
- wl_surface_post_event(&surface->base,
- (struct wl_object *) surface->compositor->wl_display,
- WL_DISPLAY_GLOBAL,
- &drag->drag_offer.base,
- drag->drag_offer.base.interface->name,
- drag->drag_offer.base.interface->version);
+ wl_client_post_global(surface->base.client,
+ &drag->drag_offer.base);
end = drag->types.data + drag->types.size;
for (p = drag->types.data; p < end; p++)
static void
drag_offer(struct wl_client *client, struct wl_drag *drag, const char *type)
{
- struct wl_display *display = wl_client_get_display (client);
char **p;
p = wl_array_add(&drag->types, sizeof *p);
if (p)
*p = strdup(type);
if (!p || !*p)
- wl_client_post_event(client,
- (struct wl_object *) display,
- WL_DISPLAY_NO_MEMORY);
+ wl_client_post_no_memory(client);
}
static void
buffer = malloc(sizeof *buffer);
if (buffer == NULL) {
- wl_client_post_event(client,
- (struct wl_object *) compositor->wl_display,
- WL_DISPLAY_NO_MEMORY, 0);
+ wl_client_post_no_memory(client);
return;
}
p[0], opcode);
continue;
} else if (closure == NULL && errno == ENOMEM) {
- wl_client_post_event(client, &client->display->base,
- WL_DISPLAY_NO_MEMORY);
+ wl_client_post_no_memory(client);
continue;
}
wl_list_insert(client->resource_list.prev, &resource->link);
}
+WL_EXPORT void
+wl_client_post_no_memory(struct wl_client *client)
+{
+ wl_client_post_event(client,
+ &client->display->base,
+ WL_DISPLAY_NO_MEMORY);
+}
+
+WL_EXPORT void
+wl_client_post_global(struct wl_client *client, struct wl_object *object)
+{
+ wl_client_post_event(client,
+ &client->display->base,
+ WL_DISPLAY_GLOBAL,
+ object,
+ object->interface->name,
+ object->interface->version);
+}
+
WL_EXPORT void
wl_resource_destroy(struct wl_resource *resource, struct wl_client *client)
{