aboutsummaryrefslogtreecommitdiffstats
path: root/include/sway/container.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/sway/container.h')
-rw-r--r--include/sway/container.h357
1 files changed, 0 insertions, 357 deletions
diff --git a/include/sway/container.h b/include/sway/container.h
deleted file mode 100644
index 37192ce3..00000000
--- a/include/sway/container.h
+++ /dev/null
@@ -1,357 +0,0 @@
1#ifndef _SWAY_CONTAINER_H
2#define _SWAY_CONTAINER_H
3#include <sys/types.h>
4#include <wlc/wlc.h>
5#include <stdint.h>
6
7#include "list.h"
8
9typedef struct sway_container swayc_t;
10
11extern swayc_t root_container;
12extern swayc_t *current_focus;
13
14/**
15 * Different kinds of containers.
16 *
17 * This enum is in order. A container will never be inside of a container below
18 * it on this list.
19 */
20enum swayc_types {
21 C_ROOT, /**< The root container. Only one of these ever exists. */
22 C_OUTPUT, /**< An output (aka monitor, head, etc). */
23 C_WORKSPACE, /**< A workspace. */
24 C_CONTAINER, /**< A manually created container. */
25 C_VIEW, /**< A view (aka window). */
26 // Keep last
27 C_TYPES,
28};
29
30/**
31 * Different ways to arrange a container.
32 */
33enum swayc_layouts {
34 L_NONE, /**< Used for containers that have no layout (views, root) */
35 L_HORIZ,
36 L_VERT,
37 L_STACKED,
38 L_TABBED,
39 L_FLOATING, /**< A psuedo-container, removed from the tree, to hold floating windows */
40
41 /* Awesome/Monad style auto layouts */
42 L_AUTO_LEFT,
43 L_AUTO_RIGHT,
44 L_AUTO_TOP,
45 L_AUTO_BOTTOM,
46
47 L_AUTO_FIRST = L_AUTO_LEFT,
48 L_AUTO_LAST = L_AUTO_BOTTOM,
49
50 // Keep last
51 L_LAYOUTS,
52};
53
54enum swayc_border_types {
55 B_NONE, /**< No border */
56 B_PIXEL, /**< 1px border */
57 B_NORMAL /**< Normal border with title bar */
58};
59
60/**
61 * Stores information about a container.
62 *
63 * The tree is made of these. Views are containers that cannot have children.
64 */
65struct sway_container {
66 /**
67 * If this container maps to a WLC object, this is set to that object's
68 * handle. Otherwise, NULL.
69 */
70 wlc_handle handle;
71
72 /**
73 * A unique ID to identify this container. Primarily used in the
74 * get_tree JSON output.
75 */
76 size_t id;
77
78 enum swayc_types type;
79 enum swayc_layouts layout;
80 enum swayc_layouts prev_layout;
81 enum swayc_layouts workspace_layout;
82
83 /**
84 * Width and height of this container, without borders or gaps.
85 */
86 double width, height;
87
88 /**
89 * Views may request geometry, which is stored in this and ignored until
90 * the views are floated.
91 */
92 int desired_width, desired_height;
93
94 /**
95 * The coordinates that this view appear at, relative to the output they
96 * are located on (output containers have absolute coordinates).
97 */
98 double x, y;
99
100 /**
101 * Cached geometry used to store view/container geometry when switching
102 * between tabbed/stacked and horizontal/vertical layouts.
103 */
104 struct wlc_geometry cached_geometry;
105
106 /**
107 * False if this view is invisible. It could be in the scratchpad or on a
108 * workspace that is not shown.
109 */
110 bool visible;
111 bool is_floating;
112 bool is_focused;
113 bool sticky; // floating view always visible on its output
114
115 // Attributes that mostly views have.
116 char *name;
117 char *class;
118 char *instance;
119 char *app_id;
120
121 // Used by output containers to keep track of swaybg child processes.
122 pid_t bg_pid;
123
124 int gaps;
125
126 list_t *children;
127 /**
128 * Children of this container that are floated.
129 */
130 list_t *floating;
131 /**
132 * Unmanaged view handles in this container.
133 */
134 list_t *unmanaged;
135
136 /**
137 * The parent of this container. NULL for the root container.
138 */
139 struct sway_container *parent;
140 /**
141 * Which of this container's children has focus.
142 */
143 struct sway_container *focused;
144 /**
145 * If this container's children include a fullscreen view, this is that view.
146 */
147 struct sway_container *fullscreen;
148 /**
149 * If this container is a view, this may be set to the window's decoration
150 * buffer (or NULL).
151 */
152 struct border *border;
153 enum swayc_border_types border_type;
154 struct wlc_geometry border_geometry;
155 struct wlc_geometry title_bar_geometry;
156 struct wlc_geometry actual_geometry;
157 int border_thickness;
158
159 /**
160 * Number of master views in auto layouts.
161 */
162 size_t nb_master;
163
164 /**
165 * Number of slave groups (e.g. columns) in auto layouts.
166 */
167 size_t nb_slave_groups;
168
169 /**
170 * Marks applied to the container, list_t of char*.
171 */
172 list_t *marks;
173};
174
175enum visibility_mask {
176 VISIBLE = true
177} visible;
178
179/**
180 * Allocates a new output container.
181 */
182swayc_t *new_output(wlc_handle handle);
183/**
184 * Allocates a new workspace container.
185 */
186swayc_t *new_workspace(swayc_t *output, const char *name);
187/**
188 * Allocates a new container and places a child into it.
189 *
190 * This is used from the split command, which creates a new container with the
191 * requested layout and replaces the focused container in the tree with the new
192 * one. Then the removed container is added as a child of the new container.
193 */
194swayc_t *new_container(swayc_t *child, enum swayc_layouts layout);
195/**
196 * Allocates a new view container.
197 *
198 * Pass in a sibling view, or a workspace to become this container's parent.
199 */
200swayc_t *new_view(swayc_t *sibling, wlc_handle handle);
201/**
202 * Allocates a new floating view in the active workspace.
203 */
204swayc_t *new_floating_view(wlc_handle handle);
205
206void floating_view_sane_size(swayc_t *view);
207
208/**
209 * Frees an output's container.
210 */
211swayc_t *destroy_output(swayc_t *output);
212/**
213 * Destroys a workspace container and returns the parent pointer, or NULL.
214 */
215swayc_t *destroy_workspace(swayc_t *workspace);
216/**
217 * Destroys a container and all empty parents. Returns the topmost non-empty
218 * parent container, or NULL.
219 */
220swayc_t *destroy_container(swayc_t *container);
221/**
222 * Destroys a view container and all empty parents. Returns the topmost
223 * non-empty parent container, or NULL.
224 */
225swayc_t *destroy_view(swayc_t *view);
226
227/**
228 * Finds a container based on test criteria. Returns the first container that
229 * passes the test.
230 */
231swayc_t *swayc_by_test(swayc_t *container, bool (*test)(swayc_t *view, void *data), void *data);
232/**
233 * Finds a parent container with the given swayc_type.
234 */
235swayc_t *swayc_parent_by_type(swayc_t *container, enum swayc_types);
236/**
237 * Finds a parent with the given swayc_layout.
238 */
239swayc_t *swayc_parent_by_layout(swayc_t *container, enum swayc_layouts);
240/**
241 * Finds the bottom-most focused container of a type.
242 */
243swayc_t *swayc_focus_by_type(swayc_t *container, enum swayc_types);
244/**
245 * Finds the bottom-most focused container of a layout.
246 */
247swayc_t *swayc_focus_by_layout(swayc_t *container, enum swayc_layouts);
248
249/**
250 * Gets the swayc_t associated with a wlc_handle.
251 */
252swayc_t *swayc_by_handle(wlc_handle handle);
253/**
254 * Gets the named swayc_t.
255 */
256swayc_t *swayc_by_name(const char *name);
257/**
258 * Gets the active output's container.
259 */
260swayc_t *swayc_active_output(void);
261/**
262 * Gets the active workspace's container.
263 */
264swayc_t *swayc_active_workspace(void);
265/**
266 * Gets the workspace for the given view container.
267 */
268swayc_t *swayc_active_workspace_for(swayc_t *view);
269/**
270 * Finds the container currently underneath the pointer.
271 */
272swayc_t *container_under_pointer(void);
273/**
274 * Finds the first container following a callback.
275 */
276swayc_t *container_find(swayc_t *container, bool (*f)(swayc_t *, const void *), const void *data);
277
278/**
279 * Returns true if a container is fullscreen.
280 */
281bool swayc_is_fullscreen(swayc_t *view);
282/**
283 * Returns true if this view is focused.
284 */
285bool swayc_is_active(swayc_t *view);
286/**
287 * Returns true if the parent is an ancestor of the child.
288 */
289bool swayc_is_parent_of(swayc_t *parent, swayc_t *child);
290/**
291 * Returns true if the child is a desecendant of the parent.
292 */
293bool swayc_is_child_of(swayc_t *child, swayc_t *parent);
294
295/**
296 * Returns true if this container is an empty workspace.
297 */
298bool swayc_is_empty_workspace(swayc_t *container);
299
300/**
301 * Returns the top most tabbed or stacked parent container. Returns NULL if
302 * view is not in a tabbed/stacked layout.
303 */
304swayc_t *swayc_tabbed_stacked_ancestor(swayc_t *view);
305
306/**
307 * Returns the immediate tabbed or stacked parent container. Returns NULL if
308 * view is not directly in a tabbed/stacked layout.
309 */
310swayc_t *swayc_tabbed_stacked_parent(swayc_t *view);
311
312/**
313 * Returns the gap (padding) of the container.
314 *
315 * This returns the inner gaps for a view, the outer gaps for a workspace, and
316 * 0 otherwise.
317 */
318int swayc_gap(swayc_t *container);
319
320/**
321 * Maps a container's children over a function.
322 */
323void container_map(swayc_t *, void (*f)(swayc_t *, void *), void *);
324
325/**
326 * Set a view as visible or invisible.
327 *
328 * This will perform the required wlc calls as well; it is not sufficient to
329 * simply toggle the boolean in swayc_t.
330 */
331void set_view_visibility(swayc_t *view, void *data);
332/**
333 * Set the gaps value for a view.
334 */
335void set_gaps(swayc_t *view, void *amount);
336/**
337 * Add to the gaps value for a view.
338 */
339void add_gaps(swayc_t *view, void *amount);
340
341/**
342 * Issue wlc calls to make the visibility of a container consistent.
343 */
344void update_visibility(swayc_t *container);
345
346/**
347 * Close all child views of container
348 */
349void close_views(swayc_t *container);
350
351/**
352 * Assign layout to a container. Needed due to workspace container specifics.
353 * Workspace should always have either L_VERT or L_HORIZ layout.
354 */
355swayc_t *swayc_change_layout(swayc_t *container, enum swayc_layouts layout);
356
357#endif