diff options
author | Ryan Dwyer <ryandwyer1@gmail.com> | 2018-07-31 18:41:30 +1000 |
---|---|---|
committer | Ryan Dwyer <ryandwyer1@gmail.com> | 2018-07-31 18:41:30 +1000 |
commit | de86d65627e96cffe77f4abf11c4a0b982326ff9 (patch) | |
tree | 1a3a914fdf561884b1bb0425d51d15684b629b3a /sway/desktop/render.c | |
parent | Merge pull request #2390 from emersion/fix-fullscreen-segfault (diff) | |
download | sway-de86d65627e96cffe77f4abf11c4a0b982326ff9.tar.gz sway-de86d65627e96cffe77f4abf11c4a0b982326ff9.tar.zst sway-de86d65627e96cffe77f4abf11c4a0b982326ff9.zip |
Fix popups
Fixes the render and container_at order for popups.
Fixes #2210
For rendering:
* render_view_surfaces has been renamed to render_view_toplevels
* render_view_toplevels now uses output_surface_for_each_surface (which
is now public), as that function uses wlr_surface_for_each_surface which
doesn't descend into popups
* Views now have a for_each_popup iterator, which is used by the
renderer to render the focused view's popups
* When rendering a popup, toplevels (xdg subsurfaces) of that popup are
also rendered
For sending frame done, the logic has been updated to match the
rendering logic:
* send_frame_done_container no longer descends into popups
* for_each_popup is used to send frame done to the focused view's popups
and their child toplevels
For container_at:
* floating_container_at is now static, which means it had to be moved
higher in the file.
* container_at now considers popups for the focused view before checking
containers.
* tiling_container_at has been introduced, so that it doesn't call
container_at recursively (it would check popups recursively if it did)
Diffstat (limited to 'sway/desktop/render.c')
-rw-r--r-- | sway/desktop/render.c | 37 |
1 files changed, 33 insertions, 4 deletions
diff --git a/sway/desktop/render.c b/sway/desktop/render.c index f25055b8..ea4361f2 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, |
@@ -241,7 +264,7 @@ static void render_view(struct sway_output *output, pixman_region32_t *damage, | |||
241 | if (view->swayc->instructions->length) { | 264 | if (view->swayc->instructions->length) { |
242 | render_saved_view(view, output, damage, view->swayc->alpha); | 265 | render_saved_view(view, output, damage, view->swayc->alpha); |
243 | } else { | 266 | } else { |
244 | render_view_surfaces(view, output, damage, view->swayc->alpha); | 267 | render_view_toplevels(view, output, damage, view->swayc->alpha); |
245 | } | 268 | } |
246 | 269 | ||
247 | if (view->using_csd) { | 270 | if (view->using_csd) { |
@@ -845,7 +868,7 @@ void output_render(struct sway_output *output, struct timespec *when, | |||
845 | render_saved_view(fullscreen_con->sway_view, | 868 | render_saved_view(fullscreen_con->sway_view, |
846 | output, damage, 1.0f); | 869 | output, damage, 1.0f); |
847 | } else { | 870 | } else { |
848 | render_view_surfaces(fullscreen_con->sway_view, | 871 | render_view_toplevels(fullscreen_con->sway_view, |
849 | output, damage, 1.0f); | 872 | output, damage, 1.0f); |
850 | } | 873 | } |
851 | } else { | 874 | } else { |
@@ -881,6 +904,12 @@ void output_render(struct sway_output *output, struct timespec *when, | |||
881 | &output->layers[ZWLR_LAYER_SHELL_V1_LAYER_TOP]); | 904 | &output->layers[ZWLR_LAYER_SHELL_V1_LAYER_TOP]); |
882 | } | 905 | } |
883 | 906 | ||
907 | struct sway_seat *seat = input_manager_current_seat(input_manager); | ||
908 | struct sway_container *focus = seat_get_focus(seat); | ||
909 | if (focus && focus->type == C_VIEW) { | ||
910 | render_view_popups(focus->sway_view, output, damage, focus->alpha); | ||
911 | } | ||
912 | |||
884 | render_overlay: | 913 | render_overlay: |
885 | render_layer(output, damage, | 914 | render_layer(output, damage, |
886 | &output->layers[ZWLR_LAYER_SHELL_V1_LAYER_OVERLAY]); | 915 | &output->layers[ZWLR_LAYER_SHELL_V1_LAYER_OVERLAY]); |