From e2acdad0c2e378c71b6c14f12998b613aceae633 Mon Sep 17 00:00:00 2001 From: Gary Guo Date: Sat, 2 Nov 2019 08:03:49 +0000 Subject: [PATCH] Fix window close handling (#98) Currently we interned WM_DELETE_WINDOW but does not call XSetWMProtocols to listen to it, causing a fatal error when closing the window by clicking "X". This patch fixes the issue. --- src/os/unix/mod.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/os/unix/mod.rs b/src/os/unix/mod.rs index 3970e4e..3b638a6 100644 --- a/src/os/unix/mod.rs +++ b/src/os/unix/mod.rs @@ -257,7 +257,7 @@ impl Window { // FIXME: this DisplayInfo should be a singleton, hence this code // is probably no good when using multiple windows. - let d = DisplayInfo::new()?; + let mut d = DisplayInfo::new()?; let scale = Self::get_scale_factor(width, height, d.screen_width, d.screen_height, opts.scale); @@ -326,6 +326,7 @@ impl Window { (d.lib.XClearWindow)(d.display, handle); (d.lib.XMapRaised)(d.display, handle); + (d.lib.XSetWMProtocols)(d.display, handle, &mut d.wm_delete_window, 1); (d.lib.XFlush)(d.display); let mut draw_buffer: Vec = Vec::new();