Resources | Resources |



Pointer event queue

This section describes how the pointer event queue is implemented.

The Brew MP event queue

The event queue limits the number of events so that the queue does not use too much memory. The queue can hold a maximum of 50 of each type of event: pointer events, joystick events, and jogdial events.

Pointer events

Whenever Brew MP is initialized, it sets an index n, which points to the next event to be removed from the queue, to 2. The event queue accepts pointer events without restriction until the queue holds the maximum number of pointer events. Then, Brew MP starts dropping older, "stale" events from the queue, and accepting new, incoming events into the queue, in the following manner:

  1. When an event arrives and the event queue is full, Brew MP removes the nth event from the queue.
  2. Brew MP adds the new event to the end of the queue.
  3. Brew MP marks the next event to be removed from the queue as (n + 1).

Whenever an event at the front of the queue is delivered to an application, Brew MP resets n to 2.

This algorithm effectively removes an orderly sampling of older events from the queue and maintains the overall flow of user input, while managing the limited size of the queue.