winit/platform_impl/linux/x11/util/
client_msg.rs

1use x11rb::x11_utils::Serialize;
2
3use super::*;
4
5impl XConnection {
6    pub fn send_client_msg(
7        &self,
8        window: xproto::Window, // The window this is "about"; not necessarily this window
9        target_window: xproto::Window, // The window we're sending to
10        message_type: xproto::Atom,
11        event_mask: Option<xproto::EventMask>,
12        data: impl Into<xproto::ClientMessageData>,
13    ) -> Result<VoidCookie<'_>, X11Error> {
14        let event = xproto::ClientMessageEvent {
15            response_type: xproto::CLIENT_MESSAGE_EVENT,
16            window,
17            format: 32,
18            data: data.into(),
19            sequence: 0,
20            type_: message_type,
21        };
22
23        self.xcb_connection()
24            .send_event(
25                false,
26                target_window,
27                event_mask.unwrap_or(xproto::EventMask::NO_EVENT),
28                event.serialize(),
29            )
30            .map_err(Into::into)
31    }
32}