summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Ryan Dwyer <ryandwyer1@gmail.com>2018-07-07 15:49:51 +1000
committerLibravatar Ryan Dwyer <ryandwyer1@gmail.com>2018-07-07 15:49:51 +1000
commit0046eed96903c745142208c40aa5f10d0b5931cb (patch)
tree2675baaf165acdfc7f8090f9a8750eb971535659
parentMerge pull request #2196 from emersion/xwayland-floating-resize (diff)
downloadsway-0046eed96903c745142208c40aa5f10d0b5931cb.tar.gz
sway-0046eed96903c745142208c40aa5f10d0b5931cb.tar.zst
sway-0046eed96903c745142208c40aa5f10d0b5931cb.zip
Fix titles when container titles contain UTF-8 characters
The title and marks textures would have their height set from the config's computed max font height, but the textures were not regenerated when the config's max font height changed which made a gap appear. Rather than making it regenerate the title textures every time the config font height was changed, I've changed it to just make the textures the height of the title itself and fill any gap when rendering. Also, the title_width and marks_width variables have been renamed to make it more obvious that they are in output-buffer-local coordinates. Fixes #1936.
-rw-r--r--sway/desktop/output.c40
-rw-r--r--sway/tree/container.c2
-rw-r--r--sway/tree/view.c2
3 files changed, 34 insertions, 10 deletions
diff --git a/sway/desktop/output.c b/sway/desktop/output.c
index e5a42db0..336163ea 100644
--- a/sway/desktop/output.c
+++ b/sway/desktop/output.c
@@ -521,7 +521,7 @@ static void render_titlebar(struct sway_output *output,
521 size_t inner_width = width - TITLEBAR_H_PADDING * 2; 521 size_t inner_width = width - TITLEBAR_H_PADDING * 2;
522 522
523 // Marks 523 // Marks
524 size_t marks_width = 0; 524 size_t marks_ob_width = 0; // output-buffer-local
525 if (config->show_marks && marks_texture) { 525 if (config->show_marks && marks_texture) {
526 struct wlr_box texture_box; 526 struct wlr_box texture_box;
527 wlr_texture_get_size(marks_texture, 527 wlr_texture_get_size(marks_texture,
@@ -540,11 +540,23 @@ static void render_titlebar(struct sway_output *output,
540 } 540 }
541 render_texture(output->wlr_output, output_damage, marks_texture, 541 render_texture(output->wlr_output, output_damage, marks_texture,
542 &texture_box, matrix, con->alpha); 542 &texture_box, matrix, con->alpha);
543 marks_width = texture_box.width; 543 marks_ob_width = texture_box.width;
544
545 // Gap between the marks and bottom padding, for when the marks texture
546 // height is smaller than the config's font height
547 memcpy(&color, colors->background, sizeof(float) * 4);
548 premultiply_alpha(color, con->alpha);
549 box.x = texture_box.x;
550 box.y = texture_box.y + texture_box.height;
551 box.width = texture_box.width;
552 box.height = config->font_height * output_scale - texture_box.height;
553 if (box.height > 0) {
554 render_rect(output->wlr_output, output_damage, &box, color);
555 }
544 } 556 }
545 557
546 // Title text 558 // Title text
547 size_t title_width = 0; 559 size_t title_ob_width = 0; // output-buffer-local
548 if (title_texture) { 560 if (title_texture) {
549 struct wlr_box texture_box; 561 struct wlr_box texture_box;
550 wlr_texture_get_size(title_texture, 562 wlr_texture_get_size(title_texture,
@@ -557,12 +569,24 @@ static void render_titlebar(struct sway_output *output,
557 WL_OUTPUT_TRANSFORM_NORMAL, 569 WL_OUTPUT_TRANSFORM_NORMAL,
558 0.0, output->wlr_output->transform_matrix); 570 0.0, output->wlr_output->transform_matrix);
559 571
560 if (inner_width * output_scale - marks_width < texture_box.width) { 572 if (inner_width * output_scale - marks_ob_width < texture_box.width) {
561 texture_box.width = inner_width * output_scale - marks_width; 573 texture_box.width = inner_width * output_scale - marks_ob_width;
562 } 574 }
563 render_texture(output->wlr_output, output_damage, title_texture, 575 render_texture(output->wlr_output, output_damage, title_texture,
564 &texture_box, matrix, con->alpha); 576 &texture_box, matrix, con->alpha);
565 title_width = texture_box.width; 577 title_ob_width = texture_box.width;
578
579 // Gap between the title and bottom padding, for when the title texture
580 // height is smaller than the config's font height
581 memcpy(&color, colors->background, sizeof(float) * 4);
582 premultiply_alpha(color, con->alpha);
583 box.x = texture_box.x;
584 box.y = texture_box.y + texture_box.height;
585 box.width = texture_box.width;
586 box.height = config->font_height * output_scale - texture_box.height;
587 if (box.height > 0) {
588 render_rect(output->wlr_output, output_damage, &box, color);
589 }
566 } 590 }
567 591
568 // Padding above title 592 // Padding above title
@@ -580,9 +604,9 @@ static void render_titlebar(struct sway_output *output,
580 render_rect(output->wlr_output, output_damage, &box, color); 604 render_rect(output->wlr_output, output_damage, &box, color);
581 605
582 // Filler between title and marks 606 // Filler between title and marks
583 box.width = inner_width * output_scale - title_width - marks_width; 607 box.width = inner_width * output_scale - title_ob_width - marks_ob_width;
584 if (box.width > 0) { 608 if (box.width > 0) {
585 box.x = (x + TITLEBAR_H_PADDING) * output_scale + title_width; 609 box.x = (x + TITLEBAR_H_PADDING) * output_scale + title_ob_width;
586 box.y = (y + TITLEBAR_V_PADDING) * output_scale; 610 box.y = (y + TITLEBAR_V_PADDING) * output_scale;
587 box.height = config->font_height * output_scale; 611 box.height = config->font_height * output_scale;
588 render_rect(output->wlr_output, output_damage, &box, color); 612 render_rect(output->wlr_output, output_damage, &box, color);
diff --git a/sway/tree/container.c b/sway/tree/container.c
index 9093feba..5fdcb6e3 100644
--- a/sway/tree/container.c
+++ b/sway/tree/container.c
@@ -783,7 +783,7 @@ static void update_title_texture(struct sway_container *con,
783 783
784 double scale = output->sway_output->wlr_output->scale; 784 double scale = output->sway_output->wlr_output->scale;
785 int width = 0; 785 int width = 0;
786 int height = config->font_height * scale; 786 int height = con->title_height * scale;
787 787
788 cairo_t *c = cairo_create(NULL); 788 cairo_t *c = cairo_create(NULL);
789 get_text_size(c, config->font, &width, NULL, scale, config->pango_markup, 789 get_text_size(c, config->font, &width, NULL, scale, config->pango_markup,
diff --git a/sway/tree/view.c b/sway/tree/view.c
index e46cb327..3ef79fa8 100644
--- a/sway/tree/view.c
+++ b/sway/tree/view.c
@@ -923,7 +923,7 @@ static void update_marks_texture(struct sway_view *view,
923 923
924 double scale = output->sway_output->wlr_output->scale; 924 double scale = output->sway_output->wlr_output->scale;
925 int width = 0; 925 int width = 0;
926 int height = config->font_height * scale; 926 int height = view->swayc->title_height * scale;
927 927
928 cairo_t *c = cairo_create(NULL); 928 cairo_t *c = cairo_create(NULL);
929 get_text_size(c, config->font, &width, NULL, scale, false, "%s", buffer); 929 get_text_size(c, config->font, &width, NULL, scale, false, "%s", buffer);