From 8c0eeb6a86d858a87f4839db4d551817136753c7 Mon Sep 17 00:00:00 2001 From: Kirill Primak Date: Fri, 2 Jun 2023 23:26:12 +0300 Subject: [PATCH] session-lock: fix buffer check If the first commit has no buffer, the unmap hook won't catch it. Check in the commit hook instead. --- types/wlr_session_lock_v1.c | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/types/wlr_session_lock_v1.c b/types/wlr_session_lock_v1.c index 431202d6f..cd7f6e7a2 100644 --- a/types/wlr_session_lock_v1.c +++ b/types/wlr_session_lock_v1.c @@ -134,6 +134,13 @@ static void lock_surface_role_commit(struct wlr_surface *surface) { wlr_session_lock_surface_v1_try_from_wlr_surface(surface); assert(lock_surface != NULL); + if (!wlr_surface_has_buffer(surface)) { + wl_resource_post_error(lock_surface->resource, + EXT_SESSION_LOCK_SURFACE_V1_ERROR_NULL_BUFFER, + "session lock surface is committed with a null buffer"); + return; + } + if (!lock_surface->configured) { wl_resource_post_error(lock_surface->resource, EXT_SESSION_LOCK_SURFACE_V1_ERROR_COMMIT_BEFORE_FIRST_ACK, @@ -155,16 +162,6 @@ static void lock_surface_role_commit(struct wlr_surface *surface) { wlr_surface_map(surface); } -static void lock_surface_role_unmap(struct wlr_surface *surface) { - struct wlr_session_lock_surface_v1 *lock_surface = - wlr_session_lock_surface_v1_try_from_wlr_surface(surface); - assert(lock_surface != NULL); - - wl_resource_post_error(lock_surface->resource, - EXT_SESSION_LOCK_SURFACE_V1_ERROR_NULL_BUFFER, - "session lock surfaces committed with null buffer"); -} - static void lock_surface_role_destroy(struct wlr_surface *surface) { struct wlr_session_lock_surface_v1 *lock_surface = wlr_session_lock_surface_v1_try_from_wlr_surface(surface); @@ -191,7 +188,6 @@ static void lock_surface_role_destroy(struct wlr_surface *surface) { static const struct wlr_surface_role lock_surface_role = { .name = "ext_session_lock_surface_v1", .commit = lock_surface_role_commit, - .unmap = lock_surface_role_unmap, .destroy = lock_surface_role_destroy, };