# Copyright (c) 1990 The Regents of the University of California. # Copyright (c) 1994-1996 Sun Microsystems, Inc. # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. # # =head1 NAME Tk_RestrictEvents - filter and selectively delay X events =for category C Programming =head1 SYNOPSIS B<#include Etk.hE> Tk_RestrictProc * B(I) =head1 ARGUMENTS =over 4 =item Tk_RestrictProc *proc (in) Predicate procedure to call to filter incoming X events. NULL means do not restrict events at all. =item ClientData clientData (in) Arbitrary argument to pass to I. =item ClientData *prevClientDataPtr (out) Pointer to place to save argument to previous restrict procedure. =back =head1 DESCRIPTION This procedure is useful in certain situations where applications are only prepared to receive certain X events. After B is called, B (and hence B) will filter X input events through I. I indicates whether a given event is to be processed immediately, deferred until some later time (e.g. when the event restriction is lifted), or discarded. I is a procedure with arguments and result that match the type B: typedef Tk_RestrictAction Tk_RestrictProc( ClientData clientData, XEvent *eventPtr); The I argument is a copy of the I passed to B; it may be used to provide I with information it needs to filter events. The I points to an event under consideration. I returns a restrict action (enumerated type B) that indicates what B should do with the event. If the return value is B, then the event will be handled immediately. If the return value is B, then the event will be left on the event queue for later processing. If the return value is B, then the event will be removed from the event queue and discarded without being processed. B uses its return value and I to return information about the current event restriction procedure (a NULL return value means there are currently no restrictions). These values may be used to restore the previous restriction state when there is no longer any need for the current restriction. There are very few places where B is needed. In most cases, the best way to restrict events is by changing the bindings with the B Tcl command or by calling B and B from C. The main place where B must be used is when performing synchronous actions (for example, if you need to wait for a particular event to occur on a particular window but you don't want to invoke any handlers for any other events). The ``obvious'' solution in these situations is to call B or B, but these procedures cannot be used because Tk keeps its own event queue that is separate from the X event queue. Instead, call B to set up a filter, then call B to retrieve the desired event(s). =head1 KEYWORDS delay, event, filter, restriction