]> git.sur5r.net Git - i3/i3/commitdiff
Merge pull request #2143 from Airblader/feature-2120
authorMichael Stapelberg <stapelberg@users.noreply.github.com>
Tue, 5 Jan 2016 21:32:15 +0000 (22:32 +0100)
committerMichael Stapelberg <stapelberg@users.noreply.github.com>
Tue, 5 Jan 2016 21:32:15 +0000 (22:32 +0100)
Allow title_format for all containers

1  2 
docs/userguide
src/x.c

diff --combined docs/userguide
index 9bcabaa75f7f5d66349f54147040f22d541a21ad,05e10da45bd2f230e907e0cdf68161b67c914835..e8dee1037fdfcb0db474c63e2a47a12211fa1f47
@@@ -836,9 -836,9 +836,9 @@@ workspace "2: vim" output VGA
  You can change all colors which i3 uses to draw the window decorations.
  
  *Syntax*:
 -------------------------------------------------------
 -<colorclass> <border> <background> <text> <indicator>
 -------------------------------------------------------
 +-------------------------------------------------------------------------
 +<colorclass> <border> <background> <text> <indicator> <decoration_border>
 +-------------------------------------------------------------------------
  
  Where colorclass can be one of:
  
@@@ -864,19 -864,19 +864,19 @@@ Colors are in HTML hex format (#rrggbb)
  
  *Examples (default colors)*:
  ---------------------------------------------------------
 -# class                 border  backgr. text    indicator
 -client.focused          #4c7899 #285577 #ffffff #2e9ef4
 -client.focused_inactive #333333 #5f676a #ffffff #484e50
 -client.unfocused        #333333 #222222 #888888 #292d2e
 -client.urgent           #2f343a #900000 #ffffff #900000
 -client.placeholder      #000000 #0c0c0c #ffffff #000000
 +# class                 border  backgr. text    indicator decoration_border
 +client.focused          #4c7899 #285577 #ffffff #2e9ef4   #285577
 +client.focused_inactive #333333 #5f676a #ffffff #484e50   #5f676a
 +client.unfocused        #333333 #222222 #888888 #292d2e   #222222
 +client.urgent           #2f343a #900000 #ffffff #900000   #900000
 +client.placeholder      #000000 #0c0c0c #ffffff #000000   #0c0c0c
  
  client.background       #ffffff
  ---------------------------------------------------------
  
  Note that for the window decorations, the color around the child window is the
 -background color, and the border color is only the two thin lines at the top of
 -the window.
 +"decoration_border", and "border" color is only the two thin lines around the
 +titlebar.
  
  The indicator color is used for indicating where a new window will be opened.
  For horizontal split containers, the right border will be painted in indicator
@@@ -2215,7 -2215,10 +2215,10 @@@ https://developer.gnome.org/pango/stabl
  and the following placeholders which will be replaced:
  
  +%title+::
-     The X11 window title (_NET_WM_NAME or WM_NAME as fallback).
+     For normal windows, this is the X11 window title (_NET_WM_NAME or WM_NAME
+     as fallback). When used on containers without a window (e.g., a split
+     container inside a tabbed/stacked layout), this will be the tree
+     representation of the container (e.g., "H[xterm xterm]").
  +%class+::
      The X11 window class (second part of WM_CLASS). This corresponds to the
      +class+ criterion, see <<command_criteria>>.
diff --combined src/x.c
index bef0e22ac14a4a1b1fce598d42becabcc274007d,c4cae1707e2978d4af938e9e1d6da3600adf7124..a5aca55b41dcf22cb73143d527a13924fcee2106
+++ b/src/x.c
@@@ -299,7 -299,7 +299,7 @@@ void x_window_kill(xcb_window_t window
      free(event);
  }
  
 -static void x_draw_decoration_border(Con *con, struct deco_render_params *p) {
 +static void x_draw_title_border(Con *con, struct deco_render_params *p) {
      assert(con->parent != NULL);
  
      Rect *dr = &(con->deco_rect);
@@@ -344,7 -344,7 +344,7 @@@ static void x_draw_decoration_after_tit
      }
  
      /* Redraw the border. */
 -    x_draw_decoration_border(con, p);
 +    x_draw_title_border(con, p);
  }
  
  /*
@@@ -464,24 -464,21 +464,24 @@@ 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->background,
 -                                0, 0, br.x, r->height);
 +            draw_util_rectangle(conn, &(con->frame_buffer), p->color->decoration_border, 0, 0, br.x, r->height);
          }
          if (!(borders_to_hide & ADJ_RIGHT_SCREEN_EDGE)) {
 -            draw_util_rectangle(conn, &(con->frame_buffer), p->color->background,
 -                                r->width + (br.width + br.x), 0, -(br.width + br.x), r->height);
 +            draw_util_rectangle(conn, &(con->frame_buffer),
 +                                p->color->decoration_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->background,
 -                                br.x, r->height + (br.height + br.y), r->width + br.width, -(br.height + br.y));
 +            draw_util_rectangle(conn, &(con->frame_buffer),
 +                                p->color->decoration_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->background,
 -                                br.x, 0, r->width + br.width, br.y);
 +            draw_util_rectangle(conn, &(con->frame_buffer),
 +                                p->color->decoration_border, br.x, 0, r->width + br.width,
 +                                br.y);
          }
  
          /* Highlight the side of the border at which the next window will be
                          con->deco_rect.x, con->deco_rect.y, con->deco_rect.width, con->deco_rect.height);
  
      /* 5: draw two unconnected horizontal lines in border color */
 -    x_draw_decoration_border(con, p);
 +    x_draw_title_border(con, p);
  
      /* 6: draw the title */
      int text_offset_y = (con->deco_rect.height - config.font.height) / 2;
  
      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);
          I3STRING_FREE(title);
  
          goto after_title;
          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)
+     if (con->title_format != NULL)
          I3STRING_FREE(title);
  
  after_title: