From 972e9dbd1b2eb2853a60632d279bd754daf7c440 Mon Sep 17 00:00:00 2001 From: emersion Date: Fri, 6 Oct 2017 15:39:39 +0200 Subject: Add close command, add close for xwayland --- include/rootston/input.h | 2 +- include/rootston/view.h | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/rootston/input.h b/include/rootston/input.h index ae3e3b80..09509e85 100644 --- a/include/rootston/input.h +++ b/include/rootston/input.h @@ -81,7 +81,7 @@ struct roots_input { struct wlr_seat *wl_seat; enum roots_cursor_mode mode; - struct roots_view *active_view; + struct roots_view *active_view, *last_active_view; int offs_x, offs_y; int view_x, view_y, view_width, view_height; float view_rotation; diff --git a/include/rootston/view.h b/include/rootston/view.h index 39ff80db..64aad45e 100644 --- a/include/rootston/view.h +++ b/include/rootston/view.h @@ -65,11 +65,13 @@ struct roots_view { void (*get_input_bounds)(struct roots_view *view, struct wlr_box *box); void (*activate)(struct roots_view *view, bool active); void (*resize)(struct roots_view *view, uint32_t width, uint32_t height); + void (*close)(struct roots_view *view); }; void view_get_size(struct roots_view *view, struct wlr_box *box); void view_get_input_bounds(struct roots_view *view, struct wlr_box *box); void view_activate(struct roots_view *view, bool active); void view_resize(struct roots_view *view, uint32_t width, uint32_t height); +void view_close(struct roots_view *view); #endif -- cgit v1.2.3 From 69aff9b35e0e5ce1031aaa65a0166423bc95d192 Mon Sep 17 00:00:00 2001 From: emersion Date: Fri, 6 Oct 2017 15:58:49 +0200 Subject: Implement wlr_xdg_toplevel_v6_send_close --- include/wlr/types/wlr_xdg_shell_v6.h | 5 +++++ rootston/xdg_shell_v6.c | 9 +++++++++ types/wlr_xdg_shell_v6.c | 5 +++++ 3 files changed, 19 insertions(+) (limited to 'include') diff --git a/include/wlr/types/wlr_xdg_shell_v6.h b/include/wlr/types/wlr_xdg_shell_v6.h index cc52d9c7..de8dfca7 100644 --- a/include/wlr/types/wlr_xdg_shell_v6.h +++ b/include/wlr/types/wlr_xdg_shell_v6.h @@ -172,4 +172,9 @@ void wlr_xdg_toplevel_v6_set_fullscreen(struct wlr_xdg_surface_v6 *surface, void wlr_xdg_toplevel_v6_set_resizing(struct wlr_xdg_surface_v6 *surface, bool resizing); +/** + * Request that this toplevel surface closes. + */ +void wlr_xdg_toplevel_v6_send_close(struct wlr_xdg_surface_v6 *surface); + #endif diff --git a/rootston/xdg_shell_v6.c b/rootston/xdg_shell_v6.c index ab34f52a..c7072354 100644 --- a/rootston/xdg_shell_v6.c +++ b/rootston/xdg_shell_v6.c @@ -33,6 +33,14 @@ static void resize(struct roots_view *view, uint32_t width, uint32_t height) { } } +static void close(struct roots_view *view) { + assert(view->type == ROOTS_XDG_SHELL_V6_VIEW); + struct wlr_xdg_surface_v6 *surf = view->xdg_surface_v6; + if (surf->role == WLR_XDG_SURFACE_V6_ROLE_TOPLEVEL) { + wlr_xdg_toplevel_v6_send_close(surf); + } +} + static void handle_request_move(struct wl_listener *listener, void *data) { struct roots_xdg_surface_v6 *roots_xdg_surface = wl_container_of(listener, roots_xdg_surface, request_move); @@ -107,6 +115,7 @@ void handle_xdg_shell_v6_surface(struct wl_listener *listener, void *data) { view->get_size = get_size; view->activate = activate; view->resize = resize; + view->close = close; view->desktop = desktop; roots_surface->view = view; list_add(desktop->views, view); diff --git a/types/wlr_xdg_shell_v6.c b/types/wlr_xdg_shell_v6.c index c30291d1..fc029f2d 100644 --- a/types/wlr_xdg_shell_v6.c +++ b/types/wlr_xdg_shell_v6.c @@ -807,3 +807,8 @@ void wlr_xdg_toplevel_v6_set_resizing(struct wlr_xdg_surface_v6 *surface, wlr_xdg_surface_v6_schedule_configure(surface, false); } + +void wlr_xdg_toplevel_v6_send_close(struct wlr_xdg_surface_v6 *surface) { + assert(surface->role == WLR_XDG_SURFACE_V6_ROLE_TOPLEVEL); + zxdg_toplevel_v6_send_close(surface->toplevel_state->resource); +} -- cgit v1.2.3