From ccd6ae8eaff5c827d85dcc80ec944e8d079fb565 Mon Sep 17 00:00:00 2001 From: shdown Date: Sat, 21 Mar 2015 19:08:40 +0300 Subject: [PATCH] i3bar: cut long statuslines from the left This draws the statusline after drawing (and calculating width of) the workspace buttons and fixes calculation of its maximum visible width. This (hopefully) guarantees that these two will never overlap. --- i3bar/src/xcb.c | 60 ++++++++++++++++++++++++++----------------------- 1 file changed, 32 insertions(+), 28 deletions(-) diff --git a/i3bar/src/xcb.c b/i3bar/src/xcb.c index 79e9ad9c..aa24fc22 100644 --- a/i3bar/src/xcb.c +++ b/i3bar/src/xcb.c @@ -1763,34 +1763,6 @@ void draw_bars(bool unhide) { 1, &rect); - if (!TAILQ_EMPTY(&statusline_head)) { - DLOG("Printing statusline!\n"); - - /* Luckily we already prepared a seperate pixmap containing the rendered - * statusline, we just have to copy the relevant parts to the relevant - * position */ - trayclient *trayclient; - int traypx = 0; - TAILQ_FOREACH(trayclient, outputs_walk->trayclients, tailq) { - if (!trayclient->mapped) - continue; - /* We assume the tray icons are quadratic (we use the font - * *height* as *width* of the icons) because we configured them - * like this. */ - traypx += font.height + logical_px(2); - } - /* Add 2px of padding if there are any tray icons */ - if (traypx > 0) - traypx += logical_px(2); - xcb_copy_area(xcb_connection, - statusline_pm, - outputs_walk->buffer, - outputs_walk->bargc, - MAX(0, (int16_t)(statusline_width - outputs_walk->rect.w + logical_px(4))), 0, - MAX(0, (int16_t)(outputs_walk->rect.w - statusline_width - traypx - logical_px(4))), 0, - MIN(outputs_walk->rect.w - traypx - logical_px(4), (int)statusline_width), bar_height); - } - if (!config.disable_ws) { i3_ws *ws_walk; TAILQ_FOREACH(ws_walk, outputs_walk->workspaces, tailq) { @@ -1888,6 +1860,38 @@ void draw_bars(bool unhide) { unhide = true; } + if (!TAILQ_EMPTY(&statusline_head)) { + DLOG("Printing statusline!\n"); + + /* Luckily we already prepared a seperate pixmap containing the rendered + * statusline, we just have to copy the relevant parts to the relevant + * position */ + trayclient *trayclient; + int traypx = 0; + TAILQ_FOREACH(trayclient, outputs_walk->trayclients, tailq) { + if (!trayclient->mapped) + continue; + /* We assume the tray icons are quadratic (we use the font + * *height* as *width* of the icons) because we configured them + * like this. */ + traypx += font.height + logical_px(2); + } + /* Add 2px of padding if there are any tray icons */ + if (traypx > 0) + traypx += logical_px(2); + + int edge_offset = logical_px(4); + int visible_statusline_width = MIN(statusline_width, outputs_walk->rect.w - i - traypx - 2*edge_offset); + + xcb_copy_area(xcb_connection, + statusline_pm, + outputs_walk->buffer, + outputs_walk->bargc, + (int16_t)(statusline_width - visible_statusline_width), 0, + (int16_t)(outputs_walk->rect.w - traypx - edge_offset - visible_statusline_width), 0, + (int16_t)visible_statusline_width, (int16_t)bar_height); + } + i = 0; } -- 2.39.5