Merge pull request #4650 from orestisfl/focused_tab_title
Add title tab color
This commit is contained in:
commit
117fb13177
@ -1057,6 +1057,10 @@ client.focused::
|
||||
client.focused_inactive::
|
||||
A client which is the focused one of its container, but it does not have
|
||||
the focus at the moment.
|
||||
client.focused_tab_title::
|
||||
Tab or stack container title that is the parent of the focused container
|
||||
but not directly focused. Defaults to focused_inactive if not specified and
|
||||
does not use the indicator and child_border colors.
|
||||
client.unfocused::
|
||||
A client which is not the focused one of its container.
|
||||
client.urgent::
|
||||
|
@ -238,9 +238,11 @@ struct Config {
|
||||
color_t background;
|
||||
struct Colortriple focused;
|
||||
struct Colortriple focused_inactive;
|
||||
struct Colortriple focused_tab_title;
|
||||
struct Colortriple unfocused;
|
||||
struct Colortriple urgent;
|
||||
struct Colortriple placeholder;
|
||||
bool got_focused_tab_title;
|
||||
} client;
|
||||
struct config_bar {
|
||||
struct Colortriple focused;
|
||||
|
@ -56,7 +56,7 @@ state INITIAL:
|
||||
exectype = 'exec_always', 'exec' -> EXEC
|
||||
colorclass = 'client.background'
|
||||
-> COLOR_SINGLE
|
||||
colorclass = 'client.focused_inactive', 'client.focused', 'client.unfocused', 'client.urgent', 'client.placeholder'
|
||||
colorclass = 'client.focused_inactive', 'client.focused_tab_title', 'client.focused', 'client.unfocused', 'client.urgent', 'client.placeholder'
|
||||
-> COLOR_BORDER
|
||||
|
||||
# We ignore comments and 'set' lines (variables).
|
||||
|
1
release-notes/changes/2-client.focused_tab_title
Normal file
1
release-notes/changes/2-client.focused_tab_title
Normal file
@ -0,0 +1 @@
|
||||
Add client.focused_tab_title color option
|
@ -197,6 +197,7 @@ bool load_configuration(const char *override_configpath, config_load_t load_type
|
||||
INIT_COLOR(config.client.focused_inactive, "#333333", "#5f676a", "#ffffff", "#484e50");
|
||||
INIT_COLOR(config.client.unfocused, "#333333", "#222222", "#888888", "#292d2e");
|
||||
INIT_COLOR(config.client.urgent, "#2f343a", "#900000", "#ffffff", "#900000");
|
||||
config.client.got_focused_tab_title = false;
|
||||
|
||||
/* border and indicator color are ignored for placeholder contents */
|
||||
INIT_COLOR(config.client.placeholder, "#000000", "#0c0c0c", "#ffffff", "#000000");
|
||||
|
@ -467,24 +467,32 @@ CFGFUN(color_single, const char *colorclass, const char *color) {
|
||||
}
|
||||
|
||||
CFGFUN(color, const char *colorclass, const char *border, const char *background, const char *text, const char *indicator, const char *child_border) {
|
||||
#define APPLY_COLORS(classname) \
|
||||
do { \
|
||||
if (strcmp(colorclass, "client." #classname) == 0) { \
|
||||
config.client.classname.border = draw_util_hex_to_color(border); \
|
||||
config.client.classname.background = draw_util_hex_to_color(background); \
|
||||
config.client.classname.text = draw_util_hex_to_color(text); \
|
||||
if (indicator != NULL) { \
|
||||
config.client.classname.indicator = draw_util_hex_to_color(indicator); \
|
||||
} \
|
||||
if (child_border != NULL) { \
|
||||
config.client.classname.child_border = draw_util_hex_to_color(child_border); \
|
||||
} else { \
|
||||
config.client.classname.child_border = config.client.classname.background; \
|
||||
} \
|
||||
} \
|
||||
#define APPLY_COLORS(classname) \
|
||||
do { \
|
||||
if (strcmp(colorclass, "client." #classname) == 0) { \
|
||||
if (strcmp("focused_tab_title", #classname) == 0) { \
|
||||
config.client.got_focused_tab_title = true; \
|
||||
if (indicator || child_border) { \
|
||||
ELOG("indicator and child_border colors have no effect for client.focused_tab_title\n"); \
|
||||
} \
|
||||
} \
|
||||
config.client.classname.border = draw_util_hex_to_color(border); \
|
||||
config.client.classname.background = draw_util_hex_to_color(background); \
|
||||
config.client.classname.text = draw_util_hex_to_color(text); \
|
||||
if (indicator != NULL) { \
|
||||
config.client.classname.indicator = draw_util_hex_to_color(indicator); \
|
||||
} \
|
||||
if (child_border != NULL) { \
|
||||
config.client.classname.child_border = draw_util_hex_to_color(child_border); \
|
||||
} else { \
|
||||
config.client.classname.child_border = config.client.classname.background; \
|
||||
} \
|
||||
return; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
APPLY_COLORS(focused_inactive);
|
||||
APPLY_COLORS(focused_tab_title);
|
||||
APPLY_COLORS(focused);
|
||||
APPLY_COLORS(unfocused);
|
||||
APPLY_COLORS(urgent);
|
||||
|
16
src/x.c
16
src/x.c
@ -490,14 +490,20 @@ void x_draw_decoration(Con *con) {
|
||||
struct deco_render_params *p = scalloc(1, sizeof(struct deco_render_params));
|
||||
|
||||
/* find out which colors to use */
|
||||
if (con->urgent)
|
||||
if (con->urgent) {
|
||||
p->color = &config.client.urgent;
|
||||
else if (con == focused || con_inside_focused(con))
|
||||
} else if (con == focused || con_inside_focused(con)) {
|
||||
p->color = &config.client.focused;
|
||||
else if (con == TAILQ_FIRST(&(parent->focus_head)))
|
||||
p->color = &config.client.focused_inactive;
|
||||
else
|
||||
} else if (con == TAILQ_FIRST(&(parent->focus_head))) {
|
||||
if (config.client.got_focused_tab_title && !leaf && con_descend_focused(con) == focused) {
|
||||
/* Stacked/tabbed parent of focused container */
|
||||
p->color = &config.client.focused_tab_title;
|
||||
} else {
|
||||
p->color = &config.client.focused_inactive;
|
||||
}
|
||||
} else {
|
||||
p->color = &config.client.unfocused;
|
||||
}
|
||||
|
||||
p->border_style = con_border_style(con);
|
||||
|
||||
|
@ -476,16 +476,18 @@ is(parser_calls($config),
|
||||
################################################################################
|
||||
|
||||
$config = <<'EOT';
|
||||
client.focused #4c7899 #285577 #ffffff #2e9ef4 #b34d4c
|
||||
client.focused_inactive #333333 #5f676a #ffffff #484e50
|
||||
client.unfocused #333333 #222222 #888888 #292d2e
|
||||
client.urgent #2f343a #900000 #ffffff #900000 #c00000
|
||||
client.placeholder #000000 #0c0c0c #ffffff #000000
|
||||
client.focused #4c7899 #285577 #ffffff #2e9ef4 #b34d4c
|
||||
client.focused_inactive #333333 #5f676a #ffffff #484e50
|
||||
client.focused_tab_title #444444 #555555 #ffffff
|
||||
client.unfocused #333333 #222222 #888888 #292d2e
|
||||
client.urgent #2f343a #900000 #ffffff #900000 #c00000
|
||||
client.placeholder #000000 #0c0c0c #ffffff #000000
|
||||
EOT
|
||||
|
||||
$expected = <<'EOT';
|
||||
cfg_color(client.focused, #4c7899, #285577, #ffffff, #2e9ef4, #b34d4c)
|
||||
cfg_color(client.focused_inactive, #333333, #5f676a, #ffffff, #484e50, NULL)
|
||||
cfg_color(client.focused_tab_title, #444444, #555555, #ffffff, NULL, NULL)
|
||||
cfg_color(client.unfocused, #333333, #222222, #888888, #292d2e, NULL)
|
||||
cfg_color(client.urgent, #2f343a, #900000, #ffffff, #900000, #c00000)
|
||||
cfg_color(client.placeholder, #000000, #0c0c0c, #ffffff, #000000, NULL)
|
||||
@ -551,6 +553,7 @@ my $expected_all_tokens = "ERROR: CONFIG: Expected one of these tokens: <end>, '
|
||||
exec
|
||||
client.background
|
||||
client.focused_inactive
|
||||
client.focused_tab_title
|
||||
client.focused
|
||||
client.unfocused
|
||||
client.urgent
|
||||
|
Loading…
x
Reference in New Issue
Block a user