1giiEventPoll(3)                       GGI                      giiEventPoll(3)
2
3
4

NAME

6       giiEventPoll,  giiEventSelect, giiEventsQueued, giiEventRead : Wait for
7       and receive events
8

SYNOPSIS

10       #include <ggi/gii.h>
11
12       gii_event_mask giiEventPoll(gii_input_t inp, gii_event_mask mask,
13                                   struct timeval *t);
14
15       int giiEventSelect(gii_input_t inp, gii_event_mask *mask, int n,
16                          fd_set *readfds, fd_set *writefds, fd_set *exceptfds,
17                          struct timeval *timeout);
18
19       int giiEventsQueued(gii_input_t inp, gii_event_mask mask);
20
21       int giiEventRead(gii_input_t inp, gii_event *ev, gii_event_mask mask);
22
23

DESCRIPTION

25       giiEventPoll waits for specific events to become available on an input.
26       This  call  somewhat  resembles  the  Unix select(2) call, but only for
27       LibGII events and is more portable.   The  function  returns  after  an
28       event matching the given event mask is available or after the amount of
29       time specified by t has elapsed, whichever occurs first.  If t is NULL,
30       there is no timeout.
31
32       The timeout value on return is updated to the time that would have been
33       remaining. So make sure to re-setup this value when  calling  giiEvent‐
34       Poll in a loop.
35
36       giiEventSelect  is the combination of giiEventPoll and select(2) allow‐
37       ing to wait for both LibGII events and arbitrary  file  descriptors  in
38       any  of  the  three states.  However, this function is not available if
39       the operating system does not support the select(2) call, not even as a
40       stub.
41
42       giiEventsQueued  returns  the  number  of events matching the specified
43       event mask that are currently queued in the input.
44
45       giiEventRead blocks for and transfers an event from the given input  to
46       the  location  pointed  to by ev. The event with the earliest timestamp
47       that matches the given mask is returned to the application.
48

RETURN VALUE

50       giiEventPoll returns a mask of available  events  (constrained  by  the
51       given  mask).   It is 0 if no events are available.  On error, an nega‐
52       tive gii-error(3) code is returned.
53
54       giiEventSelect returns the same  values  as  select(2).   Unlike  other
55       LibGGI/LibGII functions, it also uses errno. It will update the timeout
56       regardless of whether or not the system call does so.
57
58       giiEventsQueued returns the number of events.
59
60       giiEventRead returns the size of event on success, and 0 on error.
61

EXAMPLES

63       This is one of the various ways of coding an event-polling loop:
64
65       for(;;) {
66           tv.tv_sec = 0;
67           tv.tv_usec = 100; /* change to 0 for non-blocking behaviour */
68
69           ggiEventPoll(vis, emAll, &tv);
70           n = ggiEventsQueued(vis, emAll);
71
72           /* Process events in one gulp, when available */
73           while(n--) {
74               ggiEventRead(vis, &ggievent, emAll);
75               switch(ggievent.any.type) {
76                   /* ... */
77               }
78           }
79
80           /* Do other stuff */
81       }
82
83              Note: This code uses the LibGGI functions and types  instead  of
84              the LibGII ones, since the former is the more common case.
85
86
87
88libgii-1.0.x                      2006-12-30                   giiEventPoll(3)
Impressum