W_QUERYEVENT(23			WLIB-CALLS		W_QUERYEVENT(3)

NAME

	w_queryevent()

SYPNOSIS

	#include <Wlib.h>

	WEVENT *w_queryevent(fd_set *rdp, fd_set *wdp, fd_set *xfd,
			     long timeout);

	where WEVENT is defined as:

	typedef struct {
		short	handle;
		char	type;
		short	x, y;
		long	key;
		short	reserved[2];
	} WEVENT;


DESCRIPTION

	 w_queryevent() is the call which reports all kinds of user input or
	events to a client program. since a client may open several windows
	the `handle' field will give you the handle of the window where the
	event occured. you may ignore this if your program has only one
	window open.

	 the call behaves somehow like select(3), say, it takes pointers to
	file descriptor sets as defined in sys/types.h (which is automatically
	loaded by Wlib.h) and a timeout. the timeout is counted in milliseconds
	where a value of zero means "don't wait" and a negative value means
	"wait forever".

	 if an event occured you'll get a pointer to a WEVENT structure,
	otherwise 0 is returned. since w_queryevent() doesn't return the number
	of ready file descriptors you'll have to check them always, may an
	event have happened or not.

	 there are currently five different types of events which may be
	preselected when creating the window with w_create(). note that an
	EVENT_GADGET must always be expected.

	EVENT_GADGET:	 a gadget was clicked. see the `key' field to determine
			exactly which gadget was clicked. currently only the
			pseudo gadget GADGET_EXIT is send by the server if a
			client should terminate. since the server only sends
			this event when it goes down a client MUST react
			accordingly in the shortest possible time because
			otherwise the connection will break soon. there isn't
			very much to do but to close all windows quickly.

	EVENT_KEY:	 a key was pressed. see the `key' field to determine
			which one. for MiNT it will not only contain the ACSII
			value but also the complete scancode.

	EVENT_MPRESS:	 a mouse button has been pressed. `handle' will
			contain the window number, `key' the bitmask of the
			buttons involved (which can be any combination of
			BUTTON_LEFT and BUTTON_RIGHT, the BUTTON_MID is not
			supported) and `x' and `y' the position in the window.

	EVENT_MRELEASE:	 a mouse button has been released. `handle' will
			contain the window number and `key' the button
			(release events are always reported for each released
			button, not in a group). the `x' and `y' values will
			either contain the (positive) position in the window,
			or be negative if the button was released outside the
			window. note that button releases are always only
			reported to the window where the preceding press
			event occured.

	EVENT_BUTTON:	 you've selected a user defined button field. note
			that `selected' means you've pressed *and* released
			the left mouse key over it. If you press it somewhere
			else, you'll get a EVENT_MPRESS event. if you release
			it somewhere else, you won't get an event at all. the
			`key' field will tell you which button you've selected.

	 all other fields not explicitly described above will not contain
	defined data and should be ignored, as should all other types of events
	which may be defined in a later version.

RETURNS

	- a pointer to a WEVENT struct if an event occured

	- zero otherwise

	 also returns if either the timeout expired or some of the descriptors
	needs to dealt with.

SEE ALSO

	wcreate(3)

LAST CHANGED

	12/94 by TeSche, itschere@techfak.uni-bielefeld.de
