diff options
author | Drew DeVault <sir@cmpwn.com> | 2018-03-30 00:02:29 -0400 |
---|---|---|
committer | Drew DeVault <sir@cmpwn.com> | 2018-03-30 00:04:04 -0400 |
commit | f26ecd9f58bb672fe107660ce9b37f4bf0777a8c (patch) | |
tree | 997658454de40db3f8b76b68d658efaf2b686188 /include/sway/tree/container.h | |
parent | d8104db8f1820bd3d4db8bf4f1ee51ae334ee6e7 (diff) | |
parent | 7162b9bea4d66d61376ad3605e23e2d83bb95201 (diff) |
Merge remote-tracking branch 'origin/wlroots' into swaybar-layers
Diffstat (limited to 'include/sway/tree/container.h')
-rw-r--r-- | include/sway/tree/container.h | 143 |
1 files changed, 143 insertions, 0 deletions
diff --git a/include/sway/tree/container.h b/include/sway/tree/container.h new file mode 100644 index 00000000..3bb497db --- /dev/null +++ b/include/sway/tree/container.h @@ -0,0 +1,143 @@ +#ifndef _SWAY_CONTAINER_H +#define _SWAY_CONTAINER_H +#include <stdint.h> +#include <sys/types.h> +#include <wlr/types/wlr_box.h> +#include <wlr/types/wlr_surface.h> +#include "list.h" + +extern struct sway_container root_container; + +struct sway_view; +struct sway_seat; + +/** + * Different kinds of containers. + * + * This enum is in order. A container will never be inside of a container below + * it on this list. + */ +enum sway_container_type { + C_ROOT, + C_OUTPUT, + C_WORKSPACE, + C_CONTAINER, + C_VIEW, + + C_TYPES, +}; + +enum sway_container_layout { + L_NONE, + L_HORIZ, + L_VERT, + L_STACKED, + L_TABBED, + L_FLOATING, + + // Keep last + L_LAYOUTS, +}; + +enum sway_container_border { + B_NONE, + B_PIXEL, + B_NORMAL, +}; + +struct sway_root; +struct sway_output; +struct sway_view; + +struct sway_container { + union { + // TODO: Encapsulate state for other node types as well like C_CONTAINER + struct sway_root *sway_root; + struct sway_output *sway_output; + struct sway_view *sway_view; + }; + + /** + * A unique ID to identify this container. Primarily used in the + * get_tree JSON output. + */ + size_t id; + + char *name; + + enum sway_container_type type; + enum sway_container_layout layout; + enum sway_container_layout prev_layout; + enum sway_container_layout workspace_layout; + + // TODO convert to layout coordinates + double x, y; + + // does not include borders or gaps. + double width, height; + + list_t *children; + + struct sway_container *parent; + + list_t *marks; // list of char* + + struct { + struct wl_signal destroy; + } events; +}; + +// TODO only one container create function and pass the type? +struct sway_container *container_output_create( + struct sway_output *sway_output); + +struct sway_container *container_workspace_create( + struct sway_container *output, const char *name); + +struct sway_container *container_view_create( + struct sway_container *sibling, struct sway_view *sway_view); + +struct sway_container *container_output_destroy(struct sway_container *output); + +struct sway_container *container_view_destroy(struct sway_container *view); + +struct sway_container *container_set_layout(struct sway_container *container, + enum sway_container_layout layout); + +void container_descendants(struct sway_container *root, + enum sway_container_type type, + void (*func)(struct sway_container *item, void *data), void *data); + +/** + * Finds a container based on test criteria. Returns the first container that + * passes the test. + */ +struct sway_container *container_find(struct sway_container *container, + bool (*test)(struct sway_container *view, void *data), void *data); + +/** + * Finds a parent container with the given struct sway_containerype. + */ +struct sway_container *container_parent(struct sway_container *container, + enum sway_container_type type); + +/** + * Find a container at the given coordinates. + */ +struct sway_container *container_at(struct sway_container *parent, + double lx, double ly, struct wlr_surface **surface, + double *sx, double *sy); + +/** + * Apply the function for each child of the container breadth first. + */ +void container_for_each_descendant_bfs(struct sway_container *container, + void (*f)(struct sway_container *container, void *data), void *data); + +/** + * Apply the function for each child of the container depth first. + */ +void container_for_each_descendant_dfs(struct sway_container *container, + void (*f)(struct sway_container *container, void *data), void *data); + +#endif |