From b463957021db6c247d40de4059d4a31ad4e6d761 Mon Sep 17 00:00:00 2001 From: Alexander Orzechowski Date: Tue, 30 Apr 2024 20:05:11 -0400 Subject: [PATCH 1/3] sway_text_node: Allow 0 text width special case negative numbers instead. --- sway/sway_text_node.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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); From 30f5c3a9117be3e4911cba02693f7b45a197da93 Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Fri, 12 Apr 2024 19:20:36 +0200 Subject: [PATCH 2/3] tree/container: ensure pixman rect is valid in container_arrange_title_bar() Fixes "Invalid rectangle passed" errors printed by Pixman. --- sway/tree/container.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/sway/tree/container.c b/sway/tree/container.c index 9224b4fb..80ef34fe 100644 --- a/sway/tree/container.c +++ b/sway/tree/container.c @@ -352,6 +352,8 @@ void container_arrange_title_bar(struct sway_container *con) { int alloc_width = MIN((int)node->width, width - h_padding - config->titlebar_h_padding); + alloc_width = MAX(alloc_width, 0); + sway_text_node_set_max_width(node, alloc_width); wlr_scene_node_set_position(node->node, h_padding, (height - node->height) >> 1); @@ -376,6 +378,8 @@ void container_arrange_title_bar(struct sway_container *con) { int alloc_width = MIN((int) node->width, width - h_padding - config->titlebar_h_padding); + alloc_width = MAX(alloc_width, 0); + sway_text_node_set_max_width(node, alloc_width); wlr_scene_node_set_position(node->node, h_padding, (height - node->height) >> 1); From dcdb72757a5ec591c692df5e96c57c51758dbd8f Mon Sep 17 00:00:00 2001 From: Manuel Stoeckl Date: Mon, 29 Apr 2024 21:01:44 -0400 Subject: [PATCH 3/3] desktop/layer_shell: provide fractional scale on creation Also, send a matching wl_surface.preferred_buffer_scale event. --- sway/desktop/layer_shell.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/sway/desktop/layer_shell.c b/sway/desktop/layer_shell.c index 4b2584b6..6221b7b9 100644 --- a/sway/desktop/layer_shell.c +++ b/sway/desktop/layer_shell.c @@ -2,6 +2,7 @@ #include #include #include +#include #include #include #include @@ -432,6 +433,12 @@ void handle_layer_shell_surface(struct wl_listener *listener, void *data) { surface->output = output; + // now that the surface's output is known, we can advertise its scale + wlr_fractional_scale_v1_notify_scale(surface->layer_surface->surface, + layer_surface->output->scale); + wlr_surface_set_preferred_buffer_scale(surface->layer_surface->surface, + ceil(layer_surface->output->scale)); + surface->surface_commit.notify = handle_surface_commit; wl_signal_add(&layer_surface->surface->events.commit, &surface->surface_commit);