From 9f9370e949729b625d0948ec4ce99db0019d1062 Mon Sep 17 00:00:00 2001 From: Charlotte Meyer Date: Mon, 30 Dec 2019 23:23:35 +0000 Subject: [PATCH] Add view_close --- include/desktop/view.h | 2 ++ kiwmi/desktop/view.c | 8 ++++++++ kiwmi/desktop/xdg_shell.c | 11 +++++++++++ 3 files changed, 21 insertions(+) diff --git a/include/desktop/view.h b/include/desktop/view.h index d561512..1c4b370 100644 --- a/include/desktop/view.h +++ b/include/desktop/view.h @@ -43,6 +43,7 @@ struct kiwmi_view { }; struct kiwmi_view_impl { + void (*close)(struct kiwmi_view *view); void (*for_each_surface)( struct kiwmi_view *view, wlr_surface_iterator_func_t iterator, @@ -56,6 +57,7 @@ struct kiwmi_view_impl { double *sub_y); }; +void view_close(struct kiwmi_view *view); void view_for_each_surface( struct kiwmi_view *view, wlr_surface_iterator_func_t iterator, diff --git a/kiwmi/desktop/view.c b/kiwmi/desktop/view.c index 8fe222d..4e846c6 100644 --- a/kiwmi/desktop/view.c +++ b/kiwmi/desktop/view.c @@ -12,6 +12,14 @@ #include "desktop/output.h" #include "server.h" +void +view_close(struct kiwmi_view *view) +{ + if (view->impl->close) { + view->impl->close(view); + } +} + void view_for_each_surface( struct kiwmi_view *view, diff --git a/kiwmi/desktop/xdg_shell.c b/kiwmi/desktop/xdg_shell.c index 2375b1d..8aefa7e 100644 --- a/kiwmi/desktop/xdg_shell.c +++ b/kiwmi/desktop/xdg_shell.c @@ -47,6 +47,16 @@ xdg_surface_destroy_notify(struct wl_listener *listener, void *UNUSED(data)) free(view); } +static void +xdg_shell_view_close(struct kiwmi_view *view) +{ + struct wlr_xdg_surface *surface = view->xdg_surface; + + if (surface->role == WLR_XDG_SURFACE_ROLE_TOPLEVEL && surface->toplevel) { + wlr_xdg_toplevel_send_close(surface); + } +} + static void xdg_shell_view_for_each_surface( struct kiwmi_view *view, @@ -74,6 +84,7 @@ xdg_shell_view_surface_at( } static const struct kiwmi_view_impl xdg_shell_view_impl = { + .close = xdg_shell_view_close, .for_each_surface = xdg_shell_view_for_each_surface, .set_activated = xdg_shell_view_set_activated, .surface_at = xdg_shell_view_surface_at,