aboutsummaryrefslogtreecommitdiff
path: root/include/wlr
diff options
context:
space:
mode:
authorTony Crisci <tony@dubstepdish.com>2017-11-21 07:55:36 -0500
committerTony Crisci <tony@dubstepdish.com>2017-11-21 07:55:36 -0500
commite786d17f632377b6875c812d67165bcddb0a4826 (patch)
treef447fedce70e3b97778990726fc99b73c58fe885 /include/wlr
parent444257b6b17935be5dff11791e9ac9d52cf811b7 (diff)
parent6bde8dd56beebc429445196d7d4a120677289317 (diff)
Merge branch 'master' into feature/xwm-selection
Diffstat (limited to 'include/wlr')
-rw-r--r--include/wlr/types/wlr_list.h71
-rw-r--r--include/wlr/xwayland.h2
2 files changed, 43 insertions, 30 deletions
diff --git a/include/wlr/types/wlr_list.h b/include/wlr/types/wlr_list.h
index 8ddd30b6..78a30995 100644
--- a/include/wlr/types/wlr_list.h
+++ b/include/wlr/types/wlr_list.h
@@ -2,6 +2,7 @@
#define WLR_UTIL_LIST_H
#include <stddef.h>
+#include <stdbool.h>
struct wlr_list {
size_t capacity;
@@ -10,51 +11,65 @@ struct wlr_list {
};
/**
- * Creates a new list, may return `NULL` on failure
+ * Initialize a list. Returns true on success, false on failure.
*/
-struct wlr_list *wlr_list_create(void);
-void wlr_list_free(struct wlr_list *list);
-void wlr_list_foreach(struct wlr_list *list, void (*callback)(void *item));
+bool wlr_list_init(struct wlr_list *list);
+
/**
- * Add `item` to the end of a list.
- * Returns: new list length or `-1` on failure
+ * Deinitialize a list.
*/
-int wlr_list_add(struct wlr_list *list, void *item);
+void wlr_list_finish(struct wlr_list *list);
+
+/**
+ * Executes `callback` on each element in the list.
+ */
+void wlr_list_for_each(struct wlr_list *list, void (*callback)(void *item));
+
/**
* Add `item` to the end of a list.
- * Returns: new list length or `-1` on failure
+ * Returns: new list length or `-1` on failure.
*/
-int wlr_list_push(struct wlr_list *list, void *item);
+ssize_t wlr_list_push(struct wlr_list *list, void *item);
+
/**
- * Place `item` into index `index` in the list
- * Returns: new list length or `-1` on failure
+ * Place `item` into index `index` in the list.
+ * Returns: new list length or `-1` on failure.
*/
-int wlr_list_insert(struct wlr_list *list, size_t index, void *item);
+ssize_t wlr_list_insert(struct wlr_list *list, size_t index, void *item);
+
/**
- * Remove an item from the list
+ * Remove an item from the list.
*/
void wlr_list_del(struct wlr_list *list, size_t index);
+
/**
- * Remove and return an item from the end of the list
+ * Remove and return an item from the end of the list.
*/
void *wlr_list_pop(struct wlr_list *list);
+
/**
- * Get a reference to the last item of a list without removal
+ * Get a reference to the last item of a list without removal.
*/
void *wlr_list_peek(struct wlr_list *list);
+
+/**
+ * Append each item in `source` to `list`.
+ * Does not modify `source`.
+ * Returns: new list length or `-1` on failure.
+ */
+ssize_t wlr_list_cat(struct wlr_list *list, const struct wlr_list *source);
+
/**
- * Append each item in `source` to `list`
- * Does not modify `source`
- * Returns: new list length or `-1` on failure
- */
-int wlr_list_cat(struct wlr_list *list, struct wlr_list *source);
-// See qsort. Remember to use *_qsort functions as compare functions,
-// because they dereference the left and right arguments first!
-void wlr_list_qsort(struct wlr_list *list, int compare(const void *left, const void *right));
-// Return index for first item in list that returns 0 for given compare
-// function or -1 if none matches.
-int wlr_list_seq_find(struct wlr_list *list,
- int compare(const void *item, const void *cmp_to),
- const void *cmp_to);
+ * Sort a list using `qsort`.
+ */
+void wlr_list_qsort(struct wlr_list *list,
+ int compare(const void *left, const void *right));
+
+/**
+ * Return the index of the first item in the list that returns 0 for the given
+ * `compare` function, or -1 if none matches.
+ */
+ssize_t wlr_list_find(struct wlr_list *list,
+ int compare(const void *item, const void *cmp_to), const void *cmp_to);
#endif
diff --git a/include/wlr/xwayland.h b/include/wlr/xwayland.h
index 6518b703..9b493d88 100644
--- a/include/wlr/xwayland.h
+++ b/include/wlr/xwayland.h
@@ -5,7 +5,6 @@
#include <stdbool.h>
#include <wlr/types/wlr_compositor.h>
#include <xcb/xcb.h>
-#include <wlr/types/wlr_list.h>
#ifdef HAS_XCB_ICCCM
#include <xcb/xcb_icccm.h>
@@ -86,7 +85,6 @@ struct wlr_xwayland_surface {
char *class;
char *instance;
struct wlr_xwayland_surface *parent;
- struct wlr_list *state; // list of xcb_atom_t
pid_t pid;
xcb_atom_t *window_type;