diff options
| -rw-r--r-- | crates/wayland/src/udev/platform.rs | 13 | ||||
| -rw-r--r-- | crates/wayland/src/winit/platform.rs | 10 |
2 files changed, 19 insertions, 4 deletions
diff --git a/crates/wayland/src/udev/platform.rs b/crates/wayland/src/udev/platform.rs index bf887b1..8043e20 100644 --- a/crates/wayland/src/udev/platform.rs +++ b/crates/wayland/src/udev/platform.rs @@ -355,8 +355,17 @@ impl Platform for UdevPlatform { } fn close(&mut self, window: srdwm_core::WindowId) -> PlatformResult<()> { - if let Some(w) = self.state.id_to_window.get(&window).and_then(|w| w.toplevel()) { - w.send_close(); + let Some(w) = self.state.id_to_window.get(&window) else { return Ok(()) }; + if let Some(toplevel) = w.toplevel() { + toplevel.send_close(); + } else if let Some(x11) = w.x11_surface() { + // `w.toplevel()` is `None` for an XWayland window - without + // this arm, closing one (the WM's own close binding, or `srd + // dispatch close`) silently did nothing at all. `close()` itself + // handles both cases: a polite WM_DELETE_WINDOW for a + // cooperating client, outright `destroy_window` for one that + // doesn't support it. + let _ = x11.close(); } Ok(()) } diff --git a/crates/wayland/src/winit/platform.rs b/crates/wayland/src/winit/platform.rs index e5b0b89..23387b7 100644 --- a/crates/wayland/src/winit/platform.rs +++ b/crates/wayland/src/winit/platform.rs @@ -105,8 +105,14 @@ impl Platform for WaylandPlatform { } fn close(&mut self, window: WindowId) -> PlatformResult<()> { - if let Some(w) = self.state.id_to_window.get(&window).and_then(|w| w.toplevel()) { - w.send_close(); + let Some(w) = self.state.id_to_window.get(&window) else { return Ok(()) }; + if let Some(toplevel) = w.toplevel() { + toplevel.send_close(); + } else if let Some(x11) = w.x11_surface() { + // Same fix as `udev/platform.rs`'s matching function: `w.toplevel()` + // is `None` for an XWayland window, so closing one silently did + // nothing at all without this arm. + let _ = x11.close(); } Ok(()) } |