diff options
Diffstat (limited to 'include/sway/tree/container.h')
-rw-r--r-- | include/sway/tree/container.h | 150 |
1 files changed, 63 insertions, 87 deletions
diff --git a/include/sway/tree/container.h b/include/sway/tree/container.h index 7e9df59f..93f6bfbb 100644 --- a/include/sway/tree/container.h +++ b/include/sway/tree/container.h | |||
@@ -2,8 +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_box.h> | 5 | #include <wlr/types/wlr_compositor.h> |
6 | #include <wlr/types/wlr_surface.h> | 6 | #include <wlr/types/wlr_scene.h> |
7 | #include "list.h" | 7 | #include "list.h" |
8 | #include "sway/tree/node.h" | 8 | #include "sway/tree/node.h" |
9 | 9 | ||
@@ -46,9 +46,9 @@ struct sway_container_state { | |||
46 | 46 | ||
47 | enum sway_fullscreen_mode fullscreen_mode; | 47 | enum sway_fullscreen_mode fullscreen_mode; |
48 | 48 | ||
49 | struct sway_workspace *workspace; | 49 | struct sway_workspace *workspace; // NULL when hidden in the scratchpad |
50 | struct sway_container *parent; | 50 | struct sway_container *parent; // NULL if container in root of workspace |
51 | list_t *children; | 51 | list_t *children; // struct sway_container |
52 | 52 | ||
53 | struct sway_container *focused_inactive_child; | 53 | struct sway_container *focused_inactive_child; |
54 | bool focused; | 54 | bool focused; |
@@ -60,6 +60,7 @@ struct sway_container_state { | |||
60 | bool border_left; | 60 | bool border_left; |
61 | bool border_right; | 61 | bool border_right; |
62 | 62 | ||
63 | // These are in layout coordinates. | ||
63 | double content_x, content_y; | 64 | double content_x, content_y; |
64 | double content_width, content_height; | 65 | double content_width, content_height; |
65 | }; | 66 | }; |
@@ -68,14 +69,40 @@ 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 | ||
71 | // The pending state is the main container properties, and the current state is in the below struct. | 72 | struct wlr_scene_tree *scene_tree; |
72 | // This means most places of the code can refer to the main variables (pending state) and it'll just work. | 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 | |||
73 | struct sway_container_state current; | 99 | struct sway_container_state current; |
100 | struct sway_container_state pending; | ||
74 | 101 | ||
75 | char *title; // The view's title (unformatted) | 102 | char *title; // The view's title (unformatted) |
76 | 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; | ||
77 | 105 | ||
78 | enum sway_container_layout layout; | ||
79 | enum sway_container_layout prev_split_layout; | 106 | enum sway_container_layout prev_split_layout; |
80 | 107 | ||
81 | // Whether stickiness has been enabled on this container. Use | 108 | // Whether stickiness has been enabled on this container. Use |
@@ -86,11 +113,13 @@ struct sway_container { | |||
86 | // For C_ROOT, this has no meaning | 113 | // For C_ROOT, this has no meaning |
87 | // For other types, this is the position in layout coordinates | 114 | // For other types, this is the position in layout coordinates |
88 | // Includes borders | 115 | // Includes borders |
89 | double x, y; | ||
90 | double width, height; | ||
91 | double saved_x, saved_y; | 116 | double saved_x, saved_y; |
92 | double saved_width, saved_height; | 117 | double saved_width, saved_height; |
93 | 118 | ||
119 | // Used when the view changes to CSD unexpectedly. This will be a non-B_CSD | ||
120 | // border which we use to restore when the view returns to SSD. | ||
121 | enum sway_container_border saved_border; | ||
122 | |||
94 | // The share of the space of parent container this container occupies | 123 | // The share of the space of parent container this container occupies |
95 | double width_fraction; | 124 | double width_fraction; |
96 | double height_fraction; | 125 | double height_fraction; |
@@ -100,55 +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 | // These are in layout coordinates. | ||
104 | double content_x, content_y; | ||
105 | int content_width, content_height; | ||
106 | |||
107 | // In most cases this is the same as the content x and y, but if the view | ||
108 | // refuses to resize to the content dimensions then it can be smaller. | ||
109 | // These are in layout coordinates. | ||
110 | double surface_x, surface_y; | ||
111 | |||
112 | enum sway_fullscreen_mode fullscreen_mode; | ||
113 | |||
114 | enum sway_container_border border; | ||
115 | |||
116 | // Used when the view changes to CSD unexpectedly. This will be a non-B_CSD | ||
117 | // border which we use to restore when the view returns to SSD. | ||
118 | enum sway_container_border saved_border; | ||
119 | |||
120 | int border_thickness; | ||
121 | bool border_top; | ||
122 | bool border_bottom; | ||
123 | bool border_left; | ||
124 | bool border_right; | ||
125 | |||
126 | struct sway_workspace *workspace; // NULL when hidden in the scratchpad | ||
127 | struct sway_container *parent; // NULL if container in root of workspace | ||
128 | list_t *children; // struct sway_container | ||
129 | |||
130 | // Outputs currently being intersected | ||
131 | list_t *outputs; // struct sway_output | ||
132 | |||
133 | // Indicates that the container is a scratchpad container. | 132 | // Indicates that the container is a scratchpad container. |
134 | // Both hidden and visible scratchpad containers have scratchpad=true. | 133 | // Both hidden and visible scratchpad containers have scratchpad=true. |
135 | // Hidden scratchpad containers have a NULL parent. | 134 | // Hidden scratchpad containers have a NULL parent. |
136 | bool scratchpad; | 135 | bool scratchpad; |
137 | 136 | ||
138 | 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; | ||
139 | 141 | ||
140 | struct wlr_texture *title_focused; | 142 | float alpha; |
141 | struct wlr_texture *title_focused_inactive; | ||
142 | struct wlr_texture *title_unfocused; | ||
143 | struct wlr_texture *title_urgent; | ||
144 | size_t title_height; | ||
145 | size_t title_baseline; | ||
146 | 143 | ||
147 | list_t *marks; // char * | 144 | list_t *marks; // char * |
148 | struct wlr_texture *marks_focused; | ||
149 | struct wlr_texture *marks_focused_inactive; | ||
150 | struct wlr_texture *marks_unfocused; | ||
151 | struct wlr_texture *marks_urgent; | ||
152 | 145 | ||
153 | struct { | 146 | struct { |
154 | struct wl_signal destroy; | 147 | struct wl_signal destroy; |
@@ -168,23 +161,15 @@ void container_begin_destroy(struct sway_container *con); | |||
168 | struct sway_container *container_find_child(struct sway_container *container, | 161 | struct sway_container *container_find_child(struct sway_container *container, |
169 | bool (*test)(struct sway_container *view, void *data), void *data); | 162 | bool (*test)(struct sway_container *view, void *data), void *data); |
170 | 163 | ||
171 | /** | ||
172 | * Find a container at the given coordinates. Returns the surface and | ||
173 | * surface-local coordinates of the given layout coordinates if the container | ||
174 | * is a view and the view contains a surface at those coordinates. | ||
175 | */ | ||
176 | struct sway_container *container_at(struct sway_workspace *workspace, | ||
177 | double lx, double ly, struct wlr_surface **surface, | ||
178 | double *sx, double *sy); | ||
179 | |||
180 | struct sway_container *tiling_container_at( | ||
181 | struct sway_node *parent, double lx, double ly, | ||
182 | struct wlr_surface **surface, double *sx, double *sy); | ||
183 | |||
184 | void container_for_each_child(struct sway_container *container, | 164 | void container_for_each_child(struct sway_container *container, |
185 | void (*f)(struct sway_container *container, void *data), void *data); | 165 | void (*f)(struct sway_container *container, void *data), void *data); |
186 | 166 | ||
187 | /** | 167 | /** |
168 | * Returns the fullscreen container obstructing this container if it exists. | ||
169 | */ | ||
170 | struct sway_container *container_obstructing_fullscreen_container(struct sway_container *container); | ||
171 | |||
172 | /** | ||
188 | * Returns true if the given container is an ancestor of this container. | 173 | * Returns true if the given container is an ancestor of this container. |
189 | */ | 174 | */ |
190 | bool container_has_ancestor(struct sway_container *container, | 175 | bool container_has_ancestor(struct sway_container *container, |
@@ -192,18 +177,13 @@ bool container_has_ancestor(struct sway_container *container, | |||
192 | 177 | ||
193 | void container_update_textures_recursive(struct sway_container *con); | 178 | void container_update_textures_recursive(struct sway_container *con); |
194 | 179 | ||
195 | void container_damage_whole(struct sway_container *container); | ||
196 | |||
197 | void container_reap_empty(struct sway_container *con); | 180 | void container_reap_empty(struct sway_container *con); |
198 | 181 | ||
199 | struct sway_container *container_flatten(struct sway_container *container); | 182 | struct sway_container *container_flatten(struct sway_container *container); |
200 | 183 | ||
201 | void container_update_title_textures(struct sway_container *container); | 184 | void container_update_title_bar(struct sway_container *container); |
202 | 185 | ||
203 | /** | 186 | void container_update_marks(struct sway_container *container); |
204 | * Calculate the container's title_height property. | ||
205 | */ | ||
206 | void container_calculate_title_height(struct sway_container *container); | ||
207 | 187 | ||
208 | size_t container_build_representation(enum sway_container_layout layout, | 188 | size_t container_build_representation(enum sway_container_layout layout, |
209 | list_t *children, char *buffer); | 189 | list_t *children, char *buffer); |
@@ -218,6 +198,9 @@ size_t container_titlebar_height(void); | |||
218 | void floating_calculate_constraints(int *min_width, int *max_width, | 198 | void floating_calculate_constraints(int *min_width, int *max_width, |
219 | int *min_height, int *max_height); | 199 | int *min_height, int *max_height); |
220 | 200 | ||
201 | void floating_fix_coordinates(struct sway_container *con, | ||
202 | struct wlr_box *old, struct wlr_box *new); | ||
203 | |||
221 | void container_floating_resize_and_center(struct sway_container *con); | 204 | void container_floating_resize_and_center(struct sway_container *con); |
222 | 205 | ||
223 | void container_floating_set_default_size(struct sway_container *con); | 206 | void container_floating_set_default_size(struct sway_container *con); |
@@ -231,6 +214,8 @@ void container_set_geometry_from_content(struct sway_container *con); | |||
231 | /** | 214 | /** |
232 | * Determine if the given container is itself floating. | 215 | * Determine if the given container is itself floating. |
233 | * This will return false for any descendants of a floating container. | 216 | * This will return false for any descendants of a floating container. |
217 | * | ||
218 | * Uses pending container state. | ||
234 | */ | 219 | */ |
235 | bool container_is_floating(struct sway_container *container); | 220 | bool container_is_floating(struct sway_container *container); |
236 | 221 | ||
@@ -296,25 +281,12 @@ bool container_is_floating_or_child(struct sway_container *container); | |||
296 | */ | 281 | */ |
297 | bool container_is_fullscreen_or_child(struct sway_container *container); | 282 | bool container_is_fullscreen_or_child(struct sway_container *container); |
298 | 283 | ||
299 | /** | ||
300 | * Return the output which will be used for scale purposes. | ||
301 | * This is the most recently entered output. | ||
302 | */ | ||
303 | struct sway_output *container_get_effective_output(struct sway_container *con); | ||
304 | |||
305 | void container_discover_outputs(struct sway_container *con); | ||
306 | |||
307 | enum sway_container_layout container_parent_layout(struct sway_container *con); | 284 | enum sway_container_layout container_parent_layout(struct sway_container *con); |
308 | 285 | ||
309 | enum sway_container_layout container_current_parent_layout( | ||
310 | struct sway_container *con); | ||
311 | |||
312 | list_t *container_get_siblings(struct sway_container *container); | 286 | list_t *container_get_siblings(struct sway_container *container); |
313 | 287 | ||
314 | int container_sibling_index(struct sway_container *child); | 288 | int container_sibling_index(struct sway_container *child); |
315 | 289 | ||
316 | list_t *container_get_current_siblings(struct sway_container *container); | ||
317 | |||
318 | void container_handle_fullscreen_reparent(struct sway_container *con); | 290 | void container_handle_fullscreen_reparent(struct sway_container *con); |
319 | 291 | ||
320 | void container_add_child(struct sway_container *parent, | 292 | void container_add_child(struct sway_container *parent, |
@@ -362,8 +334,6 @@ bool container_has_mark(struct sway_container *container, char *mark); | |||
362 | 334 | ||
363 | void container_add_mark(struct sway_container *container, char *mark); | 335 | void container_add_mark(struct sway_container *container, char *mark); |
364 | 336 | ||
365 | void container_update_marks_textures(struct sway_container *container); | ||
366 | |||
367 | void container_raise_floating(struct sway_container *con); | 337 | void container_raise_floating(struct sway_container *con); |
368 | 338 | ||
369 | bool container_is_scratchpad_hidden(struct sway_container *con); | 339 | bool container_is_scratchpad_hidden(struct sway_container *con); |
@@ -378,7 +348,7 @@ bool container_is_sticky_or_child(struct sway_container *con); | |||
378 | * This will destroy pairs of redundant H/V splits | 348 | * This will destroy pairs of redundant H/V splits |
379 | * 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] |
380 | * 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 |
381 | * 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. |
382 | * | 352 | * |
383 | * This function is roughly equivalent to i3's tree_flatten here: | 353 | * This function is roughly equivalent to i3's tree_flatten here: |
384 | * https://github.com/i3/i3/blob/1f0c628cde40cf87371481041b7197344e0417c6/src/tree.c#L651 | 354 | * https://github.com/i3/i3/blob/1f0c628cde40cf87371481041b7197344e0417c6/src/tree.c#L651 |
@@ -387,4 +357,10 @@ bool container_is_sticky_or_child(struct sway_container *con); | |||
387 | */ | 357 | */ |
388 | int container_squash(struct sway_container *con); | 358 | int container_squash(struct sway_container *con); |
389 | 359 | ||
360 | void container_arrange_title_bar(struct sway_container *con); | ||
361 | |||
362 | void container_update(struct sway_container *con); | ||
363 | |||
364 | void container_update_itself_and_parents(struct sway_container *con); | ||
365 | |||
390 | #endif | 366 | #endif |