]> git.sur5r.net Git - i3/i3/commitdiff
Don't draw borders wider than actual width
authorMats <d912e3@gmail.com>
Thu, 25 Sep 2014 17:45:15 +0000 (19:45 +0200)
committerMichael Stapelberg <michael@stapelberg.de>
Wed, 1 Oct 2014 20:29:43 +0000 (22:29 +0200)
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.

src/x.c

diff --git a/src/x.c b/src/x.c
index ae97ef0dc19ffe54be7582238127dcaddeb8dbf1..6d836a7bd445aeaa4769084b51ada866093d880f 100644 (file)
--- a/src/x.c
+++ b/src/x.c
@@ -430,16 +430,16 @@ void x_draw_decoration(Con *con) {
             xcb_poly_fill_rectangle(conn, con->pixmap, con->pm_gc, 1, &leftline);
         }
         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);
         }
         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);
         }
         /* 1pixel border needs an additional line at the top */
         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);
         }
 
@@ -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});
             if (p->parent_layout == L_SPLITH)
                 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)
                 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)}});
         }
     }