1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
use super::*;
use x11rb::x11_utils::Serialize;

impl XConnection {
    pub fn send_client_msg(
        &self,
        window: xproto::Window, // The window this is "about"; not necessarily this window
        target_window: xproto::Window, // The window we're sending to
        message_type: xproto::Atom,
        event_mask: Option<xproto::EventMask>,
        data: impl Into<xproto::ClientMessageData>,
    ) -> Result<VoidCookie<'_>, X11Error> {
        let event = xproto::ClientMessageEvent {
            response_type: xproto::CLIENT_MESSAGE_EVENT,
            window,
            format: 32,
            data: data.into(),
            sequence: 0,
            type_: message_type,
        };

        self.xcb_connection()
            .send_event(
                false,
                target_window,
                event_mask.unwrap_or(xproto::EventMask::NO_EVENT),
                event.serialize(),
            )
            .map_err(Into::into)
    }
}