don't call applyexclusive just to return

This commit is contained in:
Devin J. Pohly 2020-12-24 22:26:44 -05:00
parent 57d0760635
commit 1678b05905

86
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 |
ZWLR_LAYER_SURFACE_V1_ANCHOR_RIGHT |
// Top ZWLR_LAYER_SURFACE_V1_ANCHOR_TOP,
edges[0].singular_anchor = ZWLR_LAYER_SURFACE_V1_ANCHOR_TOP; .positive_axis = &usable_area->y,
edges[0].anchor_triplet = ZWLR_LAYER_SURFACE_V1_ANCHOR_LEFT | .negative_axis = &usable_area->height,
ZWLR_LAYER_SURFACE_V1_ANCHOR_RIGHT | .margin = margin_top,
ZWLR_LAYER_SURFACE_V1_ANCHOR_TOP; },
edges[0].positive_axis = &usable_area->y; { // Bottom
edges[0].negative_axis = &usable_area->height; .singular_anchor = ZWLR_LAYER_SURFACE_V1_ANCHOR_BOTTOM,
edges[0].margin = margin_top; .anchor_triplet = ZWLR_LAYER_SURFACE_V1_ANCHOR_LEFT |
ZWLR_LAYER_SURFACE_V1_ANCHOR_RIGHT |
// Bottom ZWLR_LAYER_SURFACE_V1_ANCHOR_BOTTOM,
edges[1].singular_anchor = ZWLR_LAYER_SURFACE_V1_ANCHOR_BOTTOM; .positive_axis = NULL,
edges[1].anchor_triplet = ZWLR_LAYER_SURFACE_V1_ANCHOR_LEFT | .negative_axis = &usable_area->height,
ZWLR_LAYER_SURFACE_V1_ANCHOR_RIGHT | .margin = margin_bottom,
ZWLR_LAYER_SURFACE_V1_ANCHOR_BOTTOM; },
edges[1].positive_axis = NULL; { // Left
edges[1].negative_axis = &usable_area->height; .singular_anchor = ZWLR_LAYER_SURFACE_V1_ANCHOR_LEFT,
edges[1].margin = margin_bottom; .anchor_triplet = ZWLR_LAYER_SURFACE_V1_ANCHOR_LEFT |
ZWLR_LAYER_SURFACE_V1_ANCHOR_TOP |
// Left ZWLR_LAYER_SURFACE_V1_ANCHOR_BOTTOM,
edges[2].singular_anchor = ZWLR_LAYER_SURFACE_V1_ANCHOR_LEFT; .positive_axis = &usable_area->x,
edges[2].anchor_triplet = ZWLR_LAYER_SURFACE_V1_ANCHOR_LEFT | .negative_axis = &usable_area->width,
ZWLR_LAYER_SURFACE_V1_ANCHOR_TOP | .margin = margin_left,
ZWLR_LAYER_SURFACE_V1_ANCHOR_BOTTOM; },
edges[2].positive_axis = &usable_area->x; { // Right
edges[2].negative_axis = &usable_area->width; .singular_anchor = ZWLR_LAYER_SURFACE_V1_ANCHOR_RIGHT,
edges[2].margin = margin_left; .anchor_triplet = ZWLR_LAYER_SURFACE_V1_ANCHOR_RIGHT |
ZWLR_LAYER_SURFACE_V1_ANCHOR_TOP |
// Right ZWLR_LAYER_SURFACE_V1_ANCHOR_BOTTOM,
edges[3].singular_anchor = ZWLR_LAYER_SURFACE_V1_ANCHOR_RIGHT; .positive_axis = NULL,
edges[3].anchor_triplet = ZWLR_LAYER_SURFACE_V1_ANCHOR_RIGHT | .negative_axis = &usable_area->width,
ZWLR_LAYER_SURFACE_V1_ANCHOR_TOP | .margin = margin_right,
ZWLR_LAYER_SURFACE_V1_ANCHOR_BOTTOM; }
edges[3].positive_axis = NULL; };
edges[3].negative_axis = &usable_area->width;
edges[3].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,9 +571,10 @@ arrangelayer(Monitor *m, struct wl_list *list, struct wlr_box *usable_area, int
} }
layersurface->geo = box; layersurface->geo = box;
applyexclusive(usable_area, state->anchor, state->exclusive_zone, if (state->exclusive_zone > 0)
state->margin.top, state->margin.right, applyexclusive(usable_area, state->anchor, state->exclusive_zone,
state->margin.bottom, state->margin.left); state->margin.top, state->margin.right,
state->margin.bottom, state->margin.left);
wlr_layer_surface_v1_configure(wlr_layer_surface, box.width, box.height); wlr_layer_surface_v1_configure(wlr_layer_surface, box.width, box.height);
} }
} }