Name
MotionNotify — (generated event).
When Generated
A MotionNotify event reports that the user moved the
pointer or that a program warped the pointer to a new position
within a single window.
Select With
This event is selected with ButtonMotionMask,
Button1MotionMask, Button2MotionMask,
Button3MotionMask, Button4MotionMask,
Button5MotionMask, PointerMotionHintMask,
and PointerMotionMask. These masks determine the
specific conditions under which the event is generated.
See 8.3.3.3 of Volume One, for a description of selecting
button events.
XEvent Structure Name
typedef union _XEvent {
...
XMotionEvent xmotion;
...
} XEvent;
|
Event Structure
typedef struct {
int type; /* of event */
unsigned long serial; /* # of last request processed by server */
Bool send_event; /* True if this came from 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 coordinates relative to receiving
window */
int x_root, y_root; /* coordinates relative to root */
unsigned int state; /* button and modifier key mask */
char is_hint; /* is this a motion hint */
Bool same_screen; /* same screen flag */
} XMotionEvent;
typedef XMotionEvent XPointerMovedEvent;
|
Event Structure Members
subwindow | | If the source window is the child of the receiving window, then
the subwindow member is set to the ID of that child.
|
time | | The server time when the button event occurred, in milliseconds.
Time is declared as unsigned long, so it
wraps around when it reaches the maximum value of a 32-bit number
(every 49.7 days).
|
x, y | | If the receiving window is on the same screen as the root window
specified by root, then x and y are the
pointer coordinates relative to the receiving window's origin.
Otherwise, x and y are zero.
When active button grabs and pointer grabs are in effect
(see 9.4), the coordinates relative
to the receiving window may not be within the window (they may be
negative or greater than window height or width).
|
x_root, y_root | | The pointer coordinates relative to the root window which is an
ancestor of the event window. If the pointer was on a different
screen, these are zero.
|
state | | The state of all the buttons and modifier keys just before the
event, represented by a mask of the button and modifier key
symbols: Button1Mask, Button2Mask, Button3Mask,
Button4Mask, Button5Mask, ControlMask,
LockMask, Mod1Mask, Mod2Mask, Mod3Mask,
Mod4Mask, Mod5Mask, and ShiftMask.
|
is_hint | | Either the constant NotifyNormal or NotifyHint.
NotifyHint indicates that the PointerMotionHintMask
was selected. In this case, just one event is sent when the mouse moves,
and the current position can be found by calling XQueryPointer
or by examining the motion history buffer with XGetMotionEvents,
if a motion history buffer is available on the server.
NotifyNormal indicates that the event is real, but it may not be
up to date, since there may be many more later motion events on the queue.
|
same_screen | | Indicates whether the pointer is currently on the same screen as
this window. This is always True unless the pointer was
actively grabbed before the automatic grab could take place.
|
Notes
If the processing you have to do for every motion event is fast,
you can probably handle all of them without requiring motion hints.
However, if you have extensive processing to do for each one, you
might be better off using the hints and calling XQueryPointer
or using the history buffer if it exists. XQueryPointer is
a round-trip request, so it can be slow.
EnterNotify and LeaveNotify events are generated
instead of MotionEvents if the pointer starts and stops
in different windows.