diff options
Diffstat (limited to 'sway/output.c')
-rw-r--r-- | sway/output.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/sway/output.c b/sway/output.c index cf8ed9a5..53b24232 100644 --- a/sway/output.c +++ b/sway/output.c | |||
@@ -1,4 +1,6 @@ | |||
1 | #include <strings.h> | 1 | #include <strings.h> |
2 | #include <ctype.h> | ||
3 | #include <stdlib.h> | ||
2 | #include "output.h" | 4 | #include "output.h" |
3 | #include "log.h" | 5 | #include "log.h" |
4 | 6 | ||
@@ -177,3 +179,25 @@ void get_absolute_center_position(swayc_t *container, struct wlc_point *point) { | |||
177 | point->x += container->width/2; | 179 | point->x += container->width/2; |
178 | point->y += container->height/2; | 180 | point->y += container->height/2; |
179 | } | 181 | } |
182 | |||
183 | int sort_workspace_cmp_qsort(const void *_a, const void *_b) { | ||
184 | swayc_t *a = *(void **)_a; | ||
185 | swayc_t *b = *(void **)_b; | ||
186 | int retval = 0; | ||
187 | |||
188 | if (isdigit(a->name[0]) && isdigit(b->name[0])) { | ||
189 | int a_num = strtol(a->name, NULL, 10); | ||
190 | int b_num = strtol(b->name, NULL, 10); | ||
191 | retval = (a_num < b_num) ? -1 : (a_num > b_num); | ||
192 | } else if (isdigit(a->name[0])) { | ||
193 | retval = -1; | ||
194 | } else if (isdigit(b->name[0])) { | ||
195 | retval = 1; | ||
196 | } | ||
197 | |||
198 | return retval; | ||
199 | } | ||
200 | |||
201 | void sort_workspaces(swayc_t *output) { | ||
202 | list_qsort(output->children, sort_workspace_cmp_qsort); | ||
203 | } | ||