Don't draw borders wider than actual width

Rectangles passed to function xcb_poly_fill_rectangle are of type
xcb_rectangle_t and defined as:

    struct xcb_rectangle_t {
        int16_t  x;
        int16_t  y;
        uint16_t width;
        uint16_t height;
    }

The rectangles for the right and lower border had a width and height,
respectively, greater than the actual border width.

Furthermore, offset the bottom border to not overlap with the right one
and, for the top border, use r->width instead of con->rect.width as with
the other borders.
This commit is contained in:
Mats 2014-09-25 19:45:15 +02:00 committed by Michael Stapelberg
parent fd8a2b0e51
commit 7fe55090ec
1 changed files with 5 additions and 5 deletions

10
src/x.c
View File

@ -430,16 +430,16 @@ void x_draw_decoration(Con *con) {
xcb_poly_fill_rectangle(conn, con->pixmap, con->pm_gc, 1, &leftline); xcb_poly_fill_rectangle(conn, con->pixmap, con->pm_gc, 1, &leftline);
} }
if (!(borders_to_hide & ADJ_RIGHT_SCREEN_EDGE)) { if (!(borders_to_hide & ADJ_RIGHT_SCREEN_EDGE)) {
xcb_rectangle_t rightline = {r->width + br.width + br.x, 0, r->width, r->height}; xcb_rectangle_t rightline = {r->width + (br.width + br.x), 0, -(br.width + br.x), r->height};
xcb_poly_fill_rectangle(conn, con->pixmap, con->pm_gc, 1, &rightline); xcb_poly_fill_rectangle(conn, con->pixmap, con->pm_gc, 1, &rightline);
} }
if (!(borders_to_hide & ADJ_LOWER_SCREEN_EDGE)) { if (!(borders_to_hide & ADJ_LOWER_SCREEN_EDGE)) {
xcb_rectangle_t bottomline = {0, r->height + br.height + br.y, r->width, r->height}; xcb_rectangle_t bottomline = {br.x, r->height + (br.height + br.y), r->width + br.width, -(br.height + br.y)};
xcb_poly_fill_rectangle(conn, con->pixmap, con->pm_gc, 1, &bottomline); xcb_poly_fill_rectangle(conn, con->pixmap, con->pm_gc, 1, &bottomline);
} }
/* 1pixel border needs an additional line at the top */ /* 1pixel border needs an additional line at the top */
if (p->border_style == BS_PIXEL && !(borders_to_hide & ADJ_UPPER_SCREEN_EDGE)) { if (p->border_style == BS_PIXEL && !(borders_to_hide & ADJ_UPPER_SCREEN_EDGE)) {
xcb_rectangle_t topline = {br.x, 0, con->rect.width + br.width + br.x, br.y}; xcb_rectangle_t topline = {br.x, 0, r->width + br.width, br.y};
xcb_poly_fill_rectangle(conn, con->pixmap, con->pm_gc, 1, &topline); xcb_poly_fill_rectangle(conn, con->pixmap, con->pm_gc, 1, &topline);
} }
@ -453,10 +453,10 @@ void x_draw_decoration(Con *con) {
xcb_change_gc(conn, con->pm_gc, XCB_GC_FOREGROUND, (uint32_t[]) {p->color->indicator}); xcb_change_gc(conn, con->pm_gc, XCB_GC_FOREGROUND, (uint32_t[]) {p->color->indicator});
if (p->parent_layout == L_SPLITH) if (p->parent_layout == L_SPLITH)
xcb_poly_fill_rectangle(conn, con->pixmap, con->pm_gc, 1, (xcb_rectangle_t[]) { xcb_poly_fill_rectangle(conn, con->pixmap, con->pm_gc, 1, (xcb_rectangle_t[]) {
{r->width + br.width + br.x, br.y, r->width, r->height + br.height}}); {r->width + (br.width + br.x), br.y, -(br.width + br.x), r->height + br.height}});
else if (p->parent_layout == L_SPLITV) else if (p->parent_layout == L_SPLITV)
xcb_poly_fill_rectangle(conn, con->pixmap, con->pm_gc, 1, (xcb_rectangle_t[]) { xcb_poly_fill_rectangle(conn, con->pixmap, con->pm_gc, 1, (xcb_rectangle_t[]) {
{br.x, r->height + br.height + br.y, r->width - (2 * br.x), r->height}}); {br.x, r->height + (br.height + br.y), r->width + br.width, -(br.height + br.y)}});
} }
} }