]> git.sur5r.net Git - i3/i3/blobdiff - src/x.c
Remove title indentation in nested containers. (#2330)
[i3/i3] / src / x.c
diff --git a/src/x.c b/src/x.c
index bef0e22ac14a4a1b1fce598d42becabcc274007d..ed23431c59f475d4bfe9cb342ba2a2e0cd4335d1 100644 (file)
--- a/src/x.c
+++ b/src/x.c
  */
 #include "all.h"
 
+#ifndef MAX
+#define MAX(x, y) ((x) > (y) ? (x) : (y))
+#endif
+
 xcb_window_t ewmh_window;
 
 /* Stores the X11 window ID of the currently focused window */
@@ -323,13 +327,20 @@ static void x_draw_decoration_after_title(Con *con, struct deco_render_params *p
     assert(con->parent != NULL);
 
     Rect *dr = &(con->deco_rect);
-    Rect br = con_border_style_rect(con);
 
     /* Redraw the right border to cut off any text that went past it.
      * This is necessary when the text was drawn using XCB since cutting text off
      * automatically does not work there. For pango rendering, this isn't necessary. */
-    draw_util_rectangle(conn, &(con->parent->frame_buffer), p->color->background,
-                        dr->x + dr->width + br.width, dr->y, -br.width, dr->height);
+    if (!font_is_pango()) {
+        /* We actually only redraw the far right two pixels as that is the
+         * distance we keep from the edge (not the entire border width).
+         * Redrawing the entire border would cause text to be cut off. */
+        draw_util_rectangle(conn, &(con->parent->frame_buffer), p->color->background,
+                            dr->x + dr->width - 2 * logical_px(1),
+                            dr->y,
+                            2 * logical_px(1),
+                            dr->height);
+    }
 
     /* Draw a 1px separator line before and after every tab, so that tabs can
      * be easily distinguished. */
@@ -464,24 +475,22 @@ void x_draw_decoration(Con *con) {
          * rectangle because some childs are not freely resizable and we want
          * their background color to "shine through". */
         if (!(borders_to_hide & ADJ_LEFT_SCREEN_EDGE)) {
-            draw_util_rectangle(conn, &(con->frame_buffer), p->color->decoration_border, 0, 0, br.x, r->height);
+            draw_util_rectangle(conn, &(con->frame_buffer), p->color->child_border, 0, 0, br.x, r->height);
         }
         if (!(borders_to_hide & ADJ_RIGHT_SCREEN_EDGE)) {
             draw_util_rectangle(conn, &(con->frame_buffer),
-                                p->color->decoration_border, r->width + (br.width + br.x), 0,
+                                p->color->child_border, r->width + (br.width + br.x), 0,
                                 -(br.width + br.x), r->height);
         }
         if (!(borders_to_hide & ADJ_LOWER_SCREEN_EDGE)) {
             draw_util_rectangle(conn, &(con->frame_buffer),
-                                p->color->decoration_border, br.x, r->height + (br.height +
-                                                                                br.y),
+                                p->color->child_border, br.x, r->height + (br.height + br.y),
                                 r->width + br.width, -(br.height + br.y));
         }
         /* pixel border needs an additional line at the top */
         if (p->border_style == BS_PIXEL && !(borders_to_hide & ADJ_UPPER_SCREEN_EDGE)) {
             draw_util_rectangle(conn, &(con->frame_buffer),
-                                p->color->decoration_border, br.x, 0, r->width + br.width,
-                                br.y);
+                                p->color->child_border, br.x, 0, r->width + br.width, br.y);
         }
 
         /* Highlight the side of the border at which the next window will be
@@ -531,20 +540,24 @@ void x_draw_decoration(Con *con) {
 
     struct Window *win = con->window;
     if (win == NULL) {
-        /* we have a split container which gets a representation
-         * of its children as title
-         */
-        char *_title;
-        char *tree = con_get_tree_representation(con);
-        sasprintf(&_title, "i3: %s", tree);
-        free(tree);
-
-        i3String *title = i3string_from_utf8(_title);
+        i3String *title;
+        if (con->title_format == NULL) {
+            char *_title;
+            char *tree = con_get_tree_representation(con);
+            sasprintf(&_title, "i3: %s", tree);
+            free(tree);
+
+            title = i3string_from_utf8(_title);
+            FREE(_title);
+        } else {
+            title = con_parse_title_format(con);
+        }
+
         draw_util_text(title, &(parent->frame_buffer),
                        p->color->text, p->color->background,
-                       con->deco_rect.x + 2, con->deco_rect.y + text_offset_y,
-                       con->deco_rect.width - 2);
-        FREE(_title);
+                       con->deco_rect.x + logical_px(2),
+                       con->deco_rect.y + text_offset_y,
+                       con->deco_rect.width - 2 * logical_px(2));
         I3STRING_FREE(title);
 
         goto after_title;
@@ -553,23 +566,6 @@ void x_draw_decoration(Con *con) {
     if (win->name == NULL)
         goto copy_pixmaps;
 
-    int indent_level = 0,
-        indent_mult = 0;
-    Con *il_parent = parent;
-    if (il_parent->layout != L_STACKED) {
-        while (1) {
-            //DLOG("il_parent = %p, layout = %d\n", il_parent, il_parent->layout);
-            if (il_parent->layout == L_STACKED)
-                indent_level++;
-            if (il_parent->type == CT_WORKSPACE || il_parent->type == CT_DOCKAREA || il_parent->type == CT_OUTPUT)
-                break;
-            il_parent = il_parent->parent;
-            indent_mult++;
-        }
-    }
-    //DLOG("indent_level = %d, indent_mult = %d\n", indent_level, indent_mult);
-    int indent_px = (indent_level * 5) * indent_mult;
-
     int mark_width = 0;
     if (config.show_marks && !TAILQ_EMPTY(&(con->marks_head))) {
         char *formatted_mark = sstrdup("");
@@ -602,12 +598,13 @@ void x_draw_decoration(Con *con) {
         FREE(formatted_mark);
     }
 
-    i3String *title = win->title_format == NULL ? win->name : window_parse_title_format(win);
+    i3String *title = con->title_format == NULL ? win->name : con_parse_title_format(con);
     draw_util_text(title, &(parent->frame_buffer),
                    p->color->text, p->color->background,
-                   con->deco_rect.x + logical_px(2) + indent_px, con->deco_rect.y + text_offset_y,
-                   con->deco_rect.width - logical_px(2) - indent_px - mark_width - logical_px(2));
-    if (win->title_format != NULL)
+                   con->deco_rect.x + logical_px(2),
+                   con->deco_rect.y + text_offset_y,
+                   con->deco_rect.width - mark_width - 2 * logical_px(2));
+    if (con->title_format != NULL)
         I3STRING_FREE(title);
 
 after_title:
@@ -1077,6 +1074,8 @@ void x_push_changes(Con *con) {
                 xcb_warp_pointer(conn, XCB_NONE, root, 0, 0, 0, 0, mid_x, mid_y);
                 xcb_change_window_attributes(conn, root, XCB_CW_EVENT_MASK, (uint32_t[]){ROOT_EVENT_MASK});
             }
+
+            free(pointerreply);
         }
         warp_to = NULL;
     }