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.h109
1 files changed, 47 insertions, 62 deletions
diff --git a/include/sway/tree/container.h b/include/sway/tree/container.h
index 38ee68bd..93f6bfbb 100644
--- a/include/sway/tree/container.h
+++ b/include/sway/tree/container.h
@@ -2,7 +2,8 @@
2#define _SWAY_CONTAINER_H 2#define _SWAY_CONTAINER_H
3#include <stdint.h> 3#include <stdint.h>
4#include <sys/types.h> 4#include <sys/types.h>
5#include <wlr/types/wlr_surface.h> 5#include <wlr/types/wlr_compositor.h>
6#include <wlr/types/wlr_scene.h>
6#include "list.h" 7#include "list.h"
7#include "sway/tree/node.h" 8#include "sway/tree/node.h"
8 9
@@ -68,11 +69,39 @@ struct sway_container {
68 struct sway_node node; 69 struct sway_node node;
69 struct sway_view *view; 70 struct sway_view *view;
70 71
72 struct wlr_scene_tree *scene_tree;
73
74 struct {
75 struct wlr_scene_tree *tree;
76
77 struct wlr_scene_tree *border;
78 struct wlr_scene_tree *background;
79
80 struct sway_text_node *title_text;
81 struct sway_text_node *marks_text;
82 } title_bar;
83
84 struct {
85 struct wlr_scene_tree *tree;
86
87 struct wlr_scene_rect *top;
88 struct wlr_scene_rect *bottom;
89 struct wlr_scene_rect *left;
90 struct wlr_scene_rect *right;
91 } border;
92
93 struct wlr_scene_tree *content_tree;
94 struct wlr_scene_buffer *output_handler;
95
96 struct wl_listener output_enter;
97 struct wl_listener output_leave;
98
71 struct sway_container_state current; 99 struct sway_container_state current;
72 struct sway_container_state pending; 100 struct sway_container_state pending;
73 101
74 char *title; // The view's title (unformatted) 102 char *title; // The view's title (unformatted)
75 char *formatted_title; // The title displayed in the title bar 103 char *formatted_title; // The title displayed in the title bar
104 int title_width;
76 105
77 enum sway_container_layout prev_split_layout; 106 enum sway_container_layout prev_split_layout;
78 107
@@ -100,33 +129,19 @@ struct sway_container {
100 double child_total_width; 129 double child_total_width;
101 double child_total_height; 130 double child_total_height;
102 131
103 // In most cases this is the same as the content x and y, but if the view
104 // refuses to resize to the content dimensions then it can be smaller.
105 // These are in layout coordinates.
106 double surface_x, surface_y;
107
108 // Outputs currently being intersected
109 list_t *outputs; // struct sway_output
110
111 // Indicates that the container is a scratchpad container. 132 // Indicates that the container is a scratchpad container.
112 // Both hidden and visible scratchpad containers have scratchpad=true. 133 // Both hidden and visible scratchpad containers have scratchpad=true.
113 // Hidden scratchpad containers have a NULL parent. 134 // Hidden scratchpad containers have a NULL parent.
114 bool scratchpad; 135 bool scratchpad;
115 136
116 float alpha; 137 // Stores last output size and position for adjusting coordinates of
138 // scratchpad windows.
139 // Unused for non-scratchpad windows.
140 struct wlr_box transform;
117 141
118 struct wlr_texture *title_focused; 142 float alpha;
119 struct wlr_texture *title_focused_inactive;
120 struct wlr_texture *title_unfocused;
121 struct wlr_texture *title_urgent;
122 size_t title_height;
123 size_t title_baseline;
124 143
125 list_t *marks; // char * 144 list_t *marks; // char *
126 struct wlr_texture *marks_focused;
127 struct wlr_texture *marks_focused_inactive;
128 struct wlr_texture *marks_unfocused;
129 struct wlr_texture *marks_urgent;
130 145
131 struct { 146 struct {
132 struct wl_signal destroy; 147 struct wl_signal destroy;
@@ -146,19 +161,6 @@ void container_begin_destroy(struct sway_container *con);
146struct sway_container *container_find_child(struct sway_container *container, 161struct sway_container *container_find_child(struct sway_container *container,
147 bool (*test)(struct sway_container *view, void *data), void *data); 162 bool (*test)(struct sway_container *view, void *data), void *data);
148 163
149/**
150 * Find a container at the given coordinates. Returns the surface and
151 * surface-local coordinates of the given layout coordinates if the container
152 * is a view and the view contains a surface at those coordinates.
153 */
154struct sway_container *container_at(struct sway_workspace *workspace,
155 double lx, double ly, struct wlr_surface **surface,
156 double *sx, double *sy);
157
158struct sway_container *tiling_container_at(
159 struct sway_node *parent, double lx, double ly,
160 struct wlr_surface **surface, double *sx, double *sy);
161
162void container_for_each_child(struct sway_container *container, 164void container_for_each_child(struct sway_container *container,
163 void (*f)(struct sway_container *container, void *data), void *data); 165 void (*f)(struct sway_container *container, void *data), void *data);
164 166
@@ -175,18 +177,13 @@ bool container_has_ancestor(struct sway_container *container,
175 177
176void container_update_textures_recursive(struct sway_container *con); 178void container_update_textures_recursive(struct sway_container *con);
177 179
178void container_damage_whole(struct sway_container *container);
179
180void container_reap_empty(struct sway_container *con); 180void container_reap_empty(struct sway_container *con);
181 181
182struct sway_container *container_flatten(struct sway_container *container); 182struct sway_container *container_flatten(struct sway_container *container);
183 183
184void container_update_title_textures(struct sway_container *container); 184void container_update_title_bar(struct sway_container *container);
185 185
186/** 186void container_update_marks(struct sway_container *container);
187 * Calculate the container's title_height property.
188 */
189void container_calculate_title_height(struct sway_container *container);
190 187
191size_t container_build_representation(enum sway_container_layout layout, 188size_t container_build_representation(enum sway_container_layout layout,
192 list_t *children, char *buffer); 189 list_t *children, char *buffer);
@@ -201,6 +198,9 @@ size_t container_titlebar_height(void);
201void floating_calculate_constraints(int *min_width, int *max_width, 198void floating_calculate_constraints(int *min_width, int *max_width,
202 int *min_height, int *max_height); 199 int *min_height, int *max_height);
203 200
201void floating_fix_coordinates(struct sway_container *con,
202 struct wlr_box *old, struct wlr_box *new);
203
204void container_floating_resize_and_center(struct sway_container *con); 204void container_floating_resize_and_center(struct sway_container *con);
205 205
206void container_floating_set_default_size(struct sway_container *con); 206void container_floating_set_default_size(struct sway_container *con);
@@ -220,11 +220,6 @@ void container_set_geometry_from_content(struct sway_container *con);
220bool container_is_floating(struct sway_container *container); 220bool container_is_floating(struct sway_container *container);
221 221
222/** 222/**
223 * Same as above, but for current container state.
224 */
225bool container_is_current_floating(struct sway_container *container);
226
227/**
228 * Get a container's box in layout coordinates. 223 * Get a container's box in layout coordinates.
229 */ 224 */
230void container_get_box(struct sway_container *container, struct wlr_box *box); 225void container_get_box(struct sway_container *container, struct wlr_box *box);
@@ -286,26 +281,12 @@ bool container_is_floating_or_child(struct sway_container *container);
286 */ 281 */
287bool container_is_fullscreen_or_child(struct sway_container *container); 282bool container_is_fullscreen_or_child(struct sway_container *container);
288 283
289/**
290 * Return the output which will be used for scale purposes.
291 * This is the most recently entered output.
292 * If the container is not on any output, return NULL.
293 */
294struct sway_output *container_get_effective_output(struct sway_container *con);
295
296void container_discover_outputs(struct sway_container *con);
297
298enum sway_container_layout container_parent_layout(struct sway_container *con); 284enum sway_container_layout container_parent_layout(struct sway_container *con);
299 285
300enum sway_container_layout container_current_parent_layout(
301 struct sway_container *con);
302
303list_t *container_get_siblings(struct sway_container *container); 286list_t *container_get_siblings(struct sway_container *container);
304 287
305int container_sibling_index(struct sway_container *child); 288int container_sibling_index(struct sway_container *child);
306 289
307list_t *container_get_current_siblings(struct sway_container *container);
308
309void container_handle_fullscreen_reparent(struct sway_container *con); 290void container_handle_fullscreen_reparent(struct sway_container *con);
310 291
311void container_add_child(struct sway_container *parent, 292void container_add_child(struct sway_container *parent,
@@ -353,8 +334,6 @@ bool container_has_mark(struct sway_container *container, char *mark);
353 334
354void container_add_mark(struct sway_container *container, char *mark); 335void container_add_mark(struct sway_container *container, char *mark);
355 336
356void container_update_marks_textures(struct sway_container *container);
357
358void container_raise_floating(struct sway_container *con); 337void container_raise_floating(struct sway_container *con);
359 338
360bool container_is_scratchpad_hidden(struct sway_container *con); 339bool container_is_scratchpad_hidden(struct sway_container *con);
@@ -369,7 +348,7 @@ bool container_is_sticky_or_child(struct sway_container *con);
369 * This will destroy pairs of redundant H/V splits 348 * This will destroy pairs of redundant H/V splits
370 * e.g. H[V[H[app app]] app] -> H[app app app] 349 * e.g. H[V[H[app app]] app] -> H[app app app]
371 * The middle "V[H[" are eliminated by a call to container_squash 350 * The middle "V[H[" are eliminated by a call to container_squash
372 * on the V[ con. It's grandchildren are added to it's parent. 351 * on the V[ con. It's grandchildren are added to its parent.
373 * 352 *
374 * This function is roughly equivalent to i3's tree_flatten here: 353 * This function is roughly equivalent to i3's tree_flatten here:
375 * https://github.com/i3/i3/blob/1f0c628cde40cf87371481041b7197344e0417c6/src/tree.c#L651 354 * https://github.com/i3/i3/blob/1f0c628cde40cf87371481041b7197344e0417c6/src/tree.c#L651
@@ -378,4 +357,10 @@ bool container_is_sticky_or_child(struct sway_container *con);
378 */ 357 */
379int container_squash(struct sway_container *con); 358int container_squash(struct sway_container *con);
380 359
360void container_arrange_title_bar(struct sway_container *con);
361
362void container_update(struct sway_container *con);
363
364void container_update_itself_and_parents(struct sway_container *con);
365
381#endif 366#endif