diff options
author | Ryan Dwyer <ryandwyer1@gmail.com> | 2018-06-03 16:35:06 +1000 |
---|---|---|
committer | Ryan Dwyer <ryandwyer1@gmail.com> | 2018-06-09 10:08:43 +1000 |
commit | 59c94887018bdfa578c4371c4275061ca6e71b3e (patch) | |
tree | 62bdaa6ac4777d1fcb292013bddd2043dad7765a /sway/tree/view.c | |
parent | Merge pull request #2115 from RedSoxFan/restore-workspaces (diff) | |
download | sway-59c94887018bdfa578c4371c4275061ca6e71b3e.tar.gz sway-59c94887018bdfa578c4371c4275061ca6e71b3e.tar.zst sway-59c94887018bdfa578c4371c4275061ca6e71b3e.zip |
WIP: Atomic layout updates ground work
Diffstat (limited to 'sway/tree/view.c')
-rw-r--r-- | sway/tree/view.c | 98 |
1 files changed, 56 insertions, 42 deletions
diff --git a/sway/tree/view.c b/sway/tree/view.c index c9c82405..40fe2740 100644 --- a/sway/tree/view.c +++ b/sway/tree/view.c | |||
@@ -25,6 +25,7 @@ void view_init(struct sway_view *view, enum sway_view_type type, | |||
25 | view->impl = impl; | 25 | view->impl = impl; |
26 | view->executed_criteria = create_list(); | 26 | view->executed_criteria = create_list(); |
27 | view->marks = create_list(); | 27 | view->marks = create_list(); |
28 | view->instructions = create_list(); | ||
28 | wl_signal_init(&view->events.unmap); | 29 | wl_signal_init(&view->events.unmap); |
29 | } | 30 | } |
30 | 31 | ||
@@ -37,6 +38,11 @@ void view_destroy(struct sway_view *view) { | |||
37 | view_unmap(view); | 38 | view_unmap(view); |
38 | } | 39 | } |
39 | 40 | ||
41 | if (!sway_assert(view->instructions->length == 0, | ||
42 | "Tried to destroy view with pending instructions")) { | ||
43 | return; | ||
44 | } | ||
45 | |||
40 | list_free(view->executed_criteria); | 46 | list_free(view->executed_criteria); |
41 | 47 | ||
42 | for (int i = 0; i < view->marks->length; ++i) { | 48 | for (int i = 0; i < view->marks->length; ++i) { |
@@ -44,6 +50,8 @@ void view_destroy(struct sway_view *view) { | |||
44 | } | 50 | } |
45 | list_free(view->marks); | 51 | list_free(view->marks); |
46 | 52 | ||
53 | list_free(view->instructions); | ||
54 | |||
47 | wlr_texture_destroy(view->marks_focused); | 55 | wlr_texture_destroy(view->marks_focused); |
48 | wlr_texture_destroy(view->marks_focused_inactive); | 56 | wlr_texture_destroy(view->marks_focused_inactive); |
49 | wlr_texture_destroy(view->marks_unfocused); | 57 | wlr_texture_destroy(view->marks_unfocused); |
@@ -119,11 +127,12 @@ const char *view_get_shell(struct sway_view *view) { | |||
119 | return "unknown"; | 127 | return "unknown"; |
120 | } | 128 | } |
121 | 129 | ||
122 | void view_configure(struct sway_view *view, double lx, double ly, int width, | 130 | uint32_t view_configure(struct sway_view *view, double lx, double ly, int width, |
123 | int height) { | 131 | int height) { |
124 | if (view->impl->configure) { | 132 | if (view->impl->configure) { |
125 | view->impl->configure(view, lx, ly, width, height); | 133 | return view->impl->configure(view, lx, ly, width, height); |
126 | } | 134 | } |
135 | return 0; | ||
127 | } | 136 | } |
128 | 137 | ||
129 | static void view_autoconfigure_floating(struct sway_view *view) { | 138 | static void view_autoconfigure_floating(struct sway_view *view) { |
@@ -178,21 +187,23 @@ void view_autoconfigure(struct sway_view *view) { | |||
178 | } | 187 | } |
179 | } | 188 | } |
180 | 189 | ||
181 | view->border_top = view->border_bottom = true; | 190 | struct sway_container_state *state = &view->swayc->pending; |
182 | view->border_left = view->border_right = true; | 191 | |
192 | state->border_top = state->border_bottom = true; | ||
193 | state->border_left = state->border_right = true; | ||
183 | if (config->hide_edge_borders == E_BOTH | 194 | if (config->hide_edge_borders == E_BOTH |
184 | || config->hide_edge_borders == E_VERTICAL | 195 | || config->hide_edge_borders == E_VERTICAL |
185 | || (config->hide_edge_borders == E_SMART && !other_views)) { | 196 | || (config->hide_edge_borders == E_SMART && !other_views)) { |
186 | view->border_left = view->swayc->x != ws->x; | 197 | state->border_left = state->swayc_x != ws->x; |
187 | int right_x = view->swayc->x + view->swayc->width; | 198 | int right_x = state->swayc_x + state->swayc_width; |
188 | view->border_right = right_x != ws->x + ws->width; | 199 | state->border_right = right_x != ws->x + ws->width; |
189 | } | 200 | } |
190 | if (config->hide_edge_borders == E_BOTH | 201 | if (config->hide_edge_borders == E_BOTH |
191 | || config->hide_edge_borders == E_HORIZONTAL | 202 | || config->hide_edge_borders == E_HORIZONTAL |
192 | || (config->hide_edge_borders == E_SMART && !other_views)) { | 203 | || (config->hide_edge_borders == E_SMART && !other_views)) { |
193 | view->border_top = view->swayc->y != ws->y; | 204 | state->border_top = state->swayc_y != ws->y; |
194 | int bottom_y = view->swayc->y + view->swayc->height; | 205 | int bottom_y = state->swayc_y + state->swayc_height; |
195 | view->border_bottom = bottom_y != ws->y + ws->height; | 206 | state->border_bottom = bottom_y != ws->y + ws->height; |
196 | } | 207 | } |
197 | 208 | ||
198 | double x, y, width, height; | 209 | double x, y, width, height; |
@@ -202,53 +213,54 @@ void view_autoconfigure(struct sway_view *view) { | |||
202 | // In a tabbed or stacked container, the swayc's y is the top of the title | 213 | // In a tabbed or stacked container, the swayc's y is the top of the title |
203 | // area. We have to offset the surface y by the height of the title bar, and | 214 | // area. We have to offset the surface y by the height of the title bar, and |
204 | // disable any top border because we'll always have the title bar. | 215 | // disable any top border because we'll always have the title bar. |
205 | if (view->swayc->parent->layout == L_TABBED) { | 216 | if (view->swayc->parent->pending.layout == L_TABBED) { |
206 | y_offset = container_titlebar_height(); | 217 | y_offset = container_titlebar_height(); |
207 | view->border_top = false; | 218 | state->border_top = false; |
208 | } else if (view->swayc->parent->layout == L_STACKED) { | 219 | } else if (view->swayc->parent->pending.layout == L_STACKED) { |
209 | y_offset = container_titlebar_height() | 220 | y_offset = container_titlebar_height() |
210 | * view->swayc->parent->children->length; | 221 | * view->swayc->parent->children->length; |
211 | view->border_top = false; | 222 | view->border_top = false; |
212 | } | 223 | } |
213 | 224 | ||
214 | switch (view->border) { | 225 | switch (state->border) { |
215 | case B_NONE: | 226 | case B_NONE: |
216 | x = view->swayc->x; | 227 | x = state->swayc_x; |
217 | y = view->swayc->y + y_offset; | 228 | y = state->swayc_y + y_offset; |
218 | width = view->swayc->width; | 229 | width = state->swayc_width; |
219 | height = view->swayc->height - y_offset; | 230 | height = state->swayc_height - y_offset; |
220 | break; | 231 | break; |
221 | case B_PIXEL: | 232 | case B_PIXEL: |
222 | x = view->swayc->x + view->border_thickness * view->border_left; | 233 | x = state->swayc_x + state->border_thickness * state->border_left; |
223 | y = view->swayc->y + view->border_thickness * view->border_top + y_offset; | 234 | y = state->swayc_y + state->border_thickness * state->border_top + y_offset; |
224 | width = view->swayc->width | 235 | width = state->swayc_width |
225 | - view->border_thickness * view->border_left | 236 | - state->border_thickness * state->border_left |
226 | - view->border_thickness * view->border_right; | 237 | - state->border_thickness * state->border_right; |
227 | height = view->swayc->height - y_offset | 238 | height = state->swayc_height - y_offset |
228 | - view->border_thickness * view->border_top | 239 | - state->border_thickness * state->border_top |
229 | - view->border_thickness * view->border_bottom; | 240 | - state->border_thickness * state->border_bottom; |
230 | break; | 241 | break; |
231 | case B_NORMAL: | 242 | case B_NORMAL: |
232 | // Height is: 1px border + 3px pad + title height + 3px pad + 1px border | 243 | // Height is: 1px border + 3px pad + title height + 3px pad + 1px border |
233 | x = view->swayc->x + view->border_thickness * view->border_left; | 244 | x = state->swayc_x + state->border_thickness * state->border_left; |
234 | width = view->swayc->width | 245 | width = state->swayc_width |
235 | - view->border_thickness * view->border_left | 246 | - state->border_thickness * state->border_left |
236 | - view->border_thickness * view->border_right; | 247 | - state->border_thickness * state->border_right; |
237 | if (y_offset) { | 248 | if (y_offset) { |
238 | y = view->swayc->y + y_offset; | 249 | y = state->swayc_y + y_offset; |
239 | height = view->swayc->height - y_offset | 250 | height = state->swayc_height - y_offset |
240 | - view->border_thickness * view->border_bottom; | 251 | - state->border_thickness * state->border_bottom; |
241 | } else { | 252 | } else { |
242 | y = view->swayc->y + container_titlebar_height(); | 253 | y = state->swayc_y + container_titlebar_height(); |
243 | height = view->swayc->height - container_titlebar_height() | 254 | height = state->swayc_height - container_titlebar_height() |
244 | - view->border_thickness * view->border_bottom; | 255 | - state->border_thickness * state->border_bottom; |
245 | } | 256 | } |
246 | break; | 257 | break; |
247 | } | 258 | } |
248 | 259 | ||
249 | view->x = x; | 260 | state->view_x = x; |
250 | view->y = y; | 261 | state->view_y = y; |
251 | view_configure(view, x, y, width, height); | 262 | state->view_width = width; |
263 | state->view_height = height; | ||
252 | } | 264 | } |
253 | 265 | ||
254 | void view_set_activated(struct sway_view *view, bool activated) { | 266 | void view_set_activated(struct sway_view *view, bool activated) { |
@@ -307,8 +319,8 @@ void view_set_fullscreen_raw(struct sway_view *view, bool fullscreen) { | |||
307 | view_configure(view, view->saved_x, view->saved_y, | 319 | view_configure(view, view->saved_x, view->saved_y, |
308 | view->saved_width, view->saved_height); | 320 | view->saved_width, view->saved_height); |
309 | } else { | 321 | } else { |
310 | view->swayc->width = view->swayc->saved_width; | 322 | view->swayc->width = view->swayc->saved_width; |
311 | view->swayc->height = view->swayc->saved_height; | 323 | view->swayc->height = view->swayc->saved_height; |
312 | view_autoconfigure(view); | 324 | view_autoconfigure(view); |
313 | } | 325 | } |
314 | } | 326 | } |
@@ -496,6 +508,8 @@ void view_map(struct sway_view *view, struct wlr_surface *wlr_surface) { | |||
496 | view->swayc = cont; | 508 | view->swayc = cont; |
497 | view->border = config->border; | 509 | view->border = config->border; |
498 | view->border_thickness = config->border_thickness; | 510 | view->border_thickness = config->border_thickness; |
511 | view->swayc->pending.border = config->border; | ||
512 | view->swayc->pending.border_thickness = config->border_thickness; | ||
499 | 513 | ||
500 | view_init_subsurfaces(view, wlr_surface); | 514 | view_init_subsurfaces(view, wlr_surface); |
501 | wl_signal_add(&wlr_surface->events.new_subsurface, | 515 | wl_signal_add(&wlr_surface->events.new_subsurface, |
@@ -963,7 +977,7 @@ bool view_is_visible(struct sway_view *view) { | |||
963 | } | 977 | } |
964 | // Check the workspace is visible | 978 | // Check the workspace is visible |
965 | if (!is_sticky) { | 979 | if (!is_sticky) { |
966 | return workspace_is_visible(workspace); | 980 | return workspace_is_visible(workspace); |
967 | } | 981 | } |
968 | return true; | 982 | return true; |
969 | } | 983 | } |