[PATCH 5/6] Add height dimension to screen sorting
Mathieu OTHACEHE <[email protected]> Tue, 29 Nov 2016 20:00:53 +0100
| Newsgroups | gmane.comp.window-managers.ratpoison.devel |
|---|---|
| Message-ID | <[email protected]> |
Screen are only sorted according to their width offset from
origin ("left" in screen struct).
Also sort screen that share a same width offset according to their
height offset ("top" in screen struct).
---
src/screen.c | 19 +++++++++++++++----
1 file changed, 15 insertions(+), 4 deletions(-)
diff --git a/src/screen.c b/src/screen.c
index 3c49409..ddc03cb 100644
--- a/src/screen.c
+++ b/src/screen.c
@@ -198,15 +198,26 @@ screen_number (int number)
}
static int
-screen_cmp_left (void *priv, struct list_head *a, struct list_head *b)
+screen_cmp (void *priv, struct list_head *a, struct list_head *b)
{
rp_screen *sc_a = container_of (a, typeof(*sc_a), node);
rp_screen *sc_b = container_of (b, typeof(*sc_b), node);
if (sc_a->left < sc_b->left)
- return -1;
+ {
+ return -1;
+ }
else if (sc_a->left > sc_b->left)
- return 1;
+ {
+ return 1;
+ }
+ else if (sc_a->left == sc_b->left)
+ {
+ if (sc_a->top < sc_b->top)
+ return -1;
+ else
+ return 1;
+ }
return 0;
}
@@ -214,7 +225,7 @@ screen_cmp_left (void *priv, struct list_head *a, struct list_head *b)
void
screen_sort (void)
{
- return list_sort (NULL, &rp_screens, screen_cmp_left);
+ return list_sort (NULL, &rp_screens, screen_cmp);
}
static void
--
2.10.2