diff --git a/sway/lock.c b/sway/lock.c index 168d469a19..700d09d0e6 100644 --- a/sway/lock.c +++ b/sway/lock.c @@ -1,6 +1,7 @@ #include #include #include +#include #include "log.h" #include "sway/input/cursor.h" #include "sway/input/keyboard.h" @@ -331,11 +332,26 @@ void sway_session_lock_add_output(struct sway_session_lock *lock, } } +static bool wlr_surface_has_subsurface(struct wlr_surface *surface, struct wlr_surface *sub) { + struct wlr_subsurface *subsurface = wlr_subsurface_try_from_wlr_surface(sub); + if (!subsurface) { + return false; + } + if (!subsurface->parent) { + return false; + } + if (subsurface->parent == surface) { + return true; + } + return wlr_surface_has_subsurface(subsurface->parent, surface); +} + bool sway_session_lock_has_surface(struct sway_session_lock *lock, struct wlr_surface *surface) { struct sway_session_lock_output *lock_output; wl_list_for_each(lock_output, &lock->outputs, link) { - if (lock_output->surface && lock_output->surface->surface == surface) { + if (lock_output->surface && (lock_output->surface->surface == surface + || wlr_surface_has_subsurface(lock_output->surface->surface, surface))) { return true; } }