]> Pileus Git - wmpus/blobdiff - util.c
Add initial Xinerama support
[wmpus] / util.c
diff --git a/util.c b/util.c
index bf07b0283576cfc2a373609946c9120b18e1b4e5..7425be00fa41ab37cd3437ad01204633c808be7d 100644 (file)
--- a/util.c
+++ b/util.c
@@ -15,10 +15,22 @@ list_t *list_insert(list_t *next, void *data)
        return node;
 }
 
+void list_insert_after(list_t *prev, void *data)
+{
+       // prev must be valid,
+       // as we cannot return the original list head
+       list_t *node = new0(list_t);
+       node->data = data;
+       node->prev = prev;
+       node->next = prev->next;
+       prev->next = node;
+       if (node->next) node->next->prev = node;
+}
+
 list_t *list_append(list_t *head, void *data)
 {
        list_t *last = head;
-       while (last->next)
+       while (last && last->next)
                last = last->next;
        list_t *node = new0(list_t);
        node->data = data;
@@ -45,8 +57,12 @@ int list_length(list_t *node)
        return len;
 }
 
-void list_move(list_t *node, int offset)
+list_t *list_find(list_t *list, void *data)
 {
+       for (list_t *cur = list; cur; cur = cur->next)
+               if (cur->data == data)
+                       return cur;
+       return NULL;
 }
 
 /* Misc */