layer-shell: add v5 support

master
Kirill Primak 5 months ago committed by Alexander Orzechowski
parent e88988e364
commit 270e6f4ebb

@ -49,6 +49,7 @@ enum wlr_layer_surface_v1_state_field {
WLR_LAYER_SURFACE_V1_STATE_MARGIN = 1 << 3, WLR_LAYER_SURFACE_V1_STATE_MARGIN = 1 << 3,
WLR_LAYER_SURFACE_V1_STATE_KEYBOARD_INTERACTIVITY = 1 << 4, WLR_LAYER_SURFACE_V1_STATE_KEYBOARD_INTERACTIVITY = 1 << 4,
WLR_LAYER_SURFACE_V1_STATE_LAYER = 1 << 5, WLR_LAYER_SURFACE_V1_STATE_LAYER = 1 << 5,
WLR_LAYER_SURFACE_V1_STATE_EXCLUSIVE_EDGE = 1 << 6,
}; };
struct wlr_layer_surface_v1_state { struct wlr_layer_surface_v1_state {
@ -62,6 +63,7 @@ struct wlr_layer_surface_v1_state {
enum zwlr_layer_surface_v1_keyboard_interactivity keyboard_interactive; enum zwlr_layer_surface_v1_keyboard_interactivity keyboard_interactive;
uint32_t desired_width, desired_height; uint32_t desired_width, desired_height;
enum zwlr_layer_shell_v1_layer layer; enum zwlr_layer_shell_v1_layer layer;
uint32_t exclusive_edge;
uint32_t configure_serial; uint32_t configure_serial;
uint32_t actual_width, actual_height; uint32_t actual_width, actual_height;

@ -25,7 +25,7 @@
THIS SOFTWARE. THIS SOFTWARE.
</copyright> </copyright>
<interface name="zwlr_layer_shell_v1" version="4"> <interface name="zwlr_layer_shell_v1" version="5">
<description summary="create surfaces that are layers of the desktop"> <description summary="create surfaces that are layers of the desktop">
Clients can use this interface to assign the surface_layer role to 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 wl_surfaces. Such surfaces are assigned to a "layer" of the output and
@ -100,7 +100,7 @@
</request> </request>
</interface> </interface>
<interface name="zwlr_layer_surface_v1" version="4"> <interface name="zwlr_layer_surface_v1" version="5">
<description summary="layer metadata interface"> <description summary="layer metadata interface">
An interface that may be implemented by a wl_surface, for surfaces that 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 are designed to be rendered as a layer of a stacked desktop-like
@ -367,6 +367,7 @@
<entry name="invalid_size" value="1" summary="size is invalid"/> <entry name="invalid_size" value="1" summary="size is invalid"/>
<entry name="invalid_anchor" value="2" summary="anchor bitfield is invalid"/> <entry name="invalid_anchor" value="2" summary="anchor bitfield is invalid"/>
<entry name="invalid_keyboard_interactivity" value="3" summary="keyboard interactivity is invalid"/> <entry name="invalid_keyboard_interactivity" value="3" summary="keyboard interactivity is invalid"/>
<entry name="invalid_exclusive_edge" value="4" summary="exclusive edge is invalid given the surface anchors"/>
</enum> </enum>
<enum name="anchor" bitfield="true"> <enum name="anchor" bitfield="true">
@ -386,5 +387,21 @@
</description> </description>
<arg name="layer" type="uint" enum="zwlr_layer_shell_v1.layer" summary="layer to move this surface to"/> <arg name="layer" type="uint" enum="zwlr_layer_shell_v1.layer" summary="layer to move this surface to"/>
</request> </request>
<!-- Version 5 additions -->
<request name="set_exclusive_edge" since="5">
<description summary="set the edge the exclusive zone will be applied to">
Requests an edge for the exclusive zone to apply. The exclusive
edge will be automatically deduced from anchor points when possible,
but when the surface is anchored to a corner, it will be necessary
to set it explicitly to disambiguate, as it is not possible to deduce
which one of the two corner edges should be used.
The edge must be one the surface is anchored to, otherwise the
invalid_exclusive_edge protocol error will be raised.
</description>
<arg name="edge" type="uint" enum="anchor"/>
</request>
</interface> </interface>
</protocol> </protocol>

@ -11,7 +11,7 @@
// Note: zwlr_layer_surface_v1 becomes inert on wlr_layer_surface_v1_destroy() // Note: zwlr_layer_surface_v1 becomes inert on wlr_layer_surface_v1_destroy()
#define LAYER_SHELL_VERSION 4 #define LAYER_SHELL_VERSION 5
static void resource_handle_destroy(struct wl_client *client, static void resource_handle_destroy(struct wl_client *client,
struct wl_resource *resource) { struct wl_resource *resource) {
@ -264,6 +264,7 @@ static void layer_surface_set_layer(struct wl_client *client,
return; return;
} }
if (layer > ZWLR_LAYER_SHELL_V1_LAYER_OVERLAY) { if (layer > ZWLR_LAYER_SHELL_V1_LAYER_OVERLAY) {
// XXX: this sends a zwlr_layer_shell_v1 error to a zwlr_layer_surface_v1 object
wl_resource_post_error(surface->resource, wl_resource_post_error(surface->resource,
ZWLR_LAYER_SHELL_V1_ERROR_INVALID_LAYER, ZWLR_LAYER_SHELL_V1_ERROR_INVALID_LAYER,
"Invalid layer %" PRIu32, layer); "Invalid layer %" PRIu32, layer);
@ -278,6 +279,31 @@ static void layer_surface_set_layer(struct wl_client *client,
surface->pending.layer = layer; surface->pending.layer = layer;
} }
static void layer_surface_set_exclusive_edge(struct wl_client *client,
struct wl_resource *surface_resource, uint32_t edge) {
struct wlr_layer_surface_v1 *surface =
wlr_layer_surface_v1_from_resource(surface_resource);
if (!surface) {
return;
}
switch (edge) {
case 0:
case ZWLR_LAYER_SURFACE_V1_ANCHOR_TOP:
case ZWLR_LAYER_SURFACE_V1_ANCHOR_BOTTOM:
case ZWLR_LAYER_SURFACE_V1_ANCHOR_LEFT:
case ZWLR_LAYER_SURFACE_V1_ANCHOR_RIGHT:
break;
default:
wl_resource_post_error(surface->resource,
ZWLR_LAYER_SURFACE_V1_ERROR_INVALID_EXCLUSIVE_EDGE,
"invalid exclusive edge %" PRIu32, edge);
return;
}
surface->pending.committed |= WLR_LAYER_SURFACE_V1_STATE_EXCLUSIVE_EDGE;
surface->pending.exclusive_edge = edge;
}
static const struct zwlr_layer_surface_v1_interface layer_surface_implementation = { static const struct zwlr_layer_surface_v1_interface layer_surface_implementation = {
.destroy = resource_handle_destroy, .destroy = resource_handle_destroy,
.ack_configure = layer_surface_handle_ack_configure, .ack_configure = layer_surface_handle_ack_configure,
@ -288,6 +314,7 @@ static const struct zwlr_layer_surface_v1_interface layer_surface_implementation
.set_keyboard_interactivity = layer_surface_handle_set_keyboard_interactivity, .set_keyboard_interactivity = layer_surface_handle_set_keyboard_interactivity,
.get_popup = layer_surface_handle_get_popup, .get_popup = layer_surface_handle_get_popup,
.set_layer = layer_surface_set_layer, .set_layer = layer_surface_set_layer,
.set_exclusive_edge = layer_surface_set_exclusive_edge,
}; };
uint32_t wlr_layer_surface_v1_configure(struct wlr_layer_surface_v1 *surface, uint32_t wlr_layer_surface_v1_configure(struct wlr_layer_surface_v1 *surface,
@ -336,10 +363,11 @@ static void layer_surface_role_client_commit(struct wlr_surface *wlr_surface) {
return; return;
} }
uint32_t anchor = surface->pending.anchor;
const uint32_t horiz = ZWLR_LAYER_SURFACE_V1_ANCHOR_LEFT | const uint32_t horiz = ZWLR_LAYER_SURFACE_V1_ANCHOR_LEFT |
ZWLR_LAYER_SURFACE_V1_ANCHOR_RIGHT; ZWLR_LAYER_SURFACE_V1_ANCHOR_RIGHT;
if (surface->pending.desired_width == 0 && if (surface->pending.desired_width == 0 && (anchor & horiz) != horiz) {
(surface->pending.anchor & horiz) != horiz) {
wlr_surface_reject_pending(wlr_surface, surface->resource, wlr_surface_reject_pending(wlr_surface, surface->resource,
ZWLR_LAYER_SURFACE_V1_ERROR_INVALID_SIZE, ZWLR_LAYER_SURFACE_V1_ERROR_INVALID_SIZE,
"width 0 requested without setting left and right anchors"); "width 0 requested without setting left and right anchors");
@ -348,13 +376,18 @@ static void layer_surface_role_client_commit(struct wlr_surface *wlr_surface) {
const uint32_t vert = ZWLR_LAYER_SURFACE_V1_ANCHOR_TOP | const uint32_t vert = ZWLR_LAYER_SURFACE_V1_ANCHOR_TOP |
ZWLR_LAYER_SURFACE_V1_ANCHOR_BOTTOM; ZWLR_LAYER_SURFACE_V1_ANCHOR_BOTTOM;
if (surface->pending.desired_height == 0 && if (surface->pending.desired_height == 0 && (anchor & vert) != vert) {
(surface->pending.anchor & vert) != vert) {
wlr_surface_reject_pending(wlr_surface, surface->resource, wlr_surface_reject_pending(wlr_surface, surface->resource,
ZWLR_LAYER_SURFACE_V1_ERROR_INVALID_SIZE, ZWLR_LAYER_SURFACE_V1_ERROR_INVALID_SIZE,
"height 0 requested without setting top and bottom anchors"); "height 0 requested without setting top and bottom anchors");
return; return;
} }
if ((anchor & surface->pending.exclusive_edge) != surface->pending.exclusive_edge) {
wlr_surface_reject_pending(wlr_surface, surface->resource,
ZWLR_LAYER_SURFACE_V1_ERROR_INVALID_EXCLUSIVE_EDGE,
"exclusive edge is invalid given the surface anchors");
}
} }
static void layer_surface_role_commit(struct wlr_surface *wlr_surface) { static void layer_surface_role_commit(struct wlr_surface *wlr_surface) {

Loading…
Cancel
Save