From cd0c5538d129d6c57ec388af20487ad79ca3ee5b Mon Sep 17 00:00:00 2001 From: Victor Berger Date: Fri, 23 Mar 2018 19:27:04 +0100 Subject: [PATCH] shell: add method to send close events --- src/wayland/shell/mod.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/wayland/shell/mod.rs b/src/wayland/shell/mod.rs index 18eff4b..c3c7fe7 100644 --- a/src/wayland/shell/mod.rs +++ b/src/wayland/shell/mod.rs @@ -615,6 +615,18 @@ where configured } + /// Send a "close" event to the client + pub fn send_close(&self) -> EventResult<()> { + if !self.alive() { + return EventResult::Destroyed; + } + match self.shell_surface { + SurfaceKind::Wl(_) => EventResult::Sent(()), + SurfaceKind::XdgToplevel(ref s) => s.close(), + SurfaceKind::XdgPopup(_) => unreachable!(), + } + } + /// Access the underlying `wl_surface` of this toplevel surface /// /// Returns `None` if the toplevel surface actually no longer exists.