mirror of
https://github.com/swaywm/sway.git
synced 2026-04-08 08:21:13 -04:00
sway_text_node: allow max width to be fractional
Signed-off-by: Loukas Agorgianitis <loukas@agorgianitis.com>
This commit is contained in:
parent
488673cb8d
commit
57d597d32d
2 changed files with 6 additions and 6 deletions
|
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
struct sway_text_node {
|
struct sway_text_node {
|
||||||
int width;
|
int width;
|
||||||
int max_width;
|
double max_width;
|
||||||
int height;
|
int height;
|
||||||
int baseline;
|
int baseline;
|
||||||
bool pango_markup;
|
bool pango_markup;
|
||||||
|
|
@ -21,7 +21,7 @@ void sway_text_node_set_color(struct sway_text_node *node, float color[4]);
|
||||||
|
|
||||||
void sway_text_node_set_text(struct sway_text_node *node, char *text);
|
void sway_text_node_set_text(struct sway_text_node *node, char *text);
|
||||||
|
|
||||||
void sway_text_node_set_max_width(struct sway_text_node *node, int max_width);
|
void sway_text_node_set_max_width(struct sway_text_node *node, double max_width);
|
||||||
|
|
||||||
void sway_text_node_set_background(struct sway_text_node *node, float background[4]);
|
void sway_text_node_set_background(struct sway_text_node *node, float background[4]);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -56,8 +56,8 @@ struct text_buffer {
|
||||||
struct wl_listener destroy;
|
struct wl_listener destroy;
|
||||||
};
|
};
|
||||||
|
|
||||||
static int get_text_width(struct sway_text_node *props) {
|
static double get_text_width(struct sway_text_node *props) {
|
||||||
int width = props->width;
|
double width = props->width;
|
||||||
if (props->max_width >= 0) {
|
if (props->max_width >= 0) {
|
||||||
width = MIN(width, props->max_width);
|
width = MIN(width, props->max_width);
|
||||||
}
|
}
|
||||||
|
|
@ -139,7 +139,7 @@ static void render_backing_buffer(struct text_buffer *buffer) {
|
||||||
pixman_region64f_t opaque;
|
pixman_region64f_t opaque;
|
||||||
pixman_region64f_init(&opaque);
|
pixman_region64f_init(&opaque);
|
||||||
if (background[3] == 1) {
|
if (background[3] == 1) {
|
||||||
pixman_region64f_union_rect(&opaque, &opaque, 0, 0,
|
pixman_region64f_union_rectf(&opaque, &opaque, 0, 0,
|
||||||
get_text_width(&buffer->props), buffer->props.height);
|
get_text_width(&buffer->props), buffer->props.height);
|
||||||
}
|
}
|
||||||
wlr_scene_buffer_set_opaque_region(buffer->buffer_node, &opaque);
|
wlr_scene_buffer_set_opaque_region(buffer->buffer_node, &opaque);
|
||||||
|
|
@ -279,7 +279,7 @@ void sway_text_node_set_text(struct sway_text_node *node, char *text) {
|
||||||
render_backing_buffer(buffer);
|
render_backing_buffer(buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
void sway_text_node_set_max_width(struct sway_text_node *node, int max_width) {
|
void sway_text_node_set_max_width(struct sway_text_node *node, double max_width) {
|
||||||
struct text_buffer *buffer = wl_container_of(node, buffer, props);
|
struct text_buffer *buffer = wl_container_of(node, buffer, props);
|
||||||
if (max_width == buffer->props.max_width) {
|
if (max_width == buffer->props.max_width) {
|
||||||
return;
|
return;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue