check_mask_event(+EventMask, -Type, ?XEvent)
     check_mask_event(+Displayable, +EventMask, -Type, ?XEvent)

Are like mask_event/[3,4], but fail if there is no matching event in the queue, and do not block waiting for one. The output buffer is flushed only on failure.

The user can pass an existing XEvent X11 structure, which is then destructively filled with the received event's contents, or an unbound variable. In the latter case, check_mask_event/[3,4] will unify XEvent with a private, local structure, which the user can not hang on to, but is guaranteed not to change its value until the next call to an event getting routine.

EventMask is an integer bitmask, that specifies the selected events. The predicate event_list_mask/2 is useful to translate between X11 event mask names and bitmasks.