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

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