aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--common/list.c15
-rw-r--r--include/list.h2
-rw-r--r--sway/input/seat.c8
3 files changed, 25 insertions, 0 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 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include "log.h"
list_t *create_list(void) {
list_t *list = malloc(sizeof(list_t));
@@ -82,6 +83,20 @@ void list_swap(list_t *list, int src, int dest) {
list->items[dest] = tmp;
}
+void list_move_to_end(list_t *list, void *item) {
+ int i;
+ for (i = 0; i < list->length; ++i) {
+ if (list->items[i] == item) {
+ break;
+ }
+ }
+ if (!sway_assert(i < list->length, "Item not found in list")) {
+ return;
+ }
+ list_del(list, i);
+ list_add(list, item);
+}
+
static void list_rotate(list_t *list, int from, int to) {
void *tmp = list->items[to];
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
void list_stable_sort(list_t *list, int compare(const void *a, const void *b));
// swap two elements in a list
void list_swap(list_t *list, int src, int dest);
+// move item to end of list
+void list_move_to_end(list_t *list, void *item);
#endif
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,
container_damage_whole(container->parent);
}
+ // If we've focused a floating container, bring it to the front.
+ // We do this by putting it at the end of the floating list.
+ // This must happen for both the pending and current children lists.
+ if (container_is_floating(container)) {
+ list_move_to_end(container->parent->children, container);
+ list_move_to_end(container->parent->current.children, container);
+ }
+
// clean up unfocused empty workspace on new output
if (new_output_last_ws) {
if (!workspace_is_visible(new_output_last_ws)