]> git.sur5r.net Git - i3/i3/commitdiff
Support for custom bg colors for clients.
authorFernando Tarlá Cardoso Lemos <fernandotcl@gmail.com>
Sun, 12 Sep 2010 05:54:55 +0000 (02:54 -0300)
committerMichael Stapelberg <michael@stapelberg.de>
Fri, 24 Sep 2010 13:46:57 +0000 (15:46 +0200)
include/config.h
src/cfgparse.l
src/cfgparse.y
src/config.c
src/handlers.c
src/layout.c

index 0c790bf2fed3bf8bc47e49ff38bda1939248a3ac..a8c42fba7cd59d996e6f35eed38735a469189908 100644 (file)
@@ -112,6 +112,7 @@ struct Config {
 
         /* Color codes are stored here */
         struct config_client {
+                uint32_t background;
                 struct Colortriple focused;
                 struct Colortriple focused_inactive;
                 struct Colortriple unfocused;
index 10a13076c9f0a64349dac937ac354d27e344da23..0c0cee708b4d01cf0f880b1c27d8a78c6777bc88 100644 (file)
@@ -101,6 +101,7 @@ stack-limit                     { return TOKSTACKLIMIT; }
 cols                            { yylval.number = STACK_LIMIT_COLS; return TOKSTACKLIMIT; }
 rows                            { yylval.number = STACK_LIMIT_ROWS; return TOKSTACKLIMIT; }
 exec                            { BEGIN(BIND_AWS_COND); return TOKEXEC; }
+client.background               { BEGIN(COLOR_COND); yylval.single_color = &config.client.background; return TOKSINGLECOLOR; }
 client.focused                  { BEGIN(COLOR_COND); yylval.color = &config.client.focused; return TOKCOLOR; }
 client.focused_inactive         { BEGIN(COLOR_COND); yylval.color = &config.client.focused_inactive; return TOKCOLOR; }
 client.unfocused                { BEGIN(COLOR_COND); yylval.color = &config.client.unfocused; return TOKCOLOR; }
index 3ba788a953ae6d79cd353382379ccc983d7507f7..58ff6e9caf6e4c16f9d1655be4536354137f6388 100644 (file)
@@ -197,6 +197,7 @@ void parse_file(const char *f) {
 %union {
         int number;
         char *string;
+        uint32_t *single_color;
         struct Colortriple *color;
         struct Assignment *assignment;
         struct Binding *binding;
@@ -225,6 +226,7 @@ void parse_file(const char *f) {
 %token TOKSET
 %token TOKIPCSOCKET "ipc_socket"
 %token TOKEXEC "exec"
+%token TOKSINGLECOLOR
 %token TOKCOLOR
 %token TOKARROW "→"
 %token TOKMODE "mode"
@@ -255,6 +257,7 @@ line:
         | assign
         | ipcsocket
         | exec
+        | single_color
         | color
         | terminal
         | font
@@ -573,6 +576,13 @@ font:
         }
         ;
 
+single_color:
+        TOKSINGLECOLOR WHITESPACE colorpixel
+        {
+                uint32_t *dest = $<single_color>1;
+                *dest = $<number>3;
+        }
+        ;
 
 color:
         TOKCOLOR WHITESPACE colorpixel WHITESPACE colorpixel WHITESPACE colorpixel
index 6c80b7f2eb9f4b843fdffbeb9b12a007c25fa3a4..488b5fde3391c608f26c278b7a503da88a28de2c 100644 (file)
@@ -367,6 +367,7 @@ void load_configuration(xcb_connection_t *conn, const char *override_configpath,
                 x.text = get_colorpixel(conn, ctext); \
         } while (0)
 
+        config.client.background = get_colorpixel(conn, "#000000");
         INIT_COLOR(config.client.focused, "#4c7899", "#285577", "#ffffff");
         INIT_COLOR(config.client.focused_inactive, "#333333", "#5f676a", "#ffffff");
         INIT_COLOR(config.client.unfocused, "#333333", "#222222", "#888888");
index 31eeced62f0ea3b8cabaf69490312f4a0dabe555..d531b951fd5143bd223f7012ef5197a241369722 100644 (file)
@@ -817,8 +817,8 @@ int handle_expose_event(void *data, xcb_connection_t *conn, xcb_expose_event_t *
                                         {client->rect.width-1, 0}};                       /* right upper edge */
                 xcb_poly_line(conn, XCB_COORD_MODE_ORIGIN, client->frame, client->titlegc, 4, points);
 
-                /* Draw a black background */
-                xcb_change_gc_single(conn, client->titlegc, XCB_GC_FOREGROUND, get_colorpixel(conn, "#000000"));
+                /* Draw the background */
+                xcb_change_gc_single(conn, client->titlegc, XCB_GC_FOREGROUND, config.client.background);
                 if (client->titlebar_position == TITLEBAR_OFF && !client->borderless) {
                         xcb_rectangle_t crect = {1, 0, client->rect.width - (1 + 1), client->rect.height - 1};
                         xcb_poly_fill_rectangle(conn, client->frame, client->titlegc, 1, &crect);
index 3c7d2ff4dfc37e474b29d2ee36ef0276ef639cb7..012042541c9b85f3b53c13824943928ba7d42eea 100644 (file)
@@ -135,7 +135,7 @@ void decorate_window(xcb_connection_t *conn, Client *client, xcb_drawable_t draw
 
         /* Draw a rectangle in background color around the window */
         if (client->borderless && mode == MODE_DEFAULT)
-                xcb_change_gc_single(conn, gc, XCB_GC_FOREGROUND, get_colorpixel(conn, "#000000"));
+                xcb_change_gc_single(conn, gc, XCB_GC_FOREGROUND, config.client.background);
         else xcb_change_gc_single(conn, gc, XCB_GC_FOREGROUND, color->background);
 
         /* In stacking mode, we only render the rect for this specific decoration */
@@ -151,9 +151,9 @@ void decorate_window(xcb_connection_t *conn, Client *client, xcb_drawable_t draw
                 xcb_rectangle_t rect = {0, 0, client->rect.width, client->rect.height};
                 xcb_poly_fill_rectangle(conn, drawable, gc, 1, &rect);
 
-                /* Draw the inner background to have a black frame around clients (such as mplayer)
+                /* Draw the inner background to a frame around clients (such as mplayer)
                    which cannot be resized exactly in our frames and therefore are centered */
-                xcb_change_gc_single(conn, client->titlegc, XCB_GC_FOREGROUND, get_colorpixel(conn, "#000000"));
+                xcb_change_gc_single(conn, client->titlegc, XCB_GC_FOREGROUND, config.client.background);
                 if (client->titlebar_position == TITLEBAR_OFF && client->borderless) {
                         xcb_rectangle_t crect = {0, 0, client->rect.width, client->rect.height};
                         xcb_poly_fill_rectangle(conn, client->frame, client->titlegc, 1, &crect);
@@ -547,7 +547,7 @@ void render_container(xcb_connection_t *conn, Container *container) {
                  * amount of windows */
                 if (container->mode == MODE_STACK) {
                         if (container->stack_limit == STACK_LIMIT_COLS && (current_col % 2) != 0) {
-                                xcb_change_gc_single(conn, stack_win->pixmap.gc, XCB_GC_FOREGROUND, get_colorpixel(conn, "#000000"));
+                                xcb_change_gc_single(conn, stack_win->pixmap.gc, XCB_GC_FOREGROUND, config.client.background);
 
                                 int offset_x = current_col * (stack_win->rect.width / container->stack_limit_value);
                                 int offset_y = current_row * decoration_height;
@@ -556,7 +556,7 @@ void render_container(xcb_connection_t *conn, Container *container) {
                                                         offset_y + decoration_height };
                                 xcb_poly_fill_rectangle(conn, stack_win->pixmap.id, stack_win->pixmap.gc, 1, &rect);
                         } else if (container->stack_limit == STACK_LIMIT_ROWS && (current_row % 2) != 0) {
-                                xcb_change_gc_single(conn, stack_win->pixmap.gc, XCB_GC_FOREGROUND, get_colorpixel(conn, "#000000"));
+                                xcb_change_gc_single(conn, stack_win->pixmap.gc, XCB_GC_FOREGROUND, config.client.background);
 
                                 int offset_x = current_col * wrap;
                                 int offset_y = current_row * decoration_height;