mirror of
https://github.com/swaywm/sway.git
synced 2024-11-21 23:41:27 +00:00
sway_text_node: Allow 0 text width
special case negative numbers instead.
This commit is contained in:
parent
2686afb95c
commit
b463957021
|
@ -58,7 +58,7 @@ struct text_buffer {
|
||||||
|
|
||||||
static int get_text_width(struct sway_text_node *props) {
|
static int get_text_width(struct sway_text_node *props) {
|
||||||
int width = props->width;
|
int width = props->width;
|
||||||
if (props->max_width) {
|
if (props->max_width >= 0) {
|
||||||
width = MIN(width, props->max_width);
|
width = MIN(width, props->max_width);
|
||||||
}
|
}
|
||||||
return MAX(width, 0);
|
return MAX(width, 0);
|
||||||
|
@ -81,6 +81,11 @@ static void render_backing_buffer(struct text_buffer *buffer) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (buffer->props.max_width == 0) {
|
||||||
|
wlr_scene_buffer_set_buffer(buffer->buffer_node, NULL);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
float scale = buffer->scale;
|
float scale = buffer->scale;
|
||||||
int width = ceil(buffer->props.width * scale);
|
int width = ceil(buffer->props.width * scale);
|
||||||
int height = ceil(buffer->props.height * 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->buffer_node = node;
|
||||||
buffer->props.node = &node->node;
|
buffer->props.node = &node->node;
|
||||||
|
buffer->props.max_width = -1;
|
||||||
buffer->text = strdup(text);
|
buffer->text = strdup(text);
|
||||||
if (!buffer->text) {
|
if (!buffer->text) {
|
||||||
free(buffer);
|
free(buffer);
|
||||||
|
|
Loading…
Reference in a new issue