XSendEvent()XSendEvent()NameXSendEvent – send an event.
Synopsis
Status XSendEvent(display, w, propagate, event_mask, event_send)
Display *display;
Window w;
Bool propagate;
long event_mask;
XEvent *event_send;
Arguments
display Specifies a connection to an X server; returned from
XOpenDisplay().
w Specifies the ID of the window where you want to send the
event. Pass the window resource ID, PointerWindow, or Input‐
Focus.
propagate Specifies how the sent event should propagate depending on
event_mask. See description below. May be True or False.
event_mask
Specifies the event mask. See XSelectInput() for a detailed
list of the event masks.
event_send
Specifies a pointer to the event to be sent.
Returns
Zero on failure, non-zero on success.
DescriptionXSendEvent() sends an event from one client to another (or conceivably
to itself). This function is used for communication between clients
using selections, for simulating user actions in demos, and for other
purposes.
The specified event is sent to the window indicated by w regardless of
active grabs.
If w is set to PointerWindow, the destination of the event will be the
window that the pointer is in. If w is InputFocus is specified, then
the destination is the focus window, regardless of pointer position.
If propagate is False, then the event is sent to every client selecting
on the window specified by w any of the event types in event_mask. If
propagate is True and no clients have been selected on w any of the
event types in event_mask, then the event propagates like any other
event.
The event code must be one of the core events, or one of the events
defined by a loaded extension, so that the server can correctly byte
swap the contents as necessary. The contents of the event are other‐
wise unaltered and unchecked by the server. The send_event field is in
every event type; if True it indicates that the event was sent with
XSendEvent().
This function is often used in selection processing. For example, the
owner of a selection should use XSendEvent() to send a SelectionNotify
event to a requestor when a selection has been converted and stored as
a property. See Volume One, Chapter 12, Interclient Communication for
more information.
The status returned by XSendEvent() indicates whether or not the given
XEvent structure was successfully converted into a wire event. This
value is zero on failure, or non-zero on success.
Errors
BadValue Specified event is not a valid core or extension event type,
or event mask is invalid.
BadWindow
Structures
See Appendix E, Event Reference, for the contents of each event struc‐
ture.
See AlsoXQLength(), XAllowEvents(), XCheckIfEvent(), XCheckMaskEvent(), XCheck‐
TypedEvent(), XCheckTypedWindowEvent(), XCheckWindowEvent(),
XEventsQueued(), XGetInputFocus(), XGetMotionEvents(), XIfEvent(),
XMaskEvent(), XNextEvent(), XPeekEvent(), XPeekIfEvent(), XPending(),
XPutBackEvent(), XSelectInput(), XSetInputFocus(), XSynchronize(),
XWindowEvent().
Xlib - Input Handling XSendEvent()