aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Vsevolod <kefirchik3@gmail.com>2021-12-10 17:09:29 +0200
committerLibravatar GitHub <noreply@github.com>2021-12-10 16:09:29 +0100
commitf7725011efd3bc2762a0d1002ea5071470962213 (patch)
tree1ae3ada1e24f387829958961c216b2c231fa01f7
parentFixup headless output names (diff)
downloadsway-f7725011efd3bc2762a0d1002ea5071470962213.tar.gz
sway-f7725011efd3bc2762a0d1002ea5071470962213.tar.zst
sway-f7725011efd3bc2762a0d1002ea5071470962213.zip
Add focused_tab_title
-rw-r--r--include/sway/commands.h1
-rw-r--r--include/sway/config.h3
-rw-r--r--include/sway/tree/container.h2
-rw-r--r--sway/commands.c1
-rw-r--r--sway/commands/client.c16
-rw-r--r--sway/config.c2
-rw-r--r--sway/desktop/render.c18
-rw-r--r--sway/sway.5.scd12
-rw-r--r--sway/tree/container.c6
9 files changed, 60 insertions, 1 deletions
diff --git a/include/sway/commands.h b/include/sway/commands.h
index c6f5c2e0..2746ef28 100644
--- a/include/sway/commands.h
+++ b/include/sway/commands.h
@@ -112,6 +112,7 @@ sway_cmd cmd_border;
112sway_cmd cmd_client_noop; 112sway_cmd cmd_client_noop;
113sway_cmd cmd_client_focused; 113sway_cmd cmd_client_focused;
114sway_cmd cmd_client_focused_inactive; 114sway_cmd cmd_client_focused_inactive;
115sway_cmd cmd_client_focused_tab_title;
115sway_cmd cmd_client_unfocused; 116sway_cmd cmd_client_unfocused;
116sway_cmd cmd_client_urgent; 117sway_cmd cmd_client_urgent;
117sway_cmd cmd_client_placeholder; 118sway_cmd cmd_client_placeholder;
diff --git a/include/sway/config.h b/include/sway/config.h
index aa71209d..fda0e83f 100644
--- a/include/sway/config.h
+++ b/include/sway/config.h
@@ -548,12 +548,15 @@ struct sway_config {
548 struct { 548 struct {
549 struct border_colors focused; 549 struct border_colors focused;
550 struct border_colors focused_inactive; 550 struct border_colors focused_inactive;
551 struct border_colors focused_tab_title;
551 struct border_colors unfocused; 552 struct border_colors unfocused;
552 struct border_colors urgent; 553 struct border_colors urgent;
553 struct border_colors placeholder; 554 struct border_colors placeholder;
554 float background[4]; 555 float background[4];
555 } border_colors; 556 } border_colors;
556 557
558 bool has_focused_tab_title;
559
557 // floating view 560 // floating view
558 int32_t floating_maximum_width; 561 int32_t floating_maximum_width;
559 int32_t floating_maximum_height; 562 int32_t floating_maximum_height;
diff --git a/include/sway/tree/container.h b/include/sway/tree/container.h
index 97fa98c1..05761150 100644
--- a/include/sway/tree/container.h
+++ b/include/sway/tree/container.h
@@ -117,12 +117,14 @@ struct sway_container {
117 117
118 struct wlr_texture *title_focused; 118 struct wlr_texture *title_focused;
119 struct wlr_texture *title_focused_inactive; 119 struct wlr_texture *title_focused_inactive;
120 struct wlr_texture *title_focused_tab_title;
120 struct wlr_texture *title_unfocused; 121 struct wlr_texture *title_unfocused;
121 struct wlr_texture *title_urgent; 122 struct wlr_texture *title_urgent;
122 123
123 list_t *marks; // char * 124 list_t *marks; // char *
124 struct wlr_texture *marks_focused; 125 struct wlr_texture *marks_focused;
125 struct wlr_texture *marks_focused_inactive; 126 struct wlr_texture *marks_focused_inactive;
127 struct wlr_texture *marks_focused_tab_title;
126 struct wlr_texture *marks_unfocused; 128 struct wlr_texture *marks_unfocused;
127 struct wlr_texture *marks_urgent; 129 struct wlr_texture *marks_urgent;
128 130
diff --git a/sway/commands.c b/sway/commands.c
index 205406ad..5a1fd32e 100644
--- a/sway/commands.c
+++ b/sway/commands.c
@@ -51,6 +51,7 @@ static const struct cmd_handler handlers[] = {
51 { "client.background", cmd_client_noop }, 51 { "client.background", cmd_client_noop },
52 { "client.focused", cmd_client_focused }, 52 { "client.focused", cmd_client_focused },
53 { "client.focused_inactive", cmd_client_focused_inactive }, 53 { "client.focused_inactive", cmd_client_focused_inactive },
54 { "client.focused_tab_title", cmd_client_focused_tab_title },
54 { "client.placeholder", cmd_client_noop }, 55 { "client.placeholder", cmd_client_noop },
55 { "client.unfocused", cmd_client_unfocused }, 56 { "client.unfocused", cmd_client_unfocused },
56 { "client.urgent", cmd_client_urgent }, 57 { "client.urgent", cmd_client_urgent },
diff --git a/sway/commands/client.c b/sway/commands/client.c
index dd0694df..77263145 100644
--- a/sway/commands/client.c
+++ b/sway/commands/client.c
@@ -18,6 +18,12 @@ static struct cmd_results *handle_command(int argc, char **argv, char *cmd_name,
18 return error; 18 return error;
19 } 19 }
20 20
21 if (argc > 3 && strcmp(cmd_name, "client.focused_tab_title") == 0) {
22 sway_log(SWAY_ERROR,
23 "Warning: indicator and child_border colors have no effect for %s",
24 cmd_name);
25 }
26
21 struct border_colors colors = {0}; 27 struct border_colors colors = {0};
22 const char *ind_hex = argc > 3 ? argv[3] : default_indicator; 28 const char *ind_hex = argc > 3 ? argv[3] : default_indicator;
23 const char *child_hex = argc > 4 ? argv[4] : argv[1]; // def to background 29 const char *child_hex = argc > 4 ? argv[4] : argv[1]; // def to background
@@ -80,3 +86,13 @@ struct cmd_results *cmd_client_noop(int argc, char **argv) {
80 sway_log(SWAY_INFO, "Warning: %s is ignored by sway", argv[-1]); 86 sway_log(SWAY_INFO, "Warning: %s is ignored by sway", argv[-1]);
81 return cmd_results_new(CMD_SUCCESS, NULL); 87 return cmd_results_new(CMD_SUCCESS, NULL);
82} 88}
89
90struct cmd_results *cmd_client_focused_tab_title(int argc, char **argv) {
91 struct cmd_results *result = handle_command(argc, argv,
92 "client.focused_tab_title",
93 &config->border_colors.focused_tab_title, "#2e9ef4ff");
94 if (result && result->status == CMD_SUCCESS) {
95 config->has_focused_tab_title = true;
96 }
97 return result;
98}
diff --git a/sway/config.c b/sway/config.c
index 35837212..e4745a5c 100644
--- a/sway/config.c
+++ b/sway/config.c
@@ -290,6 +290,8 @@ static void config_defaults(struct sway_config *config) {
290 config->hide_edge_borders_smart = ESMART_OFF; 290 config->hide_edge_borders_smart = ESMART_OFF;
291 config->hide_lone_tab = false; 291 config->hide_lone_tab = false;
292 292
293 config->has_focused_tab_title = false;
294
293 // border colors 295 // border colors
294 color_to_rgba(config->border_colors.focused.border, 0x4C7899FF); 296 color_to_rgba(config->border_colors.focused.border, 0x4C7899FF);
295 color_to_rgba(config->border_colors.focused.background, 0x285577FF); 297 color_to_rgba(config->border_colors.focused.background, 0x285577FF);
diff --git a/sway/desktop/render.c b/sway/desktop/render.c
index 6c8c77ed..c088c936 100644
--- a/sway/desktop/render.c
+++ b/sway/desktop/render.c
@@ -762,6 +762,14 @@ static void render_containers_linear(struct sway_output *output,
762 } 762 }
763} 763}
764 764
765static bool container_is_focused(struct sway_container *con, void *data) {
766 return con->current.focused;
767}
768
769static bool container_has_focused_child(struct sway_container *con) {
770 return container_find_child(con, container_is_focused, NULL);
771}
772
765/** 773/**
766 * Render a container's children using the L_TABBED layout. 774 * Render a container's children using the L_TABBED layout.
767 */ 775 */
@@ -793,6 +801,10 @@ static void render_containers_tabbed(struct sway_output *output,
793 colors = &config->border_colors.focused; 801 colors = &config->border_colors.focused;
794 title_texture = child->title_focused; 802 title_texture = child->title_focused;
795 marks_texture = child->marks_focused; 803 marks_texture = child->marks_focused;
804 } else if (config->has_focused_tab_title && container_has_focused_child(child)) {
805 colors = &config->border_colors.focused_tab_title;
806 title_texture = child->title_focused_tab_title;
807 marks_texture = child->marks_focused_tab_title;
796 } else if (child == parent->active_child) { 808 } else if (child == parent->active_child) {
797 colors = &config->border_colors.focused_inactive; 809 colors = &config->border_colors.focused_inactive;
798 title_texture = child->title_focused_inactive; 810 title_texture = child->title_focused_inactive;
@@ -858,7 +870,11 @@ static void render_containers_stacked(struct sway_output *output,
858 colors = &config->border_colors.focused; 870 colors = &config->border_colors.focused;
859 title_texture = child->title_focused; 871 title_texture = child->title_focused;
860 marks_texture = child->marks_focused; 872 marks_texture = child->marks_focused;
861 } else if (child == parent->active_child) { 873 } else if (config->has_focused_tab_title && container_has_focused_child(child)) {
874 colors = &config->border_colors.focused_tab_title;
875 title_texture = child->title_focused_tab_title;
876 marks_texture = child->marks_focused_tab_title;
877 } else if (child == parent->active_child) {
862 colors = &config->border_colors.focused_inactive; 878 colors = &config->border_colors.focused_inactive;
863 title_texture = child->title_focused_inactive; 879 title_texture = child->title_focused_inactive;
864 marks_texture = child->marks_focused_inactive; 880 marks_texture = child->marks_focused_inactive;
diff --git a/sway/sway.5.scd b/sway/sway.5.scd
index ec34a56c..641d0925 100644
--- a/sway/sway.5.scd
+++ b/sway/sway.5.scd
@@ -499,6 +499,12 @@ runtime.
499 *client.focused_inactive* 499 *client.focused_inactive*
500 The most recently focused view within a container which is not focused. 500 The most recently focused view within a container which is not focused.
501 501
502 *client.focused_tab_title*
503 A view that has focused descendant container.
504 Tab or stack container title that is the parent of the focused container
505 but is not directly focused. Defaults to focused_inactive if not
506 specified and does not use the indicator and child_border colors.
507
502 *client.placeholder* 508 *client.placeholder*
503 Ignored (present for i3 compatibility). 509 Ignored (present for i3 compatibility).
504 510
@@ -554,6 +560,12 @@ The default colors are:
554: #ffffff 560: #ffffff
555: #484e50 561: #484e50
556: #5f676a 562: #5f676a
563| *focused_tab_title*
564: #333333
565: #5f676a
566: #ffffff
567: n/a
568: n/a
557| *unfocused* 569| *unfocused*
558: #333333 570: #333333
559: #222222 571: #222222
diff --git a/sway/tree/container.c b/sway/tree/container.c
index eb88b47e..0284c9a5 100644
--- a/sway/tree/container.c
+++ b/sway/tree/container.c
@@ -64,6 +64,7 @@ void container_destroy(struct sway_container *con) {
64 wlr_texture_destroy(con->title_focused_inactive); 64 wlr_texture_destroy(con->title_focused_inactive);
65 wlr_texture_destroy(con->title_unfocused); 65 wlr_texture_destroy(con->title_unfocused);
66 wlr_texture_destroy(con->title_urgent); 66 wlr_texture_destroy(con->title_urgent);
67 wlr_texture_destroy(con->title_focused_tab_title);
67 list_free(con->pending.children); 68 list_free(con->pending.children);
68 list_free(con->current.children); 69 list_free(con->current.children);
69 list_free(con->outputs); 70 list_free(con->outputs);
@@ -73,6 +74,7 @@ void container_destroy(struct sway_container *con) {
73 wlr_texture_destroy(con->marks_focused_inactive); 74 wlr_texture_destroy(con->marks_focused_inactive);
74 wlr_texture_destroy(con->marks_unfocused); 75 wlr_texture_destroy(con->marks_unfocused);
75 wlr_texture_destroy(con->marks_urgent); 76 wlr_texture_destroy(con->marks_urgent);
77 wlr_texture_destroy(con->marks_focused_tab_title);
76 78
77 if (con->view) { 79 if (con->view) {
78 if (con->view->container == con) { 80 if (con->view->container == con) {
@@ -582,6 +584,8 @@ void container_update_title_textures(struct sway_container *container) {
582 &config->border_colors.unfocused); 584 &config->border_colors.unfocused);
583 update_title_texture(container, &container->title_urgent, 585 update_title_texture(container, &container->title_urgent,
584 &config->border_colors.urgent); 586 &config->border_colors.urgent);
587 update_title_texture(container, &container->title_focused_tab_title,
588 &config->border_colors.focused_tab_title);
585 container_damage_whole(container); 589 container_damage_whole(container);
586} 590}
587 591
@@ -1635,6 +1639,8 @@ void container_update_marks_textures(struct sway_container *con) {
1635 &config->border_colors.unfocused); 1639 &config->border_colors.unfocused);
1636 update_marks_texture(con, &con->marks_urgent, 1640 update_marks_texture(con, &con->marks_urgent,
1637 &config->border_colors.urgent); 1641 &config->border_colors.urgent);
1642 update_marks_texture(con, &con->marks_focused_tab_title,
1643 &config->border_colors.focused_tab_title);
1638 container_damage_whole(con); 1644 container_damage_whole(con);
1639} 1645}
1640 1646