aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Ryan Dwyer <ryandwyer1@gmail.com>2018-07-11 19:50:02 +1000
committerLibravatar Ryan Dwyer <ryandwyer1@gmail.com>2018-07-11 19:50:02 +1000
commit15dc5286e280ddd06e845dc57115243e72f2339e (patch)
treec24efe7dbbc93098dd4c2273ebc2dc809c576901
parentMerge pull request #2241 from rustysec/master (diff)
downloadsway-15dc5286e280ddd06e845dc57115243e72f2339e.tar.gz
sway-15dc5286e280ddd06e845dc57115243e72f2339e.tar.zst
sway-15dc5286e280ddd06e845dc57115243e72f2339e.zip
Move floating windows to front when focused
-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 @@
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
6list_t *create_list(void) { 7list_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
86void 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
85static void list_rotate(list_t *list, int from, int to) { 100static 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
24void list_stable_sort(list_t *list, int compare(const void *a, const void *b)); 24void 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
26void list_swap(list_t *list, int src, int dest); 26void list_swap(list_t *list, int src, int dest);
27// move item to end of list
28void list_move_to_end(list_t *list, void *item);
27#endif 29#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,
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)