feat(container): add config |unfocused_tab_title|

This commit is contained in:
Shengdi 'shc' Chen 2024-05-22 22:05:11 +02:00
parent 9704152414
commit d84a73f1e5
6 changed files with 25 additions and 0 deletions

View file

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

View file

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

View file

@ -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 },

View file

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

View file

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

View file

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