diff options
author | Ryan Dwyer <ryandwyer1@gmail.com> | 2018-05-20 15:34:08 +1000 |
---|---|---|
committer | Ryan Dwyer <ryandwyer1@gmail.com> | 2018-05-21 20:16:56 +1000 |
commit | 5ab4930185d32c5ac1adbf56f7b74525a2bab98d (patch) | |
tree | b81bf4c3de475720770c567639f0d9459a307fe9 | |
parent | Use class or app_id in tree representation (diff) | |
download | sway-5ab4930185d32c5ac1adbf56f7b74525a2bab98d.tar.gz sway-5ab4930185d32c5ac1adbf56f7b74525a2bab98d.tar.zst sway-5ab4930185d32c5ac1adbf56f7b74525a2bab98d.zip |
Fix tab border issues
-rw-r--r-- | sway/desktop/output.c | 60 | ||||
-rw-r--r-- | sway/tree/view.c | 35 |
2 files changed, 59 insertions, 36 deletions
diff --git a/sway/desktop/output.c b/sway/desktop/output.c index 6d5777f3..c052cafb 100644 --- a/sway/desktop/output.c +++ b/sway/desktop/output.c | |||
@@ -709,37 +709,39 @@ static void render_tab_content(struct sway_output *output, | |||
709 | float output_scale = output->wlr_output->scale; | 709 | float output_scale = output->wlr_output->scale; |
710 | float color[4]; | 710 | float color[4]; |
711 | 711 | ||
712 | if (view->border_left) { | 712 | if (view->border != B_NONE) { |
713 | memcpy(&color, colors->child_border, sizeof(float) * 4); | 713 | if (view->border_left) { |
714 | color[3] *= con->alpha; | 714 | memcpy(&color, colors->child_border, sizeof(float) * 4); |
715 | box.x = con->x; | 715 | color[3] *= con->alpha; |
716 | box.y = con->y + config->border_thickness * 2 + config->font_height; | 716 | box.x = con->x; |
717 | box.width = view->border_thickness; | 717 | box.y = con->y + config->border_thickness * 2 + config->font_height; |
718 | box.height = view->height; | 718 | box.width = view->border_thickness; |
719 | scale_box(&box, output_scale); | 719 | box.height = view->height; |
720 | render_rect(output->wlr_output, damage, &box, color); | 720 | scale_box(&box, output_scale); |
721 | } | 721 | render_rect(output->wlr_output, damage, &box, color); |
722 | } | ||
722 | 723 | ||
723 | if (view->border_right) { | 724 | if (view->border_right) { |
724 | memcpy(&color, colors->child_border, sizeof(float) * 4); | 725 | memcpy(&color, colors->child_border, sizeof(float) * 4); |
725 | color[3] *= con->alpha; | 726 | color[3] *= con->alpha; |
726 | box.x = view->x + view->width; | 727 | box.x = view->x + view->width; |
727 | box.y = con->y + config->border_thickness * 2 + config->font_height; | 728 | box.y = con->y + config->border_thickness * 2 + config->font_height; |
728 | box.width = view->border_thickness; | 729 | box.width = view->border_thickness; |
729 | box.height = view->height; | 730 | box.height = view->height; |
730 | scale_box(&box, output_scale); | 731 | scale_box(&box, output_scale); |
731 | render_rect(output->wlr_output, damage, &box, color); | 732 | render_rect(output->wlr_output, damage, &box, color); |
732 | } | 733 | } |
733 | 734 | ||
734 | if (view->border_bottom) { | 735 | if (view->border_bottom) { |
735 | memcpy(&color, colors->child_border, sizeof(float) * 4); | 736 | memcpy(&color, colors->child_border, sizeof(float) * 4); |
736 | color[3] *= con->alpha; | 737 | color[3] *= con->alpha; |
737 | box.x = con->x; | 738 | box.x = con->x; |
738 | box.y = view->y + view->height; | 739 | box.y = view->y + view->height; |
739 | box.width = con->width; | 740 | box.width = con->width; |
740 | box.height = view->border_thickness; | 741 | box.height = view->border_thickness; |
741 | scale_box(&box, output_scale); | 742 | scale_box(&box, output_scale); |
742 | render_rect(output->wlr_output, damage, &box, color); | 743 | render_rect(output->wlr_output, damage, &box, color); |
744 | } | ||
743 | } | 745 | } |
744 | } | 746 | } |
745 | 747 | ||
diff --git a/sway/tree/view.c b/sway/tree/view.c index 51316507..64597c02 100644 --- a/sway/tree/view.c +++ b/sway/tree/view.c | |||
@@ -167,32 +167,53 @@ void view_autoconfigure(struct sway_view *view) { | |||
167 | 167 | ||
168 | double x, y, width, height; | 168 | double x, y, width, height; |
169 | x = y = width = height = 0; | 169 | x = y = width = height = 0; |
170 | double y_offset = 0; | ||
171 | |||
172 | // In a tabbed or stacked container, the swayc's y is the top of the title | ||
173 | // area. We have to offset the surface y by the height of the title bar, and | ||
174 | // disable any top border because we'll always have the title bar. | ||
175 | if (view->swayc->parent->layout == L_TABBED) { | ||
176 | y_offset = config->border_thickness * 2 + config->font_height; | ||
177 | view->border_top = 0; | ||
178 | } else if (view->swayc->parent->layout == L_STACKED) { | ||
179 | y_offset = config->border_thickness * 2 + config->font_height; | ||
180 | y_offset *= view->swayc->parent->children->length; | ||
181 | view->border_top = 0; | ||
182 | } | ||
183 | |||
170 | switch (view->border) { | 184 | switch (view->border) { |
171 | case B_NONE: | 185 | case B_NONE: |
172 | x = view->swayc->x; | 186 | x = view->swayc->x; |
173 | y = view->swayc->y; | 187 | y = view->swayc->y + y_offset; |
174 | width = view->swayc->width; | 188 | width = view->swayc->width; |
175 | height = view->swayc->height; | 189 | height = view->swayc->height - y_offset; |
176 | break; | 190 | break; |
177 | case B_PIXEL: | 191 | case B_PIXEL: |
178 | x = view->swayc->x + view->border_thickness * view->border_left; | 192 | x = view->swayc->x + view->border_thickness * view->border_left; |
179 | y = view->swayc->y + view->border_thickness * view->border_top; | 193 | y = view->swayc->y + view->border_thickness * view->border_top + y_offset; |
180 | width = view->swayc->width | 194 | width = view->swayc->width |
181 | - view->border_thickness * view->border_left | 195 | - view->border_thickness * view->border_left |
182 | - view->border_thickness * view->border_right; | 196 | - view->border_thickness * view->border_right; |
183 | height = view->swayc->height | 197 | height = view->swayc->height - y_offset |
184 | - view->border_thickness * view->border_top | 198 | - view->border_thickness * view->border_top |
185 | - view->border_thickness * view->border_bottom; | 199 | - view->border_thickness * view->border_bottom; |
186 | break; | 200 | break; |
187 | case B_NORMAL: | 201 | case B_NORMAL: |
188 | // Height is: border + title height + border + view height + border | 202 | // Height is: border + title height + border + view height + border |
189 | x = view->swayc->x + view->border_thickness * view->border_left; | 203 | x = view->swayc->x + view->border_thickness * view->border_left; |
190 | y = view->swayc->y + config->font_height + view->border_thickness * 2; | ||
191 | width = view->swayc->width | 204 | width = view->swayc->width |
192 | - view->border_thickness * view->border_left | 205 | - view->border_thickness * view->border_left |
193 | - view->border_thickness * view->border_right; | 206 | - view->border_thickness * view->border_right; |
194 | height = view->swayc->height - config->font_height | 207 | if (y_offset) { |
195 | - view->border_thickness * (2 + view->border_bottom); | 208 | y = view->swayc->y + y_offset; |
209 | height = view->swayc->height - y_offset | ||
210 | - view->border_thickness * view->border_bottom; | ||
211 | } else { | ||
212 | y = view->swayc->y + config->font_height + view->border_thickness * 2 | ||
213 | + y_offset; | ||
214 | height = view->swayc->height - config->font_height | ||
215 | - view->border_thickness * (2 + view->border_bottom); | ||
216 | } | ||
196 | break; | 217 | break; |
197 | } | 218 | } |
198 | 219 | ||