Support for custom bg colors for clients.

This commit is contained in:
Fernando Tarlá Cardoso Lemos 2010-09-12 02:54:55 -03:00 committed by Michael Stapelberg
parent 046105ff58
commit b21d8a94e6
6 changed files with 20 additions and 7 deletions

View 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;

View 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; }

View 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
@ -577,6 +580,13 @@ font:
}
;
single_color:
TOKSINGLECOLOR WHITESPACE colorpixel
{
uint32_t *dest = $<single_color>1;
*dest = $<number>3;
}
;
color:
TOKCOLOR WHITESPACE colorpixel WHITESPACE colorpixel WHITESPACE colorpixel

View File

@ -371,6 +371,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");

View 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);

View 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;