From 1724261910728bfa63eecb0f1729995c00c7ffe8 Mon Sep 17 00:00:00 2001 From: Timidger Date: Thu, 3 Oct 2019 16:06:46 -0400 Subject: [PATCH] layer_shell: set layer of existing surface --- include/wlr/types/wlr_layer_shell_v1.h | 2 +- protocol/wlr-layer-shell-unstable-v1.xml | 11 +++++++++-- types/wlr_layer_shell_v1.c | 20 +++++++++++++++++++- 3 files changed, 29 insertions(+), 4 deletions(-) diff --git a/include/wlr/types/wlr_layer_shell_v1.h b/include/wlr/types/wlr_layer_shell_v1.h index 9613621a..588da650 100644 --- a/include/wlr/types/wlr_layer_shell_v1.h +++ b/include/wlr/types/wlr_layer_shell_v1.h @@ -54,6 +54,7 @@ struct wlr_layer_surface_v1_state { bool keyboard_interactive; uint32_t desired_width, desired_height; uint32_t actual_width, actual_height; + enum zwlr_layer_shell_v1_layer layer; }; struct wlr_layer_surface_v1_configure { @@ -71,7 +72,6 @@ struct wlr_layer_surface_v1 { struct wl_list popups; // wlr_xdg_popup::link char *namespace; - enum zwlr_layer_shell_v1_layer layer; bool added, configured, mapped, closed; uint32_t configure_serial; diff --git a/protocol/wlr-layer-shell-unstable-v1.xml b/protocol/wlr-layer-shell-unstable-v1.xml index 216e0d9f..257d369b 100644 --- a/protocol/wlr-layer-shell-unstable-v1.xml +++ b/protocol/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 @@ -84,7 +84,7 @@ - + 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 @@ -231,6 +231,13 @@ + + + Change the layer that the surface is rendered on. + + + + The configure event asks the client to resize its surface. diff --git a/types/wlr_layer_shell_v1.c b/types/wlr_layer_shell_v1.c index 4b71ecda..8b092fd3 100644 --- a/types/wlr_layer_shell_v1.c +++ b/types/wlr_layer_shell_v1.c @@ -173,6 +173,22 @@ static void layer_surface_handle_get_popup(struct wl_client *client, wlr_signal_emit_safe(&parent->events.new_popup, popup); } +static void layer_surface_set_layer(struct wl_client *client, + struct wl_resource *surface_resource, uint32_t layer) { + struct wlr_layer_surface_v1 *surface = + layer_surface_from_resource(surface_resource); + if (!surface) { + return; + } + if (layer > ZWLR_LAYER_SHELL_V1_LAYER_OVERLAY) { + wl_resource_post_error(surface->resource, + ZWLR_LAYER_SHELL_V1_ERROR_INVALID_LAYER, + "Invalid layer %d", layer); + return; + } + surface->client_pending.layer = layer; +} + static const struct zwlr_layer_surface_v1_interface layer_surface_implementation = { .destroy = resource_handle_destroy, .ack_configure = layer_surface_handle_ack_configure, @@ -182,6 +198,7 @@ static const struct zwlr_layer_surface_v1_interface layer_surface_implementation .set_margin = layer_surface_handle_set_margin, .set_keyboard_interactivity = layer_surface_handle_set_keyboard_interactivity, .get_popup = layer_surface_handle_get_popup, + .set_layer = layer_surface_set_layer, }; static void layer_surface_unmap(struct wlr_layer_surface_v1 *surface) { @@ -315,6 +332,7 @@ static void layer_surface_role_commit(struct wlr_surface *wlr_surface) { surface->client_pending.keyboard_interactive; surface->current.desired_width = surface->client_pending.desired_width; surface->current.desired_height = surface->client_pending.desired_height; + surface->current.layer = surface->client_pending.layer; if (!surface->added) { surface->added = true; @@ -375,7 +393,7 @@ static void layer_shell_handle_get_layer_surface(struct wl_client *wl_client, if (output_resource) { surface->output = wlr_output_from_resource(output_resource); } - surface->layer = layer; + surface->current.layer = surface->client_pending.layer = layer; if (layer > ZWLR_LAYER_SHELL_V1_LAYER_OVERLAY) { free(surface); wl_resource_post_error(client_resource,