diff options
author | Drew DeVault <sir@cmpwn.com> | 2018-11-01 01:03:41 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-11-01 01:03:41 +0100 |
commit | 480b03b734e6d1d068859b254d8ace4fb07b2c54 (patch) | |
tree | 131faacd2b7c36e37444441cb0fd719c00818486 /sway/tree/view.c | |
parent | Merge pull request #3037 from RyanDwyer/focus-output-wrap (diff) | |
parent | Move view border properties to container struct (diff) | |
download | sway-480b03b734e6d1d068859b254d8ace4fb07b2c54.tar.gz sway-480b03b734e6d1d068859b254d8ace4fb07b2c54.tar.zst sway-480b03b734e6d1d068859b254d8ace4fb07b2c54.zip |
Merge pull request #3040 from RyanDwyer/border-props-to-container
Move view border properties to container struct
Diffstat (limited to 'sway/tree/view.c')
-rw-r--r-- | sway/tree/view.c | 61 |
1 files changed, 31 insertions, 30 deletions
diff --git a/sway/tree/view.c b/sway/tree/view.c index 4bc9e0f3..9a89b8ea 100644 --- a/sway/tree/view.c +++ b/sway/tree/view.c | |||
@@ -225,21 +225,21 @@ void view_autoconfigure(struct sway_view *view) { | |||
225 | bool no_gaps = config->hide_edge_borders != E_SMART_NO_GAPS | 225 | bool no_gaps = config->hide_edge_borders != E_SMART_NO_GAPS |
226 | || !gaps_to_edge(view); | 226 | || !gaps_to_edge(view); |
227 | 227 | ||
228 | view->border_top = view->border_bottom = true; | 228 | con->border_top = con->border_bottom = true; |
229 | view->border_left = view->border_right = true; | 229 | con->border_left = con->border_right = true; |
230 | if (config->hide_edge_borders == E_BOTH | 230 | if (config->hide_edge_borders == E_BOTH |
231 | || config->hide_edge_borders == E_VERTICAL | 231 | || config->hide_edge_borders == E_VERTICAL |
232 | || (smart && !other_views && no_gaps)) { | 232 | || (smart && !other_views && no_gaps)) { |
233 | view->border_left = con->x - con->current_gaps != ws->x; | 233 | con->border_left = con->x - con->current_gaps != ws->x; |
234 | int right_x = con->x + con->width + con->current_gaps; | 234 | int right_x = con->x + con->width + con->current_gaps; |
235 | view->border_right = right_x != ws->x + ws->width; | 235 | con->border_right = right_x != ws->x + ws->width; |
236 | } | 236 | } |
237 | if (config->hide_edge_borders == E_BOTH | 237 | if (config->hide_edge_borders == E_BOTH |
238 | || config->hide_edge_borders == E_HORIZONTAL | 238 | || config->hide_edge_borders == E_HORIZONTAL |
239 | || (smart && !other_views && no_gaps)) { | 239 | || (smart && !other_views && no_gaps)) { |
240 | view->border_top = con->y - con->current_gaps != ws->y; | 240 | con->border_top = con->y - con->current_gaps != ws->y; |
241 | int bottom_y = con->y + con->height + con->current_gaps; | 241 | int bottom_y = con->y + con->height + con->current_gaps; |
242 | view->border_bottom = bottom_y != ws->y + ws->height; | 242 | con->border_bottom = bottom_y != ws->y + ws->height; |
243 | } | 243 | } |
244 | 244 | ||
245 | double x, y, width, height; | 245 | double x, y, width, height; |
@@ -252,14 +252,14 @@ void view_autoconfigure(struct sway_view *view) { | |||
252 | enum sway_container_layout layout = container_parent_layout(con); | 252 | enum sway_container_layout layout = container_parent_layout(con); |
253 | if (layout == L_TABBED && !container_is_floating(con)) { | 253 | if (layout == L_TABBED && !container_is_floating(con)) { |
254 | y_offset = container_titlebar_height(); | 254 | y_offset = container_titlebar_height(); |
255 | view->border_top = false; | 255 | con->border_top = false; |
256 | } else if (layout == L_STACKED && !container_is_floating(con)) { | 256 | } else if (layout == L_STACKED && !container_is_floating(con)) { |
257 | list_t *siblings = container_get_siblings(con); | 257 | list_t *siblings = container_get_siblings(con); |
258 | y_offset = container_titlebar_height() * siblings->length; | 258 | y_offset = container_titlebar_height() * siblings->length; |
259 | view->border_top = false; | 259 | con->border_top = false; |
260 | } | 260 | } |
261 | 261 | ||
262 | switch (view->border) { | 262 | switch (con->border) { |
263 | case B_CSD: | 263 | case B_CSD: |
264 | case B_NONE: | 264 | case B_NONE: |
265 | x = con->x; | 265 | x = con->x; |
@@ -268,29 +268,29 @@ void view_autoconfigure(struct sway_view *view) { | |||
268 | height = con->height - y_offset; | 268 | height = con->height - y_offset; |
269 | break; | 269 | break; |
270 | case B_PIXEL: | 270 | case B_PIXEL: |
271 | x = con->x + view->border_thickness * view->border_left; | 271 | x = con->x + con->border_thickness * con->border_left; |
272 | y = con->y + view->border_thickness * view->border_top + y_offset; | 272 | y = con->y + con->border_thickness * con->border_top + y_offset; |
273 | width = con->width | 273 | width = con->width |
274 | - view->border_thickness * view->border_left | 274 | - con->border_thickness * con->border_left |
275 | - view->border_thickness * view->border_right; | 275 | - con->border_thickness * con->border_right; |
276 | height = con->height - y_offset | 276 | height = con->height - y_offset |
277 | - view->border_thickness * view->border_top | 277 | - con->border_thickness * con->border_top |
278 | - view->border_thickness * view->border_bottom; | 278 | - con->border_thickness * con->border_bottom; |
279 | break; | 279 | break; |
280 | case B_NORMAL: | 280 | case B_NORMAL: |
281 | // Height is: 1px border + 3px pad + title height + 3px pad + 1px border | 281 | // Height is: 1px border + 3px pad + title height + 3px pad + 1px border |
282 | x = con->x + view->border_thickness * view->border_left; | 282 | x = con->x + con->border_thickness * con->border_left; |
283 | width = con->width | 283 | width = con->width |
284 | - view->border_thickness * view->border_left | 284 | - con->border_thickness * con->border_left |
285 | - view->border_thickness * view->border_right; | 285 | - con->border_thickness * con->border_right; |
286 | if (y_offset) { | 286 | if (y_offset) { |
287 | y = con->y + y_offset; | 287 | y = con->y + y_offset; |
288 | height = con->height - y_offset | 288 | height = con->height - y_offset |
289 | - view->border_thickness * view->border_bottom; | 289 | - con->border_thickness * con->border_bottom; |
290 | } else { | 290 | } else { |
291 | y = con->y + container_titlebar_height(); | 291 | y = con->y + container_titlebar_height(); |
292 | height = con->height - container_titlebar_height() | 292 | height = con->height - container_titlebar_height() |
293 | - view->border_thickness * view->border_bottom; | 293 | - con->border_thickness * con->border_bottom; |
294 | } | 294 | } |
295 | break; | 295 | break; |
296 | } | 296 | } |
@@ -347,13 +347,14 @@ void view_set_csd_from_server(struct sway_view *view, bool enabled) { | |||
347 | 347 | ||
348 | void view_update_csd_from_client(struct sway_view *view, bool enabled) { | 348 | void view_update_csd_from_client(struct sway_view *view, bool enabled) { |
349 | wlr_log(WLR_DEBUG, "View %p updated CSD to %i", view, enabled); | 349 | wlr_log(WLR_DEBUG, "View %p updated CSD to %i", view, enabled); |
350 | if (enabled && view->border != B_CSD) { | 350 | struct sway_container *con = view->container; |
351 | view->saved_border = view->border; | 351 | if (enabled && con && con->border != B_CSD) { |
352 | if (view->container && container_is_floating(view->container)) { | 352 | con->saved_border = con->border; |
353 | view->border = B_CSD; | 353 | if (container_is_floating(con)) { |
354 | con->border = B_CSD; | ||
354 | } | 355 | } |
355 | } else if (!enabled && view->border == B_CSD) { | 356 | } else if (!enabled && con && con->border == B_CSD) { |
356 | view->border = view->saved_border; | 357 | con->border = con->saved_border; |
357 | } | 358 | } |
358 | view->using_csd = enabled; | 359 | view->using_csd = enabled; |
359 | } | 360 | } |
@@ -584,12 +585,12 @@ void view_map(struct sway_view *view, struct wlr_surface *wlr_surface, | |||
584 | view->surface_new_subsurface.notify = view_handle_surface_new_subsurface; | 585 | view->surface_new_subsurface.notify = view_handle_surface_new_subsurface; |
585 | 586 | ||
586 | if (view->impl->wants_floating && view->impl->wants_floating(view)) { | 587 | if (view->impl->wants_floating && view->impl->wants_floating(view)) { |
587 | view->border = config->floating_border; | 588 | view->container->border = config->floating_border; |
588 | view->border_thickness = config->floating_border_thickness; | 589 | view->container->border_thickness = config->floating_border_thickness; |
589 | container_set_floating(view->container, true); | 590 | container_set_floating(view->container, true); |
590 | } else { | 591 | } else { |
591 | view->border = config->border; | 592 | view->container->border = config->border; |
592 | view->border_thickness = config->border_thickness; | 593 | view->container->border_thickness = config->border_thickness; |
593 | view_set_tiled(view, true); | 594 | view_set_tiled(view, true); |
594 | } | 595 | } |
595 | 596 | ||