summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Orzechowski <alex@ozal.ski>2024-02-02 00:35:53 +0100
committerSimon Ser <contact@emersion.fr>2024-02-02 00:54:26 +0100
commitba427a469a8394cb2fafa1a0602d6fd78c5c4d68 (patch)
tree2e4580491d7372d6fc0bb1a97bc89033659a7fdd
parentc8676fad54bb0f4152947a6781626872bfa6ad64 (diff)
Ensure get_text_width() returns a positive value
Closes: https://github.com/swaywm/sway/issues/7940
-rw-r--r--sway/sway_text_node.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/sway/sway_text_node.c b/sway/sway_text_node.c
index b9a77d94d..664db40e9 100644
--- a/sway/sway_text_node.c
+++ b/sway/sway_text_node.c
@@ -58,11 +58,11 @@ struct text_buffer {
};
static int get_text_width(struct sway_text_node *props) {
+ int width = props->width;
if (props->max_width) {
- return MIN(props->max_width, props->width);
+ width = MIN(width, props->max_width);
}
-
- return props->width;
+ return MAX(width, 0);
}
static void update_source_box(struct text_buffer *buffer) {