Fix tab border issues

master
Ryan Dwyer 7 years ago
parent 4672cb7ccf
commit 5ab4930185

@ -709,37 +709,39 @@ static void render_tab_content(struct sway_output *output,
float output_scale = output->wlr_output->scale; float output_scale = output->wlr_output->scale;
float color[4]; float color[4];
if (view->border_left) { if (view->border != B_NONE) {
memcpy(&color, colors->child_border, sizeof(float) * 4); if (view->border_left) {
color[3] *= con->alpha; memcpy(&color, colors->child_border, sizeof(float) * 4);
box.x = con->x; color[3] *= con->alpha;
box.y = con->y + config->border_thickness * 2 + config->font_height; box.x = con->x;
box.width = view->border_thickness; box.y = con->y + config->border_thickness * 2 + config->font_height;
box.height = view->height; box.width = view->border_thickness;
scale_box(&box, output_scale); box.height = view->height;
render_rect(output->wlr_output, damage, &box, color); scale_box(&box, output_scale);
} render_rect(output->wlr_output, damage, &box, color);
}
if (view->border_right) { if (view->border_right) {
memcpy(&color, colors->child_border, sizeof(float) * 4); memcpy(&color, colors->child_border, sizeof(float) * 4);
color[3] *= con->alpha; color[3] *= con->alpha;
box.x = view->x + view->width; box.x = view->x + view->width;
box.y = con->y + config->border_thickness * 2 + config->font_height; box.y = con->y + config->border_thickness * 2 + config->font_height;
box.width = view->border_thickness; box.width = view->border_thickness;
box.height = view->height; box.height = view->height;
scale_box(&box, output_scale); scale_box(&box, output_scale);
render_rect(output->wlr_output, damage, &box, color); render_rect(output->wlr_output, damage, &box, color);
} }
if (view->border_bottom) { if (view->border_bottom) {
memcpy(&color, colors->child_border, sizeof(float) * 4); memcpy(&color, colors->child_border, sizeof(float) * 4);
color[3] *= con->alpha; color[3] *= con->alpha;
box.x = con->x; box.x = con->x;
box.y = view->y + view->height; box.y = view->y + view->height;
box.width = con->width; box.width = con->width;
box.height = view->border_thickness; box.height = view->border_thickness;
scale_box(&box, output_scale); scale_box(&box, output_scale);
render_rect(output->wlr_output, damage, &box, color); render_rect(output->wlr_output, damage, &box, color);
}
} }
} }

@ -167,32 +167,53 @@ void view_autoconfigure(struct sway_view *view) {
double x, y, width, height; double x, y, width, height;
x = y = width = height = 0; x = y = width = height = 0;
double y_offset = 0;
// In a tabbed or stacked container, the swayc's y is the top of the title
// area. We have to offset the surface y by the height of the title bar, and
// disable any top border because we'll always have the title bar.
if (view->swayc->parent->layout == L_TABBED) {
y_offset = config->border_thickness * 2 + config->font_height;
view->border_top = 0;
} else if (view->swayc->parent->layout == L_STACKED) {
y_offset = config->border_thickness * 2 + config->font_height;
y_offset *= view->swayc->parent->children->length;
view->border_top = 0;
}
switch (view->border) { switch (view->border) {
case B_NONE: case B_NONE:
x = view->swayc->x; x = view->swayc->x;
y = view->swayc->y; y = view->swayc->y + y_offset;
width = view->swayc->width; width = view->swayc->width;
height = view->swayc->height; height = view->swayc->height - y_offset;
break; break;
case B_PIXEL: case B_PIXEL:
x = view->swayc->x + view->border_thickness * view->border_left; x = view->swayc->x + view->border_thickness * view->border_left;
y = view->swayc->y + view->border_thickness * view->border_top; y = view->swayc->y + view->border_thickness * view->border_top + y_offset;
width = view->swayc->width width = view->swayc->width
- view->border_thickness * view->border_left - view->border_thickness * view->border_left
- view->border_thickness * view->border_right; - view->border_thickness * view->border_right;
height = view->swayc->height height = view->swayc->height - y_offset
- view->border_thickness * view->border_top - view->border_thickness * view->border_top
- view->border_thickness * view->border_bottom; - view->border_thickness * view->border_bottom;
break; break;
case B_NORMAL: case B_NORMAL:
// Height is: border + title height + border + view height + border // Height is: border + title height + border + view height + border
x = view->swayc->x + view->border_thickness * view->border_left; x = view->swayc->x + view->border_thickness * view->border_left;
y = view->swayc->y + config->font_height + view->border_thickness * 2;
width = view->swayc->width width = view->swayc->width
- view->border_thickness * view->border_left - view->border_thickness * view->border_left
- view->border_thickness * view->border_right; - view->border_thickness * view->border_right;
height = view->swayc->height - config->font_height if (y_offset) {
- view->border_thickness * (2 + view->border_bottom); y = view->swayc->y + y_offset;
height = view->swayc->height - y_offset
- view->border_thickness * view->border_bottom;
} else {
y = view->swayc->y + config->font_height + view->border_thickness * 2
+ y_offset;
height = view->swayc->height - config->font_height
- view->border_thickness * (2 + view->border_bottom);
}
break; break;
} }

Loading…
Cancel
Save