diff options
author | 2018-07-23 20:27:56 -0400 | |
---|---|---|
committer | 2018-07-23 20:31:11 -0400 | |
commit | f4b882475eee7a81c206c7825616cc4656b2f60b (patch) | |
tree | 38e6ebf81b235424f105dcbcbb194e5e9eac70c0 /common/list.c | |
parent | Implement pid->workspace tracking (diff) | |
parent | Merge pull request #2342 from RyanDwyer/update-cursor (diff) | |
download | sway-f4b882475eee7a81c206c7825616cc4656b2f60b.tar.gz sway-f4b882475eee7a81c206c7825616cc4656b2f60b.tar.zst sway-f4b882475eee7a81c206c7825616cc4656b2f60b.zip |
Merge branch 'master' into pid-workspaces
Diffstat (limited to 'common/list.c')
-rw-r--r-- | common/list.c | 15 |
1 files changed, 15 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 | ||
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 | ||