aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Alexander Orzechowski <alex@ozal.ski>2024-04-30 20:05:11 -0400
committerLibravatar Simon Ser <contact@emersion.fr>2024-05-07 16:14:58 +0200
commitb463957021db6c247d40de4059d4a31ad4e6d761 (patch)
tree92f45ab30617f8973b4c011e51d6c903fee80163
parentconfig/output: Print output state during tests (diff)
downloadsway-b463957021db6c247d40de4059d4a31ad4e6d761.tar.gz
sway-b463957021db6c247d40de4059d4a31ad4e6d761.tar.zst
sway-b463957021db6c247d40de4059d4a31ad4e6d761.zip
sway_text_node: Allow 0 text width
special case negative numbers instead.
-rw-r--r--sway/sway_text_node.c8
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 {
58 58
59static int get_text_width(struct sway_text_node *props) { 59static int get_text_width(struct sway_text_node *props) {
60 int width = props->width; 60 int width = props->width;
61 if (props->max_width) { 61 if (props->max_width >= 0) {
62 width = MIN(width, props->max_width); 62 width = MIN(width, props->max_width);
63 } 63 }
64 return MAX(width, 0); 64 return MAX(width, 0);
@@ -81,6 +81,11 @@ static void render_backing_buffer(struct text_buffer *buffer) {
81 return; 81 return;
82 } 82 }
83 83
84 if (buffer->props.max_width == 0) {
85 wlr_scene_buffer_set_buffer(buffer->buffer_node, NULL);
86 return;
87 }
88
84 float scale = buffer->scale; 89 float scale = buffer->scale;
85 int width = ceil(buffer->props.width * scale); 90 int width = ceil(buffer->props.width * scale);
86 int height = ceil(buffer->props.height * scale); 91 int height = ceil(buffer->props.height * scale);
@@ -236,6 +241,7 @@ struct sway_text_node *sway_text_node_create(struct wlr_scene_tree *parent,
236 241
237 buffer->buffer_node = node; 242 buffer->buffer_node = node;
238 buffer->props.node = &node->node; 243 buffer->props.node = &node->node;
244 buffer->props.max_width = -1;
239 buffer->text = strdup(text); 245 buffer->text = strdup(text);
240 if (!buffer->text) { 246 if (!buffer->text) {
241 free(buffer); 247 free(buffer);