don't call applyexclusive just to return

main
Devin J. Pohly 2020-12-24 22:26:44 -05:00
parent 57d0760635
commit 1678b05905
1 changed files with 42 additions and 44 deletions

72
dwl.c
View File

@ -404,47 +404,44 @@ applyexclusive(struct wlr_box *usable_area,
uint32_t anchor, int32_t exclusive, uint32_t anchor, int32_t exclusive,
int32_t margin_top, int32_t margin_right, int32_t margin_top, int32_t margin_right,
int32_t margin_bottom, int32_t margin_left) { int32_t margin_bottom, int32_t margin_left) {
Edge edges[4]; Edge edges[] = {
{ // Top
if (exclusive <= 0) .singular_anchor = ZWLR_LAYER_SURFACE_V1_ANCHOR_TOP,
return; .anchor_triplet = ZWLR_LAYER_SURFACE_V1_ANCHOR_LEFT |
// 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_RIGHT |
ZWLR_LAYER_SURFACE_V1_ANCHOR_TOP; ZWLR_LAYER_SURFACE_V1_ANCHOR_TOP,
edges[0].positive_axis = &usable_area->y; .positive_axis = &usable_area->y,
edges[0].negative_axis = &usable_area->height; .negative_axis = &usable_area->height,
edges[0].margin = margin_top; .margin = margin_top,
},
// Bottom { // Bottom
edges[1].singular_anchor = ZWLR_LAYER_SURFACE_V1_ANCHOR_BOTTOM; .singular_anchor = ZWLR_LAYER_SURFACE_V1_ANCHOR_BOTTOM,
edges[1].anchor_triplet = ZWLR_LAYER_SURFACE_V1_ANCHOR_LEFT | .anchor_triplet = ZWLR_LAYER_SURFACE_V1_ANCHOR_LEFT |
ZWLR_LAYER_SURFACE_V1_ANCHOR_RIGHT | ZWLR_LAYER_SURFACE_V1_ANCHOR_RIGHT |
ZWLR_LAYER_SURFACE_V1_ANCHOR_BOTTOM; ZWLR_LAYER_SURFACE_V1_ANCHOR_BOTTOM,
edges[1].positive_axis = NULL; .positive_axis = NULL,
edges[1].negative_axis = &usable_area->height; .negative_axis = &usable_area->height,
edges[1].margin = margin_bottom; .margin = margin_bottom,
},
// Left { // Left
edges[2].singular_anchor = ZWLR_LAYER_SURFACE_V1_ANCHOR_LEFT; .singular_anchor = ZWLR_LAYER_SURFACE_V1_ANCHOR_LEFT,
edges[2].anchor_triplet = 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_TOP |
ZWLR_LAYER_SURFACE_V1_ANCHOR_BOTTOM; ZWLR_LAYER_SURFACE_V1_ANCHOR_BOTTOM,
edges[2].positive_axis = &usable_area->x; .positive_axis = &usable_area->x,
edges[2].negative_axis = &usable_area->width; .negative_axis = &usable_area->width,
edges[2].margin = margin_left; .margin = margin_left,
},
// Right { // Right
edges[3].singular_anchor = ZWLR_LAYER_SURFACE_V1_ANCHOR_RIGHT; .singular_anchor = ZWLR_LAYER_SURFACE_V1_ANCHOR_RIGHT,
edges[3].anchor_triplet = 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_TOP |
ZWLR_LAYER_SURFACE_V1_ANCHOR_BOTTOM; ZWLR_LAYER_SURFACE_V1_ANCHOR_BOTTOM,
edges[3].positive_axis = NULL; .positive_axis = NULL,
edges[3].negative_axis = &usable_area->width; .negative_axis = &usable_area->width,
edges[3].margin = margin_right; .margin = margin_right,
}
};
for (size_t i = 0; i < LENGTH(edges); ++i) { for (size_t i = 0; i < LENGTH(edges); ++i) {
if ((anchor == edges[i].singular_anchor || anchor == edges[i].anchor_triplet) if ((anchor == edges[i].singular_anchor || anchor == edges[i].anchor_triplet)
&& exclusive + edges[i].margin > 0) { && exclusive + edges[i].margin > 0) {
@ -574,6 +571,7 @@ arrangelayer(Monitor *m, struct wl_list *list, struct wlr_box *usable_area, int
} }
layersurface->geo = box; layersurface->geo = box;
if (state->exclusive_zone > 0)
applyexclusive(usable_area, state->anchor, state->exclusive_zone, applyexclusive(usable_area, state->anchor, state->exclusive_zone,
state->margin.top, state->margin.right, state->margin.top, state->margin.right,
state->margin.bottom, state->margin.left); state->margin.bottom, state->margin.left);