diff options
-rw-r--r-- | common/list.c | 15 | ||||
-rw-r--r-- | include/list.h | 2 | ||||
-rw-r--r-- | sway/desktop/render.c | 7 | ||||
-rw-r--r-- | sway/input/seat.c | 8 |
4 files changed, 30 insertions, 2 deletions
diff --git a/common/list.c b/common/list.c index 39cc10e1..66d52f70 100644 --- a/common/list.c +++ b/common/list.c | |||
@@ -2,6 +2,7 @@ | |||
2 | #include <stdio.h> | 2 | #include <stdio.h> |
3 | #include <stdlib.h> | 3 | #include <stdlib.h> |
4 | #include <string.h> | 4 | #include <string.h> |
5 | #include "log.h" | ||
5 | 6 | ||
6 | list_t *create_list(void) { | 7 | list_t *create_list(void) { |
7 | list_t *list = malloc(sizeof(list_t)); | 8 | list_t *list = malloc(sizeof(list_t)); |
@@ -82,6 +83,20 @@ void list_swap(list_t *list, int src, int dest) { | |||
82 | list->items[dest] = tmp; | 83 | list->items[dest] = tmp; |
83 | } | 84 | } |
84 | 85 | ||
86 | void list_move_to_end(list_t *list, void *item) { | ||
87 | int i; | ||
88 | for (i = 0; i < list->length; ++i) { | ||
89 | if (list->items[i] == item) { | ||
90 | break; | ||
91 | } | ||
92 | } | ||
93 | if (!sway_assert(i < list->length, "Item not found in list")) { | ||
94 | return; | ||
95 | } | ||
96 | list_del(list, i); | ||
97 | list_add(list, item); | ||
98 | } | ||
99 | |||
85 | static void list_rotate(list_t *list, int from, int to) { | 100 | static void list_rotate(list_t *list, int from, int to) { |
86 | void *tmp = list->items[to]; | 101 | void *tmp = list->items[to]; |
87 | 102 | ||
diff --git a/include/list.h b/include/list.h index 7eead4ac..5a0d7d80 100644 --- a/include/list.h +++ b/include/list.h | |||
@@ -24,4 +24,6 @@ int list_seq_find(list_t *list, int compare(const void *item, const void *cmp_to | |||
24 | void list_stable_sort(list_t *list, int compare(const void *a, const void *b)); | 24 | void list_stable_sort(list_t *list, int compare(const void *a, const void *b)); |
25 | // swap two elements in a list | 25 | // swap two elements in a list |
26 | void list_swap(list_t *list, int src, int dest); | 26 | void list_swap(list_t *list, int src, int dest); |
27 | // move item to end of list | ||
28 | void list_move_to_end(list_t *list, void *item); | ||
27 | #endif | 29 | #endif |
diff --git a/sway/desktop/render.c b/sway/desktop/render.c index f554b813..28c81942 100644 --- a/sway/desktop/render.c +++ b/sway/desktop/render.c | |||
@@ -599,7 +599,9 @@ static void render_container_tabbed(struct sway_output *output, | |||
599 | struct border_colors *current_colors = &config->border_colors.unfocused; | 599 | struct border_colors *current_colors = &config->border_colors.unfocused; |
600 | struct sway_container_state *pstate = &con->current; | 600 | struct sway_container_state *pstate = &con->current; |
601 | 601 | ||
602 | int tab_width = pstate->swayc_width / pstate->children->length; | 602 | double width_gap_adjustment = 2 * pstate->current_gaps; |
603 | int tab_width = | ||
604 | (pstate->swayc_width - width_gap_adjustment) / pstate->children->length; | ||
603 | 605 | ||
604 | // Render tabs | 606 | // Render tabs |
605 | for (int i = 0; i < pstate->children->length; ++i) { | 607 | for (int i = 0; i < pstate->children->length; ++i) { |
@@ -628,7 +630,8 @@ static void render_container_tabbed(struct sway_output *output, | |||
628 | 630 | ||
629 | // Make last tab use the remaining width of the parent | 631 | // Make last tab use the remaining width of the parent |
630 | if (i == pstate->children->length - 1) { | 632 | if (i == pstate->children->length - 1) { |
631 | tab_width = pstate->swayc_width - tab_width * i; | 633 | tab_width = |
634 | pstate->swayc_width - width_gap_adjustment - tab_width * i; | ||
632 | } | 635 | } |
633 | 636 | ||
634 | render_titlebar(output, damage, child, x, cstate->swayc_y, tab_width, | 637 | render_titlebar(output, damage, child, x, cstate->swayc_y, tab_width, |
diff --git a/sway/input/seat.c b/sway/input/seat.c index 5dadb31d..bf4e8876 100644 --- a/sway/input/seat.c +++ b/sway/input/seat.c | |||
@@ -666,6 +666,14 @@ void seat_set_focus_warp(struct sway_seat *seat, | |||
666 | container_damage_whole(container->parent); | 666 | container_damage_whole(container->parent); |
667 | } | 667 | } |
668 | 668 | ||
669 | // If we've focused a floating container, bring it to the front. | ||
670 | // We do this by putting it at the end of the floating list. | ||
671 | // This must happen for both the pending and current children lists. | ||
672 | if (container_is_floating(container)) { | ||
673 | list_move_to_end(container->parent->children, container); | ||
674 | list_move_to_end(container->parent->current.children, container); | ||
675 | } | ||
676 | |||
669 | // clean up unfocused empty workspace on new output | 677 | // clean up unfocused empty workspace on new output |
670 | if (new_output_last_ws) { | 678 | if (new_output_last_ws) { |
671 | if (!workspace_is_visible(new_output_last_ws) | 679 | if (!workspace_is_visible(new_output_last_ws) |