void XdgPopup::init(wl_client *client, uint32_t id) { m_resource = wl_resource_create(client, &xdg_popup_interface, 1, id); wl_resource_set_implementation(m_resource, &s_implementation, this, [](wl_resource *resource) { static_cast<XdgPopup *>(wl_resource_get_user_data(resource))->resourceDestroyed(); }); shsurf()->popupDoneSignal.connect(this, &XdgPopup::popupDone); }
struct wlegl_handle * wlegl_handle_create(struct wl_resource *parent, uint32_t id, int32_t num_fds, struct wl_array *ints) { struct wlegl_handle *handle; handle = malloc(sizeof *handle); if (!handle) { wl_resource_post_no_memory(parent); return; } memset(handle, 0, sizeof *handle); handle->resource = wl_resource_create(wl_resource_get_client(parent), &android_wlegl_handle_interface, 1, id); if (!handle->resource) { wl_resource_post_no_memory(parent); free(handle); return; } wl_resource_set_implementation(handle->resource, &wlegl_handle_implementation, handle, destroy_wlegl_handle); wl_array_init(&handle->ints); wl_array_init(&handle->fds); wl_array_copy(&handle->ints, ints); handle->num_fds = num_fds; handle->num_ints = ints->size / sizeof(int); }
static struct wl_resource * weston_data_source_send_offer(struct weston_data_source *source, struct wl_resource *target) { struct weston_data_offer *offer; char **p; offer = malloc(sizeof *offer); if (offer == NULL) return NULL; offer->resource = wl_resource_create(wl_resource_get_client(target), &wl_data_offer_interface, 1, 0); if (offer->resource == NULL) { free(offer); return NULL; } wl_resource_set_implementation(offer->resource, &data_offer_interface, offer, destroy_data_offer); offer->source = source; offer->source_destroy_listener.notify = destroy_offer_data_source; wl_signal_add(&source->destroy_signal, &offer->source_destroy_listener); wl_data_device_send_data_offer(target, offer->resource); wl_array_for_each(p, &source->mime_types) wl_data_offer_send_offer(offer->resource, *p); return offer->resource; }
static void create_buffer(struct wl_client *client, struct wl_resource *resource, uint32_t id, uint32_t name) { struct wl_gdl_buffer *buffer; buffer = malloc(sizeof (*buffer)); if (!buffer) { wl_resource_post_no_memory(resource); return; } if (gdl_get_surface_info(name, &buffer->surface_info) != GDL_SUCCESS) { wl_resource_post_error(resource, WL_GDL_ERROR_INVALID_NAME, "invalid surface id %u", name); free(buffer); return; } buffer->resource = wl_resource_create(client, &wl_buffer_interface, 1, id); if (buffer->resource == NULL) { wl_resource_post_no_memory(resource); free(buffer); return; } wl_resource_set_implementation(buffer->resource, &gdl_buffer_interface, buffer, destroy_buffer); }
void wlb_keyboard_create_resource(struct wlb_keyboard *keyboard, struct wl_client *client, uint32_t id) { struct wl_resource *resource; int null_fd; resource = wl_resource_create(client, &wl_keyboard_interface, 1, id); if (!resource) { wl_client_post_no_memory(client); return; } wl_resource_set_implementation(resource, &keyboard_interface, NULL, unlink_resource); wl_list_insert(&keyboard->resource_list, wl_resource_get_link(resource)); if (keyboard->keymap.data) { wl_keyboard_send_keymap(resource, keyboard->keymap.format, keyboard->keymap.fd, keyboard->keymap.size); } else { null_fd = open("/dev/null", O_RDONLY); wl_keyboard_send_keymap(resource, WL_KEYBOARD_KEYMAP_FORMAT_NO_KEYMAP, null_fd, 0); close(null_fd); } }
WL_EXPORT struct wl_shm_buffer * wl_shm_buffer_create(struct wl_client *client, uint32_t id, int32_t width, int32_t height, int32_t stride, uint32_t format) { struct wl_shm_buffer *buffer; if (!format_is_supported(client, format)) return NULL; buffer = malloc(sizeof *buffer + stride * height); if (buffer == NULL) return NULL; buffer->width = width; buffer->height = height; buffer->format = format; buffer->stride = stride; buffer->offset = 0; buffer->pool = NULL; buffer->resource = wl_resource_create(client, &wl_buffer_interface, 1, id); if (buffer->resource == NULL) { free(buffer); return NULL; } wl_resource_set_implementation(buffer->resource, &shm_buffer_interface, buffer, destroy_buffer); return buffer; }
static void bind_output (struct wl_client *client, void *data, guint32 version, guint32 id) { MetaWaylandOutput *wayland_output = data; MetaMonitorInfo *monitor_info = wayland_output->monitor_info; struct wl_resource *resource; MetaOutput *output = monitor_info->outputs[0]; resource = wl_resource_create (client, &wl_output_interface, version, id); wayland_output->resources = g_list_prepend (wayland_output->resources, resource); wl_resource_set_user_data (resource, wayland_output); wl_resource_set_destructor (resource, output_resource_destroy); meta_verbose ("Binding monitor %p/%s (%u, %u, %u, %u) x %f\n", monitor_info, output->name, monitor_info->rect.x, monitor_info->rect.y, monitor_info->rect.width, monitor_info->rect.height, monitor_info->refresh_rate); send_output_events (resource, wayland_output, monitor_info, TRUE); }
static void wp_viewporter_get_viewport (struct wl_client *client, struct wl_resource *resource, uint32_t viewport_id, struct wl_resource *surface_resource) { MetaWaylandSurface *surface; struct wl_resource *viewport_resource; surface = wl_resource_get_user_data (surface_resource); if (surface->viewport.resource) { wl_resource_post_error (resource, WP_VIEWPORTER_ERROR_VIEWPORT_EXISTS, "viewport already exists on surface"); return; } viewport_resource = wl_resource_create (client, &wp_viewport_interface, wl_resource_get_version (resource), viewport_id); wl_resource_set_implementation (viewport_resource, &meta_wayland_viewport_interface, surface, wp_viewport_destructor); surface->viewport.resource = viewport_resource; surface->viewport.destroy_handler_id = g_signal_connect (surface, "destroy", G_CALLBACK (on_surface_destroyed), NULL); }
static void bind_drm(struct wl_client *client, void *data, uint32_t version, uint32_t id) { struct wl_drm *drm = data; struct wl_resource *resource; uint32_t capabilities; resource = wl_resource_create(client, &wl_drm_interface, MIN(version, 2), id); if (!resource) { wl_client_post_no_memory(client); return; } wl_resource_set_implementation(resource, &drm_interface, data, NULL); wl_resource_post_event(resource, WL_DRM_DEVICE, drm->device_name); wl_resource_post_event(resource, WL_DRM_FORMAT, WL_DRM_FORMAT_ARGB8888); wl_resource_post_event(resource, WL_DRM_FORMAT, WL_DRM_FORMAT_XRGB8888); wl_resource_post_event(resource, WL_DRM_FORMAT, WL_DRM_FORMAT_RGB565); wl_resource_post_event(resource, WL_DRM_FORMAT, WL_DRM_FORMAT_YUV410); wl_resource_post_event(resource, WL_DRM_FORMAT, WL_DRM_FORMAT_YUV411); wl_resource_post_event(resource, WL_DRM_FORMAT, WL_DRM_FORMAT_YUV420); wl_resource_post_event(resource, WL_DRM_FORMAT, WL_DRM_FORMAT_YUV422); wl_resource_post_event(resource, WL_DRM_FORMAT, WL_DRM_FORMAT_YUV444); wl_resource_post_event(resource, WL_DRM_FORMAT, WL_DRM_FORMAT_NV12); wl_resource_post_event(resource, WL_DRM_FORMAT, WL_DRM_FORMAT_NV16); wl_resource_post_event(resource, WL_DRM_FORMAT, WL_DRM_FORMAT_YUYV); /* we only support render nodes, not GEM */ capabilities = WL_DRM_CAPABILITY_PRIME; if (version >= 2) wl_resource_post_event(resource, WL_DRM_CAPABILITIES, capabilities); }
static void bind_output (struct wl_client *client, void *data, guint32 version, guint32 id) { MetaWaylandOutput *wayland_output = data; MetaOutput *output = wayland_output->output; struct wl_resource *resource; guint mode_flags; resource = wl_resource_create (client, &wl_output_interface, MIN (META_WL_OUTPUT_VERSION, version), id); wayland_output->resources = g_list_prepend (wayland_output->resources, resource); wl_resource_set_user_data (resource, wayland_output); wl_resource_set_destructor (resource, output_resource_destroy); meta_verbose ("Binding output %p/%s (%u, %u, %u, %u) x %f\n", output, output->name, output->crtc->rect.x, output->crtc->rect.y, output->crtc->rect.width, output->crtc->rect.height, output->crtc->current_mode->refresh_rate); wl_resource_post_event (resource, WL_OUTPUT_GEOMETRY, (int)output->crtc->rect.x, (int)output->crtc->rect.y, output->width_mm, output->height_mm, /* Cogl values reflect XRandR values, and so does wayland */ output->subpixel_order, output->vendor, output->product, output->crtc->transform); g_assert (output->crtc->current_mode != NULL); mode_flags = WL_OUTPUT_MODE_CURRENT; if (output->crtc->current_mode == output->preferred_mode) mode_flags |= WL_OUTPUT_MODE_PREFERRED; wl_resource_post_event (resource, WL_OUTPUT_MODE, mode_flags, (int)output->crtc->current_mode->width, (int)output->crtc->current_mode->height, (int)output->crtc->current_mode->refresh_rate); output->scale = compute_scale (output); if (version >= WL_OUTPUT_SCALE_SINCE_VERSION) wl_resource_post_event (resource, WL_OUTPUT_SCALE, output->scale); if (version >= WL_OUTPUT_DONE_SINCE_VERSION) wl_resource_post_event (resource, WL_OUTPUT_DONE); }
static void bind_runner(struct wl_client *client, void *data, uint32_t version, uint32_t id) { struct test_launcher *launcher = data; struct wl_resource *resource; resource = wl_resource_create(client, &weston_test_runner_interface, 1, id); if (!resource) { wl_client_post_no_memory(client); return; } wl_resource_set_implementation(resource, &runner_implementation, launcher, destroy_runner); if (static_context.runner_resource != NULL) { weston_log("test FATAL: " "attempting to run several tests in parallel.\n"); wl_resource_post_error(resource, WESTON_TEST_RUNNER_ERROR_TEST_FAILED, "attempt to run parallel tests"); } }
wl_resource *ClientConnection::createResource(const wl_interface *interface, quint32 version, quint32 id) { if (!d->client) { return nullptr; } return wl_resource_create(d->client, interface, version, id); }
static void bind_manager (struct wl_client *client, void *data, guint32 version, guint32 id) { struct wl_resource *resource; resource = wl_resource_create (client, &wl_data_device_manager_interface, version, id); wl_resource_set_implementation (resource, &manager_interface, NULL, NULL); }
void GammaControlManager::bind(wl_client *client, uint32_t version, uint32_t id) { static const struct gamma_control_manager_interface implementation = { wrapInterface(destroy), wrapInterface(getGammaControl) }; wl_resource *resource = wl_resource_create(client, &gamma_control_manager_interface, version, id); wl_resource_set_implementation(resource, &implementation, this, nullptr); }
void data_device_bind(struct data_device * data_device, struct wl_client * client, uint32_t id) { struct wl_resource * resource; resource = wl_resource_create(client, &wl_data_device_interface, 1, id); wl_resource_set_implementation(resource, &data_device_implementation, data_device, &swc_remove_resource); wl_list_insert(&data_device->resources, &resource->link); }
static void server_wlegl_bind(struct wl_client *client, void *data, uint32_t version, uint32_t id) { server_wlegl *wlegl = reinterpret_cast<server_wlegl *>(data); struct wl_resource *resource; resource = wl_resource_create(client, &android_wlegl_interface, version, id); wl_resource_set_implementation(resource, &server_wlegl_impl, wlegl, 0); }
static T* create(wl_client* client, uint32_t id, Args&&... args) { auto p = new T(std::forward<Args>(args)...); if (auto r = wl_resource_create(client, &T::interface, T::interface.version, id)) { p->setResource(r); wl_resource_set_implementation(p->getResource(), T::sImplInterface, p, T::hookDestroy); return p; } std::string msg("We are doomed, cannot create "); msg.append(T::interface.name); throw std::logic_error(msg); }
static void create_data_source (struct wl_client *client, struct wl_resource *resource, guint32 id) { MetaWaylandDataSource *source = g_slice_new0 (MetaWaylandDataSource); source->resource = wl_resource_create (client, &wl_data_source_interface, wl_resource_get_version (resource), id); wl_resource_set_implementation (source->resource, &data_source_interface, source, destroy_data_source); wl_array_init (&source->mime_types); }
static void bind_shell(struct wl_client *client, void *data, uint32_t version, uint32_t id) { struct wl_resource *resource; if (version > 1) version = 1; resource = wl_resource_create(client, &xdg_shell_interface, version, id); wl_resource_set_dispatcher(resource, &unversioned_dispatch, NULL, NULL, NULL); }
static void bind_wl_shell (struct wl_client *client, void *data, uint32_t version, uint32_t id) { struct wl_resource *resource; resource = wl_resource_create (client, &wl_shell_interface, version, id); wl_resource_set_implementation (resource, &meta_wayland_wl_shell_interface, data, NULL); }
static void bind_shell(struct wl_client * client, void * data, uint32_t version, uint32_t id) { struct wl_resource * resource; if (version >= 1) version = 1; resource = wl_resource_create(client, &wl_shell_interface, version, id); wl_resource_set_implementation(resource, &shell_implementation, NULL, NULL); }
void Screenshooter::bind(wl_client *client, uint32_t version, uint32_t id) { wl_resource *resource = wl_resource_create(client, &orbital_screenshooter_interface, version, id); static const struct orbital_screenshooter_interface implementation = { wrapInterface(shoot), wrapInterface(shootSurface), }; wl_resource_set_implementation(resource, &implementation, this, nullptr); }
static void get_data_device (struct wl_client *client, struct wl_resource *manager_resource, guint32 id, struct wl_resource *seat_resource) { MetaWaylandSeat *seat = wl_resource_get_user_data (seat_resource); struct wl_resource *cr; cr = wl_resource_create (client, &wl_data_device_interface, wl_resource_get_version (manager_resource), id); wl_resource_set_implementation (cr, &data_device_interface, &seat->data_device, unbind_resource); wl_list_insert (&seat->data_device.resource_list, wl_resource_get_link (cr)); }
static void wl_compositor_create_region (struct wl_client *client, struct wl_resource *compositor_resource, uint32_t id) { MetaWaylandRegion *region = g_slice_new0 (MetaWaylandRegion); region->resource = wl_resource_create (client, &wl_region_interface, wl_resource_get_version (compositor_resource), id); wl_resource_set_implementation (region->resource, &meta_wayland_region_interface, region, meta_wayland_region_resource_destroy_cb); region->region = cairo_region_create (); }
static void compositor_bind (struct wl_client *client, void *data, guint32 version, guint32 id) { MetaWaylandCompositor *compositor = data; struct wl_resource *resource; resource = wl_resource_create (client, &wl_compositor_interface, version, id); wl_resource_set_implementation (resource, &meta_wayland_compositor_interface, compositor, NULL); }
static void shm_pool_create_buffer(struct wl_client *client, struct wl_resource *resource, uint32_t id, int32_t offset, int32_t width, int32_t height, int32_t stride, uint32_t format) { struct wl_shm_pool *pool = wl_resource_get_user_data(resource); struct wl_shm_buffer *buffer; if (!format_is_supported(client, format)) { wl_resource_post_error(resource, WL_SHM_ERROR_INVALID_FORMAT, "invalid format 0x%x", format); return; } if (offset < 0 || width <= 0 || height <= 0 || stride < width || INT32_MAX / stride <= height || offset > pool->size - stride * height) { wl_resource_post_error(resource, WL_SHM_ERROR_INVALID_STRIDE, "invalid width, height or stride (%dx%d, %u)", width, height, stride); return; } buffer = malloc(sizeof *buffer); if (buffer == NULL) { wl_client_post_no_memory(client); return; } buffer->width = width; buffer->height = height; buffer->format = format; buffer->stride = stride; buffer->offset = offset; buffer->pool = pool; pool->refcount++; buffer->resource = wl_resource_create(client, &wl_buffer_interface, 1, id); if (buffer->resource == NULL) { wl_client_post_no_memory(client); shm_pool_unref(pool); free(buffer); return; } wl_resource_set_implementation(buffer->resource, &shm_buffer_interface, buffer, destroy_buffer); }
static void bind_text_cursor_position(struct wl_client *client, void *data, uint32_t version, uint32_t id) { struct wl_resource *resource; resource = wl_resource_create(client, &text_cursor_position_interface, 1, id); if (resource) wl_resource_set_implementation(resource, &text_cursor_position_implementation, data, NULL); }
static void bind_panel_manager(struct wl_client * client, void * data, uint32_t version, uint32_t id) { struct wl_resource * resource; if (version > 1) version = 1; resource = wl_resource_create(client, &swc_panel_manager_interface, version, id); wl_resource_set_implementation(resource, &panel_manager_implementation, NULL, NULL); }
static void bind_gdl(struct wl_client *client, void *data, uint32_t version, uint32_t id) { struct wl_resource *resource; resource = wl_resource_create(client, &wl_gdl_interface, 1, id); if (!resource) { wl_client_post_no_memory(client); return; } wl_resource_set_implementation(resource, &gdl_interface, data, NULL); }
static void bind_pointer_gestures (struct wl_client *client, void *data, guint32 version, guint32 id) { struct wl_resource *resource; resource = wl_resource_create (client, &zwp_pointer_gestures_v1_interface, version, id); wl_resource_set_implementation (resource, &pointer_gestures_interface, NULL, NULL); }