mirror of
https://github.com/swaywm/sway.git
synced 2024-11-28 02:41:28 +00:00
Merge branch 'master' into disable_titlebar
This commit is contained in:
commit
e23e62197c
|
@ -2,6 +2,7 @@
|
|||
#include <stdlib.h>
|
||||
#include <string.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_output.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;
|
||||
|
||||
// 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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue