9.2 The Pointer

The pointer generates events as it moves, as it crosses window borders, and as its buttons are pressed. It provides position information that can define a path in the two-dimensional space of the screen, tell you which window the pointer is in and allow the user to “point and click,” generating input without using the keyboard. In fact, the pointer is the most unique feature of a window system.

This section describes how to track the pointer and how to handle the pointer buttons. Border crossing events are discussed in 9.3 Border Crossing and Keyboard Focus Change Events, because they must be handled in concert with keyboard focus change events.

9.2.1 Tracking Pointer Motion

There are three ways of handling pointer motion events:

  • Getting all motion events. The program simply receives and processes every motion event. This option is suitable for applications that require all movements to be reported, no matter how small. Since many motion events are generated and reporting the processing of the events may lag behind the pointer, this approach is not suitable for applications that require the most current information about pointer position.

  • Getting hints and querying pointer position. This method greatly reduces the number of motion events sent but requires that XQueryPointer() be called to get the current pointer position. This option is suitable for applications that require only the final position of the mouse after each movement.

  • Reading the motion history buffer. After ...

Get XLIB Programming Manual, Rel. 5, Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.