arminfriedl / xcb-wm

Rust implementation of xcb-wm - icccm and ewmh extensions for xcb
MIT License
5 stars 3 forks source link

Can't get WM name #8

Open rice7th opened 1 year ago

rice7th commented 1 year ago

Hi, I am trying to get the current WM name using the code below:

let xcb_con = xcb::Connection::connect(Option::None).unwrap().0;
let ewmh_con = ewmh::Connection::connect(&xcb_con);
let request = ewmh::proto::GetWmName;
let cookie = ewmh_con.send_request(&request);
let reply = ewmh_con.wait_for_reply(cookie).unwrap();
println!("{:?}", reply);

but rustc says this:

error[E0277]: the trait bound `fn(xcb::x::Window) -> GetWmName {GetWmName}: ewmh::traits::EwmhPropertyRequestUnchecked` is not satisfied
  --> src/wm.rs:8:50
   |
8  |     let cookie = ewmh_con.send_request_unchecked(&request);
   |                           ---------------------- ^^^^^^^^ the trait `ewmh::traits::EwmhPropertyRequestUnchecked` is not implemented for fn item `fn(xcb::x::Window) -> GetWmName {GetWmName}`
   |                           |
   |                           required by a bound introduced by this call
   |
   = help: the following other types implement trait `ewmh::traits::EwmhPropertyRequestUnchecked`:
             DesktopLayout
             GetActiveWindow
             GetClientList
             GetClientListStacking
             GetCurrentDesktop
             GetDesktopGeometry
             GetDesktopNames
             GetDesktopViewport
           and 13 others
note: required by a bound in `xcb_wm::ewmh::Connection::<'a>::send_request_unchecked`
  --> /home/p4rsec/.cargo/registry/src/github.com-1ecc6299db9ec823/xcb-wm-0.4.0/src/ewmh/connection.rs:52:12
   |
52 |         R: EwmhPropertyRequestUnchecked,
   |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `xcb_wm::ewmh::Connection::<'a>::send_request_unchecked`

Any help would be really appreciated.

fiorematteo commented 1 year ago

You need to construct a GetWmName. As per documentation you need to pass it a Window object.

Something like this:

    let request = ewmh::proto::GetWmName(window);
    let cookie = ewmh_con.send_request(&request);