Beispiel #1
0
static void
handle_surface(struct test_client *client)
{
	uint32_t id;
	struct wl_resource *resource;
	struct weston_surface *surface;
	struct text_test_data *data = client->data;
	struct weston_seat *seat;

	assert(sscanf(client->buf, "surface %u", &id) == 1);
	fprintf(stderr, "got surface id %u\n", id);
	resource = wl_client_get_object(client->client, id);
	assert(resource);
	assert(strcmp(resource->object.interface->name, "wl_surface") == 0);

	surface = (struct weston_surface *) resource;

	weston_surface_configure(surface, 100, 100, 200, 200);
	weston_surface_update_transform(surface);
	weston_surface_set_color(surface, 0.0, 0.0, 0.0, 1.0);

	data->layer = malloc(sizeof *data->layer);
	weston_layer_init(data->layer, &client->compositor->cursor_layer.link);
	wl_list_insert(&data->layer->surface_list, &surface->layer_link);
	weston_surface_damage(surface);

	seat = get_seat(client);
	client->compositor->focus = 1; /* Make it work even if pointer is
					* outside X window. */
	wl_keyboard_set_focus(&seat->keyboard, &surface->surface);

	test_client_send(client, "create-text-model\n");
	client->handle = handle_text_model;
}
Beispiel #2
0
wl_resource *ClientConnection::getResource(quint32 id)
{
    if (!d->client) {
        return nullptr;
    }
    return wl_client_get_object(d->client, id);
}
Beispiel #3
0
static void
handle_text_model(struct test_client *client)
{
	uint32_t id;
	struct wl_resource *resource;

	assert(sscanf(client->buf, "text_model %u", &id) == 1);
	fprintf(stderr, "got text_model id %u\n", id);
	resource = wl_client_get_object(client->client, id);
	assert(resource);
	assert(strcmp(resource->object.interface->name, "text_model") == 0);

	test_client_send(client, "activate-text-model\n");
	client->handle = handle_activate_text_model;
}
Beispiel #4
0
static gboolean
associate_window_with_surface_id (MetaXWaylandManager *manager,
                                  MetaWindow          *window,
                                  guint32              surface_id)
{
  struct wl_resource *resource;

  resource = wl_client_get_object (manager->client, surface_id);
  if (resource)
    {
      MetaWaylandSurface *surface = wl_resource_get_user_data (resource);
      associate_window_with_surface (window, surface);
      return TRUE;
    }
  else
    return FALSE;
}
void XWaylandManager::handleSurfaceId(XWaylandShellSurface *window, xcb_client_message_event_t *event)
{
    if (window->surface()) {
        qCWarning(XWAYLAND_TRACE) << "Window" << window->window() << "already has a surface id";
        return;
    }

    quint32 id = event->data.data32[0];
    window->setSurfaceId(id);

    wl_resource *resource = wl_client_get_object(m_server->client(), id);
    if (resource) {
        window->setSurface(QWaylandSurface::fromResource(resource));
    } else {
        window->setSurface(Q_NULLPTR);
        m_unpairedWindows.append(window);
    }
}
Beispiel #6
0
/** Resolve an internal compositor error by disconnecting the client.
 *
 * This function is used in cases when the dmabuf-based wl_buffer
 * turns out unusable and there is no fallback path. This is used by
 * renderers which are the fallback path in the first place.
 *
 * It is possible the fault is caused by a compositor bug, the underlying
 * graphics stack bug or normal behaviour, or perhaps a client mistake.
 * In any case, the options are to either composite garbage or nothing,
 * or disconnect the client. This is a helper function for the latter.
 *
 * The error is sent as a INVALID_OBJECT error on the client's wl_display.
 *
 * \param buffer The linux_dmabuf_buffer that is unusable.
 * \param msg A custom error message attached to the protocol error.
 */
WL_EXPORT void
linux_dmabuf_buffer_send_server_error(struct linux_dmabuf_buffer *buffer,
				      const char *msg)
{
	struct wl_client *client;
	struct wl_resource *display_resource;
	uint32_t id;

	assert(buffer->buffer_resource);
	id = wl_resource_get_id(buffer->buffer_resource);
	client = wl_resource_get_client(buffer->buffer_resource);
	display_resource = wl_client_get_object(client, 1);

	assert(display_resource);
	wl_resource_post_error(display_resource,
			       WL_DISPLAY_ERROR_INVALID_OBJECT,
			       "linux_dmabuf server error with "
			       "wl_buffer@%u: %s", id, msg);
}
void QWaylandPointerPrivate::pointer_set_cursor(wl_pointer::Resource *resource, uint32_t serial, wl_resource *surface, int32_t hotspot_x, int32_t hotspot_y)
{
    Q_UNUSED(resource);
    Q_UNUSED(serial);

    if (!surface) {
        seat->cursorSurfaceRequest(Q_NULLPTR, 0, 0);
        return;
    }

    QWaylandSurface *s = QWaylandSurface::fromResource(surface);
    // XXX FIXME
    // The role concept was formalized in wayland 1.7, so that release adds one error
    // code for each interface that implements a role, and we are supposed to pass here
    // the newly constructed resource and the correct error code so that if setting the
    // role fails, a proper error can be sent to the client.
    // However we're still using wayland 1.4, which doesn't have interface specific role
    // errors, so the best we can do is to use wl_display's object_id error.
    wl_resource *displayRes = wl_client_get_object(resource->client(), 1);
    if (s->setRole(&QWaylandPointerPrivate::s_role, displayRes, WL_DISPLAY_ERROR_INVALID_OBJECT)) {
        s->markAsCursorSurface(true);
        seat->cursorSurfaceRequest(s, hotspot_x, hotspot_y);
    }
}