Support for custom bg colors for clients.
This commit is contained in:
parent
046105ff58
commit
b21d8a94e6
|
@ -112,6 +112,7 @@ struct Config {
|
||||||
|
|
||||||
/* Color codes are stored here */
|
/* Color codes are stored here */
|
||||||
struct config_client {
|
struct config_client {
|
||||||
|
uint32_t background;
|
||||||
struct Colortriple focused;
|
struct Colortriple focused;
|
||||||
struct Colortriple focused_inactive;
|
struct Colortriple focused_inactive;
|
||||||
struct Colortriple unfocused;
|
struct Colortriple unfocused;
|
||||||
|
|
|
@ -101,6 +101,7 @@ stack-limit { return TOKSTACKLIMIT; }
|
||||||
cols { yylval.number = STACK_LIMIT_COLS; return TOKSTACKLIMIT; }
|
cols { yylval.number = STACK_LIMIT_COLS; return TOKSTACKLIMIT; }
|
||||||
rows { yylval.number = STACK_LIMIT_ROWS; return TOKSTACKLIMIT; }
|
rows { yylval.number = STACK_LIMIT_ROWS; return TOKSTACKLIMIT; }
|
||||||
exec { BEGIN(BIND_AWS_COND); return TOKEXEC; }
|
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 { 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.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; }
|
client.unfocused { BEGIN(COLOR_COND); yylval.color = &config.client.unfocused; return TOKCOLOR; }
|
||||||
|
|
|
@ -197,6 +197,7 @@ void parse_file(const char *f) {
|
||||||
%union {
|
%union {
|
||||||
int number;
|
int number;
|
||||||
char *string;
|
char *string;
|
||||||
|
uint32_t *single_color;
|
||||||
struct Colortriple *color;
|
struct Colortriple *color;
|
||||||
struct Assignment *assignment;
|
struct Assignment *assignment;
|
||||||
struct Binding *binding;
|
struct Binding *binding;
|
||||||
|
@ -225,6 +226,7 @@ void parse_file(const char *f) {
|
||||||
%token TOKSET
|
%token TOKSET
|
||||||
%token TOKIPCSOCKET "ipc_socket"
|
%token TOKIPCSOCKET "ipc_socket"
|
||||||
%token TOKEXEC "exec"
|
%token TOKEXEC "exec"
|
||||||
|
%token TOKSINGLECOLOR
|
||||||
%token TOKCOLOR
|
%token TOKCOLOR
|
||||||
%token TOKARROW "→"
|
%token TOKARROW "→"
|
||||||
%token TOKMODE "mode"
|
%token TOKMODE "mode"
|
||||||
|
@ -255,6 +257,7 @@ line:
|
||||||
| assign
|
| assign
|
||||||
| ipcsocket
|
| ipcsocket
|
||||||
| exec
|
| exec
|
||||||
|
| single_color
|
||||||
| color
|
| color
|
||||||
| terminal
|
| terminal
|
||||||
| font
|
| font
|
||||||
|
@ -577,6 +580,13 @@ font:
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
|
single_color:
|
||||||
|
TOKSINGLECOLOR WHITESPACE colorpixel
|
||||||
|
{
|
||||||
|
uint32_t *dest = $<single_color>1;
|
||||||
|
*dest = $<number>3;
|
||||||
|
}
|
||||||
|
;
|
||||||
|
|
||||||
color:
|
color:
|
||||||
TOKCOLOR WHITESPACE colorpixel WHITESPACE colorpixel WHITESPACE colorpixel
|
TOKCOLOR WHITESPACE colorpixel WHITESPACE colorpixel WHITESPACE colorpixel
|
||||||
|
|
|
@ -371,6 +371,7 @@ void load_configuration(xcb_connection_t *conn, const char *override_configpath,
|
||||||
x.text = get_colorpixel(conn, ctext); \
|
x.text = get_colorpixel(conn, ctext); \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
|
config.client.background = get_colorpixel(conn, "#000000");
|
||||||
INIT_COLOR(config.client.focused, "#4c7899", "#285577", "#ffffff");
|
INIT_COLOR(config.client.focused, "#4c7899", "#285577", "#ffffff");
|
||||||
INIT_COLOR(config.client.focused_inactive, "#333333", "#5f676a", "#ffffff");
|
INIT_COLOR(config.client.focused_inactive, "#333333", "#5f676a", "#ffffff");
|
||||||
INIT_COLOR(config.client.unfocused, "#333333", "#222222", "#888888");
|
INIT_COLOR(config.client.unfocused, "#333333", "#222222", "#888888");
|
||||||
|
|
|
@ -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 */
|
{client->rect.width-1, 0}}; /* right upper edge */
|
||||||
xcb_poly_line(conn, XCB_COORD_MODE_ORIGIN, client->frame, client->titlegc, 4, points);
|
xcb_poly_line(conn, XCB_COORD_MODE_ORIGIN, client->frame, client->titlegc, 4, points);
|
||||||
|
|
||||||
/* Draw a black background */
|
/* Draw the background */
|
||||||
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) {
|
if (client->titlebar_position == TITLEBAR_OFF && !client->borderless) {
|
||||||
xcb_rectangle_t crect = {1, 0, client->rect.width - (1 + 1), client->rect.height - 1};
|
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);
|
xcb_poly_fill_rectangle(conn, client->frame, client->titlegc, 1, &crect);
|
||||||
|
|
10
src/layout.c
10
src/layout.c
|
@ -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 */
|
/* Draw a rectangle in background color around the window */
|
||||||
if (client->borderless && mode == MODE_DEFAULT)
|
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);
|
else xcb_change_gc_single(conn, gc, XCB_GC_FOREGROUND, color->background);
|
||||||
|
|
||||||
/* In stacking mode, we only render the rect for this specific decoration */
|
/* 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_rectangle_t rect = {0, 0, client->rect.width, client->rect.height};
|
||||||
xcb_poly_fill_rectangle(conn, drawable, gc, 1, &rect);
|
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 */
|
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) {
|
if (client->titlebar_position == TITLEBAR_OFF && client->borderless) {
|
||||||
xcb_rectangle_t crect = {0, 0, client->rect.width, client->rect.height};
|
xcb_rectangle_t crect = {0, 0, client->rect.width, client->rect.height};
|
||||||
xcb_poly_fill_rectangle(conn, client->frame, client->titlegc, 1, &crect);
|
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 */
|
* amount of windows */
|
||||||
if (container->mode == MODE_STACK) {
|
if (container->mode == MODE_STACK) {
|
||||||
if (container->stack_limit == STACK_LIMIT_COLS && (current_col % 2) != 0) {
|
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_x = current_col * (stack_win->rect.width / container->stack_limit_value);
|
||||||
int offset_y = current_row * decoration_height;
|
int offset_y = current_row * decoration_height;
|
||||||
|
@ -556,7 +556,7 @@ void render_container(xcb_connection_t *conn, Container *container) {
|
||||||
offset_y + decoration_height };
|
offset_y + decoration_height };
|
||||||
xcb_poly_fill_rectangle(conn, stack_win->pixmap.id, stack_win->pixmap.gc, 1, &rect);
|
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) {
|
} 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_x = current_col * wrap;
|
||||||
int offset_y = current_row * decoration_height;
|
int offset_y = current_row * decoration_height;
|
||||||
|
|
Loading…
Reference in New Issue