12.07.2015 Views

Xlib − C Language X Interface

Xlib − C Language X Interface

Xlib − C Language X Interface

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>Xlib</strong> − C LibraryX11, Release 6.7 DRAFTChapter 11Event Handling FunctionsThis chapter discusses the <strong>Xlib</strong> functions you can use to:• Select events• Handle the output buffer and the event queue• Select events from the event queue• Send and get events• Handle protocol errorsNoteSome toolkits use their own event-handling functions and do not allow you tointerchange these event-handling functions with those in <strong>Xlib</strong>. For furtherinformation, see the documentation supplied with the toolkit.Most applications simply are event loops: they wait for an event, decide what to do with it,execute some amount of code that results in changes to the display, and then wait for the nextevent.11.1. Selecting EventsThere are two ways to select the events you want reported to your client application. One way isto set the event_mask member of the XSetWindowAttributes structure when you call XCreateWindowand XChangeWindowAttributes. Another way is to use XSelectInput.XSelectInput (display, w, event_mask)Display *display;Window w;long event_mask;displaywevent_maskSpecifies the connection to the X server.Specifies the window whose events you are interested in.Specifies the event mask.The XSelectInput function requests that the X server report the events associated with the specifiedevent mask. Initially, Xwill not report any ofthese events. Events are reported relative to awindow. Ifawindow isnot interested in a device event, it usually propagates to the closest ancestorthat is interested, unless the do_not_propagate mask prohibits it.Setting the event-mask attribute of a window overrides any previous call for the same window butnot for other clients. Multiple clients can select for the same events on the same window with thefollowing restrictions:• Multiple clients can select events on the same window because their event masks are disjoint.When the X server generates an event, it reports it to all interested clients.231

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!