Output: abstract away a view switch statement

We have our view abstraction, so why not use it?
This commit is contained in:
Jente Hidskes 2019-01-02 21:23:16 +01:00
parent 431320443a
commit 9a99ba604f
No known key found for this signature in database
GPG key ID: 04BE5A29F32D91EA
5 changed files with 29 additions and 21 deletions

View file

@ -73,24 +73,6 @@ render_surface(struct wlr_surface *surface, int sx, int sy, void *data)
wlr_surface_send_frame_done(surface, rdata->when);
}
static void
view_for_each_surface(struct cg_view *view, struct render_data *rdata,
wlr_surface_iterator_func_t iterator)
{
switch(view->type) {
case CAGE_XDG_SHELL_VIEW:
wlr_xdg_surface_for_each_surface(view->xdg_surface, iterator, rdata);
break;
#ifdef CAGE_HAS_XWAYLAND
case CAGE_XWAYLAND_VIEW:
wlr_surface_for_each_surface(view->wlr_surface, iterator, rdata);
break;
#endif
default:
wlr_log(WLR_ERROR, "Unrecognized view type: %d", view->type);
}
}
static void
handle_output_frame(struct wl_listener *listener, void *data)
{
@ -122,7 +104,7 @@ handle_output_frame(struct wl_listener *listener, void *data)
struct cg_view *view;
wl_list_for_each_reverse(view, &output->server->views, link) {
rdata.view = view;
view_for_each_surface(view, &rdata, render_surface);
view_for_each_surface(view, render_surface, &rdata);
}
wlr_renderer_end(renderer);