.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1994, 1996 X Consortium
.\"
.\" Permission is hereby granted, free of charge, to any person obtaining
.\" a copy of this software and associated documentation files (the
.\" "Software"), to deal in the Software without restriction, including
.\" without limitation the rights to use, copy, modify, merge, publish,
.\" distribute, sublicense, and/or sell copies of the Software, and to
.\" permit persons to whom the Software is furnished to do so, subject to
.\" the following conditions:
.\"
.\" The above copyright notice and this permission notice shall be included
.\" in all copies or substantial portions of the Software.
.\"
.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
.\" IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
.\" OTHER DEALINGS IN THE SOFTWARE.
.\"
.\" Except as contained in this notice, the name of the X Consortium shall
.\" not be used in advertising or otherwise to promote the sale, use or
.\" other dealings in this Software without prior written authorization
.\" from the X Consortium.
.\"
.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991 by
.\" Digital Equipment Corporation
.\"
.\" Portions Copyright \(co 1990, 1991 by
.\" Tektronix, Inc.
.\"
.\" Permission to use, copy, modify and distribute this documentation for
.\" any purpose and without fee is hereby granted, provided that the above
.\" copyright notice appears in all copies and that both that copyright notice
.\" and this permission notice appear in all copies, and that the names of
.\" Digital and Tektronix not be used in in advertising or publicity pertaining
.\" to this documentation without specific, written prior permission.
.\" Digital and Tektronix makes no representations about the suitability
.\" of this documentation for any purpose.
.\" It is provided ``as is'' without express or implied warranty.
.\" 
\&
.sp 1
.ce 3
\s+1\fBChapter 10\fP\s-1

\s+1\fBEvents\fP\s-1
.sp 2
.nr H1 10
.nr H2 0
.nr H3 0
.nr H4 0
.nr H5 0
.na
.LP
.XS
Chapter 10: Events
.XE
A client application communicates with the X server through the connection you
establish with the 
.PN XOpenDisplay 
.IN "XOpenDisplay"
function.
A client application sends requests to the X server over this connection.
.IN "Requests" "" "@DEF@"
These requests are made by the Xlib functions that are 
called in the client application.
Many Xlib functions cause the X server to generate events,
and the user's typing or moving the pointer can generate events asynchronously.
The X server returns events to the client on the same connection.
.LP
This chapter discusses the following topics associated with events:
.IP \(bu 5
Event types
.IP \(bu 5
Event structures
.IP \(bu 5
Event masks
.IP \(bu 5
Event processing
.LP
Functions for handling events are dealt with in the next chapter.
.NH 2
Event Types
.XS
\*(SN Event Types 
.XE
.LP
.IN "Event" "types"
An event is data generated asynchronously by the X server as a result of some 
device activity or as side effects of a request sent by an Xlib function.
.IN "Event" 
Device-related events propagate from the source window to ancestor windows
until some client application has selected that event type 
or until the event is explicitly discarded.
The X server generally sends an event to a client application
only if the client has specifically asked to be informed of that event type, 
typically by setting the event-mask attribute of the window.
The mask can also be set when you create a window
or by changing the window's
event-mask.
You can also mask out events that would propagate to ancestor windows
by manipulating the
do-not-propagate mask of the window's attributes.
However,
.PN MappingNotify
events are always sent to all clients.
.IN "Input Control"
.IN "Output Control"
.LP
An event type describes a specific event generated by the X server.
For each event type, 
a corresponding constant name is defined in
.hN X11/X.h ,
which is used when referring to an event type.
.IN "Event" "categories"
The following table lists the event category 
and its associated event type or types. 
The processing associated with these events is discussed in section 10.5.
.LP
.\".CP T 1
.\"Event Categories and Event Types
.LP
.TS H
lw(2.25i) lw(3.5i).
_
.sp 6p
.B
Event Category	Event Type
.sp 6p
_
.sp 6p
.TH
.R
T{
Keyboard events
T}	T{
.PN KeyPress ,
.PN KeyRelease
T}
.sp 6p
T{
Pointer events
T}	T{
.PN ButtonPress , 
.PN ButtonRelease  ,
.PN MotionNotify
T}
.sp 6p
T{
Window crossing events
T}	T{
.PN EnterNotify , 
.PN LeaveNotify
T}
.sp 6p
T{
Input focus events
T}	T{
.PN FocusIn , 
.PN FocusOut
T}
.sp 6p
T{
Keymap state notification event
T}	T{
.PN KeymapNotify
T}
.sp 6p
T{
Exposure events	
T}	T{
.PN Expose , 
.PN GraphicsExpose , 
.PN NoExpose
T}
.sp 6p
T{
Structure control events
T}	T{
.PN CirculateRequest , 
.PN ConfigureRequest , 
.PN MapRequest ,
.PN ResizeRequest
T}
.sp 6p
T{
Window state notification events
T}	T{
.PN CirculateNotify , 
.PN ConfigureNotify , 
.PN CreateNotify , 
.PN DestroyNotify , 
.PN GravityNotify , 
.PN MapNotify ,
.PN MappingNotify , 
.PN ReparentNotify , 
.PN UnmapNotify , 
.br
.PN VisibilityNotify
T}
.sp 6p
T{
Colormap state notification event
T}	T{
.PN ColormapNotify
T}
.sp 6p
T{
Client communication events
T}	T{
.PN ClientMessage , 
.PN PropertyNotify , 
.PN SelectionClear , 
.PN SelectionNotify , 
.PN SelectionRequest
T}
.sp 6p
_
.TE
.\".LP
.\"Table 8-1 lists the event types and the Xlib functions that could cause
.\"the X server to generate that event type.
.\"The event types are listed alphabetically.
.\"Note that the error event is not listed in this table.
.\"For a list of the constants associated with an error event, see the Handling
.\"Errors section in this chapter.
.\".LP
.\".so eventtable
.NH 2
Event Structures
.XS
\*(SN Event Structures 
.XE
.LP
For each event type,
a corresponding structure is declared in
.hN X11/Xlib.h .
All the event structures have the following common members:
.LP
.IN "XAnyEvent" "" "@DEF@"
.sM
.Ds 0
.TA .5i 3i
.ta .5i 3i
typedef struct {
	int type;
	unsigned long serial;	/* # of last request processed by server */
	Bool send_event;	/* true if this came from a SendEvent request */
	Display *display;	/* Display the event was read from */
	Window window;
} XAnyEvent;
.De
.LP
.eM
The type member is set to the event type constant name that uniquely identifies
it.
For example, when the X server reports a
.PN GraphicsExpose
event to a client application, it sends an
.PN XGraphicsExposeEvent
structure with the type member set to
.PN GraphicsExpose .
The display member is set to a pointer to the display the event was read on.
The send_event member is set to
.PN True
if the event came from a
.PN SendEvent
protocol request.
The serial member is set from the serial number reported in the protocol
but expanded from the 16-bit least-significant bits to a full 32-bit value.
The window member is set to the window that is most useful to toolkit
dispatchers.
.LP
The X server can send events at any time in the input stream. 
Xlib stores any events received while waiting for a reply in an event queue 
for later use.
Xlib also provides functions that allow you to check events 
in the event queue (see section 11.3).
.LP
In addition to the individual structures declared for each event type, the
.PN XEvent
structure is a union of the individual structures declared for each event type.
Depending on the type,
you should access members of each event by using the 
.PN XEvent
union.
.LP
.IN "XEvent" "" "@DEF@"
.sM
.Ds 0
.TA .5i 3i
.ta .5i 3i
typedef union _XEvent {
	int type;	/* must not be changed */
	XAnyEvent xany;
	XKeyEvent xkey;
	XButtonEvent xbutton;
	XMotionEvent xmotion;
	XCrossingEvent xcrossing;
	XFocusChangeEvent xfocus;
	XExposeEvent xexpose;
	XGraphicsExposeEvent xgraphicsexpose;
	XNoExposeEvent xnoexpose;
	XVisibilityEvent xvisibility;
	XCreateWindowEvent xcreatewindow;
	XDestroyWindowEvent xdestroywindow;
	XUnmapEvent xunmap;
	XMapEvent xmap;
	XMapRequestEvent xmaprequest;
	XReparentEvent xreparent;
	XConfigureEvent xconfigure;
	XGravityEvent xgravity;
	XResizeRequestEvent xresizerequest;
	XConfigureRequestEvent xconfigurerequest;
	XCirculateEvent xcirculate;
	XCirculateRequestEvent xcirculaterequest;
	XPropertyEvent xproperty;
	XSelectionClearEvent xselectionclear;
	XSelectionRequestEvent xselectionrequest;
	XSelectionEvent xselection;
	XColormapEvent xcolormap;
	XClientMessageEvent xclient;
	XMappingEvent xmapping;
	XErrorEvent xerror;
	XKeymapEvent xkeymap;
	long pad[24];
} XEvent;
.De
.LP
.eM
An
.PN XEvent
structure's first entry always is the type member,
which is set to the event type.
The second member always is the serial number of the protocol request
that generated the event.
The third member always is send_event,
which is a
.PN Bool
that indicates if the event was sent by a different client.
The fourth member always is a display,
which is the display that the event was read from.
Except for keymap events,
the fifth member always is a window,
which has been carefully selected to be useful to toolkit dispatchers.
To avoid breaking toolkits,
the order of these first five entries is not to change.
Most events also contain a time member,
which is the time at which an event occurred.
In addition, a pointer to the generic event must be cast before it
is used to access any other information in the structure.
.NH 2
Event Masks
.XS
\*(SN Event Masks
.XE
.LP
.IN "Event mask" "" "@DEF@"
Clients select event reporting of most events relative to a window.
To do this, pass an event mask to an Xlib event-handling
function that takes an event_mask argument.
The bits of the event mask are defined in
.hN X11/X.h .
Each bit in the event mask maps to an event mask name,
which describes the event or events you want the X server to
return to a client application.
.LP
Unless the client has specifically asked for them,
most events are not reported to clients when they are generated. 
Unless the client suppresses them by setting graphics-exposures in the GC to
.PN False ,
.PN GraphicsExpose 
and 
.PN NoExpose 
are reported by default as a result of
.PN XCopyPlane
and
.PN XCopyArea .
.PN SelectionClear ,
.PN SelectionRequest ,
.PN SelectionNotify ,
or
.PN ClientMessage
cannot be masked.
Selection-related events are only sent to clients cooperating
with selections (see section 4.5).
When the keyboard or pointer mapping is changed,
.PN MappingNotify
is always sent to clients.
.LP
.\"Table 8-2 
The following table 
lists the event mask constants you can pass to
the event_mask argument and
the circumstances in which you would want to specify the
event mask:
.LP
.\" .CP T 2
.\"Event Mask Definitions
.TS H
lw(2i) lw(3.5i).
_
.sp 6p
.B
Event Mask	Circumstances
.sp 6p
_
.sp 6p
.TH
.R
T{
.PN NoEventMask
T}	T{
No events wanted
T}
T{
.PN KeyPressMask
T}	T{
Keyboard down events wanted
T}
T{
.PN KeyReleaseMask
T}	T{
Keyboard up events wanted
T}
T{
.PN ButtonPressMask
T}	T{
Pointer button down events wanted
T}
T{
.PN ButtonReleaseMask
T}	T{
Pointer button up events wanted
T}
T{
.PN EnterWindowMask
T}	T{
Pointer window entry events wanted
T}
T{
.PN LeaveWindowMask
T}	T{
Pointer window leave events wanted
T}
T{
.PN PointerMotionMask
T}	T{
Pointer motion events wanted
T}
T{
.PN PointerMotionHintMask
T}	T{
Pointer motion hints wanted
T}
T{
.PN Button1MotionMask
T}	T{
Pointer motion while button 1 down
T}
T{
.PN Button2MotionMask
T}	T{
Pointer motion while button 2 down
T}
T{
.PN Button3MotionMask
T}	T{
Pointer motion while button 3 down
T}
T{
.PN Button4MotionMask
T}	T{
Pointer motion while button 4 down
T}
T{
.PN Button5MotionMask
T}	T{
Pointer motion while button 5 down
T}
T{
.PN ButtonMotionMask
T}	T{
Pointer motion while any button down
T}
T{
.PN KeymapStateMask
T}	T{
Keyboard state wanted at window entry and focus in
T}
T{
.PN ExposureMask
T}	T{
Any exposure wanted
T}
T{
.PN VisibilityChangeMask
T}	T{
Any change in visibility wanted
T}
T{
.PN StructureNotifyMask
T}	T{
Any change in window structure wanted
T}
T{
.PN ResizeRedirectMask
T}	T{
Redirect resize of this window
T}
T{
.PN SubstructureNotifyMask
T}	T{
Substructure notification wanted
T}
T{
.PN SubstructureRedirectMask
T}	T{
Redirect structure requests on children
T}
T{
.PN FocusChangeMask
T}	T{
Any change in input focus wanted
T}
T{
.PN PropertyChangeMask
T}	T{
Any change in property wanted
T}
T{
.PN ColormapChangeMask
T}	T{
Any change in colormap wanted
T}
T{
.PN OwnerGrabButtonMask
T}	T{
Automatic grabs should activate with owner_events set to 
.PN True
T}
.sp 6p
_
.TE
.LP
.NH 2
Event Processing Overview
.XS
\*(SN Event Processing Overview
.XE
.LP
The event reported to a client application during event processing
depends on which event masks you provide as the event-mask attribute 
for a window.
For some event masks, there is a one-to-one correspondence between
the event mask constant and the event type constant.
For example, if you pass the event mask
.PN ButtonPressMask ,
the X server sends back only
.PN ButtonPress
events.
.IN "CurrentTime"
Most events contain a time member,
which is the time at which an event occurred.
.LP
In other cases, one event mask constant can map to several event type constants.
For example, if you pass the event mask
.PN SubstructureNotifyMask ,
the X server can send back
.PN CirculateNotify ,
.PN ConfigureNotify ,
.PN CreateNotify ,
.PN DestroyNotify ,
.PN GravityNotify ,
.PN MapNotify ,
.PN ReparentNotify ,
or
.PN UnmapNotify
events.
.LP
In another case, 
two event masks can map to one event type.
For example, 
if you pass either
.PN PointerMotionMask 
or
.PN ButtonMotionMask ,
the X server sends back
a
.PN MotionNotify
event.
.LP
The following table 
lists the event mask, 
its associated event type or types, 
and the structure name associated with the event type.
Some of these structures actually are typedefs to a generic structure
that is shared between two event types.
Note that N.A. appears in columns for which the information is not applicable.
.LP
.ps 9
.nr PS 9
.TS H
lw(1.5i) lw(1i) lw(1.5i) lw(1.5i).
_
.sp 6p
.B
Event Mask	Event Type	Structure	Generic Structure
.sp 6p
_
.sp 6p
.TH
.R
ButtonMotionMask	MotionNotify	XPointerMovedEvent	XMotionEvent
Button1MotionMask		
Button2MotionMask		
Button3MotionMask		
Button4MotionMask		
Button5MotionMask		
.sp 6p
ButtonPressMask	ButtonPress	XButtonPressedEvent	XButtonEvent
.sp 6p
ButtonReleaseMask	ButtonRelease	XButtonReleasedEvent	XButtonEvent
.sp 6p
ColormapChangeMask	ColormapNotify	XColormapEvent
.sp 6p
EnterWindowMask	EnterNotify	XEnterWindowEvent	XCrossingEvent
.sp 6p
LeaveWindowMask	LeaveNotify	XLeaveWindowEvent	XCrossingEvent
.sp 6p
ExposureMask	Expose	XExposeEvent 
GCGraphicsExposures in GC	GraphicsExpose	XGraphicsExposeEvent
	NoExpose	XNoExposeEvent
.sp 6p
FocusChangeMask	FocusIn	XFocusInEvent	XFocusChangeEvent
	FocusOut	XFocusOutEvent	XFocusChangeEvent
.sp 6p
KeymapStateMask	KeymapNotify	XKeymapEvent
.sp 6p
KeyPressMask	KeyPress	XKeyPressedEvent	XKeyEvent
KeyReleaseMask	KeyRelease	XKeyReleasedEvent	XKeyEvent
.sp 6p
OwnerGrabButtonMask	N.A.	N.A.
.sp 6p
PointerMotionMask	MotionNotify	XPointerMovedEvent	XMotionEvent
PointerMotionHintMask	N.A.	N.A.
.sp 6p
PropertyChangeMask	PropertyNotify	XPropertyEvent
.sp 6p
ResizeRedirectMask	ResizeRequest	XResizeRequestEvent
.sp 6p
StructureNotifyMask	CirculateNotify	XCirculateEvent
	ConfigureNotify	XConfigureEvent
	DestroyNotify	XDestroyWindowEvent
	GravityNotify	XGravityEvent
	MapNotify	XMapEvent
	ReparentNotify	XReparentEvent
	UnmapNotify	XUnmapEvent
.sp 6p
SubstructureNotifyMask	CirculateNotify	XCirculateEvent
	ConfigureNotify	XConfigureEvent
	CreateNotify	XCreateWindowEvent
	DestroyNotify	XDestroyWindowEvent
	GravityNotify	XGravityEvent
	MapNotify	XMapEvent
	ReparentNotify	XReparentEvent
	UnmapNotify	XUnmapEvent
.sp 6p
SubstructureRedirectMask	CirculateRequest	XCirculateRequestEvent
	ConfigureRequest	XConfigureRequestEvent
	MapRequest	XMapRequestEvent
.sp 6p
N.A.	ClientMessage	XClientMessageEvent
.sp 6p
N.A.	MappingNotify	XMappingEvent
.sp 6p
N.A.	SelectionClear	XSelectionClearEvent
.sp 6p
N.A.	SelectionNotify	XSelectionEvent
.sp 6p
N.A.	SelectionRequest	XSelectionRequestEvent
.sp 6p
VisibilityChangeMask	VisibilityNotify	XVisibilityEvent
.sp 6p
_
.TE
.ps 11
.nr PS 11
.LP
The sections that follow describe the processing that occurs 
when you select the different event masks.
The sections are organized according to these processing categories:
.IP \(bu 5
Keyboard and pointer events
.IP \(bu 5
Window crossing events
.IP \(bu 5
Input focus events
.IP \(bu 5
Keymap state notification events
.IP \(bu 5
Exposure events
.IP \(bu 5
Window state notification events
.IP \(bu 5
Structure control events
.IP \(bu 5
Colormap state notification events
.IP \(bu 5
Client communication events
.NH 2
Keyboard and Pointer Events
.XS
\*(SN Keyboard and Pointer Events
.XE
.LP
This section discusses:
.IP \(bu 5
Pointer button events
.IP \(bu 5
Keyboard and pointer events
.NH 3
Pointer Button Events
.XS
\*(SN Pointer Button Events
.XE
.LP
The following describes the event processing that occurs when a pointer button 
press is processed with the pointer in some window w and 
when no active pointer grab is in progress.
.LP
The X server searches the ancestors of w from the root down,
looking for a passive grab to activate.
If no matching passive grab on the button exists,
the X server automatically starts an active grab for the client receiving
the event and sets the last-pointer-grab time to the current server time.
The effect is essentially equivalent to an
.PN XGrabButton
with these client passed arguments:
.TS H
lw(1.5i) lw(3.5i).
_
.sp 6p
.B
Argument	Value
.sp 6p
_
.sp 6p
.TH
.R
T{
\fIw\fP
T}	T{
The event window 
T}
T{
\fIevent_mask\fP
T}	T{
The client's selected pointer events on the event window
T}
T{
\fIpointer_mode\fP
T}	T{
.PN GrabModeAsync
T}
T{
\fIkeyboard_mode\fP
T}	T{
.PN GrabModeAsync 
T}
T{
\fIowner_events\fP
T}	T{
.PN True ,
if the client has selected
.PN OwnerGrabButtonMask
on the event window,
otherwise
.PN False 
T}
T{
\fIconfine_to\fP
T}	T{
.PN None 
T}
T{
\fIcursor\fP
T}	T{
.PN None 
T}
.sp 6p
_
.TE
.LP
The active grab is automatically terminated when 
the logical state of the pointer has all buttons released.
Clients can modify the active grab by calling
.PN XUngrabPointer
and
.PN XChangeActivePointerGrab .
.NH 3
Keyboard and Pointer Events
.XS
\*(SN Keyboard and Pointer Events
.XE
.LP
.IN "Events" "ButtonPress"
.IN "Events" "ButtonRelease"
.IN "Events" "KeyPress"
.IN "Events" "KeyRelease"
.IN "Events" "MotionNotify"
This section discusses the processing that occurs for the
keyboard events
.PN KeyPress
and 
.PN KeyRelease 
and the pointer events
.PN ButtonPress ,
.PN ButtonRelease ,
and
.PN MotionNotify .
For information about the keyboard event-handling utilities,
see chapter 11.
.LP
.IN "KeyPress" "" "@DEF@"
.IN "KeyRelease" "" "@DEF@"
The X server reports
.PN KeyPress
or
.PN KeyRelease
events to clients wanting information about keys that logically change state.
Note that these events are generated for all keys, 
even those mapped to modifier bits.
.IN "ButtonPress" "" "@DEF@"
.IN "ButtonRelease" "" "@DEF@"
The X server reports
.PN ButtonPress
or
.PN ButtonRelease
events to clients wanting information about buttons that logically change state.
.LP
.IN "MotionNotify" "" "@DEF@"
The X server reports
.PN MotionNotify
events to clients wanting information about when the pointer logically moves.
The X server generates this event whenever the pointer is moved 
and the pointer motion begins and ends in the window.
The granularity of
.PN MotionNotify
events is not guaranteed, 
but a client that selects this event type is guaranteed
to receive at least one event when the pointer moves and then rests.
.LP
The generation of the logical changes lags the physical changes 
if device event processing is frozen.
.LP
To receive
.PN KeyPress ,
.PN KeyRelease ,
.PN ButtonPress ,
and
.PN ButtonRelease 
events, set 
.PN KeyPressMask ,
.PN KeyReleaseMask ,
.PN ButtonPressMask ,
and
.PN ButtonReleaseMask 
bits in the event-mask attribute of the window.
.LP
To receive 
.PN MotionNotify
events, set one or more of the following event 
masks bits in the event-mask attribute of the window.
.IP \(bu 5
.PN Button1MotionMask \ \-
.PN Button5MotionMask
.IP
The client application receives
.PN MotionNotify
events only when one or more of the specified buttons is pressed.
.IP \(bu 5
.PN ButtonMotionMask
.IP
The client application receives
.PN MotionNotify
events only when at least one button is pressed.
.IP \(bu 5
.PN PointerMotionMask
.IP
The client application receives 
.PN MotionNotify
events independent of the state of
the pointer buttons.
.IP \(bu 5
.PN PointerMotionHintMask
.IP
If
.PN PointerMotionHintMask
is selected in combination with one or more of the above masks, 
the X server is free to send only one
.PN MotionNotify
event (with the is_hint member  of the
.PN XPointerMovedEvent
structure set to
.PN NotifyHint )
to the client for the event window, 
until either the key or button state changes,
the pointer leaves the event window, or the client calls
.PN XQueryPointer
or
.PN XGetMotionEvents .
The server still may send
.PN MotionNotify
events without is_hint set to
.PN NotifyHint .
.LP
The source of the event is the viewable window that the pointer is in.
The window used by the X server to report these events depends on 
the window's position in the window hierarchy 
and whether any intervening window prohibits the generation of these events.
Starting with the source window, 
the X server searches up the window hierarchy until it locates the first 
window specified by a client as having an interest in these events.
If one of the intervening windows has its do-not-propagate-mask
set to prohibit generation of the event type,
the events of those types will be suppressed.
Clients can modify the actual window used for reporting by performing
active grabs and, in the case of keyboard events, by using the focus window.
.LP
The structures for these event types contain:
.LP
.IN "XButtonEvent" "" "@DEF@"
.IN "XButtonPressedEvent" "" "@DEF@"
.IN "XButtonReleasedEvent" "" "@DEF@"
.sM
.Ds 0
.TA .5i 3i
.ta .5i 3i
typedef struct {
	int type;	/* ButtonPress or ButtonRelease */
	unsigned long serial;	/* # of last request processed by server */
	Bool send_event;	/* true if this came from a SendEvent request */
	Display *display;	/* Display the event was read from */
	Window window;	/* ``event'' window it is reported relative to */
	Window root;	/* root window that the event occurred on */
	Window subwindow;	/* child window */
	Time time;	/* milliseconds */
	int x, y;	/* pointer x, y coordinates in event window */
	int x_root, y_root;	/* coordinates relative to root */
	unsigned int state;	/* key or button mask */
	unsigned int button;	/* detail */
	Bool same_screen;	/* same screen flag */
} XButtonEvent;
typedef XButtonEvent XButtonPressedEvent;
typedef XButtonEvent XButtonReleasedEvent;
.De
.LP
.IN "XKeyEvent" "" "@DEF@"
.IN "XKeyPressedEvent" "" "@DEF@"
.IN "XKeyReleasedEvent" "" "@DEF@"
.Ds 0
.TA .5i 3i
.ta .5i 3i
typedef struct {
	int type;	/* KeyPress or KeyRelease */
	unsigned long serial;	/* # of last request processed by server */
	Bool send_event;	/* true if this came from a SendEvent request */
	Display *display;	/* Display the event was read from */
	Window window;	/* ``event'' window it is reported relative to */
	Window root;	/* root window that the event occurred on */
	Window subwindow;	/* child window */
	Time time;	/* milliseconds */
	int x, y;	/* pointer x, y coordinates in event window */
	int x_root, y_root;	/* coordinates relative to root */
	unsigned int state;	/* key or button mask */
	unsigned int keycode;	/* detail */
	Bool same_screen;	/* same screen flag */
} XKeyEvent;
typedef XKeyEvent XKeyPressedEvent;
typedef XKeyEvent XKeyReleasedEvent;
.De
.LP
.IN "XMotionEvent" "" "@DEF@"
.IN "XPointerMovedEvent" "" "@DEF@"
.Ds 0
.TA .5i 3i
.ta .5i 3i
typedef struct {
	int type;	/* MotionNotify */
	unsigned long serial;	/* # of last request processed by server */
	Bool send_event;	/* true if this came from a SendEvent request */
	Display *display;	/* Display the event was read from */
	Window window;	/* ``event'' window reported relative to */
	Window root;	/* root window that the event occurred on */
	Window subwindow;	/* child window */
	Time time;	/* milliseconds */
	int x, y;	/* pointer x, y coordinates in event window */
	int x_root, y_root;	/* coordinates relative to root */
	unsigned int state;	/* key or button mask */
	char is_hint;	/* detail */
	Bool same_screen;	/* same screen flag */
} XMotionEvent;
typedef XMotionEvent XPointerMovedEvent;
.De
.LP
.eM
These structures have the following common members:
window, root, subwindow, time, x, y, x_root, y_root, state, and same_screen.
The window member is set to the window on which the
event was generated and is referred to as the event window. 
As long as the conditions previously discussed are met,
this is the window used by the X server to report the event.
The root member is set to the source window's root window.
The x_root and y_root members are set to the pointer's coordinates
relative to the root window's origin at the time of the event.
.LP
The same_screen member is set to indicate whether the event 
window is on the same screen
as the root window and can be either
.PN True 
or
.PN False .
If
.PN True ,
the event and root windows are on the same screen.
If
.PN False ,
the event and root windows are not on the same screen.
.LP
If the source window is an inferior of the event window, 
the subwindow member of the structure is set to the child of the event window
that is the source window or the child of the event window that is
an ancestor of the source window.
Otherwise, the X server sets the subwindow member to
.PN None .
The time member is set to the time when the event was generated 
and is expressed in milliseconds.
.LP
If the event window is on the same screen as the root window, 
the x and y members
are set to the coordinates relative to the event window's origin.
Otherwise, these members are set to zero.
.LP
The state member is set to indicate the logical state of the pointer buttons 
and modifier keys just prior to the event,
which is the bitwise inclusive OR of one or more of the
button or modifier key masks:
.PN Button1Mask ,
.PN Button2Mask ,
.PN Button3Mask ,
.PN Button4Mask ,
.PN Button5Mask ,
.PN ShiftMask ,
.PN LockMask ,
.PN ControlMask ,
.PN Mod1Mask ,
.PN Mod2Mask ,
.PN Mod3Mask ,
.PN Mod4Mask ,
and
.PN Mod5Mask .
.LP
Each of these structures also has a member that indicates the detail.
For the
.PN XKeyPressedEvent
and
.PN XKeyReleasedEvent
structures, this member is called a keycode.
It is set to a number that represents a physical key on the keyboard.
The keycode is an arbitrary representation for any key on the keyboard
(see sections 12.7 and 16.1).
.LP
For the
.PN XButtonPressedEvent
and
.PN XButtonReleasedEvent
structures, this member is called button.
It represents the pointer button that changed state and can be the
.PN Button1 ,
.PN Button2 ,
.PN Button3 ,
.PN Button4 ,
or
.PN Button5 
value.
For the
.PN XPointerMovedEvent
structure, this member is called is_hint.
It can be set to 
.PN NotifyNormal
or
.PN NotifyHint .
.LP
Some of the symbols mentioned in this section have fixed values, as
follows:
.TS H
lw(2i) lw(3.5i).
_
.sp 6p
.B
Symbol	Value
.sp 6p
_
.sp 6p
.TH
.R
T{
.PN Button1MotionMask
T}	T{
(1L<<8)
T}
T{
.PN Button2MotionMask
T}	T{
(1L<<9)
T}
T{
.PN Button3MotionMask
T}	T{
(1L<<10)
T}
T{
.PN Button4MotionMask
T}	T{
(1L<<11)
T}
T{
.PN Button5MotionMask
T}	T{
(1L<<12)
T}
T{
.PN Button1Mask
T}	T{
(1<<8)
T}
T{
.PN Button2Mask
T}	T{
(1<<9)
T}
T{
.PN Button3Mask
T}	T{
(1<<10)
T}
T{
.PN Button4Mask
T}	T{
(1<<11)
T}
T{
.PN Button5Mask
T}	T{
(1<<12)
T}
T{
.PN ShiftMask
T}	T{
(1<<0)
T}
T{
.PN LockMask
T}	T{
(1<<1)
T}
T{
.PN ControlMask
T}	T{
(1<<2)
T}
T{
.PN Mod1Mask
T}	T{
(1<<3)
T}
T{
.PN Mod2Mask
T}	T{
(1<<4)
T}
T{
.PN Mod3Mask
T}	T{
(1<<5)
T}
T{
.PN Mod4Mask
T}	T{
(1<<6)
T}
T{
.PN Mod5Mask
T}	T{
(1<<7)
T}
T{
.PN Button1
T}	T{
1
T}
T{
.PN Button2
T}	T{
2
T}
T{
.PN Button3
T}	T{
3
T}
T{
.PN Button4
T}	T{
4
T}
T{
.PN Button5
T}	T{
5
T}
.sp 6p
_
.TE
.NH 2
Window Entry/Exit Events
.XS
\*(SN Window Entry/Exit Events
.XE
.LP
.IN "Events" "EnterNotify"
.IN "Events" "LeaveNotify"
This section describes the processing that 
occurs for the window crossing events
.PN EnterNotify
and
.PN LeaveNotify .
.IN "EnterNotify" "" "@DEF@"
.IN "LeaveNotify" "" "@DEF@"
If a pointer motion or a window hierarchy change causes the
pointer to be in a different window than before, the X server reports
.PN EnterNotify
or
.PN LeaveNotify
events to clients who have selected for these events.
All 
.PN EnterNotify
and 
.PN LeaveNotify
events caused by a hierarchy change are
generated after any hierarchy event
.Pn ( UnmapNotify ,
.PN MapNotify ,
.PN ConfigureNotify ,
.PN GravityNotify ,
.PN CirculateNotify )
caused by that change;
however, the X protocol does not constrain the ordering of 
.PN EnterNotify 
and 
.PN LeaveNotify 
events with respect to
.PN FocusOut , 
.PN VisibilityNotify ,
and 
.PN Expose 
events.
.LP
This contrasts with
.PN MotionNotify
events, which are also generated when the pointer moves
but only when the pointer motion begins and ends in a single window.
An
.PN EnterNotify
or
.PN LeaveNotify
event also can be generated when some client application calls
.PN XGrabPointer
and
.PN XUngrabPointer .
.LP
To receive
.PN EnterNotify
or
.PN LeaveNotify
events, set the
.PN EnterWindowMask
or
.PN LeaveWindowMask
bits of the event-mask attribute of the window.
.LP
The structure for these event types contains:
.LP
.IN "XCrossingEvent" "" "@DEF@"
.IN "XEnterWindowEvent" "" "@DEF@"
.IN "XLeaveWindowEvent" "" "@DEF@"
.sM
.Ds 0
.TA .5i 3i
.ta .5i 3i
typedef struct {
	int type;	/* EnterNotify or LeaveNotify */
	unsigned long serial;	/* # of last request processed by server */
	Bool send_event;	/* true if this came from a SendEvent request */
	Display *display;	/* Display the event was read from */
	Window window;	/* ``event'' window reported relative to */
	Window root;	/* root window that the event occurred on */
	Window subwindow;	/* child window */
	Time time;	/* milliseconds */
	int x, y;	/* pointer x, y coordinates in event window */
	int x_root, y_root;	/* coordinates relative to root */
	int mode;	/* NotifyNormal, NotifyGrab, NotifyUngrab */
	int detail;
		/*
	 	* NotifyAncestor, NotifyVirtual, NotifyInferior, 
	 	* NotifyNonlinear,NotifyNonlinearVirtual
	 	*/
	Bool same_screen;	/* same screen flag */
	Bool focus;	/* boolean focus */
	unsigned int state;	/* key or button mask */
} XCrossingEvent;
typedef XCrossingEvent XEnterWindowEvent;
typedef XCrossingEvent XLeaveWindowEvent;
.De
.LP
.eM
The window member is set to the window on which the
.PN EnterNotify
or
.PN LeaveNotify
event was generated and is referred to as the event window. 
This is the window used by the X server to report the event, 
and is relative to the root
window on which the event occurred. 
The root member is set to the root window of the screen
on which the event occurred.
.LP
For a
.PN LeaveNotify 
event,
if a child of the event window contains the initial position of the pointer,
the subwindow component is set to that child.
Otherwise, the X server sets the subwindow member to
.PN None .
For an
.PN EnterNotify 
event, if a child of the event window contains the final pointer position, 
the subwindow component is set to that child or
.PN None .
.LP
The time member is set to the time when the event was generated
and is expressed in milliseconds.
The x and y members are set to the coordinates of the pointer position in 
the event window.
This position is always the pointer's final position,
not its initial position.
If the event window is on the same
screen as the root window, x and y are the pointer coordinates
relative to the event window's origin. 
Otherwise, x and y are set to zero.
The x_root and y_root members are set to the pointer's coordinates relative to the
root window's origin at the time of the event.
.LP
The same_screen member is set to indicate whether the event window is on the same screen
as the root window and can be either
.PN True 
or
.PN False .
If
.PN True ,
the event and root windows are on the same screen.
If
.PN False ,
the event and root windows are not on the same screen.
.LP
The focus member is set to indicate whether the event window is the focus window or an
inferior of the focus window.
The X server can set this member to either
.PN True 
or
.PN False .
If
.PN True ,
the event window is the focus window or an inferior of the focus window.
If
.PN False ,
the event window is not the focus window or an inferior of the focus window.
.LP
The state member is set to indicate the state of the pointer buttons and
modifier keys just prior to the
event.
The X server can set this member to the bitwise inclusive OR of one 
or more of the button or modifier key masks:
.PN Button1Mask ,
.PN Button2Mask ,
.PN Button3Mask ,
.PN Button4Mask ,
.PN Button5Mask ,
.PN ShiftMask ,
.PN LockMask ,
.PN ControlMask ,
.PN Mod1Mask ,
.PN Mod2Mask ,
.PN Mod3Mask ,
.PN Mod4Mask ,
.PN Mod5Mask .
.LP
The mode member is set to indicate whether the events are normal events, 
pseudo-motion events
when a grab activates, or pseudo-motion events when a grab deactivates.
The X server can set this member to 
.PN NotifyNormal ,
.PN NotifyGrab ,
or
.PN NotifyUngrab .
.LP
The detail member is set to indicate the notify detail and can be
.PN NotifyAncestor ,
.PN NotifyVirtual ,
.PN NotifyInferior ,
.PN NotifyNonlinear ,
or
.PN NotifyNonlinearVirtual .
.NH 3 
Normal Entry/Exit Events
.XS
\*(SN Normal Entry/Exit Events
.XE
.LP
.PN EnterNotify
and
.PN LeaveNotify
events are generated when the pointer moves from
one window to another window.
Normal events are identified by
.PN XEnterWindowEvent
or
.PN XLeaveWindowEvent
structures whose mode member is set to
.PN NotifyNormal .
.IP \(bu 5
When the pointer moves from window A to window B and A is an inferior of B, 
the X server does the following:
.RS
.IP \- 5
It generates a
.PN LeaveNotify
event on window A, with the detail member of the
.PN XLeaveWindowEvent
structure set to
.PN NotifyAncestor .
.IP \- 5
It generates a
.PN LeaveNotify
event on each window between window A and window B, exclusive,
with the detail member of each
.PN XLeaveWindowEvent
structure set to
.PN NotifyVirtual .
.IP \- 5
It generates an
.PN EnterNotify
event on window B, with the detail member of the 
.PN XEnterWindowEvent
structure set to
.PN NotifyInferior .
.RE
.IP \(bu 5
When the pointer moves from window A to window B and B is an inferior of A,
the X server does the following:
.RS
.IP \- 5
It generates a
.PN LeaveNotify
event on window A,
with the detail member of the
.PN XLeaveWindowEvent
structure set to
.PN NotifyInferior .
.IP \- 5
It generates an
.PN EnterNotify
event on each window between window A and window B, exclusive, with the 
detail member of each 
.PN XEnterWindowEvent
structure set to
.PN NotifyVirtual . 
.IP \- 5
It generates an
.PN EnterNotify
event on window B, with the detail member of the 
.PN XEnterWindowEvent
structure set to
.PN NotifyAncestor .
.RE
.IP \(bu 5
When the pointer moves from window A to window B 
and window C is their least common ancestor, 
the X server does the following:
.RS
.IP \- 5
It generates a
.PN LeaveNotify
event on window A,
with the detail member of the
.PN XLeaveWindowEvent
structure set to 
.PN NotifyNonlinear .
.IP \- 5
It generates a
.PN LeaveNotify
event on each window between window A and window C, exclusive,
with the detail member of each
.PN XLeaveWindowEvent
structure set to
.PN NotifyNonlinearVirtual .
.IP \- 5
It generates an
.PN EnterNotify
event on each window between window C and window B, exclusive, 
with the detail member of each
.PN XEnterWindowEvent
structure set to
.PN NotifyNonlinearVirtual .
.IP \- 5
It generates an
.PN EnterNotify
event on window B, with the detail member of the 
.PN XEnterWindowEvent
structure set to 
.PN NotifyNonlinear .
.RE
.IP \(bu 5
When the pointer moves from window A to window B on different screens, 
the X server does the following:
.RS
.IP \- 5
It generates a
.PN LeaveNotify
event on window A,
with the detail member of the
.PN XLeaveWindowEvent
structure set to 
.PN NotifyNonlinear .
.IP \- 5
If window A is not a root window,
it generates a
.PN LeaveNotify
event on each window above window A up to and including its root,
with the detail member of each
.PN XLeaveWindowEvent
structure set to 
.PN NotifyNonlinearVirtual .
.IP \- 5
If window B is not a root window,
it generates an
.PN EnterNotify
event on each window from window B's root down to but not including
window B, with the detail member of each
.PN XEnterWindowEvent
structure set to 
.PN NotifyNonlinearVirtual .
.IP \- 5
It generates an
.PN EnterNotify
event on window B, with the detail member of the
.PN XEnterWindowEvent
structure set to 
.PN NotifyNonlinear .
.RE
.\".SH 3
.NH 3 
Grab and Ungrab Entry/Exit Events
.XS
\*(SN Grab and Ungrab Entry/Exit Events
.XE
.LP
Pseudo-motion mode
.PN EnterNotify
and
.PN LeaveNotify
events are generated when a pointer grab activates or deactivates.
Events in which the pointer grab activates
are identified by
.PN XEnterWindowEvent
or
.PN XLeaveWindowEvent
structures whose mode member is set to 
.PN NotifyGrab .
Events in which the pointer grab deactivates
are identified by
.PN XEnterWindowEvent
or
.PN XLeaveWindowEvent
structures whose mode member is set to 
.PN NotifyUngrab
(see
.PN XGrabPointer ).
.IP \(bu 5
When a pointer grab activates after any initial warp into a confine_to
window and before generating any actual
.PN ButtonPress
event that activates the grab, 
G is the grab_window for the grab, 
and P is the window the pointer is in, 
the X server does the following:
.RS
.IP \- 5
It generates
.PN EnterNotify
and
.PN LeaveNotify
events (see section 10.6.1)
with the mode members of the 
.PN XEnterWindowEvent
and
.PN XLeaveWindowEvent
structures set to 
.PN NotifyGrab .
These events are generated
as if the pointer were to suddenly warp from
its current position in P to some position in G.
However, the pointer does not warp, and the X server uses the pointer position 
as both the initial and final positions for the events.
.RE
.IP \(bu 5
When a pointer grab deactivates after generating any actual
.PN ButtonRelease
event that deactivates the grab, 
G is the grab_window for the grab,
and P is the window the pointer is in, 
the X server does the following:
.RS
.IP \- 5
It generates
.PN EnterNotify
and
.PN LeaveNotify
events (see section 10.6.1)
with the mode members of the
.PN XEnterWindowEvent
and
.PN XLeaveWindowEvent
structures set to 
.PN NotifyUngrab .
These events are generated as if the pointer were to suddenly warp from
some position in G to its current position in P.
However, the pointer does not warp, and the X server uses the
current pointer position as both the
initial and final positions for the events.
.RE
.NH 2
Input Focus Events
.XS
\*(SN Input Focus Events 
.XE
.LP
.IN "Events" "FocusIn"
.IN "Events" "FocusOut"
This section describes the processing that occurs for the input focus events
.PN FocusIn
and
.PN FocusOut .
.IN "FocusIn" "" "@DEF@"
.IN "FocusOut" "" "@DEF@"
The X server can report
.PN FocusIn
or
.PN FocusOut
events to clients wanting information about when the input focus changes.
The keyboard is always attached to some window 
(typically, the root window or a top-level window), 
which is called the focus window.
The focus window and the position of the pointer determine the window that
receives keyboard input.
Clients may need to know when the input focus changes
to control highlighting of areas on the screen.
.LP
To receive
.PN FocusIn
or
.PN FocusOut
events, set the
.PN FocusChangeMask
bit in the event-mask attribute of the window. 
.LP
The structure for these event types contains:
.LP
.IN "XFocusChangeEvent" "" "@DEF@"
.IN "XFocusInEvent" "" "@DEF@"
.IN "XFocusOutEvent" "" "@DEF@"
.sM
.Ds 0
.TA .5i 3i
.ta .5i 3i
typedef struct {
	int type;	/* FocusIn or FocusOut */
	unsigned long serial;	/* # of last request processed by server */
	Bool send_event;	/* true if this came from a SendEvent request */
	Display *display;	/* Display the event was read from */
	Window window;	/* window of event */
	int mode;	/* NotifyNormal, NotifyGrab, NotifyUngrab */
	int detail;
		/*
	 	* NotifyAncestor, NotifyVirtual, NotifyInferior, 
	 	* NotifyNonlinear,NotifyNonlinearVirtual, NotifyPointer,
	 	* NotifyPointerRoot, NotifyDetailNone 
	 	*/
} XFocusChangeEvent;
typedef XFocusChangeEvent XFocusInEvent;
typedef XFocusChangeEvent XFocusOutEvent;
.De
.LP
.eM
The window member is set to the window on which the
.PN FocusIn
or
.PN FocusOut
event was generated.
This is the window used by the X server to report the event. 
The mode member is set to indicate whether the focus events 
are normal focus events, 
focus events while grabbed,
focus events
when a grab activates, or focus events when a grab deactivates.
The X server can set the mode member to 
.PN NotifyNormal ,
.PN NotifyWhileGrabbed ,
.PN NotifyGrab ,
or
.PN NotifyUngrab .
.LP
All 
.PN FocusOut
events caused by a window unmap are generated after any
.PN UnmapNotify
event; however, the X protocol does not constrain the ordering of 
.PN FocusOut
events with respect to
generated 
.PN EnterNotify ,
.PN LeaveNotify ,
.PN VisibilityNotify ,
and
.PN Expose
events.
.LP
Depending on the event mode,
the detail member is set to indicate the notify detail and can be
.PN NotifyAncestor ,
.PN NotifyVirtual ,
.PN NotifyInferior ,
.PN NotifyNonlinear ,
.PN NotifyNonlinearVirtual ,
.PN NotifyPointer ,
.PN NotifyPointerRoot ,
or
.PN NotifyDetailNone .
.NH 3 
Normal Focus Events and Focus Events While Grabbed 
.XS
\*(SN Normal Focus Events and Focus Events While Grabbed 
.XE
.LP
Normal focus events are identified by
.PN XFocusInEvent
or
.PN XFocusOutEvent
structures whose mode member is set to 
.PN NotifyNormal .
Focus events while grabbed are identified by
.PN XFocusInEvent
or
.PN XFocusOutEvent
structures whose mode member is set to 
.PN NotifyWhileGrabbed .
The X server processes normal focus and focus events while grabbed according to 
the following:
.IP \(bu 5
When the focus moves from window A to window B, A is an inferior of B, 
and the pointer is in window P, 
the X server does the following:
.RS
.IP \- 5
It generates a
.PN FocusOut
event on window A, with the detail member of the
.PN XFocusOutEvent
structure set to 
.PN NotifyAncestor . 
.IP \- 5
It generates a
.PN FocusOut
event on each window between window A and window B, exclusive,
with the detail member of each
.PN XFocusOutEvent
structure set to 
.PN NotifyVirtual .
.IP \- 5
It generates a
.PN FocusIn
event on window B, with the detail member of the 
.PN XFocusOutEvent
structure set to 
.PN NotifyInferior .
.IP \- 5
If window P is an inferior of window B
but window P is not window A or an inferior or ancestor of window A,
it generates a
.PN FocusIn
event on each window below window B, down to and including window P, 
with the detail member of each 
.PN XFocusInEvent
structure set to 
.PN NotifyPointer .
.RE
.IP \(bu 5
When the focus moves from window A to window B, B is an inferior of A, 
and the pointer is in window P, 
the X server does the following:
.RS
.IP \- 5
If window P is an inferior of window A
but P is not an inferior of window B or an ancestor of B,
it generates a
.PN FocusOut
event on each window from window P up to but not including window A,
with the detail member of each 
.PN XFocusOutEvent
structure set to  
.PN NotifyPointer .
.IP \- 5
It generates a
.PN FocusOut
event on window A,
with the detail member of the
.PN XFocusOutEvent
structure set to  
.PN NotifyInferior . 
.IP \- 5
It generates a
.PN FocusIn
event on each window between window A and window B, exclusive, with the 
detail member of each 
.PN XFocusInEvent
structure set to  
.PN NotifyVirtual . 
.IP \- 5
It generates a
.PN FocusIn
event on window B, with the detail member of the 
.PN XFocusInEvent
structure set to  
.PN NotifyAncestor .
.RE
.IP \(bu 5
When the focus moves from window A to window B, 
window C is their least common ancestor, 
and the pointer is in window P, 
the X server does the following:
.RS
.IP \- 5
If window P is an inferior of window A,
it generates a
.PN FocusOut
event on each window from window P up to but not including window A, 
with the detail member of the 
.PN XFocusOutEvent
structure set to  
.PN NotifyPointer .
.IP \- 5
It generates a
.PN FocusOut
event on window A,
with the detail member of the
.PN XFocusOutEvent
structure set to  
.PN NotifyNonlinear .
.IP \- 5
It generates a
.PN FocusOut
event on each window between window A and window C, exclusive,
with the detail member of each
.PN XFocusOutEvent
structure set to  
.PN NotifyNonlinearVirtual .
.IP \- 5
It generates a
.PN FocusIn
event on each window between C and B, exclusive,
with the detail member of each
.PN XFocusInEvent
structure set to  
.PN NotifyNonlinearVirtual .
.IP \- 5
It generates a
.PN FocusIn
event on window B, with the detail member of the 
.PN XFocusInEvent
structure set to  
.PN NotifyNonlinear .
.IP \- 5
If window P is an inferior of window B, it generates a
.PN FocusIn
event on each window below window B down to and including window P, 
with the detail member of the 
.PN XFocusInEvent
structure set to  
.PN NotifyPointer .
.RE
.IP \(bu 5
When the focus moves from window A to window B on different screens 
and the pointer is in window P, 
the X server does the following:
.RS
.IP \- 5
If window P is an inferior of window A, it generates a
.PN FocusOut
event on each window from window P up to but not including window A, 
with the detail member of each 
.PN XFocusOutEvent
structure set to  
.PN NotifyPointer .
.IP \- 5
It generates a
.PN FocusOut
event on window A,
with the detail member of the
.PN XFocusOutEvent
structure set to  
.PN NotifyNonlinear .
.IP \- 5
If window A is not a root window,
it generates a
.PN FocusOut
event on each window above window A up to and including its root, 
with the detail member of each
.PN XFocusOutEvent
structure set to  
.PN NotifyNonlinearVirtual .
.IP \- 5
If window B is not a root window,
it generates a
.PN FocusIn
event on each window from window B's root down to but not including
window B, with the detail member of each
.PN XFocusInEvent
structure set to  
.PN NotifyNonlinearVirtual .
.IP \- 5
It generates a
.PN FocusIn
event on window B, with the detail member of each 
.PN XFocusInEvent
structure set to  
.PN NotifyNonlinear .
.IP \- 5
If window P is an inferior of window B, it generates a
.PN FocusIn
event on each window below window B down to and including window P, 
with the detail member of each 
.PN XFocusInEvent
structure set to  
.PN NotifyPointer .
.RE
.IP \(bu 5
When the focus moves from window A to 
.PN PointerRoot
(events sent to the window under the pointer)
or
.PN None 
(discard), and the pointer is in window P,
the X server does the following:
.RS
.IP \- 5
If window P is an inferior of window A, it generates a
.PN FocusOut
event on each window from window P up to but not including window A, 
with the detail member of each 
.PN XFocusOutEvent
structure set to  
.PN NotifyPointer .
.IP \- 5
It generates a
.PN FocusOut
event on window A, with the detail member of the
.PN XFocusOutEvent
structure set to
.PN NotifyNonlinear .
.IP \- 5
If window A is not a root window,
it generates a
.PN FocusOut
event on each window above window A up to and including its root, 
with the detail member of each
.PN XFocusOutEvent
structure set to
.PN NotifyNonlinearVirtual .
.IP \- 5
It generates a
.PN FocusIn
event on the root window of all screens, with the detail member of each
.PN XFocusInEvent
structure set to
.PN NotifyPointerRoot
(or
.PN NotifyDetailNone ).
.IP \- 5
If the new focus is
.PN PointerRoot ,
it generates a
.PN FocusIn
event on each window from window P's root down to and including window P, 
with the detail member of each
.PN XFocusInEvent
structure set to
.PN NotifyPointer .
.RE
.IP \(bu 5
When the focus moves from 
.PN PointerRoot
(events sent to the window under the pointer)
or
.PN None 
to window A, and the pointer is in window P, 
the X server does the following: 
.RS
.IP \- 5
If the old focus is
.PN PointerRoot ,
it generates a
.PN FocusOut
event on each window from window P up to and including window P's root, 
with the detail member of each
.PN XFocusOutEvent
structure set to
.PN NotifyPointer .
.IP \- 5
It generates a
.PN FocusOut
event on all root windows,
with the detail member of each
.PN XFocusOutEvent
structure set to
.PN NotifyPointerRoot
(or
.PN NotifyDetailNone ).
.IP \- 5
If window A is not a root window,
it generates a
.PN FocusIn
event on each window from window A's root down to but not including window A,
with the detail member of each
.PN XFocusInEvent
structure set to
.PN NotifyNonlinearVirtual .
.IP \- 5
It generates a
.PN FocusIn
event on window A,
with the detail member of the 
.PN XFocusInEvent
structure set to  
.PN NotifyNonlinear .
.IP \- 5
If window P is an inferior of window A, it generates a
.PN FocusIn
event on each window below window A down to and including window P, 
with the detail member of each 
.PN XFocusInEvent
structure set to  
.PN NotifyPointer .
.RE
.IP \(bu 5
When the focus moves from 
.PN PointerRoot
(events sent to the window under the pointer)
to
.PN None
(or vice versa), and the pointer is in window P, 
the X server does the following:
.RS
.IP \- 5
If the old focus is
.PN PointerRoot ,
it generates a
.PN FocusOut
event on each window from window P up to and including window P's root, 
with the detail member of each
.PN XFocusOutEvent
structure set to
.PN NotifyPointer .
.IP \- 5
It generates a
.PN FocusOut
event on all root windows,
with the detail member of each 
.PN XFocusOutEvent
structure set to either
.PN NotifyPointerRoot
or
.PN NotifyDetailNone . 
.IP \- 5
It generates a
.PN FocusIn
event on all root windows,
with the detail member of each
.PN XFocusInEvent
structure set to
.PN NotifyDetailNone 
or
.PN NotifyPointerRoot .
.IP \- 5
If the new focus is
.PN PointerRoot ,
it generates a
.PN FocusIn
event on each window from window P's root down to and including window P, 
with the detail member of each
.PN XFocusInEvent
structure set to
.PN NotifyPointer .
.RE
.\".SH 3
.NH 3 
Focus Events Generated by Grabs
.XS
\*(SN Focus Events Generated by Grabs 
.XE
.LP
Focus events in which the keyboard grab activates
are identified by
.PN XFocusInEvent
or
.PN XFocusOutEvent
structures whose mode member is set to 
.PN NotifyGrab .
Focus events in which the keyboard grab deactivates
are identified by
.PN XFocusInEvent
or
.PN XFocusOutEvent
structures whose mode member is set to 
.PN NotifyUngrab 
(see 
.PN XGrabKeyboard ).
.IP \(bu 5
When a keyboard grab activates before generating any actual 
.PN KeyPress
event that activates the grab,
G is the grab_window, and F is the current focus, 
the X server does the following:
.RS
.IP \- 5
It generates 
.PN FocusIn
and
.PN FocusOut
events, with the mode members of the 
.PN XFocusInEvent
and
.PN XFocusOutEvent
structures set to 
.PN NotifyGrab .
These events are generated
as if the focus were to change from
F to G.
.RE
.IP \(bu 5
When a keyboard grab deactivates after generating any actual
.PN KeyRelease
event that deactivates the grab,
G is the grab_window, and F is the current focus,
the X server does the following:
.RS
.IP \- 5
It generates 
.PN FocusIn
and
.PN FocusOut
events, with the mode members of the 
.PN XFocusInEvent
and
.PN XFocusOutEvent
structures set to
.PN NotifyUngrab .
These events are generated
as if the focus were to change from
G to F.
.RE
.NH 2
Key Map State Notification Events
.XS
\*(SN Key Map State Notification Events
.XE
.LP
.IN "Events" "KeymapNotify"
.IN "KeymapNotify" "" "@DEF@"
The X server can report
.PN KeymapNotify
events to clients that want information about changes in their keyboard state.
.LP
To receive
.PN KeymapNotify
events, set the
.PN KeymapStateMask
bit in the event-mask attribute of the window. 
The X server generates this event immediately after every
.PN EnterNotify
and
.PN FocusIn
event.
.LP
The structure for this event type contains:
.LP
.IN "XKeymapEvent" "" "@DEF@"
.sM
.Ds 0
.TA .5i 3i
.ta .5i 3i
/* generated on EnterWindow and FocusIn when KeymapState selected */
typedef struct {
	int type;	/* KeymapNotify */
	unsigned long serial;	/* # of last request processed by server */
	Bool send_event;	/* true if this came from a SendEvent request */
	Display *display;	/* Display the event was read from */
	Window window;
	char key_vector[32];
} XKeymapEvent;	
.De
.LP
.eM
The window member is not used but is present to aid some toolkits.
The key_vector member is set to the bit vector of the keyboard.
Each bit set to 1 indicates that the corresponding key 
is currently pressed.
The vector is represented as 32 bytes.
Byte N (from 0) contains the bits for keys 8N to 8N + 7 
with the least significant bit in the byte representing key 8N.
.NH 2
Exposure Events
.XS
\*(SN Exposure Events
.XE
.LP
The X protocol does not guarantee to preserve the contents of window 
regions when
the windows are obscured or reconfigured.
Some implementations may preserve the contents of windows.
Other implementations are free to destroy the contents of windows
when exposed.
X expects client applications to assume the responsibility for
restoring the contents of an exposed window region. 
(An exposed window region describes a formerly obscured window whose 
region becomes visible.) 
Therefore, the X server sends 
.PN Expose 
events describing the window and the region of the window that has been exposed.
A naive client application usually redraws the entire window. 
A more sophisticated client application redraws only the exposed region.
.NH 3
Expose Events
.XS
\*(SN Expose Events
.XE
.LP
.IN "Events" "Expose"
.IN "Expose" "" "@DEF@"
The X server can report
.PN Expose
events to clients wanting information about when the contents of window regions
have been lost.
The circumstances in which the X server generates
.PN Expose
events are not as definite as those for other events.
However, the X server never generates
.PN Expose
events on windows whose class you specified as
.PN InputOnly .
The X server can generate
.PN Expose
events when no valid contents are available for regions of a window
and either the regions are visible, 
the regions are viewable and the server is (perhaps newly) maintaining 
backing store on the window,
or the window is not viewable but the server is (perhaps newly) honoring the
window's backing-store attribute of
.PN Always
or
.PN WhenMapped .
The regions decompose into an (arbitrary) set of rectangles,
and an
.PN Expose
event is generated for each rectangle.
For any given window,
the X server guarantees to report contiguously 
all of the regions exposed by some action that causes 
.PN Expose 
events, such as raising a window.
.LP
To receive
.PN Expose
events, set the
.PN ExposureMask
bit in the event-mask attribute of the window. 
.LP
The structure for this event type contains:
.LP
.IN "XExposeEvent" "" "@DEF@"
.sM
.Ds 0
.TA .5i 3i
.ta .5i 3i
typedef struct {
	int type;	/* Expose */
	unsigned long serial;	/* # of last request processed by server */
	Bool send_event;	/* true if this came from a SendEvent request */
	Display *display;	/* Display the event was read from */
	Window window;
	int x, y;
	int width, height;
	int count;	/* if nonzero, at least this many more */
} XExposeEvent;
.De
.LP
.eM
The window member is set to the exposed (damaged) window.
The x and y members are set to the coordinates relative to the window's origin
and indicate the upper-left corner of the rectangle.
The width and height members are set to the size (extent) of the rectangle.
The count member is set to the number of
.PN Expose
events that are to follow.
If count is zero, no more
.PN Expose
events follow for this window.
However, if count is nonzero, at least that number of 
.PN Expose 
events (and possibly more) follow for this window.
Simple applications that do not want to optimize redisplay by distinguishing
between subareas of its window can just ignore all
.PN Expose
events with nonzero counts and perform full redisplays
on events with zero counts.
.NH 3
GraphicsExpose and NoExpose Events
.XS
\*(SN GraphicsExpose and NoExpose Events
.XE
.LP
.IN "Events" "GraphicsExpose"
.IN "Events" "NoExpose"
.IN "GraphicsExpose" "" "@DEF@"
The X server can report
.PN GraphicsExpose
events to clients wanting information about when a destination region could not
be computed during certain graphics requests:
.PN XCopyArea
or
.PN XCopyPlane .
The X server generates this event whenever a destination region could not be
computed because of an obscured or out-of-bounds source region.
In addition, the X server guarantees to report contiguously all of the regions exposed by
some graphics request 
(for example, copying an area of a drawable to a destination
drawable).
.LP
.IN "NoExpose" "" "@DEF@"
The X server generates a
.PN NoExpose
event whenever a graphics request that might
produce a
.PN GraphicsExpose
event does not produce any.
In other words, the client is really asking for a
.PN GraphicsExpose
event but instead receives a
.PN NoExpose
event.
.LP
To receive
.PN GraphicsExpose
or
.PN NoExpose
events, you must first set the graphics-exposure 
attribute of the graphics context to
.PN True .
You also can set the graphics-expose attribute when creating a graphics
context using
.PN XCreateGC 
or by calling
.PN XSetGraphicsExposures .
.LP
The structures for these event types contain:
.LP
.IN "XGraphicsExposeEvent" "" "@DEF@"
.sM
.Ds 0
.TA .5i 3i
.ta .5i 3i
typedef struct {
	int type;	/* GraphicsExpose */
	unsigned long serial;	/* # of last request processed by server */
	Bool send_event;	/* true if this came from a SendEvent request */
	Display *display;	/* Display the event was read from */
	Drawable drawable;
	int x, y;
	int width, height;
	int count;	/* if nonzero, at least this many more */
	int major_code;	/* core is CopyArea or CopyPlane */
	int minor_code;	/* not defined in the core */
} XGraphicsExposeEvent;
.De
.LP
.IN "XNoExposeEvent" "" "@DEF@"
.Ds 0
.TA .5i 3i
.ta .5i 3i
typedef struct {
	int type;	/* NoExpose */
	unsigned long serial;	/* # of last request processed by server */
	Bool send_event;	/* true if this came from a SendEvent request */
	Display *display;	/* Display the event was read from */
	Drawable drawable;
	int major_code;	/* core is CopyArea or CopyPlane */
	int minor_code;	/* not defined in the core */
} XNoExposeEvent;
.De
.LP
.eM
Both structures have these common members: drawable, major_code, and minor_code.
The drawable member is set to the drawable of the destination region on 
which the graphics request was to be performed.
The major_code member is set to the graphics request initiated by the client
and can be either
.PN X_CopyArea
or
.PN X_CopyPlane .
If it is
.PN X_CopyArea ,
a call to
.PN XCopyArea
initiated the request.
If it is
.PN X_CopyPlane ,
a call to
.PN XCopyPlane
initiated the request.
These constants are defined in 
.hN X11/Xproto.h .
The minor_code member,
like the major_code member, 
indicates which graphics request was initiated by
the client. 
However, the minor_code member is not defined by the core
X protocol and will be zero in these cases, 
although it may be used by an extension.
.LP
The 
.PN XGraphicsExposeEvent
structure has these additional members: x, y, width, height, and count. 
The x and y members are set to the coordinates relative to the drawable's origin
and indicate the upper-left corner of the rectangle.
The width and height members are set to the size (extent) of the rectangle.
The count member is set to the number of
.PN GraphicsExpose
events to follow.
If count is zero, no more
.PN GraphicsExpose
events follow for this window.
However, if count is nonzero, at least that number of
.PN GraphicsExpose
events (and possibly more) are to follow for this window.
.NH 2
Window State Change Events 
.XS
\*(SN Window State Change Events
.XE
.LP
The following sections discuss:
.IP \(bu 5
.PN CirculateNotify
events
.IP \(bu 5
.PN ConfigureNotify
events
.IP \(bu 5
.PN CreateNotify 
events
.IP \(bu 5
.PN DestroyNotify
events
.IP \(bu 5
.PN GravityNotify
events
.IP \(bu 5
.PN MapNotify
events
.IP \(bu 5
.PN MappingNotify
events
.IP \(bu 5
.PN ReparentNotify 
events
.IP \(bu 5
.PN UnmapNotify
events
.IP \(bu 5
.PN VisibilityNotify
events
.\" .SH 3
.NH 3
CirculateNotify Events
.XS
\*(SN CirculateNotify Events
.XE
.LP
.IN "Events" "CirculateNotify"
.IN "CirculateNotify" "" "@DEF@"
The X server can report
.PN CirculateNotify
events to clients wanting information about when a window changes 
its position in the stack.
The X server generates this event type whenever a window is actually restacked 
as a result of a client application calling
.PN XCirculateSubwindows ,
.PN XCirculateSubwindowsUp ,
or
.PN XCirculateSubwindowsDown .
.LP
To receive 
.PN CirculateNotify
events, set the
.PN StructureNotifyMask
bit in the event-mask attribute of the window
or the
.PN SubstructureNotifyMask
bit in the event-mask attribute of the parent window
(in which case, circulating any child generates an event).
.LP
The structure for this event type contains:
.LP
.IN "XCirculateEvent" "" "@DEF@"
.sM
.Ds 0
.TA .5i 3i
.ta .5i 3i
typedef struct {
	int type;	/* CirculateNotify */
	unsigned long serial;	/* # of last request processed by server */
	Bool send_event;	/* true if this came from a SendEvent request */
	Display *display;	/* Display the event was read from */
	Window event;
	Window window;
	int place;	/* PlaceOnTop, PlaceOnBottom */
} XCirculateEvent;
.De
.LP
.eM
The event member is set either to the restacked window or to its parent,
depending on whether
.PN StructureNotify
or
.PN SubstructureNotify
was selected.
The window member is set to the window that was restacked.
The place member is set to the window's position after the restack occurs and
is either
.PN PlaceOnTop
or
.PN PlaceOnBottom .
If it is
.PN PlaceOnTop ,
the window is now on top of all siblings.
If it is
.PN PlaceOnBottom ,
the window is now below all siblings.
.NH 3
ConfigureNotify Events
.XS
\*(SN ConfigureNotify Events
.XE
.LP
.IN "Events" "ConfigureNotify"
.IN "ConfigureNotify" "" "@DEF@"
The X server can report
.PN ConfigureNotify
events to clients wanting information about actual changes to a window's
state, such as size, position, border, and stacking order.
The X server generates this event type whenever one of the following configure 
window requests made by a client application actually completes:
.IP \(bu 5
A window's size, position, border, and/or stacking order is reconfigured 
by calling
.PN XConfigureWindow .
.IP \(bu 5
The window's position in the stacking order is changed by calling
.PN XLowerWindow ,
.PN XRaiseWindow ,
or
.PN XRestackWindows .
.IP \(bu 5
A window is moved by calling
.PN XMoveWindow .
.IP \(bu 5
A window's size is changed by calling
.PN XResizeWindow .
.IP \(bu 5
A window's size and location is changed by calling
.PN XMoveResizeWindow .
.IP \(bu 5
A window is mapped and its position in the stacking order is changed
by calling
.PN XMapRaised .
.IP \(bu 5
A window's border width is changed by calling
.PN XSetWindowBorderWidth .
.LP
To receive 
.PN ConfigureNotify
events, set the
.PN StructureNotifyMask
bit in the event-mask attribute of the window or the
.PN SubstructureNotifyMask
bit in the event-mask attribute of the parent window
(in which case, configuring any child generates an event).
.LP
The structure for this event type contains:
.LP
.IN "XConfigureEvent" "" "@DEF@"
.sM
.Ds 0
.TA .5i 3i
.ta .5i 3i
typedef struct {
	int type;	/* ConfigureNotify */
	unsigned long serial;	/* # of last request processed by server */
	Bool send_event;	/* true if this came from a SendEvent request */
	Display *display;	/* Display the event was read from */
	Window event;
	Window window;
	int x, y;
	int width, height;
	int border_width;
	Window above;
	Bool override_redirect;
} XConfigureEvent;
.De
.LP
.eM
The event member is set either to the reconfigured window or to its parent,
depending on whether
.PN StructureNotify
or
.PN SubstructureNotify
was selected.
The window member is set to the window whose size, position, 
border, and/or stacking
order was changed.
.LP
The x and y members are set to the coordinates relative to the parent window's 
origin and indicate the position of the upper-left outside corner of the window.
The width and height members are set to the inside size of the window, 
not including
the border.
The border_width member is set to the width of the window's border, in pixels.
.LP
The above member is set to the sibling window and is used 
for stacking operations.
If the X server sets this member to
.PN None ,
the window whose state was changed is on the bottom of the stack
with respect to sibling windows.
However, if this member is set to a sibling window, 
the window whose state was changed is placed on top of this sibling window.
.LP
The override_redirect member is set to the override-redirect attribute of the
window.
Window manager clients normally should ignore this window if the 
override_redirect member
is
.PN True .
.NH 3
CreateNotify Events
.XS
\*(SN CreateNotify Events
.XE
.LP
.IN "Events" "CreateNotify"
.IN "CreateNotify" "" "@DEF@"
The X server can report
.PN CreateNotify
events to clients wanting information about creation of windows.
The X server generates this event whenever a client
application creates a window by calling
.PN XCreateWindow
or
.PN XCreateSimpleWindow .
.LP
To receive 
.PN CreateNotify
events, set the
.PN SubstructureNotifyMask
bit in the event-mask attribute of the window.
Creating any children then generates an event.
.LP
The structure for the event type contains:
.LP
.IN "XCreateWindowEvent" "" "@DEF@"
.sM
.Ds 0
.TA .5i 3i
.ta .5i 3i
typedef struct {
	int type;	/* CreateNotify */
	unsigned long serial;	/* # of last request processed by server */
	Bool send_event;	/* true if this came from a SendEvent request */
	Display *display;	/* Display the event was read from */
	Window parent;	/* parent of the window */
	Window window;	/* window id of window created */
	int x, y;	/* window location */
	int width, height;	/* size of window */
	int border_width;	/* border width */
	Bool override_redirect;	/* creation should be overridden */
} XCreateWindowEvent;
.De
.LP
.eM
The parent member is set to the created window's parent.
The window member specifies the created window.
The x and y members are set to the created window's coordinates relative 
to the parent window's origin and indicate the position of the upper-left 
outside corner of the created window.
The width and height members are set to the inside size of the created window 
(not including the border) and are always nonzero.
The border_width member is set to the width of the created window's border, in pixels.
The override_redirect member is set to the override-redirect attribute of the
window.
Window manager clients normally should ignore this window 
if the override_redirect member is
.PN True .
.NH 3
DestroyNotify Events
.XS
\*(SN DestroyNotify Events
.XE
.LP
.IN "Events" "DestroyNotify"
.IN "DestroyNotify" "" "@DEF@"
The X server can report
.PN DestroyNotify
events to clients wanting information about which windows are destroyed.
The X server generates this event whenever a client application destroys a 
window by calling
.PN XDestroyWindow
or
.PN XDestroySubwindows .
.LP
The ordering of the 
.PN DestroyNotify 
events is such that for any given window, 
.PN DestroyNotify
is generated on all inferiors of the window
before being generated on the window itself.  
The X protocol does not constrain the ordering among
siblings and across subhierarchies.
.LP
To receive 
.PN DestroyNotify
events, set the
.PN StructureNotifyMask
bit in the event-mask attribute of the window or the
.PN SubstructureNotifyMask
bit in the event-mask attribute of the parent window
(in which case, destroying any child generates an event).
.LP
The structure for this event type contains:
.LP
.IN "XDestroyWindowEvent" "" "@DEF@"
.sM
.Ds 0
.TA .5i 3i
.ta .5i 3i
typedef struct {
	int type;	/* DestroyNotify */
	unsigned long serial;	/* # of last request processed by server */
	Bool send_event;	/* true if this came from a SendEvent request */
	Display *display;	/* Display the event was read from */
	Window event;
	Window window;
} XDestroyWindowEvent;
.De
.LP
.eM
The event member is set either to the destroyed window or to its parent,
depending on whether
.PN StructureNotify
or 
.PN SubstructureNotify
was selected.
The window member is set to the window that is destroyed.
.NH 3
GravityNotify Events
.XS
\*(SN GravityNotify Events
.XE
.LP
.IN "Events" "GravityNotify"
.IN "GravityNotify" "" "@DEF@"
The X server can report
.PN GravityNotify
events to clients wanting information about when a window is moved because of a
change in the size of its parent.
The X server generates this event whenever a client
application actually moves a child window as a result of resizing its parent by calling
.PN XConfigureWindow ,
.PN XMoveResizeWindow ,
or
.PN XResizeWindow . 
.LP
To receive 
.PN GravityNotify
events, set the
.PN StructureNotifyMask
bit in the event-mask attribute of the window or the
.PN SubstructureNotifyMask
bit in the event-mask attribute of the parent window
(in which case, any child that is moved because its parent has been resized
generates an event).
.LP
The structure for this event type contains:
.LP
.IN "XGravityEvent" "" "@DEF@"
.sM
.Ds 0
.TA .5i 3i
.ta .5i 3i
typedef struct {
	int type;	/* GravityNotify */
	unsigned long serial;	/* # of last request processed by server */
	Bool send_event;	/* true if this came from a SendEvent request */
	Display *display;	/* Display the event was read from */
	Window event;
	Window window;
	int x, y;
} XGravityEvent;
.De
.LP
.eM
The event member is set either to the window that was moved or to its parent,
depending on whether
.PN StructureNotify
or
.PN SubstructureNotify
was selected.
The window member is set to the child window that was moved.
The x and y members are set to the coordinates relative to the 
new parent window's origin
and indicate the position of the upper-left outside corner of the 
window.
.NH 3
MapNotify Events
.XS
\*(SN MapNotify Events
.XE
.LP
.IN "Events" "MapNotify"
.IN "MapNotify" "" "@DEF@"
The X server can report
.PN MapNotify
events to clients wanting information about which windows are mapped.
The X server generates this event type whenever a client application changes the
window's state from unmapped to mapped by calling
.PN XMapWindow ,
.PN XMapRaised ,
.PN XMapSubwindows ,
.PN XReparentWindow ,
or as a result of save-set processing.
.LP
To receive 
.PN MapNotify
events, set the
.PN StructureNotifyMask
bit in the event-mask attribute of the window or the
.PN SubstructureNotifyMask
bit in the event-mask attribute of the parent window
(in which case, mapping any child generates an event).
.LP
The structure for this event type contains:
.LP
.IN "XMapEvent" "" "@DEF@"
.sM
.Ds 0
.TA .5i 3i
.ta .5i 3i
typedef struct {
	int type;	/* MapNotify */
	unsigned long serial;	/* # of last request processed by server */
	Bool send_event;	/* true if this came from a SendEvent request */
	Display *display;	/* Display the event was read from */
	Window event;
	Window window;
	Bool override_redirect;	/* boolean, is override set... */
} XMapEvent;
.De
.LP
.eM
The event member is set either to the window that was mapped or to its parent,
depending on whether
.PN StructureNotify
or
.PN SubstructureNotify
was selected.
The window member is set to the window that was mapped.
The override_redirect member is set to the override-redirect attribute
of the window.
Window manager clients normally should ignore this window 
if the override-redirect attribute is
.PN True ,
because these events usually are generated from pop-ups,
which override structure control.
.NH 3
MappingNotify Events
.XS
\*(SN MappingNotify Events
.XE
.LP
.IN "Events" "MappingNotify"
.IN "MappingNotify" "" "@DEF@"
The X server reports
.PN MappingNotify
events to all clients.
There is no mechanism to express disinterest in this event.
The X server generates this event type whenever a client application 
successfully calls:
.IP \(bu 5
.PN XSetModifierMapping
to indicate which KeyCodes are to be used as modifiers
.IP \(bu 5
.PN XChangeKeyboardMapping
to change the keyboard mapping
.IP \(bu 5
.PN XSetPointerMapping
to set the pointer mapping
.LP
The structure for this event type contains:
.LP
.IN "XMappingEvent" "" "@DEF@"
.sM
.Ds 0
.TA .5i 3i
.ta .5i 3i
typedef struct {
	int type;	/* MappingNotify */
	unsigned long serial;	/* # of last request processed by server */
	Bool send_event;	/* true if this came from a SendEvent request */
	Display *display;	/* Display the event was read from */
	Window window;	/* unused */
	int request;	/* one of MappingModifier, MappingKeyboard,
		   MappingPointer */
	int first_keycode;	/* first keycode */
	int count;	/* defines range of change w. first_keycode*/
} XMappingEvent;
.De
.LP
.eM
The request member is set to indicate the kind of mapping change that occurred
and can be
.PN MappingModifier ,
.PN MappingKeyboard ,
or
.PN MappingPointer .
If it is
.PN MappingModifier ,
the modifier mapping was changed.
If it is
.PN MappingKeyboard ,
the keyboard mapping was changed.
If it is
.PN MappingPointer ,
the pointer button mapping was changed. 
The first_keycode and count members are set only 
if the request member was set to
.PN MappingKeyboard .
The number in first_keycode represents the first number in the range 
of the altered mapping, 
and count represents the number of keycodes altered.
.LP
To update the client application's knowledge of the keyboard,
you should call
.PN XRefreshKeyboardMapping . 
.NH 3
ReparentNotify Events
.XS
\*(SN ReparentNotify Events
.XE
.LP
.IN "Events" "ReparentNotify"
.IN "ReparentNotify" "" "@DEF@"
The X server can report
.PN ReparentNotify
events to clients wanting information about changing a window's parent.
The X server generates this event whenever a client
application calls
.PN XReparentWindow 
and the window is actually reparented.
.LP
To receive 
.PN ReparentNotify
events, set the
.PN StructureNotifyMask
bit in the event-mask attribute of the window or the
.PN SubstructureNotifyMask
bit in the event-mask attribute of either the old or the new parent window
(in which case, reparenting any child generates an event).
.LP
The structure for this event type contains:
.LP
.IN "XReparentEvent" "" "@DEF@"
.sM
.Ds 0
.TA .5i 3i
.ta .5i 3i
typedef struct {
	int type;	/* ReparentNotify */
	unsigned long serial;	/* # of last request processed by server */
	Bool send_event;	/* true if this came from a SendEvent request */
	Display *display;	/* Display the event was read from */
	Window event;
	Window window;
	Window parent;
	int x, y;
	Bool override_redirect;
} XReparentEvent;
.De
.LP
.eM
The event member is set either to the reparented window
or to the old or the new parent, depending on whether
.PN StructureNotify
or
.PN SubstructureNotify
was selected. 
The window member is set to the window that was reparented.
The parent member is set to the new parent window.
The x and y members are set to the reparented window's coordinates relative 
to the new parent window's
origin and define the upper-left outer corner of the reparented window.
The override_redirect member is set to the override-redirect attribute of the
window specified by the window member.
Window manager clients normally should ignore this window 
if the override_redirect member is
.PN True .
.NH 3
UnmapNotify Events
.XS
\*(SN UnmapNotify Events
.XE
.LP
.IN "Events" "UnmapNotify"
.IN "UnmapNotify" "" "@DEF@"
The X server can report
.PN UnmapNotify
events to clients wanting information about which windows are unmapped.
The X server generates this event type whenever a client application changes the
window's state from mapped to unmapped.
.LP
To receive 
.PN UnmapNotify
events, set the
.PN StructureNotifyMask
bit in the event-mask attribute of the window or the
.PN SubstructureNotifyMask
bit in the event-mask attribute of the parent window
(in which case, unmapping any child window generates an event).
.LP
The structure for this event type contains:
.LP
.IN "XUnmapEvent" "" "@DEF@"
.sM
.Ds 0
.TA .5i 3i
.ta .5i 3i
typedef struct {
	int type;	/* UnmapNotify */
	unsigned long serial;	/* # of last request processed by server */
	Bool send_event;	/* true if this came from a SendEvent request */
	Display *display;	/* Display the event was read from */
	Window event;
	Window window;
	Bool from_configure;
} XUnmapEvent;
.De
.LP
.eM
The event member is set either to the unmapped window or to its parent,
depending on whether
.PN StructureNotify
or
.PN SubstructureNotify
was selected.
This is the window used by the X server to report the event.
The window member is set to the window that was unmapped.
The from_configure member is set to
.PN True 
if the event was generated as a result of a resizing of the window's parent when
the window itself had a win_gravity of
.PN UnmapGravity .
.NH 3
VisibilityNotify Events
.XS
\*(SN VisibilityNotify Events
.XE
.LP
.IN "Events" "VisibilityNotify"
.IN "VisibilityNotify" "" "@DEF@"
The X server can report
.PN VisibilityNotify
events to clients wanting any change in the visibility of the specified window.
A region of a window is visible if someone looking at the screen can
actually see it.
The X server generates this event whenever the visibility changes state. 
However, this event is never generated for windows whose class is
.PN InputOnly .
.LP
All 
.PN VisibilityNotify
events caused by a hierarchy change are generated
after any hierarchy event
.Pn ( UnmapNotify , 
.PN MapNotify , 
.PN ConfigureNotify ,
.PN GravityNotify ,
.PN CirculateNotify )
caused by that change.  Any
.PN VisibilityNotify
event on a given window is generated before any
.PN Expose 
events on that window, but it is not required that all
.PN VisibilityNotify
events on all windows be generated before all 
.PN Expose
events on all windows.  
The X protocol does not constrain the ordering of 
.PN VisibilityNotify
events with
respect to 
.PN FocusOut , 
.PN EnterNotify ,
and 
.PN LeaveNotify
events.
.LP
To receive 
.PN VisibilityNotify
events, set the
.PN VisibilityChangeMask
bit in the event-mask attribute of the window. 
.LP
The structure for this event type contains:
.LP
.IN "XVisibilityEvent" "" "@DEF@"
.sM
.Ds 0
.TA .5i 3i
.ta .5i 3i
typedef struct {
	int type;	/* VisibilityNotify */
	unsigned long serial;	/* # of last request processed by server */
	Bool send_event;	/* true if this came from a SendEvent request */
	Display *display;	/* Display the event was read from */
	Window window;
	int state;
} XVisibilityEvent;
.De
.LP
.eM
The window member is set to the window whose visibility state changes.
The state member is set to the state of the window's visibility and can be
.PN VisibilityUnobscured ,
.PN VisibilityPartiallyObscured ,
or
.PN VisibilityFullyObscured .
The X server ignores all of a window's subwindows
when determining the visibility state of the window and processes 
.PN VisibilityNotify
events according to the following:
.IP \(bu 5
When the window changes state from partially obscured, fully obscured,
or not viewable to viewable and completely unobscured,
the X server generates the event with the state member of the
.PN XVisibilityEvent
structure set to
.PN VisibilityUnobscured .
.IP \(bu 5
When the window changes state from viewable and completely unobscured or 
not viewable to viewable and partially obscured,
the X server generates the event with the state member of the
.PN XVisibilityEvent
structure set to
.PN VisibilityPartiallyObscured .
.IP \(bu 5
When the window changes state from viewable and completely unobscured, 
viewable and partially obscured, or not viewable to viewable and 
fully obscured,
the X server generates the event with the state member of the
.PN XVisibilityEvent
structure set to
.PN VisibilityFullyObscured .
.NH 2
Structure Control Events
.XS
\*(SN Structure Control Events
.XE
.LP
This section discusses:
.IP \(bu 5
.PN CirculateRequest
events
.IP \(bu 5
.PN ConfigureRequest
events
.IP \(bu 5
.PN MapRequest 
events
.IP \(bu 5
.PN ResizeRequest 
events
.NH 3 
CirculateRequest Events
.XS
\*(SN CirculateRequest Events
.XE
.LP
.IN "Events" "CirculateRequest"
.IN "CirculateRequest" "" "@DEF@"
The X server can report
.PN CirculateRequest
events to clients wanting information about 
when another client initiates a circulate window request 
on a specified window.
The X server generates this event type whenever a client initiates a circulate
window request on a window and a subwindow actually needs to be restacked. 
The client initiates a circulate window request on the window by calling
.PN XCirculateSubwindows ,
.PN XCirculateSubwindowsUp ,
or
.PN XCirculateSubwindowsDown .
.LP
To receive
.PN CirculateRequest
events, set the
.PN SubstructureRedirectMask
in the event-mask attribute of the window. 
Then, in the future,
the circulate window request for the specified window is not executed,
and thus, any subwindow's position in the stack is not changed.
For example, suppose a client application calls
.PN XCirculateSubwindowsUp
to raise a subwindow to the top of the stack.
If you had selected
.PN SubstructureRedirectMask
on the window, the X server reports to you a
.PN CirculateRequest
event and does not raise the subwindow to the top of the stack.
.LP
The structure for this event type contains:
.LP
.IN "XCirculateRequestEvent" "" "@DEF@"
.sM
.Ds 0
.TA .5i 3i
.ta .5i 3i
typedef struct {
	int type;	/* CirculateRequest */
	unsigned long serial;	/* # of last request processed by server */
	Bool send_event;	/* true if this came from a SendEvent request */
	Display *display;	/* Display the event was read from */
	Window parent;
	Window window;
	int place;	/* PlaceOnTop, PlaceOnBottom */
} XCirculateRequestEvent;
.De
.LP
.eM
The parent member is set to the parent window.
The window member is set to the subwindow to be restacked.
The place member is set to what the new position in the stacking order should be
and is either
.PN PlaceOnTop
or
.PN PlaceOnBottom .
If it is
.PN PlaceOnTop ,
the subwindow should be on top of all siblings.
If it is
.PN PlaceOnBottom ,
the subwindow should be below all siblings.
.NH 3
ConfigureRequest Events
.XS
\*(SN ConfigureRequest Events
.XE
.LP
.IN "Events" "ConfigureRequest"
.IN "ConfigureRequest" "" "@DEF@"
The X server can report
.PN ConfigureRequest
events to clients wanting information about when a different client initiates 
a configure window request on any child of a specified window. 
The configure window request attempts to 
reconfigure a window's size, position, border, and stacking order.
The X server generates this event whenever a different client initiates
a configure window request on a window by calling
.PN XConfigureWindow ,
.PN XLowerWindow ,
.PN XRaiseWindow ,
.PN XMapRaised ,
.PN XMoveResizeWindow ,
.PN XMoveWindow ,
.PN XResizeWindow ,
.PN XRestackWindows ,
or
.PN XSetWindowBorderWidth .
.LP
To receive
.PN ConfigureRequest
events, set the
.PN SubstructureRedirectMask
bit in the event-mask attribute of the window. 
.PN ConfigureRequest
events are generated when a
.PN ConfigureWindow
protocol request is issued on a child window by another client.
For example, suppose a client application calls
.PN XLowerWindow
to lower a window.
If you had selected
.PN SubstructureRedirectMask 
on the parent window and if the override-redirect attribute 
of the window is set to
.PN False ,
the X server reports a
.PN ConfigureRequest
event to you and does not lower the specified window.
.LP
The structure for this event type contains:
.LP
.IN "XConfigureRequestEvent" "" "@DEF@"
.sM
.Ds 0
.TA .5i 3i
.ta .5i 3i
typedef struct {
	int type;	/* ConfigureRequest */
	unsigned long serial;	/* # of last request processed by server */
	Bool send_event;	/* true if this came from a SendEvent request */
	Display *display;	/* Display the event was read from */
	Window parent;
	Window window;
	int x, y;
	int width, height;
	int border_width;
	Window above;
	int detail;	/* Above, Below, TopIf, BottomIf, Opposite */
	unsigned long value_mask;
} XConfigureRequestEvent;
.De
.LP
.eM
The parent member is set to the parent window.
The window member is set to the window whose size, position, border width, 
and/or stacking order is to be reconfigured.
The value_mask member indicates which components were specified in the
.PN ConfigureWindow 
protocol request.
The corresponding values are reported as given in the request.
The remaining values are filled in from the current geometry of the window,
except in the case of above (sibling) and detail (stack-mode),
which are reported as
.PN None
and
.PN Above ,
respectively, if they are not given in the request.
.NH 3
MapRequest Events
.XS
\*(SN MapRequest Events
.XE
.LP
.IN "Events" "MapRequest"
.IN "MapRequest" "" "@DEF@"
The X server can report
.PN MapRequest
events to clients wanting information about a different client's desire 
to map windows.
A window is considered mapped when a map window request completes.
The X server generates this event whenever a different client initiates 
a map window request on an unmapped window whose override_redirect member 
is set to
.PN False .
Clients initiate map window requests by calling
.PN XMapWindow ,
.PN XMapRaised ,
or
.PN XMapSubwindows .
.LP
To receive
.PN MapRequest
events, set the
.PN SubstructureRedirectMask
bit in the event-mask attribute of the window. 
This means another client's attempts to map a child window by calling one of
the map window request functions is intercepted, and you are sent a 
.PN MapRequest
instead.
For example, suppose a client application calls
.PN XMapWindow
to map a window.
If you (usually a window manager) had selected
.PN SubstructureRedirectMask 
on the parent window and if the override-redirect attribute 
of the window is set to
.PN False ,
the X server reports a
.PN MapRequest
event to you 
and does not map the specified window.
Thus, this event gives your window manager client the ability 
to control the placement of subwindows.
.LP
The structure for this event type contains:
.LP
.IN "XMapRequestEvent" "" "@DEF@"
.sM
.Ds 0
.TA .5i 3i
.ta .5i 3i
typedef struct {
	int type;	/* MapRequest */
	unsigned long serial;	/* # of last request processed by server */
	Bool send_event;	/* true if this came from a SendEvent request */
	Display *display;	/* Display the event was read from */
	Window parent;
	Window window;
} XMapRequestEvent;
.De
.LP
.eM
The parent member is set to the parent window.
The window member is set to the window to be mapped.
.NH 3
ResizeRequest Events
.XS
\*(SN ResizeRequest Events
.XE
.LP
.IN "Events" "ResizeRequest"
.IN "ResizeRequest" "" "@DEF@"
The X server can report
.PN ResizeRequest
events to clients wanting information about another client's attempts to change the
size of a window.
The X server generates this event whenever some other client attempts to change
the size of the specified window by calling
.PN XConfigureWindow ,
.PN XResizeWindow ,
or
.PN XMoveResizeWindow .
.LP
To receive
.PN ResizeRequest
events, set the
.PN ResizeRedirect
bit in the event-mask attribute of the window. 
Any attempts to change the size by other clients are then redirected.
.LP
The structure for this event type contains:
.LP
.IN "XResizeRequestEvent" "" "@DEF@"
.sM
.Ds 0
.TA .5i 3i
.ta .5i 3i
typedef struct {
	int type;	/* ResizeRequest */
	unsigned long serial;	/* # of last request processed by server */
	Bool send_event;	/* true if this came from a SendEvent request */
	Display *display;	/* Display the event was read from */
	Window window;
	int width, height;
} XResizeRequestEvent;
.De
.LP
.eM
The window member is set to the window whose size another 
client attempted to change.
The width and height members are set to the inside size of the window, 
excluding the border.
.NH 2
Colormap State Change Events
.XS
\*(SN Colormap State Change Events
.XE
.LP
.IN "Events" "ColormapNotify"
.IN "ColormapNotify" "" "@DEF@"
The X server can report
.PN ColormapNotify
events to clients wanting information about when the colormap changes 
and when a colormap is installed or uninstalled. 
The X server generates this event type whenever a client application:
.IP \(bu 5
Changes the colormap member of the
.PN XSetWindowAttributes
structure by 
calling
.PN XChangeWindowAttributes ,
.PN XFreeColormap ,
or
.PN XSetWindowColormap 
.IP \(bu 5
Installs or uninstalls the colormap by calling
.PN XInstallColormap
or
.PN XUninstallColormap 
.LP
To receive 
.PN ColormapNotify 
events, set the
.PN ColormapChangeMask
bit in the event-mask attribute of the window. 
.LP
The structure for this event type contains:
.LP
.IN "XColormapEvent" "" "@DEF@"
.sM
.Ds 0
.TA .5i 3i
.ta .5i 3i
typedef struct {
	int type;	/* ColormapNotify */
	unsigned long serial;	/* # of last request processed by server */
	Bool send_event;	/* true if this came from a SendEvent request */
	Display *display;	/* Display the event was read from */
	Window window;
	Colormap colormap;	/* colormap or None */
	Bool new;
	int state;	/* ColormapInstalled, ColormapUninstalled */
} XColormapEvent;
.De
.LP
.eM
The window member is set to the window whose associated 
colormap is changed, installed, or uninstalled.
For a colormap that is changed, installed, or uninstalled,
the colormap member is set to the colormap associated with the window. 
For a colormap that is changed by a call to
.PN XFreeColormap ,
the colormap member is set to
.PN None .
The new member is set to indicate whether the colormap 
for the specified window was changed or installed or uninstalled
and can be 
.PN True
or
.PN False .
If it is
.PN True ,
the colormap was changed.
If it is
.PN False ,
the colormap was installed or uninstalled.
The state member is always set to indicate whether the colormap is installed or
uninstalled and can be 
.PN ColormapInstalled
or
.PN ColormapUninstalled .
.NH 2
Client Communication Events
.XS
\*(SN Client Communication Events
.XE
.LP
This section discusses:
.IP \(bu 5
.PN ClientMessage 
events
.IP \(bu 5
.PN PropertyNotify
events
.IP \(bu 5
.PN SelectionClear
events
.IP \(bu 5
.PN SelectionNotify
events
.IP \(bu 5
.PN SelectionRequest
events
.NH 3
ClientMessage Events
.XS
\*(SN ClientMessage Events
.XE
.LP
.IN "Events" "ClientMessage"
.IN "ClientMessage" "" "@DEF@"
The X server generates
.PN ClientMessage
events only when a client calls the function
.PN XSendEvent .
.LP
The structure for this event type contains:
.LP
.IN "XClientMessageEvent" "" "@DEF@"
.sM
.Ds 0
.TA .5i 1i 3i
.ta .5i 1i 3i
typedef struct {
	int type;	/* ClientMessage */
	unsigned long serial;		/* # of last request processed by server */
	Bool send_event;		/* true if this came from a SendEvent request */
	Display *display;		/* Display the event was read from */
	Window window;
	Atom message_type;
	int format;
	union {
		char b[20];
		short s[10];
		long l[5];
	        } data;
} XClientMessageEvent;
.De
.LP
.eM
The message_type member is set to an atom that indicates how the data 
should be interpreted by the receiving client.
The format member is set to 8, 16, or 32 and specifies whether the data
should be viewed as a list of bytes, shorts, or longs.
The data member is a union that contains the members b, s, and l.
The b, s, and l members represent data of twenty 8-bit values, 
ten 16-bit values, and five 32-bit values.
Particular message types might not make use of all these values.
The X server places no interpretation on the values in the window,
message_type, or data members.
.NH 3
PropertyNotify Events
.XS
\*(SN PropertyNotify Events
.XE
.LP
.IN "Events" "PropertyNotify"
.IN "PropertyNotify" "" "@DEF@"
The X server can report
.PN PropertyNotify
events to clients wanting information about property changes 
for a specified window.
.LP
To receive
.PN PropertyNotify
events, set the
.PN PropertyChangeMask
bit in the event-mask attribute of the window. 
.LP
The structure for this event type contains:
.LP
.IN "XPropertyEvent" "" "@DEF@"
.sM
.Ds 0
.TA .5i 3i
.ta .5i 3i
typedef struct {
	int type;	/* PropertyNotify */
	unsigned long serial;	/* # of last request processed by server */
	Bool send_event;	/* true if this came from a SendEvent request */
	Display *display;	/* Display the event was read from */
	Window window;
	Atom atom;
	Time time;
	int state;	/* PropertyNewValue or PropertyDelete */
} XPropertyEvent;
.De
.LP
.eM
The window member is set to the window whose associated 
property was changed.
The atom member is set to the property's atom and indicates which
property was changed or desired.
The time member is set to the server time when the property was changed.
The state member is set to indicate whether the property was changed 
to a new value or deleted and can be
.PN PropertyNewValue
or
.PN PropertyDelete .
The state member is set to
.PN PropertyNewValue
when a property of the window is changed using
.PN XChangeProperty
or
.PN XRotateWindowProperties
(even when adding zero-length data using
.PN XChangeProperty )
and when replacing all or part of a property with identical data using
.PN XChangeProperty
or 
.PN XRotateWindowProperties .
The state member is set to
.PN PropertyDelete
when a property of the window is deleted using
.PN XDeleteProperty
or, if the delete argument is 
.PN True ,
.PN XGetWindowProperty .
.NH 3
SelectionClear Events
.XS
\*(SN SelectionClear Events
.XE
.LP
.IN "Events" "SelectionClear" 
.IN "SelectionClear" "" "@DEF@"
The X server reports
.PN SelectionClear
events to the client losing ownership of a selection.
The X server generates this event type when another client
asserts ownership of the selection by calling
.PN XSetSelectionOwner .
.LP
The structure for this event type contains:
.LP
.IN "XSelectionClearEvent" "" "@DEF@"
.sM
.Ds 0
.TA .5i 3i
.ta .5i 3i
typedef struct {
	int type;	/* SelectionClear */
	unsigned long serial;	/* # of last request processed by server */
	Bool send_event;	/* true if this came from a SendEvent request */
	Display *display;	/* Display the event was read from */
	Window window;
	Atom selection;
	Time time;
} XSelectionClearEvent;
.De
.LP
.eM
The selection member is set to the selection atom.
The time member is set to the last change time recorded for the 
selection.
The window member is the window that was specified by the current owner
(the owner losing the selection) in its
.PN XSetSelectionOwner
call.
.NH 3
SelectionRequest Events
.XS
\*(SN SelectionRequest Events
.XE
.LP
.IN "Events" "SelectionRequest"
.IN "SelectionRequest" "" "@DEF@"
The X server reports
.PN SelectionRequest
events to the owner of a selection.
The X server generates this event whenever a client 
requests a selection conversion by calling 
.PN XConvertSelection 
for the owned selection.
.LP
The structure for this event type contains:
.LP
.IN "XSelectionRequestEvent" "" "@DEF@"
.sM
.Ds 0
.TA .5i 3i
.ta .5i 3i
typedef struct {
	int type;	/* SelectionRequest */
	unsigned long serial;	/* # of last request processed by server */
	Bool send_event;	/* true if this came from a SendEvent request */
	Display *display;	/* Display the event was read from */
	Window owner;
	Window requestor;
	Atom selection;
	Atom target;
	Atom property;
	Time time;
} XSelectionRequestEvent;
.De
.LP
.eM
The owner member is set to the window
that was specified by the current owner in its
.PN XSetSelectionOwner
call.
The requestor member is set to the window requesting the selection.
The selection member is set to the atom that names the selection.
For example, PRIMARY is used to indicate the primary selection.
The target member is set to the atom that indicates the type
the selection is desired in.
The property member can be a property name or 
.PN None .
The time member is set to the timestamp or 
.PN CurrentTime 
value from the
.PN ConvertSelection
request.
.LP
The owner should convert the selection based on the specified target type
and send a
.PN SelectionNotify
event back to the requestor.
A complete specification for using selections is given in the X Consortium
standard \fIInter-Client Communication Conventions Manual\fP.
.NH 3
SelectionNotify Events
.XS
\*(SN SelectionNotify Events
.XE
.LP
.IN "Events" "SelectionNotify"
.IN "SelectionNotify" "" "@DEF@"
This event is generated by the X server in response to a
.PN ConvertSelection 
protocol request when there is no owner for the selection.
When there is an owner, it should be generated by the owner
of the selection by using
.PN XSendEvent .
The owner of a selection should send this event to a requestor when a selection
has been converted and stored as a property
or when a selection conversion could
not be performed (which is indicated by setting the property member to
.PN None ).
.LP
If
.PN None
is specified as the property in the 
.PN ConvertSelection
protocol request, the owner should choose a property name,
store the result as that property on the requestor window,
and then send a 
.PN SelectionNotify
giving that actual property name.
.LP
The structure for this event type contains:
.LP
.IN "XSelectionEvent" "" "@DEF@"
.sM
.Ds 0
.TA .5i 3i
.ta .5i 3i
typedef struct {
	int type;	/* SelectionNotify */
	unsigned long serial;	/* # of last request processed by server */
	Bool send_event;	/* true if this came from a SendEvent request */
	Display *display;	/* Display the event was read from */
	Window requestor;
	Atom selection;
	Atom target;
	Atom property;	/* atom or None */
	Time time;
} XSelectionEvent;
.De
.LP
.eM
The requestor member is set to the window associated with
the requestor of the selection.
The selection member is set to the atom that indicates the selection.
For example, PRIMARY is used for the primary selection.
The target member is set to the atom that indicates the converted type.
For example, PIXMAP is used for a pixmap.
The property member is set to the atom that indicates which
property the result was stored on.
If the conversion failed, 
the property member is set to
.PN None .
The time member is set to the time the conversion took place and
can be a timestamp or
.PN CurrentTime .
.bp
