Exemplo n.º 1
0
static int attach(struct view * view, struct wld_buffer * buffer)
{
    struct cursor_plane * plane = wl_container_of(view, plane, view);

    if (buffer)
    {
        union wld_object object;

        if (!wld_export(buffer, WLD_DRM_OBJECT_HANDLE, &object))
        {
            ERROR("Could not get export buffer to DRM handle\n");
            /* XXX: Not the best error code, but we don't know better until wld
             * returns an actual error code. */
            return -EINVAL;
        }

        if (swc.active && drmModeSetCursor(swc.drm->fd, plane->crtc, object.u32,
                                           buffer->width, buffer->height) < 0)
        {
            ERROR("Could not set cursor: %s\n", strerror(errno));
            return -errno;
        }
    }
    else if (swc.active && drmModeSetCursor(swc.drm->fd, plane->crtc,
                                            0, 0, 0) < 0)
    {
        ERROR("Could not unset cursor: %s\n", strerror(errno));
        return -errno;
    }

    view_set_size_from_buffer(view, buffer);
    return 0;
}
Exemplo n.º 2
0
static bool attach(struct view * view, struct wld_buffer * buffer)
{
    struct cursor_plane * plane = CONTAINER_OF(view, typeof(*plane), view);

    if (buffer)
    {
        union wld_object object;

        if (!wld_export(buffer, WLD_DRM_OBJECT_HANDLE, &object))
        {
            ERROR("Could not get export buffer to DRM handle\n");
            return false;
        }

        if (drmModeSetCursor(swc.drm->fd, plane->crtc, object.u32,
                             buffer->width, buffer->height) != 0)
        {
            ERROR("Could not set cursor: %s\n", strerror(errno));
            return false;
        }
    }
    else
    {
        if (drmModeSetCursor(swc.drm->fd, plane->crtc, 0, 0, 0) != 0)
        {
            ERROR("Could not unset cursor: %s\n", strerror(errno));
            return false;
        }
    }

    view_set_size_from_buffer(view, buffer);

    return true;
}