Skip to content
This repository has been archived by the owner on Nov 1, 2021. It is now read-only.

layer_shell: set layer of existing surface #1842

Merged
merged 1 commit into from
Oct 16, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion include/wlr/types/wlr_layer_shell_v1.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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;
Expand Down
11 changes: 9 additions & 2 deletions protocol/wlr-layer-shell-unstable-v1.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
THIS SOFTWARE.
</copyright>

<interface name="zwlr_layer_shell_v1" version="1">
<interface name="zwlr_layer_shell_v1" version="2">
<description summary="create surfaces that are layers of the desktop">
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
Expand Down Expand Up @@ -84,7 +84,7 @@
</enum>
</interface>

<interface name="zwlr_layer_surface_v1" version="1">
<interface name="zwlr_layer_surface_v1" version="2">
<description summary="layer metadata interface">
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
Expand Down Expand Up @@ -231,6 +231,13 @@
</description>
</request>

<request name="set_layer" since="2">
<description summary="change the layer of the surface">
Change the layer that the surface is rendered on.
</description>
<arg name="layer" type="uint" enum="layer" summary="layer to move this surface to"/>
</request>

<event name="configure">
<description summary="suggest a surface change">
The configure event asks the client to resize its surface.
Expand Down
20 changes: 19 additions & 1 deletion types/wlr_layer_shell_v1.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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) {
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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,
Expand Down