summaryrefslogtreecommitdiffstats
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.h148
1 files changed, 35 insertions, 113 deletions
diff --git a/include/sway/tree/container.h b/include/sway/tree/container.h
index e4071cfe..c51425c9 100644
--- a/include/sway/tree/container.h
+++ b/include/sway/tree/container.h
@@ -5,8 +5,7 @@
5#include <wlr/types/wlr_box.h> 5#include <wlr/types/wlr_box.h>
6#include <wlr/types/wlr_surface.h> 6#include <wlr/types/wlr_surface.h>
7#include "list.h" 7#include "list.h"
8 8#include "sway/tree/node.h"
9extern struct sway_container root_container;
10 9
11struct sway_view; 10struct sway_view;
12struct sway_seat; 11struct sway_seat;
@@ -17,23 +16,6 @@ struct sway_seat;
17#define TITLEBAR_H_PADDING 3 16#define TITLEBAR_H_PADDING 3
18#define TITLEBAR_V_PADDING 4 17#define TITLEBAR_V_PADDING 4
19 18
20/**
21 * Different kinds of containers.
22 *
23 * This enum is in order. A container will never be inside of a container below
24 * it on this list.
25 */
26enum sway_container_type {
27 C_ROOT,
28 C_OUTPUT,
29 C_WORKSPACE,
30 C_CONTAINER,
31 C_VIEW,
32
33 // Keep last
34 C_TYPES,
35};
36
37enum sway_container_layout { 19enum sway_container_layout {
38 L_NONE, 20 L_NONE,
39 L_HORIZ, 21 L_HORIZ,
@@ -57,18 +39,14 @@ enum movement_direction;
57enum wlr_direction; 39enum wlr_direction;
58 40
59struct sway_container_state { 41struct sway_container_state {
60 // Container/swayc properties 42 // Container properties
61 enum sway_container_layout layout; 43 enum sway_container_layout layout;
62 double swayc_x, swayc_y; 44 double con_x, con_y;
63 double swayc_width, swayc_height; 45 double con_width, con_height;
64 46
65 bool is_fullscreen; 47 bool is_fullscreen;
66 48
67 bool has_gaps; 49 struct sway_workspace *workspace;
68 double current_gaps;
69 double gaps_inner;
70 double gaps_outer;
71
72 struct sway_container *parent; 50 struct sway_container *parent;
73 list_t *children; 51 list_t *children;
74 52
@@ -86,35 +64,19 @@ struct sway_container_state {
86 bool border_left; 64 bool border_left;
87 bool border_right; 65 bool border_right;
88 bool using_csd; 66 bool using_csd;
89
90 // Workspace properties
91 struct sway_container *ws_fullscreen;
92 list_t *ws_floating;
93}; 67};
94 68
95struct sway_container { 69struct sway_container {
96 union { 70 struct sway_node node;
97 // TODO: Encapsulate state for other node types as well like C_CONTAINER 71 struct sway_view *view;
98 struct sway_root *sway_root;
99 struct sway_output *sway_output;
100 struct sway_workspace *sway_workspace;
101 struct sway_view *sway_view;
102 };
103
104 /**
105 * A unique ID to identify this container. Primarily used in the
106 * get_tree JSON output.
107 */
108 size_t id;
109 72
110 // The pending state is the main container properties, and the current state is in the below struct. 73 // The pending state is the main container properties, and the current state is in the below struct.
111 // This means most places of the code can refer to the main variables (pending state) and it'll just work. 74 // This means most places of the code can refer to the main variables (pending state) and it'll just work.
112 struct sway_container_state current; 75 struct sway_container_state current;
113 76
114 char *name; // The view's title (unformatted) 77 char *title; // The view's title (unformatted)
115 char *formatted_title; // The title displayed in the title bar 78 char *formatted_title; // The title displayed in the title bar
116 79
117 enum sway_container_type type;
118 enum sway_container_layout layout; 80 enum sway_container_layout layout;
119 enum sway_container_layout prev_split_layout; 81 enum sway_container_layout prev_split_layout;
120 82
@@ -132,14 +94,13 @@ struct sway_container {
132 94
133 // The gaps currently applied to the container. 95 // The gaps currently applied to the container.
134 double current_gaps; 96 double current_gaps;
135
136 bool has_gaps; 97 bool has_gaps;
137 double gaps_inner; 98 double gaps_inner;
138 double gaps_outer; 99 double gaps_outer;
139 100
140 list_t *children; 101 struct sway_workspace *workspace; // NULL when hidden in the scratchpad
141 102 struct sway_container *parent; // NULL if container in root of workspace
142 struct sway_container *parent; 103 list_t *children; // struct sway_container
143 104
144 // Outputs currently being intersected 105 // Outputs currently being intersected
145 list_t *outputs; // struct sway_output 106 list_t *outputs; // struct sway_output
@@ -157,42 +118,17 @@ struct sway_container {
157 struct wlr_texture *title_urgent; 118 struct wlr_texture *title_urgent;
158 size_t title_height; 119 size_t title_height;
159 120
160 // The number of transactions which reference this container.
161 size_t ntxnrefs;
162
163 // If this container is a view and is waiting for the client to respond to a
164 // configure then this will be populated, otherwise NULL.
165 struct sway_transaction_instruction *instruction;
166
167 bool destroying;
168
169 // If true, indicates that the container has pending state that differs from
170 // the current.
171 bool dirty;
172
173 struct { 121 struct {
174 struct wl_signal destroy; 122 struct wl_signal destroy;
175 } events; 123 } events;
176}; 124};
177 125
178struct sway_container *container_create(enum sway_container_type type); 126struct sway_container *container_create(struct sway_view *view);
179
180const char *container_type_to_str(enum sway_container_type type);
181
182/*
183 * Create a new view container. A view can be a child of a workspace container
184 * or a container container and are rendered in the order and structure of
185 * how they are attached to the tree.
186 */
187struct sway_container *container_view_create(
188 struct sway_container *sibling, struct sway_view *sway_view);
189 127
190void container_destroy(struct sway_container *con); 128void container_destroy(struct sway_container *con);
191 129
192void container_begin_destroy(struct sway_container *con); 130void container_begin_destroy(struct sway_container *con);
193 131
194struct sway_container *container_close(struct sway_container *container);
195
196/** 132/**
197 * Search a container's descendants a container based on test criteria. Returns 133 * Search a container's descendants a container based on test criteria. Returns
198 * the first container that passes the test. 134 * the first container that passes the test.
@@ -201,22 +137,16 @@ struct sway_container *container_find_child(struct sway_container *container,
201 bool (*test)(struct sway_container *view, void *data), void *data); 137 bool (*test)(struct sway_container *view, void *data), void *data);
202 138
203/** 139/**
204 * Finds a parent container with the given struct sway_containerype.
205 */
206struct sway_container *container_parent(struct sway_container *container,
207 enum sway_container_type type);
208
209/**
210 * Find a container at the given coordinates. Returns the the surface and 140 * Find a container at the given coordinates. Returns the the surface and
211 * surface-local coordinates of the given layout coordinates if the container 141 * surface-local coordinates of the given layout coordinates if the container
212 * is a view and the view contains a surface at those coordinates. 142 * is a view and the view contains a surface at those coordinates.
213 */ 143 */
214struct sway_container *container_at(struct sway_container *workspace, 144struct sway_container *container_at(struct sway_workspace *workspace,
215 double lx, double ly, struct wlr_surface **surface, 145 double lx, double ly, struct wlr_surface **surface,
216 double *sx, double *sy); 146 double *sx, double *sy);
217 147
218struct sway_container *tiling_container_at( 148struct sway_container *tiling_container_at(
219 struct sway_container *con, double lx, double ly, 149 struct sway_node *parent, double lx, double ly,
220 struct wlr_surface **surface, double *sx, double *sy); 150 struct wlr_surface **surface, double *sx, double *sy);
221 151
222void container_for_each_child(struct sway_container *container, 152void container_for_each_child(struct sway_container *container,
@@ -228,16 +158,11 @@ void container_for_each_child(struct sway_container *container,
228bool container_has_ancestor(struct sway_container *container, 158bool container_has_ancestor(struct sway_container *container,
229 struct sway_container *ancestor); 159 struct sway_container *ancestor);
230 160
231int container_count_descendants_of_type(struct sway_container *con,
232 enum sway_container_type type);
233
234void container_create_notify(struct sway_container *container);
235
236void container_update_textures_recursive(struct sway_container *con); 161void container_update_textures_recursive(struct sway_container *con);
237 162
238void container_damage_whole(struct sway_container *container); 163void container_damage_whole(struct sway_container *container);
239 164
240struct sway_container *container_reap_empty(struct sway_container *con); 165void container_reap_empty(struct sway_container *con);
241 166
242struct sway_container *container_flatten(struct sway_container *container); 167struct sway_container *container_flatten(struct sway_container *container);
243 168
@@ -248,11 +173,10 @@ void container_update_title_textures(struct sway_container *container);
248 */ 173 */
249void container_calculate_title_height(struct sway_container *container); 174void container_calculate_title_height(struct sway_container *container);
250 175
251/** 176size_t container_build_representation(enum sway_container_layout layout,
252 * Notify a container that a tree modification has changed in its children, 177 list_t *children, char *buffer);
253 * so the container can update its tree representation. 178
254 */ 179void container_update_representation(struct sway_container *container);
255void container_notify_subtree_changed(struct sway_container *container);
256 180
257/** 181/**
258 * Return the height of a regular title bar. 182 * Return the height of a regular title bar.
@@ -288,8 +212,7 @@ void container_floating_translate(struct sway_container *con,
288/** 212/**
289 * Choose an output for the floating container's new position. 213 * Choose an output for the floating container's new position.
290 */ 214 */
291struct sway_container *container_floating_find_output( 215struct sway_output *container_floating_find_output(struct sway_container *con);
292 struct sway_container *con);
293 216
294/** 217/**
295 * Move a floating container to a new layout-local position. 218 * Move a floating container to a new layout-local position.
@@ -302,12 +225,6 @@ void container_floating_move_to(struct sway_container *con,
302 */ 225 */
303void container_floating_move_to_center(struct sway_container *con); 226void container_floating_move_to_center(struct sway_container *con);
304 227
305/**
306 * Mark a container as dirty if it isn't already. Dirty containers will be
307 * included in the next transaction then unmarked as dirty.
308 */
309void container_set_dirty(struct sway_container *container);
310
311bool container_has_urgent_child(struct sway_container *container); 228bool container_has_urgent_child(struct sway_container *container);
312 229
313/** 230/**
@@ -342,10 +259,18 @@ void container_remove_gaps(struct sway_container *container);
342 259
343void container_add_gaps(struct sway_container *container); 260void container_add_gaps(struct sway_container *container);
344 261
262enum sway_container_layout container_parent_layout(struct sway_container *con);
263
264enum sway_container_layout container_current_parent_layout(
265 struct sway_container *con);
266
267list_t *container_get_siblings(const struct sway_container *container);
268
345int container_sibling_index(const struct sway_container *child); 269int container_sibling_index(const struct sway_container *child);
346 270
347void container_handle_fullscreen_reparent(struct sway_container *con, 271list_t *container_get_current_siblings(struct sway_container *container);
348 struct sway_container *old_parent); 272
273void container_handle_fullscreen_reparent(struct sway_container *con);
349 274
350void container_add_child(struct sway_container *parent, 275void container_add_child(struct sway_container *parent,
351 struct sway_container *child); 276 struct sway_container *child);
@@ -353,19 +278,16 @@ void container_add_child(struct sway_container *parent,
353void container_insert_child(struct sway_container *parent, 278void container_insert_child(struct sway_container *parent,
354 struct sway_container *child, int i); 279 struct sway_container *child, int i);
355 280
356struct sway_container *container_add_sibling(struct sway_container *parent, 281void container_add_sibling(struct sway_container *parent,
357 struct sway_container *child); 282 struct sway_container *child, int offset);
358 283
359struct sway_container *container_remove_child(struct sway_container *child); 284void container_detach(struct sway_container *child);
360 285
361struct sway_container *container_replace_child(struct sway_container *child, 286void container_replace(struct sway_container *container,
362 struct sway_container *new_child); 287 struct sway_container *replacement);
363 288
364bool sway_dir_to_wlr(enum movement_direction dir, enum wlr_direction *out); 289bool sway_dir_to_wlr(enum movement_direction dir, enum wlr_direction *out);
365 290
366enum sway_container_layout container_get_default_layout(
367 struct sway_container *con);
368
369struct sway_container *container_split(struct sway_container *child, 291struct sway_container *container_split(struct sway_container *child,
370 enum sway_container_layout layout); 292 enum sway_container_layout layout);
371 293