mirror of
https://github.com/hyprwm/wlroots-hyprland.git
synced 2024-11-29 16:05:59 +01:00
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.
This commit is contained in:
parent
ad7651a370
commit
3364eec07e
2 changed files with 14 additions and 22 deletions
|
@ -70,7 +70,7 @@ struct wlr_layer_surface_v1 {
|
||||||
|
|
||||||
char *namespace;
|
char *namespace;
|
||||||
|
|
||||||
bool added, configured, mapped, closed;
|
bool added, configured, mapped;
|
||||||
uint32_t configure_serial;
|
uint32_t configure_serial;
|
||||||
uint32_t configure_next_serial;
|
uint32_t configure_next_serial;
|
||||||
struct wl_list configure_list;
|
struct wl_list configure_list;
|
||||||
|
@ -125,9 +125,10 @@ void wlr_layer_surface_v1_configure(struct wlr_layer_surface_v1 *surface,
|
||||||
uint32_t width, uint32_t height);
|
uint32_t width, uint32_t height);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Unmaps this layer surface and notifies the client that it has been closed.
|
* Notify the client that the surface has been closed and destroy the
|
||||||
|
* wlr_layer_surface_v1, rendering the resource inert.
|
||||||
*/
|
*/
|
||||||
void wlr_layer_surface_v1_close(struct wlr_layer_surface_v1 *surface);
|
void wlr_layer_surface_v1_destroy(struct wlr_layer_surface_v1 *surface);
|
||||||
|
|
||||||
bool wlr_surface_is_layer_surface(struct wlr_surface *surface);
|
bool wlr_surface_is_layer_surface(struct wlr_surface *surface);
|
||||||
|
|
||||||
|
|
|
@ -60,7 +60,7 @@ static void layer_surface_handle_ack_configure(struct wl_client *client,
|
||||||
struct wl_resource *resource, uint32_t serial) {
|
struct wl_resource *resource, uint32_t serial) {
|
||||||
struct wlr_layer_surface_v1 *surface = layer_surface_from_resource(resource);
|
struct wlr_layer_surface_v1 *surface = layer_surface_from_resource(resource);
|
||||||
|
|
||||||
if (!surface || surface->closed) {
|
if (!surface) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -302,15 +302,9 @@ void wlr_layer_surface_v1_configure(struct wlr_layer_surface_v1 *surface,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void wlr_layer_surface_v1_close(struct wlr_layer_surface_v1 *surface) {
|
void wlr_layer_surface_v1_destroy(struct wlr_layer_surface_v1 *surface) {
|
||||||
if (surface->closed) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
surface->closed = true;
|
|
||||||
if (surface->mapped) {
|
|
||||||
layer_surface_unmap(surface);
|
|
||||||
}
|
|
||||||
zwlr_layer_surface_v1_send_closed(surface->resource);
|
zwlr_layer_surface_v1_send_closed(surface->resource);
|
||||||
|
layer_surface_destroy(surface);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void layer_surface_role_commit(struct wlr_surface *wlr_surface) {
|
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) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (surface->closed) {
|
|
||||||
// Ignore commits after the compositor has closed it
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (surface->acked_configure) {
|
if (surface->acked_configure) {
|
||||||
struct wlr_layer_surface_v1_configure *configure =
|
struct wlr_layer_surface_v1_configure *configure =
|
||||||
surface->acked_configure;
|
surface->acked_configure;
|
||||||
|
@ -374,12 +363,14 @@ static void layer_surface_role_commit(struct wlr_surface *wlr_surface) {
|
||||||
|
|
||||||
if (!surface->added) {
|
if (!surface->added) {
|
||||||
surface->added = true;
|
surface->added = true;
|
||||||
wlr_signal_emit_safe(&surface->shell->events.new_surface,
|
assert(!surface->configured);
|
||||||
surface);
|
assert(!surface->mapped);
|
||||||
// either the compositor found a suitable output or it must
|
wlr_signal_emit_safe(&surface->shell->events.new_surface, surface);
|
||||||
// have closed the surface
|
// Return early here as the compositor may have closed this layer surface
|
||||||
assert(surface->output || surface->closed);
|
// in response to the new_surface event.
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (surface->configured && wlr_surface_has_buffer(surface->surface) &&
|
if (surface->configured && wlr_surface_has_buffer(surface->surface) &&
|
||||||
!surface->mapped) {
|
!surface->mapped) {
|
||||||
surface->mapped = true;
|
surface->mapped = true;
|
||||||
|
|
Loading…
Reference in a new issue