diff options
author | Giulio Camuffo <giulio.camuffo@kdab.com> | 2016-02-08 19:31:59 +0200 |
---|---|---|
committer | Giulio Camuffo <giuliocamuffo@gmail.com> | 2016-02-11 16:22:41 +0000 |
commit | 19d018dd6c7023dff7f7dcbaa7c38e486897495c (patch) | |
tree | 13614bfef93e529e73e02e355b7780833ef8cd03 /src/compositor/compositor_api/qwaylandsurface.cpp | |
parent | b4f3f890475b50fac20c0d542a584dfdab4888a7 (diff) |
Add surface roles back
Task-number: QTBUG-49809
Change-Id: Id62ddea68c89b6999b66d3df8eeeffd858ae844f
Reviewed-by: Paul Olav Tvete <paul.tvete@theqtcompany.com>
Diffstat (limited to 'src/compositor/compositor_api/qwaylandsurface.cpp')
-rw-r--r-- | src/compositor/compositor_api/qwaylandsurface.cpp | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/compositor/compositor_api/qwaylandsurface.cpp b/src/compositor/compositor_api/qwaylandsurface.cpp index ed028824f..3ea2bc87c 100644 --- a/src/compositor/compositor_api/qwaylandsurface.cpp +++ b/src/compositor/compositor_api/qwaylandsurface.cpp @@ -123,6 +123,7 @@ QWaylandSurfacePrivate::QWaylandSurfacePrivate() , refCount(1) , client(Q_NULLPTR) , buffer(0) + , role(0) , inputPanelSurface(0) , inputRegion(infiniteRegion()) , isCursorSurface(false) @@ -742,6 +743,31 @@ struct wl_resource *QWaylandSurface::resource() const return d->resource()->handle; } +/*! + * Sets a role on the surface. A role defines how a surface will be mapped on screen, without a role + * a surface is supposed to be hidden. Only one role at all times can be set on a surface. Attempting + * to change the role of a surface will trigger a protocol error to the client, while setting the same + * role many times is allowed. + * + * \param errorResource The resource the error will be sent to if the role is being changed. + * \param errorCode The error code that will be sent to the client. + */ +bool QWaylandSurface::setRole(QWaylandSurfaceRole *role, wl_resource *errorResource, uint32_t errorCode) +{ + Q_D(QWaylandSurface); + + if (d->role && d->role != role) { + wl_resource_post_error(errorResource, errorCode, + "Cannot assign role %s to wl_surface@%d, already has role %s\n", + role->name().constData(), wl_resource_get_id(resource()), + d->role->name().constData()); + return false; + } + + d->role = role; + return true; +} + QWaylandSurfacePrivate *QWaylandSurfacePrivate::get(QWaylandSurface *surface) { return surface ? surface->d_func() : Q_NULLPTR; |