diff options
author | Ryan Dwyer <ryandwyer1@gmail.com> | 2018-08-02 23:30:26 +1000 |
---|---|---|
committer | Ryan Dwyer <ryandwyer1@gmail.com> | 2018-08-02 23:36:36 +1000 |
commit | 8392eae40f17e550338b8b7058d8e9c1a6ad4f78 (patch) | |
tree | ffefcdd261970549f8b83adae8d93b6c3b9ebbbb /sway/desktop | |
parent | Merge pull request #2366 from RedSoxFan/nagbar (diff) | |
download | sway-8392eae40f17e550338b8b7058d8e9c1a6ad4f78.tar.gz sway-8392eae40f17e550338b8b7058d8e9c1a6ad4f78.tar.zst sway-8392eae40f17e550338b8b7058d8e9c1a6ad4f78.zip |
Revert "Revert "Fix popups""
This reverts commit 9aa258d33a9baa42895214da7e82f4568fcb8f76.
Reverting the revert, so that popups can be fixed.
Diffstat (limited to 'sway/desktop')
-rw-r--r-- | sway/desktop/output.c | 19 | ||||
-rw-r--r-- | sway/desktop/render.c | 37 | ||||
-rw-r--r-- | sway/desktop/xdg_shell.c | 9 | ||||
-rw-r--r-- | sway/desktop/xdg_shell_v6.c | 10 |
4 files changed, 70 insertions, 5 deletions
diff --git a/sway/desktop/output.c b/sway/desktop/output.c index 31b53213..66747a3f 100644 --- a/sway/desktop/output.c +++ b/sway/desktop/output.c | |||
@@ -119,7 +119,7 @@ static void output_for_each_surface_iterator(struct wlr_surface *surface, | |||
119 | data->user_data); | 119 | data->user_data); |
120 | } | 120 | } |
121 | 121 | ||
122 | static void output_surface_for_each_surface(struct sway_output *output, | 122 | void output_surface_for_each_surface(struct sway_output *output, |
123 | struct wlr_surface *surface, double ox, double oy, | 123 | struct wlr_surface *surface, double ox, double oy, |
124 | sway_surface_iterator_func_t iterator, void *user_data) { | 124 | sway_surface_iterator_func_t iterator, void *user_data) { |
125 | struct surface_iterator_data data = { | 125 | struct surface_iterator_data data = { |
@@ -155,6 +155,23 @@ void output_view_for_each_surface(struct sway_output *output, | |||
155 | output_for_each_surface_iterator, &data); | 155 | output_for_each_surface_iterator, &data); |
156 | } | 156 | } |
157 | 157 | ||
158 | void output_view_for_each_popup(struct sway_output *output, | ||
159 | struct sway_view *view, sway_surface_iterator_func_t iterator, | ||
160 | void *user_data) { | ||
161 | struct surface_iterator_data data = { | ||
162 | .user_iterator = iterator, | ||
163 | .user_data = user_data, | ||
164 | .output = output, | ||
165 | .ox = view->swayc->current.view_x - output->swayc->current.swayc_x, | ||
166 | .oy = view->swayc->current.view_y - output->swayc->current.swayc_y, | ||
167 | .width = view->swayc->current.view_width, | ||
168 | .height = view->swayc->current.view_height, | ||
169 | .rotation = 0, // TODO | ||
170 | }; | ||
171 | |||
172 | view_for_each_popup(view, output_for_each_surface_iterator, &data); | ||
173 | } | ||
174 | |||
158 | void output_layer_for_each_surface(struct sway_output *output, | 175 | void output_layer_for_each_surface(struct sway_output *output, |
159 | struct wl_list *layer_surfaces, sway_surface_iterator_func_t iterator, | 176 | struct wl_list *layer_surfaces, sway_surface_iterator_func_t iterator, |
160 | void *user_data) { | 177 | void *user_data) { |
diff --git a/sway/desktop/render.c b/sway/desktop/render.c index f0e47c95..1f374740 100644 --- a/sway/desktop/render.c +++ b/sway/desktop/render.c | |||
@@ -186,13 +186,36 @@ static void premultiply_alpha(float color[4], float opacity) { | |||
186 | color[2] *= color[3]; | 186 | color[2] *= color[3]; |
187 | } | 187 | } |
188 | 188 | ||
189 | static void render_view_surfaces(struct sway_view *view, | 189 | static void render_view_toplevels(struct sway_view *view, |
190 | struct sway_output *output, pixman_region32_t *damage, float alpha) { | 190 | struct sway_output *output, pixman_region32_t *damage, float alpha) { |
191 | struct render_data data = { | 191 | struct render_data data = { |
192 | .damage = damage, | 192 | .damage = damage, |
193 | .alpha = alpha, | 193 | .alpha = alpha, |
194 | }; | 194 | }; |
195 | output_view_for_each_surface(output, view, render_surface_iterator, &data); | 195 | // Render all toplevels without descending into popups |
196 | output_surface_for_each_surface(output, view->surface, | ||
197 | view->swayc->current.view_x, view->swayc->current.view_y, | ||
198 | render_surface_iterator, &data); | ||
199 | } | ||
200 | |||
201 | static void render_popup_iterator(struct sway_output *output, | ||
202 | struct wlr_surface *surface, struct wlr_box *box, float rotation, | ||
203 | void *data) { | ||
204 | // Render this popup's surface | ||
205 | render_surface_iterator(output, surface, box, rotation, data); | ||
206 | |||
207 | // Render this popup's child toplevels | ||
208 | output_surface_for_each_surface(output, surface, box->x, box->y, | ||
209 | render_surface_iterator, data); | ||
210 | } | ||
211 | |||
212 | static void render_view_popups(struct sway_view *view, | ||
213 | struct sway_output *output, pixman_region32_t *damage, float alpha) { | ||
214 | struct render_data data = { | ||
215 | .damage = damage, | ||
216 | .alpha = alpha, | ||
217 | }; | ||
218 | output_view_for_each_popup(output, view, render_popup_iterator, &data); | ||
196 | } | 219 | } |
197 | 220 | ||
198 | static void render_saved_view(struct sway_view *view, | 221 | static void render_saved_view(struct sway_view *view, |
@@ -239,7 +262,7 @@ static void render_view(struct sway_output *output, pixman_region32_t *damage, | |||
239 | if (view->saved_buffer) { | 262 | if (view->saved_buffer) { |
240 | render_saved_view(view, output, damage, view->swayc->alpha); | 263 | render_saved_view(view, output, damage, view->swayc->alpha); |
241 | } else { | 264 | } else { |
242 | render_view_surfaces(view, output, damage, view->swayc->alpha); | 265 | render_view_toplevels(view, output, damage, view->swayc->alpha); |
243 | } | 266 | } |
244 | 267 | ||
245 | if (view->using_csd) { | 268 | if (view->using_csd) { |
@@ -843,7 +866,7 @@ void output_render(struct sway_output *output, struct timespec *when, | |||
843 | render_saved_view(fullscreen_con->sway_view, | 866 | render_saved_view(fullscreen_con->sway_view, |
844 | output, damage, 1.0f); | 867 | output, damage, 1.0f); |
845 | } else { | 868 | } else { |
846 | render_view_surfaces(fullscreen_con->sway_view, | 869 | render_view_toplevels(fullscreen_con->sway_view, |
847 | output, damage, 1.0f); | 870 | output, damage, 1.0f); |
848 | } | 871 | } |
849 | } else { | 872 | } else { |
@@ -879,6 +902,12 @@ void output_render(struct sway_output *output, struct timespec *when, | |||
879 | &output->layers[ZWLR_LAYER_SHELL_V1_LAYER_TOP]); | 902 | &output->layers[ZWLR_LAYER_SHELL_V1_LAYER_TOP]); |
880 | } | 903 | } |
881 | 904 | ||
905 | struct sway_seat *seat = input_manager_current_seat(input_manager); | ||
906 | struct sway_container *focus = seat_get_focus(seat); | ||
907 | if (focus && focus->type == C_VIEW) { | ||
908 | render_view_popups(focus->sway_view, output, damage, focus->alpha); | ||
909 | } | ||
910 | |||
882 | render_overlay: | 911 | render_overlay: |
883 | render_layer(output, damage, | 912 | render_layer(output, damage, |
884 | &output->layers[ZWLR_LAYER_SHELL_V1_LAYER_OVERLAY]); | 913 | &output->layers[ZWLR_LAYER_SHELL_V1_LAYER_OVERLAY]); |
diff --git a/sway/desktop/xdg_shell.c b/sway/desktop/xdg_shell.c index 9d6b27e5..b364663d 100644 --- a/sway/desktop/xdg_shell.c +++ b/sway/desktop/xdg_shell.c | |||
@@ -179,6 +179,14 @@ static void for_each_surface(struct sway_view *view, | |||
179 | user_data); | 179 | user_data); |
180 | } | 180 | } |
181 | 181 | ||
182 | static void for_each_popup(struct sway_view *view, | ||
183 | wlr_surface_iterator_func_t iterator, void *user_data) { | ||
184 | if (xdg_shell_view_from_view(view) == NULL) { | ||
185 | return; | ||
186 | } | ||
187 | wlr_xdg_surface_for_each_popup(view->wlr_xdg_surface, iterator, user_data); | ||
188 | } | ||
189 | |||
182 | static void _close(struct sway_view *view) { | 190 | static void _close(struct sway_view *view) { |
183 | if (xdg_shell_view_from_view(view) == NULL) { | 191 | if (xdg_shell_view_from_view(view) == NULL) { |
184 | return; | 192 | return; |
@@ -219,6 +227,7 @@ static const struct sway_view_impl view_impl = { | |||
219 | .set_fullscreen = set_fullscreen, | 227 | .set_fullscreen = set_fullscreen, |
220 | .wants_floating = wants_floating, | 228 | .wants_floating = wants_floating, |
221 | .for_each_surface = for_each_surface, | 229 | .for_each_surface = for_each_surface, |
230 | .for_each_popup = for_each_popup, | ||
222 | .close = _close, | 231 | .close = _close, |
223 | .close_popups = close_popups, | 232 | .close_popups = close_popups, |
224 | .destroy = destroy, | 233 | .destroy = destroy, |
diff --git a/sway/desktop/xdg_shell_v6.c b/sway/desktop/xdg_shell_v6.c index 6e4aae62..ffea03ad 100644 --- a/sway/desktop/xdg_shell_v6.c +++ b/sway/desktop/xdg_shell_v6.c | |||
@@ -175,6 +175,15 @@ static void for_each_surface(struct sway_view *view, | |||
175 | user_data); | 175 | user_data); |
176 | } | 176 | } |
177 | 177 | ||
178 | static void for_each_popup(struct sway_view *view, | ||
179 | wlr_surface_iterator_func_t iterator, void *user_data) { | ||
180 | if (xdg_shell_v6_view_from_view(view) == NULL) { | ||
181 | return; | ||
182 | } | ||
183 | wlr_xdg_surface_v6_for_each_popup(view->wlr_xdg_surface_v6, iterator, | ||
184 | user_data); | ||
185 | } | ||
186 | |||
178 | static void _close(struct sway_view *view) { | 187 | static void _close(struct sway_view *view) { |
179 | if (xdg_shell_v6_view_from_view(view) == NULL) { | 188 | if (xdg_shell_v6_view_from_view(view) == NULL) { |
180 | return; | 189 | return; |
@@ -215,6 +224,7 @@ static const struct sway_view_impl view_impl = { | |||
215 | .set_fullscreen = set_fullscreen, | 224 | .set_fullscreen = set_fullscreen, |
216 | .wants_floating = wants_floating, | 225 | .wants_floating = wants_floating, |
217 | .for_each_surface = for_each_surface, | 226 | .for_each_surface = for_each_surface, |
227 | .for_each_popup = for_each_popup, | ||
218 | .close = _close, | 228 | .close = _close, |
219 | .close_popups = close_popups, | 229 | .close_popups = close_popups, |
220 | .destroy = destroy, | 230 | .destroy = destroy, |