mirror of
https://github.com/swaywm/sway.git
synced 2024-11-24 08:51:27 +00:00
sway_text_node: avoid unnecessary redraws
When a floating container has a titlebar, render_backing_buffer() ends up being called each time the container is moved. Add some more checks for no-op changes in sway_text_node_set_max_width() and sway_text_node_set_background(). This makes the move smoother.
This commit is contained in:
parent
d8c4a2d5fe
commit
818ea17389
|
@ -294,6 +294,9 @@ 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, int 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) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
buffer->props.max_width = max_width;
|
buffer->props.max_width = max_width;
|
||||||
wlr_scene_buffer_set_dest_size(buffer->buffer_node,
|
wlr_scene_buffer_set_dest_size(buffer->buffer_node,
|
||||||
get_text_width(&buffer->props), buffer->props.height);
|
get_text_width(&buffer->props), buffer->props.height);
|
||||||
|
@ -303,6 +306,9 @@ void sway_text_node_set_max_width(struct sway_text_node *node, int 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]) {
|
||||||
struct text_buffer *buffer = wl_container_of(node, buffer, props);
|
struct text_buffer *buffer = wl_container_of(node, buffer, props);
|
||||||
|
if (memcmp(&node->background, background, sizeof(*background) * 4) == 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
memcpy(&node->background, background, sizeof(*background) * 4);
|
memcpy(&node->background, background, sizeof(*background) * 4);
|
||||||
render_backing_buffer(buffer);
|
render_backing_buffer(buffer);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue