From f33ddd08391706802f07c6999e3a64540e8aefb4 Mon Sep 17 00:00:00 2001 From: John Good Date: Sun, 22 Mar 2020 18:19:38 +0100 Subject: [PATCH] Allow programmatically closing xwayland window --- libweston-desktop/xwayland.c | 12 ++++++++++++ xwayland/window-manager.c | 11 +++++++++++ xwayland/xwayland-internal-interface.h | 1 + 3 files changed, 24 insertions(+) diff --git a/libweston-desktop/xwayland.c b/libweston-desktop/xwayland.c index c1c5fc4a..cdb65dfc 100644 --- a/libweston-desktop/xwayland.c +++ b/libweston-desktop/xwayland.c @@ -193,6 +193,17 @@ weston_desktop_xwayland_surface_destroy(struct weston_desktop_surface *dsurface, free(surface); } +static void +weston_desktop_xwayland_surface_close(struct weston_desktop_surface *dsurface, + void *user_data) +{ + struct weston_desktop_xwayland_surface *surface = user_data; + struct weston_surface *wsurface = + weston_desktop_surface_get_surface(surface->surface); + + surface->client_interface->send_close(wsurface); +} + static bool weston_desktop_xwayland_surface_get_maximized(struct weston_desktop_surface *dsurface, void *user_data) @@ -219,6 +230,7 @@ static const struct weston_desktop_surface_implementation weston_desktop_xwaylan .get_fullscreen = weston_desktop_xwayland_surface_get_fullscreen, .destroy = weston_desktop_xwayland_surface_destroy, + .close = weston_desktop_xwayland_surface_close, }; static void diff --git a/xwayland/window-manager.c b/xwayland/window-manager.c index a680cdd1..9c2413d9 100644 --- a/xwayland/window-manager.c +++ b/xwayland/window-manager.c @@ -2783,6 +2783,16 @@ send_configure(struct weston_surface *surface, int32_t width, int32_t height) weston_wm_window_configure, window); } +static void +send_close(struct weston_surface *surface) +{ + struct weston_wm_window *window = get_wm_window(surface); + if (!window || !window->wm) + return; + weston_wm_window_close(window, XCB_CURRENT_TIME); + xcb_flush(window->wm->conn); +} + static void send_position(struct weston_surface *surface, int32_t x, int32_t y) { @@ -2812,6 +2822,7 @@ send_position(struct weston_surface *surface, int32_t x, int32_t y) static const struct weston_xwayland_client_interface shell_client = { send_configure, + send_close, }; static int diff --git a/xwayland/xwayland-internal-interface.h b/xwayland/xwayland-internal-interface.h index 10964440..c7dfd19b 100644 --- a/xwayland/xwayland-internal-interface.h +++ b/xwayland/xwayland-internal-interface.h @@ -31,6 +31,7 @@ struct weston_desktop_xwayland_surface; struct weston_xwayland_client_interface { void (*send_configure)(struct weston_surface *surface, int32_t width, int32_t height); + void (*send_close)(struct weston_surface *surface); }; struct weston_desktop_xwayland_interface {