Fix X11 window names not supporting UTF-8 (#295)

This commit is contained in:
Edgar Onghena 2022-05-06 15:16:42 +02:00 committed by GitHub
parent aea92d0f6e
commit 3da7b7b22e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -440,6 +440,22 @@ impl Window {
} }
(d.lib.XStoreName)(d.display, handle, name.as_ptr()); (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.lib.XSelectInput)(
d.display, d.display,