Skip to content

Commit

Permalink
Merge remote-tracking branch 'vanilla/next' into gaps-next
Browse files Browse the repository at this point in the history
  • Loading branch information
Airblader committed Nov 5, 2021
2 parents 952939d + 20d0591 commit e9a0c70
Show file tree
Hide file tree
Showing 10 changed files with 63 additions and 28 deletions.
4 changes: 4 additions & 0 deletions docs/userguide
Original file line number Diff line number Diff line change
Expand Up @@ -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::
Expand Down
2 changes: 2 additions & 0 deletions include/configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion parser-specs/config.spec
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,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).
Expand Down
1 change: 1 addition & 0 deletions release-notes/bugfixes/2-fix-focus-wrap
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fix focus when moving container between outputs with mouse warp and focus_follows_mouse
1 change: 1 addition & 0 deletions release-notes/changes/2-client.focused_tab_title
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add client.focused_tab_title color option
1 change: 1 addition & 0 deletions src/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
38 changes: 23 additions & 15 deletions src/config_directives.c
Original file line number Diff line number Diff line change
Expand Up @@ -625,24 +625,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);
Expand Down
13 changes: 11 additions & 2 deletions src/move.c
Original file line number Diff line number Diff line change
Expand Up @@ -228,10 +228,19 @@ static void move_to_output_directed(Con *con, direction_t direction) {
* the focused container, con, is now a child of ws. To work around this
* and still produce the correct workspace focus events (see
* 517-regress-move-direction-ipc.t) we need to temporarily set focused
* to the old workspace. */
* to the old workspace.
*
* The following happen:
* 1. Focus con to push it on the top of the focus stack in its new
* workspace
* 2. Set focused to the old workspace to force workspace_show to
* execute
* 3. workspace_show will descend focus and target our con for
* focusing. This also ensures that the mouse warps correctly.
* See: #3518. */
con_focus(con);
focused = old_ws;
workspace_show(ws);
con_focus(con);
}

/* force re-painting the indicators */
Expand Down
16 changes: 11 additions & 5 deletions src/x.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
13 changes: 8 additions & 5 deletions testcases/t/201-config-parser.t
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -554,6 +556,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
Expand Down

0 comments on commit e9a0c70

Please sign in to comment.