[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.4 Sending Events

Clients can send events to each other. Most often these are general-purpose ClientMessage events, but any event type can be sent.

To send an event, an event object must be created. This is done by instantiating an event class, providing values to all its fields as keyword parameters. The event is then sent with the send_event() method:

Method on Window: send_event ( event, event_mask = 0, propagate = 0, onerror = None )

Send event to this window.

If event_mask is 0, the event is sent to the client that created the window. Otherwise the event is sent to every client selecting any of the event types in event_mask.

If no clients have selected any of the event types and propagate is true, the X server will search for an ancestor of this window on which some client has selected any of the event types. For details, see XSendEvent(3X11).

Method on Display: send_event ( destination, event, event_mask = 0, propagate = 0, onerror = None )

Send event to destination, which can either be a Window object or a constant: If X.PointerWindow is specified, send the event to the window the pointer is in. If X.InputFocus is specified and the focus window contains the pointer, send the event to the window that the pointer is in. Otherwise, send the event to the focus window.

As an example, this creates and sends a ClientMessage event of the client specific type HELLO_WORLD (an atom), to the window dest and with the 8-bitformat value "G'day, mate" (which must be exactly twenty bytes):

cm_event = Xlib.protocol.event.ClientMessage(
    window = dest,
    client_type = HELLO_WORLD,
    data = (8, "G'day mate\0\0\0\0\0\0\0\0\0\0"))


[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

This document was generated on September 16, 2020 using texi2html 5.0.