aboutsummaryrefslogtreecommitdiffstats
path: root/include/sway/tree/container.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/sway/tree/container.h')
-rw-r--r--include/sway/tree/container.h66
1 files changed, 51 insertions, 15 deletions
diff --git a/include/sway/tree/container.h b/include/sway/tree/container.h
index aff2e58e..fa22ea75 100644
--- a/include/sway/tree/container.h
+++ b/include/sway/tree/container.h
@@ -90,37 +90,61 @@ struct sway_container {
90 } events; 90 } events;
91}; 91};
92 92
93// TODO make private and use the container-specific create functions
94struct sway_container *container_create(enum sway_container_type type);
95
93const char *container_type_to_str(enum sway_container_type type); 96const char *container_type_to_str(enum sway_container_type type);
94 97
95// TODO only one container create function and pass the type? 98// TODO only one container create function and pass the type?
96struct sway_container *container_output_create( 99struct sway_container *container_output_create(
97 struct sway_output *sway_output); 100 struct sway_output *sway_output);
98 101
99struct sway_container *container_workspace_create( 102/**
100 struct sway_container *output, const char *name); 103 * Create a new container container. A container container can be a a child of
104 * a workspace container or another container container.
105 */
106struct sway_container *container_container_create();
101 107
102struct sway_container *container_view_create( 108/**
103 struct sway_container *sibling, struct sway_view *sway_view); 109 * Create a new output. Outputs are children of the root container and have no
110 * order in the tree structure.
111 */
112struct sway_container *container_output_create(struct sway_output *sway_output);
104 113
105struct sway_container *container_output_destroy(struct sway_container *output); 114/**
115 * Create a new workspace container. Workspaces are children of an output
116 * container and are ordered alphabetically by name.
117 */
118struct sway_container *container_workspace_create(struct sway_container *output, const char *name);
106 119
107struct sway_container *container_workspace_destroy( 120/*
108 struct sway_container *workspace); 121 * Create a new view container. A view can be a child of a workspace container
122 * or a container container and are rendered in the order and structure of
123 * how they are attached to the tree.
124 */
125// TODO view containers should be created in a detached state.
126struct sway_container *container_view_create(
127 struct sway_container *sibling, struct sway_view *sway_view);
109 128
110struct sway_container *container_view_destroy(struct sway_container *view); 129// TODO don't return the parent on destroy
130struct sway_container *container_destroy(struct sway_container *container);
111 131
112struct sway_container *container_destroy(struct sway_container *cont); 132struct sway_container *container_workspace_destroy(struct sway_container *container);
133struct sway_container *container_output_destroy(struct sway_container *container);
134struct sway_container *container_view_destroy(struct sway_container *container);
113 135
136// TODO move to layout.c
114struct sway_container *container_set_layout(struct sway_container *container, 137struct sway_container *container_set_layout(struct sway_container *container,
115 enum sway_container_layout layout); 138 enum sway_container_layout layout);
116 139
140// TODO rename to container_descendants_for_each()
117void container_descendants(struct sway_container *root, 141void container_descendants(struct sway_container *root,
118 enum sway_container_type type, 142 enum sway_container_type type,
119 void (*func)(struct sway_container *item, void *data), void *data); 143 void (*func)(struct sway_container *item, void *data), void *data);
120 144
121/** 145/**
122 * Finds a container based on test criteria. Returns the first container that 146 * Search a container's descendants a container based on test criteria. Returns
123 * passes the test. 147 * the first container that passes the test.
124 */ 148 */
125struct sway_container *container_find(struct sway_container *container, 149struct sway_container *container_find(struct sway_container *container,
126 bool (*test)(struct sway_container *view, void *data), void *data); 150 bool (*test)(struct sway_container *view, void *data), void *data);
@@ -128,18 +152,21 @@ struct sway_container *container_find(struct sway_container *container,
128/** 152/**
129 * Finds a parent container with the given struct sway_containerype. 153 * Finds a parent container with the given struct sway_containerype.
130 */ 154 */
155// TODO rename to container_parent_of_type()
131struct sway_container *container_parent(struct sway_container *container, 156struct sway_container *container_parent(struct sway_container *container,
132 enum sway_container_type type); 157 enum sway_container_type type);
133 158
134/** 159/**
135 * Find a container at the given coordinates. 160 * Find a container at the given coordinates. Returns the the surface and
161 * surface-local coordinates of the given layout coordinates if the container
162 * is a view and the view contains a surface at those coordinates.
136 */ 163 */
137struct sway_container *container_at(struct sway_container *parent, 164struct sway_container *container_at(struct sway_container *container,
138 double lx, double ly, struct wlr_surface **surface, 165 double lx, double ly, struct wlr_surface **surface,
139 double *sx, double *sy); 166 double *sx, double *sy);
140 167
141/** 168/**
142 * Apply the function for each child of the container breadth first. 169 * Apply the function for each descendant of the container breadth first.
143 */ 170 */
144void container_for_each_descendant_bfs(struct sway_container *container, 171void container_for_each_descendant_bfs(struct sway_container *container,
145 void (*f)(struct sway_container *container, void *data), void *data); 172 void (*f)(struct sway_container *container, void *data), void *data);
@@ -150,7 +177,16 @@ void container_for_each_descendant_bfs(struct sway_container *container,
150void container_for_each_descendant_dfs(struct sway_container *container, 177void container_for_each_descendant_dfs(struct sway_container *container,
151 void (*f)(struct sway_container *container, void *data), void *data); 178 void (*f)(struct sway_container *container, void *data), void *data);
152 179
153bool container_has_anscestor(struct sway_container *descendant, 180/**
181 * Returns true if the given container is an ancestor of this container.
182 */
183bool container_has_anscestor(struct sway_container *container,
154 struct sway_container *anscestor); 184 struct sway_container *anscestor);
155 185
186/**
187 * Returns true if the given container is a child descendant of this container.
188 */
189bool container_has_child(struct sway_container *con,
190 struct sway_container *child);
191
156#endif 192#endif