From 07042486c3c4b8e7083405ba9b34b1b87f8d396d Mon Sep 17 00:00:00 2001 From: Tudor Brindus Date: Tue, 3 Nov 2020 00:16:15 -0500 Subject: tree/container: introduce `container_is_sticky[_or_child]` functions To query whether a container is sticky, checking `con->is_sticky` is insufficient. `container_is_floating_or_child` must also return true; this led to a lot of repetition. This commit introduces `container_is_sticky[_or_child]` functions, and switches all stickiness checks to use them. (Including ones where the container is already known to be floating, for consistency.) --- include/sway/tree/container.h | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'include') diff --git a/include/sway/tree/container.h b/include/sway/tree/container.h index 136d618b..c9290108 100644 --- a/include/sway/tree/container.h +++ b/include/sway/tree/container.h @@ -78,6 +78,9 @@ struct sway_container { enum sway_container_layout layout; enum sway_container_layout prev_split_layout; + // Whether stickiness has been enabled on this container. Use + // `container_is_sticky_[or_child]` rather than accessing this field + // directly; it'll also check that the container is floating. bool is_sticky; // For C_ROOT, this has no meaning @@ -367,4 +370,8 @@ bool container_is_scratchpad_hidden(struct sway_container *con); bool container_is_scratchpad_hidden_or_child(struct sway_container *con); +bool container_is_sticky(struct sway_container *con); + +bool container_is_sticky_or_child(struct sway_container *con); + #endif -- cgit v1.2.3-54-g00ecf