aboutsummaryrefslogtreecommitdiffstats
path: root/sway/sway_text_node.c
diff options
context:
space:
mode:
Diffstat (limited to 'sway/sway_text_node.c')
-rw-r--r--sway/sway_text_node.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/sway/sway_text_node.c b/sway/sway_text_node.c
index b9a77d94..4b7ee999 100644
--- a/sway/sway_text_node.c
+++ b/sway/sway_text_node.c
@@ -1,4 +1,3 @@
1#define _POSIX_C_SOURCE 200809L
2#include <drm_fourcc.h> 1#include <drm_fourcc.h>
3#include <stdio.h> 2#include <stdio.h>
4#include <stdlib.h> 3#include <stdlib.h>
@@ -58,11 +57,11 @@ struct text_buffer {
58}; 57};
59 58
60static int get_text_width(struct sway_text_node *props) { 59static int get_text_width(struct sway_text_node *props) {
61 if (props->max_width) { 60 int width = props->width;
62 return MIN(props->max_width, props->width); 61 if (props->max_width >= 0) {
62 width = MIN(width, props->max_width);
63 } 63 }
64 64 return MAX(width, 0);
65 return props->width;
66} 65}
67 66
68static void update_source_box(struct text_buffer *buffer) { 67static void update_source_box(struct text_buffer *buffer) {
@@ -82,6 +81,11 @@ static void render_backing_buffer(struct text_buffer *buffer) {
82 return; 81 return;
83 } 82 }
84 83
84 if (buffer->props.max_width == 0) {
85 wlr_scene_buffer_set_buffer(buffer->buffer_node, NULL);
86 return;
87 }
88
85 float scale = buffer->scale; 89 float scale = buffer->scale;
86 int width = ceil(buffer->props.width * scale); 90 int width = ceil(buffer->props.width * scale);
87 int height = ceil(buffer->props.height * scale); 91 int height = ceil(buffer->props.height * scale);
@@ -237,6 +241,7 @@ struct sway_text_node *sway_text_node_create(struct wlr_scene_tree *parent,
237 241
238 buffer->buffer_node = node; 242 buffer->buffer_node = node;
239 buffer->props.node = &node->node; 243 buffer->props.node = &node->node;
244 buffer->props.max_width = -1;
240 buffer->text = strdup(text); 245 buffer->text = strdup(text);
241 if (!buffer->text) { 246 if (!buffer->text) {
242 free(buffer); 247 free(buffer);