From 3da7b7b22e3686b20803c100da9c9dec53ec2f3a Mon Sep 17 00:00:00 2001 From: Edgar Onghena Date: Fri, 6 May 2022 15:16:42 +0200 Subject: [PATCH] Fix X11 window names not supporting UTF-8 (#295) --- src/os/posix/x11.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/os/posix/x11.rs b/src/os/posix/x11.rs index 3f66bde..cf357b3 100644 --- a/src/os/posix/x11.rs +++ b/src/os/posix/x11.rs @@ -440,6 +440,22 @@ impl Window { } (d.lib.XStoreName)(d.display, handle, name.as_ptr()); + if let Ok(name_len) = c_int::try_from(name.to_bytes().len()) { + let net_wm_name = d.intern_atom("_NET_WM_NAME", false); + let utf8_string = d.intern_atom("UTF8_STRING", false); + (d.lib.XChangeProperty)( + d.display, + handle, + net_wm_name, + utf8_string, + 8, + xlib::PropModeReplace, + name.as_ptr() as *const c_uchar, + name_len, + ); + } else { + return Err(Error::WindowCreate("Window name too long".to_owned())); + } (d.lib.XSelectInput)( d.display,