diff options
author | Devin J. Pohly <djpohly@gmail.com> | 2020-12-24 22:26:44 -0500 |
---|---|---|
committer | Devin J. Pohly <djpohly@gmail.com> | 2020-12-24 22:36:32 -0500 |
commit | 1678b059055e6b0686724ac3a4233c98b95c205a (patch) | |
tree | 620e80cdbf69fb51fb630a0e3478da65757d5a73 /dwl.c | |
parent | 57d07606357d4ce3b1c1a6461a5b7c6c90c1df9e (diff) |
don't call applyexclusive just to return
Diffstat (limited to 'dwl.c')
-rw-r--r-- | dwl.c | 86 |
1 files changed, 42 insertions, 44 deletions
@@ -404,47 +404,44 @@ applyexclusive(struct wlr_box *usable_area, uint32_t anchor, int32_t exclusive, int32_t margin_top, int32_t margin_right, int32_t margin_bottom, int32_t margin_left) { - Edge edges[4]; - - if (exclusive <= 0) - return; - - // Top - edges[0].singular_anchor = ZWLR_LAYER_SURFACE_V1_ANCHOR_TOP; - edges[0].anchor_triplet = ZWLR_LAYER_SURFACE_V1_ANCHOR_LEFT | - ZWLR_LAYER_SURFACE_V1_ANCHOR_RIGHT | - ZWLR_LAYER_SURFACE_V1_ANCHOR_TOP; - edges[0].positive_axis = &usable_area->y; - edges[0].negative_axis = &usable_area->height; - edges[0].margin = margin_top; - - // Bottom - edges[1].singular_anchor = ZWLR_LAYER_SURFACE_V1_ANCHOR_BOTTOM; - edges[1].anchor_triplet = ZWLR_LAYER_SURFACE_V1_ANCHOR_LEFT | - ZWLR_LAYER_SURFACE_V1_ANCHOR_RIGHT | - ZWLR_LAYER_SURFACE_V1_ANCHOR_BOTTOM; - edges[1].positive_axis = NULL; - edges[1].negative_axis = &usable_area->height; - edges[1].margin = margin_bottom; - - // Left - edges[2].singular_anchor = ZWLR_LAYER_SURFACE_V1_ANCHOR_LEFT; - edges[2].anchor_triplet = ZWLR_LAYER_SURFACE_V1_ANCHOR_LEFT | - ZWLR_LAYER_SURFACE_V1_ANCHOR_TOP | - ZWLR_LAYER_SURFACE_V1_ANCHOR_BOTTOM; - edges[2].positive_axis = &usable_area->x; - edges[2].negative_axis = &usable_area->width; - edges[2].margin = margin_left; - - // Right - edges[3].singular_anchor = ZWLR_LAYER_SURFACE_V1_ANCHOR_RIGHT; - edges[3].anchor_triplet = ZWLR_LAYER_SURFACE_V1_ANCHOR_RIGHT | - ZWLR_LAYER_SURFACE_V1_ANCHOR_TOP | - ZWLR_LAYER_SURFACE_V1_ANCHOR_BOTTOM; - edges[3].positive_axis = NULL; - edges[3].negative_axis = &usable_area->width; - edges[3].margin = margin_right; - + Edge edges[] = { + { // Top + .singular_anchor = ZWLR_LAYER_SURFACE_V1_ANCHOR_TOP, + .anchor_triplet = ZWLR_LAYER_SURFACE_V1_ANCHOR_LEFT | + ZWLR_LAYER_SURFACE_V1_ANCHOR_RIGHT | + ZWLR_LAYER_SURFACE_V1_ANCHOR_TOP, + .positive_axis = &usable_area->y, + .negative_axis = &usable_area->height, + .margin = margin_top, + }, + { // Bottom + .singular_anchor = ZWLR_LAYER_SURFACE_V1_ANCHOR_BOTTOM, + .anchor_triplet = ZWLR_LAYER_SURFACE_V1_ANCHOR_LEFT | + ZWLR_LAYER_SURFACE_V1_ANCHOR_RIGHT | + ZWLR_LAYER_SURFACE_V1_ANCHOR_BOTTOM, + .positive_axis = NULL, + .negative_axis = &usable_area->height, + .margin = margin_bottom, + }, + { // Left + .singular_anchor = ZWLR_LAYER_SURFACE_V1_ANCHOR_LEFT, + .anchor_triplet = ZWLR_LAYER_SURFACE_V1_ANCHOR_LEFT | + ZWLR_LAYER_SURFACE_V1_ANCHOR_TOP | + ZWLR_LAYER_SURFACE_V1_ANCHOR_BOTTOM, + .positive_axis = &usable_area->x, + .negative_axis = &usable_area->width, + .margin = margin_left, + }, + { // Right + .singular_anchor = ZWLR_LAYER_SURFACE_V1_ANCHOR_RIGHT, + .anchor_triplet = ZWLR_LAYER_SURFACE_V1_ANCHOR_RIGHT | + ZWLR_LAYER_SURFACE_V1_ANCHOR_TOP | + ZWLR_LAYER_SURFACE_V1_ANCHOR_BOTTOM, + .positive_axis = NULL, + .negative_axis = &usable_area->width, + .margin = margin_right, + } + }; for (size_t i = 0; i < LENGTH(edges); ++i) { if ((anchor == edges[i].singular_anchor || anchor == edges[i].anchor_triplet) && exclusive + edges[i].margin > 0) { @@ -574,9 +571,10 @@ arrangelayer(Monitor *m, struct wl_list *list, struct wlr_box *usable_area, int } layersurface->geo = box; - applyexclusive(usable_area, state->anchor, state->exclusive_zone, - state->margin.top, state->margin.right, - state->margin.bottom, state->margin.left); + if (state->exclusive_zone > 0) + applyexclusive(usable_area, state->anchor, state->exclusive_zone, + state->margin.top, state->margin.right, + state->margin.bottom, state->margin.left); wlr_layer_surface_v1_configure(wlr_layer_surface, box.width, box.height); } } |