Merge branch 'master' into disable_titlebar

This commit is contained in:
neuromagus 2024-05-08 19:01:02 +03:00 committed by GitHub
commit e23e62197c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 18 additions and 1 deletions

View file

@ -2,6 +2,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <wayland-server-core.h> #include <wayland-server-core.h>
#include <wlr/types/wlr_fractional_scale_v1.h>
#include <wlr/types/wlr_layer_shell_v1.h> #include <wlr/types/wlr_layer_shell_v1.h>
#include <wlr/types/wlr_output.h> #include <wlr/types/wlr_output.h>
#include <wlr/types/wlr_scene.h> #include <wlr/types/wlr_scene.h>
@ -432,6 +433,12 @@ void handle_layer_shell_surface(struct wl_listener *listener, void *data) {
surface->output = output; 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; surface->surface_commit.notify = handle_surface_commit;
wl_signal_add(&layer_surface->surface->events.commit, wl_signal_add(&layer_surface->surface->events.commit,
&surface->surface_commit); &surface->surface_commit);

View file

@ -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);

View file

@ -352,6 +352,8 @@ void container_arrange_title_bar(struct sway_container *con) {
int alloc_width = MIN((int)node->width, int alloc_width = MIN((int)node->width,
width - h_padding - config->titlebar_h_padding); width - h_padding - config->titlebar_h_padding);
alloc_width = MAX(alloc_width, 0);
sway_text_node_set_max_width(node, alloc_width); sway_text_node_set_max_width(node, alloc_width);
wlr_scene_node_set_position(node->node, wlr_scene_node_set_position(node->node,
h_padding, (height - node->height) >> 1); 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, int alloc_width = MIN((int) node->width,
width - h_padding - config->titlebar_h_padding); width - h_padding - config->titlebar_h_padding);
alloc_width = MAX(alloc_width, 0);
sway_text_node_set_max_width(node, alloc_width); sway_text_node_set_max_width(node, alloc_width);
wlr_scene_node_set_position(node->node, wlr_scene_node_set_position(node->node,
h_padding, (height - node->height) >> 1); h_padding, (height - node->height) >> 1);