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;
The type member is set to the event type constant name that uniquely identifies
it.
For example, when the X server reports a
GraphicsExpose
event to a client application, it sends an
XGraphicsExposeEvent
structure with the type member set to
GraphicsExpose.
The display member is set to a pointer to the display the event was read on.
The send_event member is set to
True
if the event came from a
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.
type メンバーは、一意にそれを識別するイベント型(type)定数名が設定される。
例えば、Xサーバーが
GraphicsExposeイベントをクライアント・アプリケーションへ通知するときに、それは、
GraphicsExposeを type メンバーに設定された
XGraphicsExposeEvent構造体を送る。
display メンバーは、イベントが読まれたディスプレイへのポインター(pointer)に設定される。
send_event メンバーは、イベントが
SendEventプロトコルリクエストによって
送られた物なら
Trueに設定される。
serial メンバはプロトコルで通知されたシリアル番号を基に設定される。
ただし、最少桁の16ビットから完全な32ビットの値に拡張される。
window メンバーは、ツールキット・ディスパッチャーにとって最も役に立つウインドウが設定される。
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 "Event Queue Management").
X サーバーは、入力ストリームでいつでもイベントを送ることができる。
Xlib はイベント・キューで応答(reply)を待っている間に受け取ったどんなイベントも後で使うために保存する。
Xlibはまた、あなたがイベント・キューのイベントを調べることを可能にする機能を提供する(セクション11.3を見ろ)。
In addition to the individual structures declared for each event type, the
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
XEvent
union.
それぞれのイベント型(type)のために宣言されている個々の構造体に加えて、
XEvent構造体はそれぞれのイベント型(type)のために宣言されている個々の構造体の共用体である。
型(type)に応じて、あなたは、
XEvent共用体を使ってそれぞれのイベントのメンバーにアクセスすべきだ。
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;
An
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
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.
XEvent構造体の最初のエントリーは、必ず type メンバーだ(イベント型(type)が設定される)。
第2のメンバーは、必ず、イベントを発生させたプロトコル要求のシリアル番号だ。
第3のメンバーは、必ず、send_event だ(異なるクライアントによって送られたイベントかを示す
Bool値だ)。
第4のメンバーは、いつも display だ(そのイベントが読まれたディスプレイを示す)。
keymap イベントを除いて、第5のメンバーは、いつも window だ(ツールキット・ディスパッチャーにとって役に立つと注意ぶかく選ばれた)。
toolkits を壊すことを避けるために、これらの最初の 5 つのエントリーの順序は、変えない。
さらにほとんどのイベントは、time メンバーを含む(そこでイベントが起こった時間である)。
加えて、汎用のイベントへのポインターは構造体の中の他のいずれかの情報にアクセスする前にキャストしなくてはならない。