aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Leon Plickat <leonhenrik.plickat@stud.uni-goettingen.de>2020-03-21 15:15:01 +0100
committerLibravatar Simon Ser <contact@emersion.fr>2020-03-30 17:45:05 +0200
commitdffc184a68c2d6839d4e601be141fe1adcd385aa (patch)
treecbbce5f78e17dfad28c9d4b3774cc84eb402dfb5
parenttray: track SNI callbacks (diff)
downloadsway-dffc184a68c2d6839d4e601be141fe1adcd385aa.tar.gz
sway-dffc184a68c2d6839d4e601be141fe1adcd385aa.tar.zst
sway-dffc184a68c2d6839d4e601be141fe1adcd385aa.zip
change apply_exclusive() to closer match layer shell protocol
With these changes, sway will respect positive exclusive zones of layer surfaces anchored to one or three sides. This matches the protocol, which states that a positive exclusive zone should be respected, "if the surface is anchored to one edge or an edge and both perpendicular edges". If the surfaces is "anchored to only two perpendicular edges (a corner), anchored to only two parallel edges or anchored to all edges a positive value will be treated the same as zero".
-rw-r--r--sway/desktop/layer_shell.c23
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}