summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Ryan Dwyer <ryandwyer1@gmail.com>2018-05-20 23:16:51 +1000
committerLibravatar Ryan Dwyer <ryandwyer1@gmail.com>2018-05-21 20:16:56 +1000
commit90607dc32970a422f375234539cd6d6182ee89d1 (patch)
tree13a74e80f1c183fd1a9f4b9d4c0943fd54cb83ad
parentFix tab border issues (diff)
downloadsway-90607dc32970a422f375234539cd6d6182ee89d1.tar.gz
sway-90607dc32970a422f375234539cd6d6182ee89d1.tar.zst
sway-90607dc32970a422f375234539cd6d6182ee89d1.zip
Add left/right borders to tabs
-rw-r--r--sway/desktop/output.c53
1 files changed, 24 insertions, 29 deletions
diff --git a/sway/desktop/output.c b/sway/desktop/output.c
index c052cafb..829029a7 100644
--- a/sway/desktop/output.c
+++ b/sway/desktop/output.c
@@ -605,13 +605,11 @@ static void render_tab(struct sway_output *output, pixman_region32_t *damage,
605 float output_scale = output->wlr_output->scale; 605 float output_scale = output->wlr_output->scale;
606 float color[4]; 606 float color[4];
607 struct wlr_box box; 607 struct wlr_box box;
608 bool is_first = (child_index == 0);
609 bool is_last = (child_index == parent->children->length - 1);
610 608
611 int tab_width = parent->width / parent->children->length; 609 int tab_width = parent->width / parent->children->length;
612 int x = parent->x + tab_width * child_index; 610 int x = parent->x + tab_width * child_index;
613 // Make last tab use the remaining width of the parent 611 // Make last tab use the remaining width of the parent
614 if (is_last) { 612 if (child_index == parent->children->length - 1) {
615 tab_width = parent->width - tab_width * child_index; 613 tab_width = parent->width - tab_width * child_index;
616 } 614 }
617 615
@@ -625,22 +623,29 @@ static void render_tab(struct sway_output *output, pixman_region32_t *damage,
625 render_rect(output->wlr_output, damage, &box, color); 623 render_rect(output->wlr_output, damage, &box, color);
626 624
627 // Single pixel bar below title 625 // Single pixel bar below title
628 memcpy(&color, colors->border, sizeof(float) * 4); 626 box.y = (parent->y + config->border_thickness * 2 + config->font_height - 1)
629 box.x = x + config->border_thickness * is_first; 627 * output_scale;
630 box.y = parent->y + config->border_thickness * 2 + config->font_height - 1; 628 render_rect(output->wlr_output, damage, &box, color);
631 box.width = tab_width - config->border_thickness * is_first 629
632 - config->border_thickness * is_last; 630 // Single pixel bar on left
633 box.height = 1; 631 box.x = x;
632 box.y = parent->y + 1;
633 box.width = 1;
634 box.height = config->border_thickness * 2 + config->font_height - 2;
634 scale_box(&box, output_scale); 635 scale_box(&box, output_scale);
635 render_rect(output->wlr_output, damage, &box, color); 636 render_rect(output->wlr_output, damage, &box, color);
636 637
638 // Single pixel bar on right
639 box.x = (x + tab_width - 1) * output_scale;
640 render_rect(output->wlr_output, damage, &box, color);
641
637 // Title text 642 // Title text
638 size_t title_width = 0; 643 size_t title_width = 0;
639 if (title_texture) { 644 if (title_texture) {
640 struct wlr_box texture_box; 645 struct wlr_box texture_box;
641 wlr_texture_get_size(title_texture, 646 wlr_texture_get_size(title_texture,
642 &texture_box.width, &texture_box.height); 647 &texture_box.width, &texture_box.height);
643 texture_box.x = (x + config->border_thickness) * output_scale; 648 texture_box.x = (x + 1 + config->border_thickness) * output_scale;
644 texture_box.y = (parent->y + config->border_thickness) * output_scale; 649 texture_box.y = (parent->y + config->border_thickness) * output_scale;
645 650
646 float matrix[9]; 651 float matrix[9];
@@ -648,7 +653,7 @@ static void render_tab(struct sway_output *output, pixman_region32_t *damage,
648 WL_OUTPUT_TRANSFORM_NORMAL, 653 WL_OUTPUT_TRANSFORM_NORMAL,
649 0.0, output->wlr_output->transform_matrix); 654 0.0, output->wlr_output->transform_matrix);
650 655
651 int available = (tab_width - config->border_thickness * 2) 656 int available = (tab_width - config->border_thickness * 2 - 2)
652 * output_scale; 657 * output_scale;
653 if (texture_box.width > available) { 658 if (texture_box.width > available) {
654 texture_box.width = available; 659 texture_box.width = available;
@@ -660,9 +665,9 @@ static void render_tab(struct sway_output *output, pixman_region32_t *damage,
660 665
661 // Title background - above the text 666 // Title background - above the text
662 memcpy(&color, colors->background, sizeof(float) * 4); 667 memcpy(&color, colors->background, sizeof(float) * 4);
663 box.x = x + config->border_thickness; 668 box.x = x + 1;
664 box.y = parent->y + 1; 669 box.y = parent->y + 1;
665 box.width = tab_width - config->border_thickness * 2; 670 box.width = tab_width - 2;
666 box.height = config->border_thickness - 1; 671 box.height = config->border_thickness - 1;
667 scale_box(&box, output_scale); 672 scale_box(&box, output_scale);
668 render_rect(output->wlr_output, damage, &box, color); 673 render_rect(output->wlr_output, damage, &box, color);
@@ -672,28 +677,18 @@ static void render_tab(struct sway_output *output, pixman_region32_t *damage,
672 * output_scale; 677 * output_scale;
673 render_rect(output->wlr_output, damage, &box, color); 678 render_rect(output->wlr_output, damage, &box, color);
674 679
675 // Title background - left border 680 // Title background - left of text
676 box.x = x; 681 box.x = x + 1;
677 box.y = parent->y + 1; 682 box.y = parent->y + config->border_thickness;
678 box.width = config->border_thickness;
679 box.height = config->border_thickness * 2
680 + config->font_height - 1 - !is_first;
681 scale_box(&box, output_scale);
682 render_rect(output->wlr_output, damage, &box, color);
683
684 // Title background - right border
685 box.x = x + tab_width - config->border_thickness;
686 box.y = parent->y + 1;
687 box.width = config->border_thickness; 683 box.width = config->border_thickness;
688 box.height = config->border_thickness * 2 684 box.height = config->font_height;
689 + config->font_height - 1 - !is_last;
690 scale_box(&box, output_scale); 685 scale_box(&box, output_scale);
691 render_rect(output->wlr_output, damage, &box, color); 686 render_rect(output->wlr_output, damage, &box, color);
692 687
693 // Title background - right of text 688 // Title background - right of text
694 box.x = (x + config->border_thickness) * output_scale + title_width; 689 box.x = (x + 1 + config->border_thickness) * output_scale + title_width;
695 box.y = (parent->y + config->border_thickness) * output_scale; 690 box.y = (parent->y + config->border_thickness) * output_scale;
696 box.width = (tab_width - config->border_thickness * 2) * output_scale 691 box.width = (tab_width - config->border_thickness - 2) * output_scale
697 - title_width; 692 - title_width;
698 box.height = config->font_height * output_scale; 693 box.height = config->font_height * output_scale;
699 render_rect(output->wlr_output, damage, &box, color); 694 render_rect(output->wlr_output, damage, &box, color);