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

Commit 3364eec

Browse files
ifreundemersion
authored andcommitted
layer-shell: replace close() with destroy()
The protocol specifies that all requests (aside from destroy) are ignored after the compositor sends the closed event. Therefore, destroying the wlroots object and rendering the resource inert when sending the closed event keeps things simpler for wlroots and compositors.
1 parent ad7651a commit 3364eec

File tree

2 files changed

+14
-22
lines changed

2 files changed

+14
-22
lines changed

include/wlr/types/wlr_layer_shell_v1.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ struct wlr_layer_surface_v1 {
7070

7171
char *namespace;
7272

73-
bool added, configured, mapped, closed;
73+
bool added, configured, mapped;
7474
uint32_t configure_serial;
7575
uint32_t configure_next_serial;
7676
struct wl_list configure_list;
@@ -125,9 +125,10 @@ void wlr_layer_surface_v1_configure(struct wlr_layer_surface_v1 *surface,
125125
uint32_t width, uint32_t height);
126126

127127
/**
128-
* Unmaps this layer surface and notifies the client that it has been closed.
128+
* Notify the client that the surface has been closed and destroy the
129+
* wlr_layer_surface_v1, rendering the resource inert.
129130
*/
130-
void wlr_layer_surface_v1_close(struct wlr_layer_surface_v1 *surface);
131+
void wlr_layer_surface_v1_destroy(struct wlr_layer_surface_v1 *surface);
131132

132133
bool wlr_surface_is_layer_surface(struct wlr_surface *surface);
133134

types/wlr_layer_shell_v1.c

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ static void layer_surface_handle_ack_configure(struct wl_client *client,
6060
struct wl_resource *resource, uint32_t serial) {
6161
struct wlr_layer_surface_v1 *surface = layer_surface_from_resource(resource);
6262

63-
if (!surface || surface->closed) {
63+
if (!surface) {
6464
return;
6565
}
6666

@@ -302,15 +302,9 @@ void wlr_layer_surface_v1_configure(struct wlr_layer_surface_v1 *surface,
302302
}
303303
}
304304

305-
void wlr_layer_surface_v1_close(struct wlr_layer_surface_v1 *surface) {
306-
if (surface->closed) {
307-
return;
308-
}
309-
surface->closed = true;
310-
if (surface->mapped) {
311-
layer_surface_unmap(surface);
312-
}
305+
void wlr_layer_surface_v1_destroy(struct wlr_layer_surface_v1 *surface) {
313306
zwlr_layer_surface_v1_send_closed(surface->resource);
307+
layer_surface_destroy(surface);
314308
}
315309

316310
static void layer_surface_role_commit(struct wlr_surface *wlr_surface) {
@@ -340,11 +334,6 @@ static void layer_surface_role_commit(struct wlr_surface *wlr_surface) {
340334
return;
341335
}
342336

343-
if (surface->closed) {
344-
// Ignore commits after the compositor has closed it
345-
return;
346-
}
347-
348337
if (surface->acked_configure) {
349338
struct wlr_layer_surface_v1_configure *configure =
350339
surface->acked_configure;
@@ -374,12 +363,14 @@ static void layer_surface_role_commit(struct wlr_surface *wlr_surface) {
374363

375364
if (!surface->added) {
376365
surface->added = true;
377-
wlr_signal_emit_safe(&surface->shell->events.new_surface,
378-
surface);
379-
// either the compositor found a suitable output or it must
380-
// have closed the surface
381-
assert(surface->output || surface->closed);
366+
assert(!surface->configured);
367+
assert(!surface->mapped);
368+
wlr_signal_emit_safe(&surface->shell->events.new_surface, surface);
369+
// Return early here as the compositor may have closed this layer surface
370+
// in response to the new_surface event.
371+
return;
382372
}
373+
383374
if (surface->configured && wlr_surface_has_buffer(surface->surface) &&
384375
!surface->mapped) {
385376
surface->mapped = true;

0 commit comments

Comments
 (0)