diff options
-rw-r--r-- | sway/desktop/layer_shell.c | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/sway/desktop/layer_shell.c b/sway/desktop/layer_shell.c index b1ee8ae3..60a8f06b 100644 --- a/sway/desktop/layer_shell.c +++ b/sway/desktop/layer_shell.c | |||
@@ -25,13 +25,16 @@ static void apply_exclusive(struct wlr_box *usable_area, | |||
25 | return; | 25 | return; |
26 | } | 26 | } |
27 | struct { | 27 | struct { |
28 | uint32_t anchors; | 28 | uint32_t singular_anchor; |
29 | uint32_t anchor_triplet; | ||
29 | int *positive_axis; | 30 | int *positive_axis; |
30 | int *negative_axis; | 31 | int *negative_axis; |
31 | int margin; | 32 | int margin; |
32 | } edges[] = { | 33 | } edges[] = { |
34 | // Top | ||
33 | { | 35 | { |
34 | .anchors = | 36 | .singular_anchor = ZWLR_LAYER_SURFACE_V1_ANCHOR_TOP, |
37 | .anchor_triplet = | ||
35 | ZWLR_LAYER_SURFACE_V1_ANCHOR_LEFT | | 38 | ZWLR_LAYER_SURFACE_V1_ANCHOR_LEFT | |
36 | ZWLR_LAYER_SURFACE_V1_ANCHOR_RIGHT | | 39 | ZWLR_LAYER_SURFACE_V1_ANCHOR_RIGHT | |
37 | ZWLR_LAYER_SURFACE_V1_ANCHOR_TOP, | 40 | ZWLR_LAYER_SURFACE_V1_ANCHOR_TOP, |
@@ -39,8 +42,10 @@ static void apply_exclusive(struct wlr_box *usable_area, | |||
39 | .negative_axis = &usable_area->height, | 42 | .negative_axis = &usable_area->height, |
40 | .margin = margin_top, | 43 | .margin = margin_top, |
41 | }, | 44 | }, |
45 | // Bottom | ||
42 | { | 46 | { |
43 | .anchors = | 47 | .singular_anchor = ZWLR_LAYER_SURFACE_V1_ANCHOR_BOTTOM, |
48 | .anchor_triplet = | ||
44 | ZWLR_LAYER_SURFACE_V1_ANCHOR_LEFT | | 49 | ZWLR_LAYER_SURFACE_V1_ANCHOR_LEFT | |
45 | ZWLR_LAYER_SURFACE_V1_ANCHOR_RIGHT | | 50 | ZWLR_LAYER_SURFACE_V1_ANCHOR_RIGHT | |
46 | ZWLR_LAYER_SURFACE_V1_ANCHOR_BOTTOM, | 51 | ZWLR_LAYER_SURFACE_V1_ANCHOR_BOTTOM, |
@@ -48,8 +53,10 @@ static void apply_exclusive(struct wlr_box *usable_area, | |||
48 | .negative_axis = &usable_area->height, | 53 | .negative_axis = &usable_area->height, |
49 | .margin = margin_bottom, | 54 | .margin = margin_bottom, |
50 | }, | 55 | }, |
56 | // Left | ||
51 | { | 57 | { |
52 | .anchors = | 58 | .singular_anchor = ZWLR_LAYER_SURFACE_V1_ANCHOR_LEFT, |
59 | .anchor_triplet = | ||
53 | ZWLR_LAYER_SURFACE_V1_ANCHOR_LEFT | | 60 | ZWLR_LAYER_SURFACE_V1_ANCHOR_LEFT | |
54 | ZWLR_LAYER_SURFACE_V1_ANCHOR_TOP | | 61 | ZWLR_LAYER_SURFACE_V1_ANCHOR_TOP | |
55 | ZWLR_LAYER_SURFACE_V1_ANCHOR_BOTTOM, | 62 | ZWLR_LAYER_SURFACE_V1_ANCHOR_BOTTOM, |
@@ -57,8 +64,10 @@ static void apply_exclusive(struct wlr_box *usable_area, | |||
57 | .negative_axis = &usable_area->width, | 64 | .negative_axis = &usable_area->width, |
58 | .margin = margin_left, | 65 | .margin = margin_left, |
59 | }, | 66 | }, |
67 | // Right | ||
60 | { | 68 | { |
61 | .anchors = | 69 | .singular_anchor = ZWLR_LAYER_SURFACE_V1_ANCHOR_RIGHT, |
70 | .anchor_triplet = | ||
62 | ZWLR_LAYER_SURFACE_V1_ANCHOR_RIGHT | | 71 | ZWLR_LAYER_SURFACE_V1_ANCHOR_RIGHT | |
63 | ZWLR_LAYER_SURFACE_V1_ANCHOR_TOP | | 72 | ZWLR_LAYER_SURFACE_V1_ANCHOR_TOP | |
64 | ZWLR_LAYER_SURFACE_V1_ANCHOR_BOTTOM, | 73 | ZWLR_LAYER_SURFACE_V1_ANCHOR_BOTTOM, |
@@ -68,13 +77,15 @@ static void apply_exclusive(struct wlr_box *usable_area, | |||
68 | }, | 77 | }, |
69 | }; | 78 | }; |
70 | for (size_t i = 0; i < sizeof(edges) / sizeof(edges[0]); ++i) { | 79 | for (size_t i = 0; i < sizeof(edges) / sizeof(edges[0]); ++i) { |
71 | if ((anchor & edges[i].anchors) == edges[i].anchors && exclusive + edges[i].margin > 0) { | 80 | if ((anchor == edges[i].singular_anchor || anchor == edges[i].anchor_triplet) |
81 | && exclusive + edges[i].margin > 0) { | ||
72 | if (edges[i].positive_axis) { | 82 | if (edges[i].positive_axis) { |
73 | *edges[i].positive_axis += exclusive + edges[i].margin; | 83 | *edges[i].positive_axis += exclusive + edges[i].margin; |
74 | } | 84 | } |
75 | if (edges[i].negative_axis) { | 85 | if (edges[i].negative_axis) { |
76 | *edges[i].negative_axis -= exclusive + edges[i].margin; | 86 | *edges[i].negative_axis -= exclusive + edges[i].margin; |
77 | } | 87 | } |
88 | break; | ||
78 | } | 89 | } |
79 | } | 90 | } |
80 | } | 91 | } |