diff options
| author | Alexander Orzechowski <alex@ozal.ski> | 2024-04-30 20:05:11 -0400 |
|---|---|---|
| committer | Simon Ser <contact@emersion.fr> | 2024-05-07 16:14:58 +0200 |
| commit | b463957021db6c247d40de4059d4a31ad4e6d761 (patch) | |
| tree | 92f45ab30617f8973b4c011e51d6c903fee80163 | |
| parent | 2686afb95c5dd76b22abdd76ffbb4b30688f8fd3 (diff) | |
sway_text_node: Allow 0 text width
special case negative numbers instead.
| -rw-r--r-- | sway/sway_text_node.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/sway/sway_text_node.c b/sway/sway_text_node.c index 5eba53ba..4b7ee999 100644 --- a/sway/sway_text_node.c +++ b/sway/sway_text_node.c @@ -58,7 +58,7 @@ struct text_buffer { static int get_text_width(struct sway_text_node *props) { int width = props->width; - if (props->max_width) { + if (props->max_width >= 0) { width = MIN(width, props->max_width); } return MAX(width, 0); @@ -81,6 +81,11 @@ static void render_backing_buffer(struct text_buffer *buffer) { return; } + if (buffer->props.max_width == 0) { + wlr_scene_buffer_set_buffer(buffer->buffer_node, NULL); + return; + } + float scale = buffer->scale; int width = ceil(buffer->props.width * scale); int height = ceil(buffer->props.height * scale); @@ -236,6 +241,7 @@ struct sway_text_node *sway_text_node_create(struct wlr_scene_tree *parent, buffer->buffer_node = node; buffer->props.node = &node->node; + buffer->props.max_width = -1; buffer->text = strdup(text); if (!buffer->text) { free(buffer); |
