diff options
Diffstat (limited to 'include/sway/tree/container.h')
-rw-r--r-- | include/sway/tree/container.h | 66 |
1 files changed, 26 insertions, 40 deletions
diff --git a/include/sway/tree/container.h b/include/sway/tree/container.h index 7e9df59f..751612e2 100644 --- a/include/sway/tree/container.h +++ b/include/sway/tree/container.h | |||
@@ -2,8 +2,7 @@ | |||
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> | ||
7 | #include "list.h" | 6 | #include "list.h" |
8 | #include "sway/tree/node.h" | 7 | #include "sway/tree/node.h" |
9 | 8 | ||
@@ -46,9 +45,9 @@ struct sway_container_state { | |||
46 | 45 | ||
47 | enum sway_fullscreen_mode fullscreen_mode; | 46 | enum sway_fullscreen_mode fullscreen_mode; |
48 | 47 | ||
49 | struct sway_workspace *workspace; | 48 | struct sway_workspace *workspace; // NULL when hidden in the scratchpad |
50 | struct sway_container *parent; | 49 | struct sway_container *parent; // NULL if container in root of workspace |
51 | list_t *children; | 50 | list_t *children; // struct sway_container |
52 | 51 | ||
53 | struct sway_container *focused_inactive_child; | 52 | struct sway_container *focused_inactive_child; |
54 | bool focused; | 53 | bool focused; |
@@ -60,6 +59,7 @@ struct sway_container_state { | |||
60 | bool border_left; | 59 | bool border_left; |
61 | bool border_right; | 60 | bool border_right; |
62 | 61 | ||
62 | // These are in layout coordinates. | ||
63 | double content_x, content_y; | 63 | double content_x, content_y; |
64 | double content_width, content_height; | 64 | double content_width, content_height; |
65 | }; | 65 | }; |
@@ -68,14 +68,12 @@ struct sway_container { | |||
68 | struct sway_node node; | 68 | struct sway_node node; |
69 | struct sway_view *view; | 69 | struct sway_view *view; |
70 | 70 | ||
71 | // The pending state is the main container properties, and the current state is in the below struct. | ||
72 | // This means most places of the code can refer to the main variables (pending state) and it'll just work. | ||
73 | struct sway_container_state current; | 71 | struct sway_container_state current; |
72 | struct sway_container_state pending; | ||
74 | 73 | ||
75 | char *title; // The view's title (unformatted) | 74 | char *title; // The view's title (unformatted) |
76 | char *formatted_title; // The title displayed in the title bar | 75 | char *formatted_title; // The title displayed in the title bar |
77 | 76 | ||
78 | enum sway_container_layout layout; | ||
79 | enum sway_container_layout prev_split_layout; | 77 | enum sway_container_layout prev_split_layout; |
80 | 78 | ||
81 | // Whether stickiness has been enabled on this container. Use | 79 | // Whether stickiness has been enabled on this container. Use |
@@ -86,11 +84,13 @@ struct sway_container { | |||
86 | // For C_ROOT, this has no meaning | 84 | // For C_ROOT, this has no meaning |
87 | // For other types, this is the position in layout coordinates | 85 | // For other types, this is the position in layout coordinates |
88 | // Includes borders | 86 | // Includes borders |
89 | double x, y; | ||
90 | double width, height; | ||
91 | double saved_x, saved_y; | 87 | double saved_x, saved_y; |
92 | double saved_width, saved_height; | 88 | double saved_width, saved_height; |
93 | 89 | ||
90 | // Used when the view changes to CSD unexpectedly. This will be a non-B_CSD | ||
91 | // border which we use to restore when the view returns to SSD. | ||
92 | enum sway_container_border saved_border; | ||
93 | |||
94 | // The share of the space of parent container this container occupies | 94 | // The share of the space of parent container this container occupies |
95 | double width_fraction; | 95 | double width_fraction; |
96 | double height_fraction; | 96 | double height_fraction; |
@@ -100,33 +100,11 @@ struct sway_container { | |||
100 | double child_total_width; | 100 | double child_total_width; |
101 | double child_total_height; | 101 | double child_total_height; |
102 | 102 | ||
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 | 103 | // 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. | 104 | // refuses to resize to the content dimensions then it can be smaller. |
109 | // These are in layout coordinates. | 105 | // These are in layout coordinates. |
110 | double surface_x, surface_y; | 106 | double surface_x, surface_y; |
111 | 107 | ||
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 | 108 | // Outputs currently being intersected |
131 | list_t *outputs; // struct sway_output | 109 | list_t *outputs; // struct sway_output |
132 | 110 | ||
@@ -139,14 +117,14 @@ struct sway_container { | |||
139 | 117 | ||
140 | struct wlr_texture *title_focused; | 118 | struct wlr_texture *title_focused; |
141 | struct wlr_texture *title_focused_inactive; | 119 | struct wlr_texture *title_focused_inactive; |
120 | struct wlr_texture *title_focused_tab_title; | ||
142 | struct wlr_texture *title_unfocused; | 121 | struct wlr_texture *title_unfocused; |
143 | struct wlr_texture *title_urgent; | 122 | struct wlr_texture *title_urgent; |
144 | size_t title_height; | ||
145 | size_t title_baseline; | ||
146 | 123 | ||
147 | list_t *marks; // char * | 124 | list_t *marks; // char * |
148 | struct wlr_texture *marks_focused; | 125 | struct wlr_texture *marks_focused; |
149 | struct wlr_texture *marks_focused_inactive; | 126 | struct wlr_texture *marks_focused_inactive; |
127 | struct wlr_texture *marks_focused_tab_title; | ||
150 | struct wlr_texture *marks_unfocused; | 128 | struct wlr_texture *marks_unfocused; |
151 | struct wlr_texture *marks_urgent; | 129 | struct wlr_texture *marks_urgent; |
152 | 130 | ||
@@ -185,6 +163,11 @@ void container_for_each_child(struct sway_container *container, | |||
185 | void (*f)(struct sway_container *container, void *data), void *data); | 163 | void (*f)(struct sway_container *container, void *data), void *data); |
186 | 164 | ||
187 | /** | 165 | /** |
166 | * Returns the fullscreen container obstructing this container if it exists. | ||
167 | */ | ||
168 | struct sway_container *container_obstructing_fullscreen_container(struct sway_container *container); | ||
169 | |||
170 | /** | ||
188 | * Returns true if the given container is an ancestor of this container. | 171 | * Returns true if the given container is an ancestor of this container. |
189 | */ | 172 | */ |
190 | bool container_has_ancestor(struct sway_container *container, | 173 | bool container_has_ancestor(struct sway_container *container, |
@@ -200,11 +183,6 @@ 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_textures(struct sway_container *container); |
202 | 185 | ||
203 | /** | ||
204 | * Calculate the container's title_height property. | ||
205 | */ | ||
206 | void container_calculate_title_height(struct sway_container *container); | ||
207 | |||
208 | size_t container_build_representation(enum sway_container_layout layout, | 186 | size_t container_build_representation(enum sway_container_layout layout, |
209 | list_t *children, char *buffer); | 187 | list_t *children, char *buffer); |
210 | 188 | ||
@@ -231,10 +209,17 @@ void container_set_geometry_from_content(struct sway_container *con); | |||
231 | /** | 209 | /** |
232 | * Determine if the given container is itself floating. | 210 | * Determine if the given container is itself floating. |
233 | * This will return false for any descendants of a floating container. | 211 | * This will return false for any descendants of a floating container. |
212 | * | ||
213 | * Uses pending container state. | ||
234 | */ | 214 | */ |
235 | bool container_is_floating(struct sway_container *container); | 215 | bool container_is_floating(struct sway_container *container); |
236 | 216 | ||
237 | /** | 217 | /** |
218 | * Same as above, but for current container state. | ||
219 | */ | ||
220 | bool container_is_current_floating(struct sway_container *container); | ||
221 | |||
222 | /** | ||
238 | * Get a container's box in layout coordinates. | 223 | * Get a container's box in layout coordinates. |
239 | */ | 224 | */ |
240 | void container_get_box(struct sway_container *container, struct wlr_box *box); | 225 | void container_get_box(struct sway_container *container, struct wlr_box *box); |
@@ -299,6 +284,7 @@ bool container_is_fullscreen_or_child(struct sway_container *container); | |||
299 | /** | 284 | /** |
300 | * Return the output which will be used for scale purposes. | 285 | * Return the output which will be used for scale purposes. |
301 | * This is the most recently entered output. | 286 | * This is the most recently entered output. |
287 | * If the container is not on any output, return NULL. | ||
302 | */ | 288 | */ |
303 | struct sway_output *container_get_effective_output(struct sway_container *con); | 289 | struct sway_output *container_get_effective_output(struct sway_container *con); |
304 | 290 | ||
@@ -378,7 +364,7 @@ bool container_is_sticky_or_child(struct sway_container *con); | |||
378 | * This will destroy pairs of redundant H/V splits | 364 | * This will destroy pairs of redundant H/V splits |
379 | * e.g. H[V[H[app app]] app] -> H[app app app] | 365 | * 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 | 366 | * 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. | 367 | * on the V[ con. It's grandchildren are added to its parent. |
382 | * | 368 | * |
383 | * This function is roughly equivalent to i3's tree_flatten here: | 369 | * This function is roughly equivalent to i3's tree_flatten here: |
384 | * https://github.com/i3/i3/blob/1f0c628cde40cf87371481041b7197344e0417c6/src/tree.c#L651 | 370 | * https://github.com/i3/i3/blob/1f0c628cde40cf87371481041b7197344e0417c6/src/tree.c#L651 |