From 5438cc158a1b9fa3bf76445a6dc986e30c5e78f6 Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Fri, 8 Jan 2021 10:46:12 +0100 Subject: Switch to wlr_xdg_surface_for_each_popup_surface Instead of calling wlr_xdg_surface_for_each_popup and then wlr_surface_for_each_surface, use the new for_each_popup_surface helper introduced in [1] that does it in one go. [1]: https://github.com/swaywm/wlroots/pull/2609 --- include/sway/output.h | 2 +- include/sway/tree/view.h | 6 +++--- sway/desktop/output.c | 4 ++-- sway/desktop/render.c | 14 ++------------ sway/desktop/xdg_shell.c | 7 ++++--- sway/tree/view.c | 6 +++--- 6 files changed, 15 insertions(+), 24 deletions(-) diff --git a/include/sway/output.h b/include/sway/output.h index 16451d81..300fcd48 100644 --- a/include/sway/output.h +++ b/include/sway/output.h @@ -116,7 +116,7 @@ void output_view_for_each_surface(struct sway_output *output, struct sway_view *view, sway_surface_iterator_func_t iterator, void *user_data); -void output_view_for_each_popup(struct sway_output *output, +void output_view_for_each_popup_surface(struct sway_output *output, struct sway_view *view, sway_surface_iterator_func_t iterator, void *user_data); diff --git a/include/sway/tree/view.h b/include/sway/tree/view.h index dac348ee..e071e6c9 100644 --- a/include/sway/tree/view.h +++ b/include/sway/tree/view.h @@ -47,7 +47,7 @@ struct sway_view_impl { bool (*wants_floating)(struct sway_view *view); void (*for_each_surface)(struct sway_view *view, wlr_surface_iterator_func_t iterator, void *user_data); - void (*for_each_popup)(struct sway_view *view, + void (*for_each_popup_surface)(struct sway_view *view, wlr_surface_iterator_func_t iterator, void *user_data); bool (*is_transient_for)(struct sway_view *child, struct sway_view *ancestor); @@ -297,9 +297,9 @@ void view_for_each_surface(struct sway_view *view, wlr_surface_iterator_func_t iterator, void *user_data); /** - * Iterate all popups recursively. + * Iterate all popup surfaces of a view. */ -void view_for_each_popup(struct sway_view *view, +void view_for_each_popup_surface(struct sway_view *view, wlr_surface_iterator_func_t iterator, void *user_data); // view implementation diff --git a/sway/desktop/output.c b/sway/desktop/output.c index 06acb868..7921d597 100644 --- a/sway/desktop/output.c +++ b/sway/desktop/output.c @@ -179,7 +179,7 @@ void output_view_for_each_surface(struct sway_output *output, view_for_each_surface(view, output_for_each_surface_iterator, &data); } -void output_view_for_each_popup(struct sway_output *output, +void output_view_for_each_popup_surface(struct sway_output *output, struct sway_view *view, sway_surface_iterator_func_t iterator, void *user_data) { struct surface_iterator_data data = { @@ -196,7 +196,7 @@ void output_view_for_each_popup(struct sway_output *output, .rotation = 0, // TODO }; - view_for_each_popup(view, output_for_each_surface_iterator, &data); + view_for_each_popup_surface(view, output_for_each_surface_iterator, &data); } void output_layer_for_each_surface(struct sway_output *output, diff --git a/sway/desktop/render.c b/sway/desktop/render.c index 3a422293..acf503a4 100644 --- a/sway/desktop/render.c +++ b/sway/desktop/render.c @@ -265,24 +265,14 @@ static void render_view_toplevels(struct sway_view *view, render_surface_iterator, &data); } -static void render_popup_iterator(struct sway_output *output, struct sway_view *view, - struct wlr_surface *surface, struct wlr_box *box, float rotation, - void *data) { - // Render this popup's surface - render_surface_iterator(output, view, surface, box, rotation, data); - - // Render this popup's child toplevels - output_surface_for_each_surface(output, surface, box->x, box->y, - render_surface_iterator, data); -} - static void render_view_popups(struct sway_view *view, struct sway_output *output, pixman_region32_t *damage, float alpha) { struct render_data data = { .damage = damage, .alpha = alpha, }; - output_view_for_each_popup(output, view, render_popup_iterator, &data); + output_view_for_each_popup_surface(output, view, + render_surface_iterator, &data); } static void render_saved_view(struct sway_view *view, diff --git a/sway/desktop/xdg_shell.c b/sway/desktop/xdg_shell.c index fdac6171..667fb9e5 100644 --- a/sway/desktop/xdg_shell.c +++ b/sway/desktop/xdg_shell.c @@ -211,12 +211,13 @@ static void for_each_surface(struct sway_view *view, user_data); } -static void for_each_popup(struct sway_view *view, +static void for_each_popup_surface(struct sway_view *view, wlr_surface_iterator_func_t iterator, void *user_data) { if (xdg_shell_view_from_view(view) == NULL) { return; } - wlr_xdg_surface_for_each_popup(view->wlr_xdg_surface, iterator, user_data); + wlr_xdg_surface_for_each_popup_surface(view->wlr_xdg_surface, iterator, + user_data); } static bool is_transient_for(struct sway_view *child, @@ -271,7 +272,7 @@ static const struct sway_view_impl view_impl = { .set_resizing = set_resizing, .wants_floating = wants_floating, .for_each_surface = for_each_surface, - .for_each_popup = for_each_popup, + .for_each_popup_surface = for_each_popup_surface, .is_transient_for = is_transient_for, .close = _close, .close_popups = close_popups, diff --git a/sway/tree/view.c b/sway/tree/view.c index e690c334..07ca3dff 100644 --- a/sway/tree/view.c +++ b/sway/tree/view.c @@ -449,13 +449,13 @@ void view_for_each_surface(struct sway_view *view, } } -void view_for_each_popup(struct sway_view *view, +void view_for_each_popup_surface(struct sway_view *view, wlr_surface_iterator_func_t iterator, void *user_data) { if (!view->surface) { return; } - if (view->impl->for_each_popup) { - view->impl->for_each_popup(view, iterator, user_data); + if (view->impl->for_each_popup_surface) { + view->impl->for_each_popup_surface(view, iterator, user_data); } } -- cgit v1.2.3-54-g00ecf