Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow configuring unfocused tab title #8174

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions include/sway/commands.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ sway_cmd cmd_client_focused;
sway_cmd cmd_client_focused_inactive;
sway_cmd cmd_client_focused_tab_title;
sway_cmd cmd_client_unfocused;
sway_cmd cmd_client_unfocused_tab_title;
sway_cmd cmd_client_urgent;
sway_cmd cmd_client_placeholder;
sway_cmd cmd_client_background;
Expand Down
2 changes: 2 additions & 0 deletions include/sway/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -571,12 +571,14 @@ struct sway_config {
struct border_colors focused_inactive;
struct border_colors focused_tab_title;
struct border_colors unfocused;
struct border_colors unfocused_tab_title;
struct border_colors urgent;
struct border_colors placeholder;
float background[4];
} border_colors;

bool has_focused_tab_title;
bool has_unfocused_tab_title;

// floating view
int32_t floating_maximum_width;
Expand Down
1 change: 1 addition & 0 deletions sway/commands.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ static const struct cmd_handler handlers[] = {
{ "client.focused_tab_title", cmd_client_focused_tab_title },
{ "client.placeholder", cmd_client_noop },
{ "client.unfocused", cmd_client_unfocused },
{ "client.unfocused_tab_title", cmd_client_unfocused_tab_title },
{ "client.urgent", cmd_client_urgent },
{ "default_border", cmd_default_border },
{ "default_floating_border", cmd_default_floating_border },
Expand Down
10 changes: 10 additions & 0 deletions sway/commands/client.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,3 +90,13 @@ struct cmd_results *cmd_client_focused_tab_title(int argc, char **argv) {
}
return result;
}

struct cmd_results *cmd_client_unfocused_tab_title(int argc, char **argv) {
struct cmd_results *result = handle_command(argc, argv,
"client.unfocused_tab_title",
&config->border_colors.unfocused_tab_title, "#2e9ef4ff");
if (result && result->status == CMD_SUCCESS) {
config->has_unfocused_tab_title = true;
}
return result;
}
1 change: 1 addition & 0 deletions sway/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,7 @@ static void config_defaults(struct sway_config *config) {
config->hide_lone_tab = false;

config->has_focused_tab_title = false;
config->has_unfocused_tab_title = false;

// border colors
color_to_rgba(config->border_colors.focused.border, 0x4C7899FF);
Expand Down
11 changes: 11 additions & 0 deletions sway/sway.5.scd
Original file line number Diff line number Diff line change
Expand Up @@ -579,6 +579,11 @@ runtime.
*client.unfocused*
A view that does not have focus.

*client.unfocused_tab_title*
Title of a tab or stack container that does not have focus. Defaults to
unfocused if not specified and does not use the indicator and child_border
colors.

*client.urgent*
A view with an urgency hint. *Note*: Native Wayland windows do not
support urgency. Urgency only works for Xwayland windows.
Expand Down Expand Up @@ -640,6 +645,12 @@ The default colors are:
: #888888
: #292d2e
: #222222
| *unfocused_tab_title*
: #333333
: #222222
: #888888
: n/a
: n/a
| *urgent*
: #2f343a
: #900000
Expand Down
10 changes: 10 additions & 0 deletions sway/tree/container.c
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,14 @@ static bool container_has_focused_child(struct sway_container *con) {
return container_find_child(con, container_is_focused, NULL);
}

static bool container_is_container(struct sway_container *con, void *data) {
return true; // intentional tautology
}

static bool container_has_child(struct sway_container *con) {
return container_find_child(con, container_is_container, NULL);
}

static bool container_is_current_parent_focused(struct sway_container *con) {
if (con->current.parent) {
struct sway_container *parent = con->current.parent;
Expand Down Expand Up @@ -211,6 +219,8 @@ static struct border_colors *container_get_current_colors(
colors = &config->border_colors.focused_tab_title;
} else if (con == active_child) {
colors = &config->border_colors.focused_inactive;
} else if (config->has_unfocused_tab_title && container_has_child(con)) {
colors = &config->border_colors.unfocused_tab_title;
} else {
colors = &config->border_colors.unfocused;
}
Expand Down