aboutsummaryrefslogtreecommitdiffstats
path: root/sway
diff options
context:
space:
mode:
authorLibravatar Aleksei Bavshin <alebastr89@gmail.com>2020-02-27 17:55:55 -0800
committerLibravatar Simon Ser <contact@emersion.fr>2020-04-10 10:45:47 +0200
commit525b48ede795effb6ef61b7caf6ad333393cfd64 (patch)
treea1b4dfbbc8f0fe1b03e65cf219153334e6ea16c8 /sway
parentRender layer shell popups over the top layer (diff)
downloadsway-525b48ede795effb6ef61b7caf6ad333393cfd64.tar.gz
sway-525b48ede795effb6ef61b7caf6ad333393cfd64.tar.zst
sway-525b48ede795effb6ef61b7caf6ad333393cfd64.zip
Adjust focus order to match rendering order of layer shell popups.
Diffstat (limited to 'sway')
-rw-r--r--sway/input/cursor.c39
1 files changed, 39 insertions, 0 deletions
diff --git a/sway/input/cursor.c b/sway/input/cursor.c
index 470bb996..11a2de85 100644
--- a/sway/input/cursor.c
+++ b/sway/input/cursor.c
@@ -52,6 +52,30 @@ static struct wlr_surface *layer_surface_at(struct sway_output *output,
52 return NULL; 52 return NULL;
53} 53}
54 54
55static bool surface_is_xdg_popup(struct wlr_surface *surface) {
56 if (wlr_surface_is_xdg_surface(surface)) {
57 struct wlr_xdg_surface *xdg_surface =
58 wlr_xdg_surface_from_wlr_surface(surface);
59 return xdg_surface->role == WLR_XDG_SURFACE_ROLE_POPUP;
60 }
61 return false;
62}
63
64static struct wlr_surface *layer_surface_popup_at(struct sway_output *output,
65 struct wl_list *layer, double ox, double oy, double *sx, double *sy) {
66 struct sway_layer_surface *sway_layer;
67 wl_list_for_each_reverse(sway_layer, layer, link) {
68 double _sx = ox - sway_layer->geo.x;
69 double _sy = oy - sway_layer->geo.y;
70 struct wlr_surface *sub = wlr_layer_surface_v1_surface_at(
71 sway_layer->layer_surface, _sx, _sy, sx, sy);
72 if (sub && surface_is_xdg_popup(sub)) {
73 return sub;
74 }
75 }
76 return NULL;
77}
78
55/** 79/**
56 * Returns the node at the cursor's position. If there is a surface at that 80 * Returns the node at the cursor's position. If there is a surface at that
57 * location, it is stored in **surface (it may not be a view). 81 * location, it is stored in **surface (it may not be a view).
@@ -132,6 +156,21 @@ struct sway_node *node_at_coords(
132 } 156 }
133 return NULL; 157 return NULL;
134 } 158 }
159 if ((*surface = layer_surface_popup_at(output,
160 &output->layers[ZWLR_LAYER_SHELL_V1_LAYER_TOP],
161 ox, oy, sx, sy))) {
162 return NULL;
163 }
164 if ((*surface = layer_surface_popup_at(output,
165 &output->layers[ZWLR_LAYER_SHELL_V1_LAYER_BOTTOM],
166 ox, oy, sx, sy))) {
167 return NULL;
168 }
169 if ((*surface = layer_surface_popup_at(output,
170 &output->layers[ZWLR_LAYER_SHELL_V1_LAYER_BACKGROUND],
171 ox, oy, sx, sy))) {
172 return NULL;
173 }
135 if ((*surface = layer_surface_at(output, 174 if ((*surface = layer_surface_at(output,
136 &output->layers[ZWLR_LAYER_SHELL_V1_LAYER_TOP], 175 &output->layers[ZWLR_LAYER_SHELL_V1_LAYER_TOP],
137 ox, oy, sx, sy))) { 176 ox, oy, sx, sy))) {