aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFurkan Sahin <furkan-dev@proton.me>2021-02-24 15:15:22 -0500
committerFurkan Sahin <furkan-dev@proton.me>2021-02-24 15:15:22 -0500
commit3569c53cc9b93bf811087d69f3bef5025e84e850 (patch)
tree18d23151d020320bf0a9252f0ee77593b23f6ee5
parentdf061ce2aac7c8f5b29d9e76d9effc9b44652a5b (diff)
render: handle containers without output when rendering titles
In 43977eb92c4c5f1db0c4d9abe418535053cf039a, it was believed that if the container is being rendered, it must have an output. This turned out not to be the case. When rendering a container, all its children are rendered, even if the children is positioned off screen and thus not having any output. This is the cause of the crash in #6061. This commit introduces a null-check, which fixes #6061.
-rw-r--r--include/sway/tree/container.h1
-rw-r--r--sway/desktop/render.c6
2 files changed, 6 insertions, 1 deletions
diff --git a/include/sway/tree/container.h b/include/sway/tree/container.h
index 5c368df2..2c973f71 100644
--- a/include/sway/tree/container.h
+++ b/include/sway/tree/container.h
@@ -285,6 +285,7 @@ bool container_is_fullscreen_or_child(struct sway_container *container);
/**
* Return the output which will be used for scale purposes.
* This is the most recently entered output.
+ * If the container is not on any output, return NULL.
*/
struct sway_output *container_get_effective_output(struct sway_container *con);
diff --git a/sway/desktop/render.c b/sway/desktop/render.c
index 20832cc4..908ad819 100644
--- a/sway/desktop/render.c
+++ b/sway/desktop/render.c
@@ -519,7 +519,11 @@ static void render_titlebar(struct sway_output *output,
wlr_texture_get_size(title_texture,
&texture_box.width, &texture_box.height);
- float title_scale = container_get_effective_output(con)->wlr_output->scale;
+ // The effective output may be NULL when con is not on any output.
+ // This can happen because we render all children of containers,
+ // even those that are out of the bounds of any output.
+ struct sway_output *effective = container_get_effective_output(con);
+ float title_scale = effective ? effective->wlr_output->scale : output_scale;
texture_box.width = texture_box.width * output_scale / title_scale;
texture_box.height = texture_box.height * output_scale / title_scale;
ob_title_width = texture_box.width;