diff options
author | Tony Crisci <tony@dubstepdish.com> | 2018-03-31 20:52:34 -0400 |
---|---|---|
committer | Tony Crisci <tony@dubstepdish.com> | 2018-03-31 20:52:34 -0400 |
commit | 81556f4b2aad49c21058d9cc9695195a12f0239b (patch) | |
tree | 3c2af5ae9f17c0749f6e0c33a9cbf6ec0070a7b1 /include/sway/tree/container.h | |
parent | fix children list segfault (diff) | |
download | sway-81556f4b2aad49c21058d9cc9695195a12f0239b.tar.gz sway-81556f4b2aad49c21058d9cc9695195a12f0239b.tar.zst sway-81556f4b2aad49c21058d9cc9695195a12f0239b.zip |
add docstrings and todos
Diffstat (limited to 'include/sway/tree/container.h')
-rw-r--r-- | include/sway/tree/container.h | 63 |
1 files changed, 45 insertions, 18 deletions
diff --git a/include/sway/tree/container.h b/include/sway/tree/container.h index 285f1011..f0e87fb5 100644 --- a/include/sway/tree/container.h +++ b/include/sway/tree/container.h | |||
@@ -87,37 +87,55 @@ struct sway_container { | |||
87 | } events; | 87 | } events; |
88 | }; | 88 | }; |
89 | 89 | ||
90 | // TODO make private and use the container-specific create functions | ||
90 | struct sway_container *container_create(enum sway_container_type type); | 91 | struct sway_container *container_create(enum sway_container_type type); |
91 | 92 | ||
92 | // TODO only one container create function and pass the type? | 93 | /** |
93 | struct sway_container *container_output_create( | 94 | * Create a new container container. A container container can be a a child of |
94 | struct sway_output *sway_output); | 95 | * a workspace container or another container container. |
96 | */ | ||
97 | struct sway_container *container_container_create(); | ||
95 | 98 | ||
96 | struct sway_container *container_workspace_create( | 99 | /** |
97 | struct sway_container *output, const char *name); | 100 | * Create a new output. Outputs are children of the root container and have no |
101 | * order in the tree structure. | ||
102 | */ | ||
103 | struct sway_container *container_output_create(struct sway_output *sway_output); | ||
104 | |||
105 | /** | ||
106 | * Create a new workspace container. Workspaces are children of an output | ||
107 | * container and are ordered alphabetically by name. | ||
108 | */ | ||
109 | struct sway_container *container_workspace_create(struct sway_container *output, const char *name); | ||
98 | 110 | ||
111 | /* | ||
112 | * Create a new view container. A view can be a child of a workspace container | ||
113 | * or a container container and are rendered in the order and structure of | ||
114 | * how they are attached to the tree. | ||
115 | */ | ||
116 | // TODO view containers should be created in a detached state. | ||
99 | struct sway_container *container_view_create( | 117 | struct sway_container *container_view_create( |
100 | struct sway_container *sibling, struct sway_view *sway_view); | 118 | struct sway_container *sibling, struct sway_view *sway_view); |
101 | 119 | ||
102 | struct sway_container *container_output_destroy(struct sway_container *output); | 120 | // TODO don't return the parent on destroy |
103 | 121 | struct sway_container *container_destroy(struct sway_container *container); | |
104 | struct sway_container *container_workspace_destroy( | ||
105 | struct sway_container *workspace); | ||
106 | 122 | ||
107 | struct sway_container *container_view_destroy(struct sway_container *view); | 123 | struct sway_container *container_workspace_destroy(struct sway_container *container); |
108 | 124 | struct sway_container *container_output_destroy(struct sway_container *container); | |
109 | struct sway_container *container_destroy(struct sway_container *cont); | 125 | struct sway_container *container_view_destroy(struct sway_container *container); |
110 | 126 | ||
127 | // TODO move to layout.c | ||
111 | struct sway_container *container_set_layout(struct sway_container *container, | 128 | struct sway_container *container_set_layout(struct sway_container *container, |
112 | enum sway_container_layout layout); | 129 | enum sway_container_layout layout); |
113 | 130 | ||
131 | // TODO rename to container_descendants_for_each() | ||
114 | void container_descendants(struct sway_container *root, | 132 | void container_descendants(struct sway_container *root, |
115 | enum sway_container_type type, | 133 | enum sway_container_type type, |
116 | void (*func)(struct sway_container *item, void *data), void *data); | 134 | void (*func)(struct sway_container *item, void *data), void *data); |
117 | 135 | ||
118 | /** | 136 | /** |
119 | * Finds a container based on test criteria. Returns the first container that | 137 | * Search a container's descendants a container based on test criteria. Returns |
120 | * passes the test. | 138 | * the first container that passes the test. |
121 | */ | 139 | */ |
122 | struct sway_container *container_find(struct sway_container *container, | 140 | struct sway_container *container_find(struct sway_container *container, |
123 | bool (*test)(struct sway_container *view, void *data), void *data); | 141 | bool (*test)(struct sway_container *view, void *data), void *data); |
@@ -125,18 +143,21 @@ struct sway_container *container_find(struct sway_container *container, | |||
125 | /** | 143 | /** |
126 | * Finds a parent container with the given struct sway_containerype. | 144 | * Finds a parent container with the given struct sway_containerype. |
127 | */ | 145 | */ |
146 | // TODO rename to container_parent_of_type() | ||
128 | struct sway_container *container_parent(struct sway_container *container, | 147 | struct sway_container *container_parent(struct sway_container *container, |
129 | enum sway_container_type type); | 148 | enum sway_container_type type); |
130 | 149 | ||
131 | /** | 150 | /** |
132 | * Find a container at the given coordinates. | 151 | * Find a container at the given coordinates. Returns the the surface and |
152 | * surface-local coordinates of the given layout coordinates if the container | ||
153 | * is a view and the view contains a surface at those coordinates. | ||
133 | */ | 154 | */ |
134 | struct sway_container *container_at(struct sway_container *parent, | 155 | struct sway_container *container_at(struct sway_container *container, |
135 | double lx, double ly, struct wlr_surface **surface, | 156 | double lx, double ly, struct wlr_surface **surface, |
136 | double *sx, double *sy); | 157 | double *sx, double *sy); |
137 | 158 | ||
138 | /** | 159 | /** |
139 | * Apply the function for each child of the container breadth first. | 160 | * Apply the function for each descendant of the container breadth first. |
140 | */ | 161 | */ |
141 | void container_for_each_descendant_bfs(struct sway_container *container, | 162 | void container_for_each_descendant_bfs(struct sway_container *container, |
142 | void (*f)(struct sway_container *container, void *data), void *data); | 163 | void (*f)(struct sway_container *container, void *data), void *data); |
@@ -147,9 +168,15 @@ void container_for_each_descendant_bfs(struct sway_container *container, | |||
147 | void container_for_each_descendant_dfs(struct sway_container *container, | 168 | void container_for_each_descendant_dfs(struct sway_container *container, |
148 | void (*f)(struct sway_container *container, void *data), void *data); | 169 | void (*f)(struct sway_container *container, void *data), void *data); |
149 | 170 | ||
150 | bool container_has_anscestor(struct sway_container *descendant, | 171 | /** |
172 | * Returns true if the given container is an ancestor of this container. | ||
173 | */ | ||
174 | bool container_has_anscestor(struct sway_container *container, | ||
151 | struct sway_container *anscestor); | 175 | struct sway_container *anscestor); |
152 | 176 | ||
177 | /** | ||
178 | * Returns true if the given container is a child descendant of this container. | ||
179 | */ | ||
153 | bool container_has_child(struct sway_container *con, | 180 | bool container_has_child(struct sway_container *con, |
154 | struct sway_container *child); | 181 | struct sway_container *child); |
155 | 182 | ||