From 258f16752800b672061d910854a446903bf7e6f4 Mon Sep 17 00:00:00 2001 From: Kirill Primak Date: Fri, 30 Jul 2021 11:34:10 +0300 Subject: [PATCH] view: add lock/unlock functions --- include/sway/tree/view.h | 7 +++++++ sway/tree/view.c | 19 +++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/include/sway/tree/view.h b/include/sway/tree/view.h index c404b97a7..bf2f0a789 100644 --- a/include/sway/tree/view.h +++ b/include/sway/tree/view.h @@ -70,6 +70,9 @@ struct sway_view { // Used when changing a view from tiled to floating. int natural_width, natural_height; + bool surface_locked; + uint32_t lock_seq; + char *title_format; bool using_csd; @@ -341,6 +344,10 @@ void view_set_urgent(struct sway_view *view, bool enable); bool view_is_urgent(struct sway_view *view); +void view_lock_pending(struct sway_view *view); + +void view_unlock_cached(struct sway_view *view); + bool view_is_transient_for(struct sway_view *child, struct sway_view *ancestor); #endif diff --git a/sway/tree/view.c b/sway/tree/view.c index 1aab7f1c9..dcd5a0e78 100644 --- a/sway/tree/view.c +++ b/sway/tree/view.c @@ -875,6 +875,11 @@ void view_unmap(struct sway_view *view) { } transaction_commit_dirty(); + + if (view->surface_locked) { + view_unlock_cached(view); + } + view->surface = NULL; } @@ -1377,3 +1382,17 @@ bool view_is_transient_for(struct sway_view *child, return child->impl->is_transient_for && child->impl->is_transient_for(child, ancestor); } + +void view_lock_pending(struct sway_view *view) { + sway_assert(!view->surface_locked, "Can't lock a locked view"); + if (view->surface) { + view->surface_locked = true; + view->lock_seq = wlr_surface_lock_pending(view->surface); + } +} + +void view_unlock_cached(struct sway_view *view) { + sway_assert(view->surface_locked, "Can't unlock an unlocked view"); + view->surface_locked = false; + wlr_surface_unlock_cached(view->surface, view->lock_seq); +}