| 1 |
# Copyright (c) 1990 The Regents of the University of California. |
| 2 |
# Copyright (c) 1994-1996 Sun Microsystems, Inc. |
| 3 |
# See the file "license.terms" for information on usage and redistribution |
| 4 |
# of this file, and for a DISCLAIMER OF ALL WARRANTIES. |
| 5 |
# |
| 6 |
# |
| 7 |
|
| 8 |
=head1 NAME |
| 9 |
|
| 10 |
Tk_RestrictEvents - filter and selectively delay X events |
| 11 |
|
| 12 |
=for category C Programming |
| 13 |
|
| 14 |
=head1 SYNOPSIS |
| 15 |
|
| 16 |
B<#include E<lt>tk.hE<gt>> |
| 17 |
|
| 18 |
Tk_RestrictProc * |
| 19 |
B<Tk_RestrictEvents>(I<proc, clientData, prevClientDataPtr>) |
| 20 |
|
| 21 |
=head1 ARGUMENTS |
| 22 |
|
| 23 |
=over 4 |
| 24 |
|
| 25 |
=item Tk_RestrictProc *proc (in) |
| 26 |
|
| 27 |
Predicate procedure to call to filter incoming X events. |
| 28 |
NULL means do not restrict events at all. |
| 29 |
|
| 30 |
=item ClientData clientData (in) |
| 31 |
|
| 32 |
Arbitrary argument to pass to I<proc>. |
| 33 |
|
| 34 |
=item ClientData *prevClientDataPtr (out) |
| 35 |
|
| 36 |
Pointer to place to save argument to previous restrict procedure. |
| 37 |
|
| 38 |
=back |
| 39 |
|
| 40 |
=head1 DESCRIPTION |
| 41 |
|
| 42 |
This procedure is useful in certain situations where applications |
| 43 |
are only prepared to receive certain X events. After |
| 44 |
B<Tk_RestrictEvents> is called, B<Tk_DoOneEvent> (and |
| 45 |
hence B<Tk_MainLoop>) will filter X input events through |
| 46 |
I<proc>. I<Proc> indicates whether a |
| 47 |
given event is to be processed immediately, deferred until some |
| 48 |
later time (e.g. when the event restriction is lifted), or discarded. |
| 49 |
I<Proc> |
| 50 |
is a procedure with arguments and result that match |
| 51 |
the type B<Tk_RestrictProc>: |
| 52 |
|
| 53 |
typedef Tk_RestrictAction Tk_RestrictProc( |
| 54 |
ClientData clientData, |
| 55 |
XEvent *eventPtr); |
| 56 |
|
| 57 |
The I<clientData> argument is a copy of the I<clientData> passed |
| 58 |
to B<Tk_RestrictEvents>; it may be used to provide I<proc> with |
| 59 |
information it needs to filter events. The I<eventPtr> points to |
| 60 |
an event under consideration. I<Proc> returns a restrict action |
| 61 |
(enumerated type B<Tk_RestrictAction>) that indicates what |
| 62 |
B<Tk_DoOneEvent> should do with the event. If the return value is |
| 63 |
B<TK_PROCESS_EVENT>, then the event will be handled immediately. |
| 64 |
If the return value is B<TK_DEFER_EVENT>, then the event will be |
| 65 |
left on the event queue for later processing. If the return value is |
| 66 |
B<TK_DISCARD_EVENT>, then the event will be removed from the event |
| 67 |
queue and discarded without being processed. |
| 68 |
|
| 69 |
B<Tk_RestrictEvents> uses its return value and I<prevClientDataPtr> |
| 70 |
to return information about the current event restriction procedure |
| 71 |
(a NULL return value means there are currently no restrictions). |
| 72 |
These values may be used to restore the previous restriction state |
| 73 |
when there is no longer any need for the current restriction. |
| 74 |
|
| 75 |
There are very few places where B<Tk_RestrictEvents> is needed. |
| 76 |
In most cases, the best way to restrict events is by changing the |
| 77 |
bindings with the B<bind> Tcl command or by calling |
| 78 |
B<Tk_CreateEventHandler> and B<Tk_DeleteEventHandler> from C. |
| 79 |
The main place where B<Tk_RestrictEvents> must be used is when |
| 80 |
performing synchronous actions (for example, if you need to wait |
| 81 |
for a particular event to occur on a particular window but you don't |
| 82 |
want to invoke any handlers for any other events). The ``obvious'' |
| 83 |
solution in these situations is to call B<XNextEvent> or |
| 84 |
B<XWindowEvent>, but these procedures cannot be used because |
| 85 |
Tk keeps its own event queue that is separate from the X event |
| 86 |
queue. Instead, call B<Tk_RestrictEvents> to set up a filter, |
| 87 |
then call B<Tk_DoOneEvent> to retrieve the desired event(s). |
| 88 |
|
| 89 |
=head1 KEYWORDS |
| 90 |
|
| 91 |
delay, event, filter, restriction |