]> git.sur5r.net Git - i3/i3/commitdiff
tabbed: floor(), put extra pixels into the last tab (Thanks xeen)
authorMichael Stapelberg <michael@stapelberg.de>
Sun, 7 Apr 2013 07:58:34 +0000 (09:58 +0200)
committerMichael Stapelberg <michael@stapelberg.de>
Sun, 7 Apr 2013 08:00:28 +0000 (10:00 +0200)
This is the only sane way I can think of to deal with the problem that
the screen size may not be dividable by the amount of tabbed children
(e.g. 1280 / 41 = 31.219512…).

fixes #645
fixes #791

src/render.c

index 16bfc55bb1f17c876b2a9582f181059b8a6cd9c7..6061838a15e0e97d09b3ef8a726f5ff23ef40c1f 100644 (file)
@@ -372,10 +372,16 @@ void render_con(Con *con, bool render_fullscreen) {
             child->rect.width = rect.width;
             child->rect.height = rect.height;
 
-            child->deco_rect.width = ceil((float)child->rect.width / children);
+            child->deco_rect.width = floor((float)child->rect.width / children);
             child->deco_rect.x = x - con->rect.x + i * child->deco_rect.width;
             child->deco_rect.y = y - con->rect.y;
 
+            /* Since the tab width may be something like 31,6 px per tab, we
+             * let the last tab have all the extra space (0,6 * children). */
+            if (i == (children-1)) {
+                child->deco_rect.width += (child->rect.width - (child->deco_rect.x + child->deco_rect.width));
+            }
+
             if (children > 1 || (child->border_style != BS_PIXEL && child->border_style != BS_NONE)) {
                 child->rect.y += deco_height;
                 child->rect.height -= deco_height;