-
Notifications
You must be signed in to change notification settings - Fork 10
Description
My Specific case
I'm writing a program that reads the current focused window title. For that, I'm trying to read the WM_NAME property of my focused window. By using the xprop command, I can see the atom type of the WM_NAME is UTF8_STRING, and by using the command xlsatoms | grep UTF8_STRING, I can see it's id is 408. Therefore, I tried writing this code:
const UTF8_STRING_ATOM: u32 = 408;
let window_title = {
let cookie = connection.get_property(
false,
focused_window,
wm_name_atom,
UTF8_STRING_ATOM,
0,
1024,
)?;
connection.wait_for_reply(cookie)?
};However, I'm getting this compiler error:
UTF8_STRING_ATOM,
^^^^^^^^^^^^^^^^ the trait `From<u32>` is not implemented for `GetPropertyType`
The Problem
The struct GetPropertyType internally holds a u8 instead of a u32, and therefore, when calling connection.get_property, the atom type can only be up to 255.
This does not conform to the X11 specification, which states that the type argument is of type ATOM, which is a 32 bit value.
Proposed Solution
Change the internal value of GetPropertyType to be a u32, and implement the trait From<u32>.
Workarounds
Instead of using the correct type in the function get_property, using the breadx::protocol::xproto::AtomEnum::ANY type works. Example:
let any_type_atom: u8 = breadx::protocol::xproto::AtomEnum::ANY.into();
let window_title = {
let cookie = connection.get_property(
false,
focused_window,
wm_name_atom,
any_type_atom,
0,
1024,
)?;
connection.wait_for_reply(cookie)?
};