From b4c62f7926b845d4215d13e4a5af2a0cad68739d Mon Sep 17 00:00:00 2001 From: Vlad Zahorodnii Date: Wed, 7 Apr 2021 18:15:15 +0300 Subject: [PATCH] Expose set_layer The set_layer request allows to move a surface to another layer after creating it. --- src/interfaces/window.cpp | 5 +++ src/interfaces/window.h | 12 +++++ src/qwaylandlayersurface.cpp | 6 +++ src/qwaylandlayersurface_p.h | 1 + src/wlr-layer-shell-unstable-v1.xml | 69 ++++++++++++++++++++++------- 5 files changed, 78 insertions(+), 15 deletions(-) diff --git a/src/interfaces/window.cpp b/src/interfaces/window.cpp index 9239981..a1eaa99 100644 --- a/src/interfaces/window.cpp +++ b/src/interfaces/window.cpp @@ -45,6 +45,11 @@ void Window::setKeyboardInteractivity(bool enabled) d->surface->setKeyboardInteractivity(enabled); } +void Window::setLayer(Layer layer) +{ + d->surface->setLayer(layer); +} + Window::Window(WindowPrivate *d) : d(d) { diff --git a/src/interfaces/window.h b/src/interfaces/window.h index 78cc9ce..64fbbcb 100644 --- a/src/interfaces/window.h +++ b/src/interfaces/window.h @@ -31,10 +31,22 @@ public: }; Q_ENUM(Anchor); + /** + * This enum type is used to specify the layer where a surface can be put in. + */ + enum Layer { + LayerBackground = 0, + LayerBottom = 1, + LayerTop = 2, + LayerOverlay = 3, + }; + Q_ENUM(Layer) + void setAnchor(Anchor anchor); void setExclusiveZone(int32_t zone); void setMargins(const QMargins &margins); void setKeyboardInteractivity(bool enabled); + void setLayer(Layer layer); static Window *get(QWindow *window); diff --git a/src/qwaylandlayersurface.cpp b/src/qwaylandlayersurface.cpp index 60b6f27..d1bcd3c 100644 --- a/src/qwaylandlayersurface.cpp +++ b/src/qwaylandlayersurface.cpp @@ -77,4 +77,10 @@ void QWaylandLayerSurface::setKeyboardInteractivity(bool enabled) set_keyboard_interactivity(enabled); } +void QWaylandLayerSurface::setLayer(uint32_t layer) +{ + if (zwlr_layer_surface_v1_get_version(object()) >= ZWLR_LAYER_SURFACE_V1_SET_LAYER_SINCE_VERSION) + set_layer(layer); +} + } diff --git a/src/qwaylandlayersurface_p.h b/src/qwaylandlayersurface_p.h index bd062d9..40d9e0e 100644 --- a/src/qwaylandlayersurface_p.h +++ b/src/qwaylandlayersurface_p.h @@ -34,6 +34,7 @@ public: void setExclusiveZone(int32_t zone); void setMargins(const QMargins &margins); void setKeyboardInteractivity(bool enabled); + void setLayer(uint32_t layer); void applyConfigure() override; diff --git a/src/wlr-layer-shell-unstable-v1.xml b/src/wlr-layer-shell-unstable-v1.xml index fcfdd98..0736a45 100644 --- a/src/wlr-layer-shell-unstable-v1.xml +++ b/src/wlr-layer-shell-unstable-v1.xml @@ -25,7 +25,7 @@ THIS SOFTWARE. - + Clients can use this interface to assign the surface_layer role to wl_surfaces. Such surfaces are assigned to a "layer" of the output and @@ -47,6 +47,12 @@ or manipulate a buffer prior to the first layer_surface.configure call must also be treated as errors. + After creating a layer_surface object and setting it up, the client + must perform an initial commit without any buffer attached. + The compositor will reply with a layer_surface.configure event. + The client must acknowledge it and is then allowed to attach a buffer + to map the surface. + You may pass NULL for output to allow the compositor to decide which output to use. Generally this will be the one that the user most recently interacted with. @@ -58,8 +64,7 @@ - - + @@ -83,17 +88,35 @@ + + + + + + This request indicates that the client will not use the layer_shell + object any more. Objects that have been created through this instance + are not affected. + + - + An interface that may be implemented by a wl_surface, for surfaces that are designed to be rendered as a layer of a stacked desktop-like environment. - Layer surface state (size, anchor, exclusive zone, margin, interactivity) - is double-buffered, and will be applied at the time wl_surface.commit of - the corresponding wl_surface is called. + Layer surface state (layer, size, anchor, exclusive zone, + margin, interactivity) is double-buffered, and will be applied at the + time wl_surface.commit of the corresponding wl_surface is called. + + Attaching a null buffer to a layer surface unmaps it. + + Unmapping a layer_surface means that the surface cannot be shown by the + compositor until it is explicitly mapped again. The layer_surface + returns to the state it had right after layer_shell.get_layer_surface. + The client can re-map the surface by performing a commit without any + buffer attached, waiting for a configure event and handling it as usual. @@ -116,7 +139,7 @@ Requests that the compositor anchor the surface to the specified edges - and corners. If two orthoginal edges are specified (e.g. 'top' and + and corners. If two orthogonal edges are specified (e.g. 'top' and 'left'), then the anchor point will be the intersection of the edges (e.g. the top left corner of the output); otherwise the anchor point will be centered on that edge, or in the center if none is specified. @@ -128,20 +151,25 @@ - Requests that the compositor avoids occluding an area of the surface - with other surfaces. The compositor's use of this information is + Requests that the compositor avoids occluding an area with other + surfaces. The compositor's use of this information is implementation-dependent - do not assume that this region will not actually be occluded. - A positive value is only meaningful if the surface is anchored to an - edge, rather than a corner. The zone is the number of surface-local - coordinates from the edge that are considered exclusive. + A positive value is only meaningful if the surface is anchored to one + edge or an edge and both perpendicular edges. If the surface is not + anchored, anchored to only two perpendicular edges (a corner), anchored + to only two parallel edges or anchored to all edges, a positive value + will be treated the same as zero. + + A positive zone is the distance from the edge in surface-local + coordinates to consider exclusive. Surfaces that do not wish to have an exclusive zone may instead specify how they should interact with surfaces that do. If set to zero, the surface indicates that it would like to be moved to avoid occluding - surfaces with a positive excluzive zone. If set to -1, the surface - indicates that it would not like to be moved to accomodate for other + surfaces with a positive exclusive zone. If set to -1, the surface + indicates that it would not like to be moved to accommodate for other surfaces, and the compositor should extend it all the way to the edges it is anchored to. @@ -282,5 +310,16 @@ + + + + + + Change the layer that the surface is rendered on. + + Layer is double-buffered, see wl_surface.commit. + + +