diff options
author | emersion <contact@emersion.fr> | 2019-02-23 14:18:32 +0100 |
---|---|---|
committer | emersion <contact@emersion.fr> | 2019-02-23 14:18:32 +0100 |
commit | 9f11bf571e2644447b7b39aec8ee87ceab8015f0 (patch) | |
tree | cf4e552797ed0aabfc029cd9e1677cef4d473260 /rootston/view.c | |
parent | e86c7a3dd67f14d738b058c4aa3698e9e74958c9 (diff) |
rootston: add a view child interface
Diffstat (limited to 'rootston/view.c')
-rw-r--r-- | rootston/view.c | 29 |
1 files changed, 17 insertions, 12 deletions
diff --git a/rootston/view.c b/rootston/view.c index c409c75c..f2b5f12f 100644 --- a/rootston/view.c +++ b/rootston/view.c @@ -354,7 +354,7 @@ bool view_center(struct roots_view *view) { return true; } -void view_child_finish(struct roots_view_child *child) { +void view_child_destroy(struct roots_view_child *child) { if (child == NULL) { return; } @@ -362,6 +362,7 @@ void view_child_finish(struct roots_view_child *child) { wl_list_remove(&child->link); wl_list_remove(&child->commit.link); wl_list_remove(&child->new_subsurface.link); + child->impl->destroy(child); } static void view_child_handle_commit(struct wl_listener *listener, @@ -378,9 +379,11 @@ static void view_child_handle_new_subsurface(struct wl_listener *listener, subsurface_create(child->view, wlr_subsurface); } -void view_child_init(struct roots_view_child *child, struct roots_view *view, +void view_child_init(struct roots_view_child *child, + const struct roots_view_child_interface *impl, struct roots_view *view, struct wlr_surface *wlr_surface) { - assert(child->destroy); + assert(impl->destroy); + child->impl = impl; child->view = view; child->wlr_surface = wlr_surface; child->commit.notify = view_child_handle_commit; @@ -390,24 +393,26 @@ void view_child_init(struct roots_view_child *child, struct roots_view *view, wl_list_insert(&view->children, &child->link); } +static const struct roots_view_child_interface subsurface_impl; + static void subsurface_destroy(struct roots_view_child *child) { - assert(child->destroy == subsurface_destroy); + assert(child->impl == &subsurface_impl); struct roots_subsurface *subsurface = (struct roots_subsurface *)child; - if (subsurface == NULL) { - return; - } wl_list_remove(&subsurface->destroy.link); wl_list_remove(&subsurface->map.link); wl_list_remove(&subsurface->unmap.link); - view_child_finish(&subsurface->view_child); free(subsurface); } +static const struct roots_view_child_interface subsurface_impl = { + .destroy = subsurface_destroy, +}; + static void subsurface_handle_destroy(struct wl_listener *listener, void *data) { struct roots_subsurface *subsurface = wl_container_of(listener, subsurface, destroy); - subsurface_destroy(&subsurface->view_child); + view_child_destroy(&subsurface->view_child); } static void subsurface_handle_map(struct wl_listener *listener, @@ -436,8 +441,8 @@ struct roots_subsurface *subsurface_create(struct roots_view *view, return NULL; } subsurface->wlr_subsurface = wlr_subsurface; - subsurface->view_child.destroy = subsurface_destroy; - view_child_init(&subsurface->view_child, view, wlr_subsurface->surface); + view_child_init(&subsurface->view_child, &subsurface_impl, + view, wlr_subsurface->surface); subsurface->destroy.notify = subsurface_handle_destroy; wl_signal_add(&wlr_subsurface->events.destroy, &subsurface->destroy); subsurface->map.notify = subsurface_handle_map; @@ -509,7 +514,7 @@ void view_unmap(struct roots_view *view) { struct roots_view_child *child, *tmp; wl_list_for_each_safe(child, tmp, &view->children, link) { - child->destroy(child); + view_child_destroy(child); } if (view->fullscreen_output != NULL) { |