annotate lwlib/dispatch.c @ 89473:3b15f21df0b6

*** empty log message ***
author Kenichi Handa <handa@m17n.org>
date Fri, 06 Jun 2003 03:59:55 +0000
parents e0d966fb548f
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
5626
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1 /* Defines a function to find the Widget that XtDispatchEvent() would use.
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2 Copyright (C) 1992 Lucid, Inc.
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4 This file is part of the Lucid Widget Library.
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6 The Lucid Widget Library is free software; you can redistribute it and/or
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7 modify it under the terms of the GNU General Public License as published by
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8 the Free Software Foundation; either version 1, or (at your option)
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
9 any later version.
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
10
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
11 The Lucid Widget Library is distributed in the hope that it will be useful,
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
14 GNU General Public License for more details.
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
15
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
16 You should have received a copy of the GNU General Public License
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
17 along with GNU Emacs; see the file COPYING. If not, write to
14186
ee40177f6c68 Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents: 6900
diff changeset
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
ee40177f6c68 Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents: 6900
diff changeset
19 Boston, MA 02111-1307, USA. */
5626
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
20
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
21 /*
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
22 * The function XtWidgetToDispatchTo(), given an XEvent, returns the
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
23 * widget that XtDispatchEvent() would send that event to if called now.
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
24 * This file copies much code from the X11r4 Xt source, and is thus a
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
25 * portability problem. It also requires data structures defined in
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
26 * IntrinsicI.h, which is a non-exported Xt header file, so you can't
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
27 * compile this file unless you have the Xt sources online.
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
28 */
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
29
26087
e0d966fb548f Add support for large files, plus some locale improvements.
Paul Eggert <eggert@twinsun.com>
parents: 14186
diff changeset
30 #ifdef HAVE_CONFIG_H
e0d966fb548f Add support for large files, plus some locale improvements.
Paul Eggert <eggert@twinsun.com>
parents: 14186
diff changeset
31 #include <config.h>
e0d966fb548f Add support for large files, plus some locale improvements.
Paul Eggert <eggert@twinsun.com>
parents: 14186
diff changeset
32 #endif
e0d966fb548f Add support for large files, plus some locale improvements.
Paul Eggert <eggert@twinsun.com>
parents: 14186
diff changeset
33
5626
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
34 #include <IntrinsicI.h> /* Don't change this: see comments in Imakefile. */
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
35 #include <X11/Xatom.h>
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
36 #include "dispatch.h"
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
37
6900
a3fd3d082bc4 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 5626
diff changeset
38 #include <X11/Xlib.h>
a3fd3d082bc4 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 5626
diff changeset
39 #include <X11/cursorfont.h>
a3fd3d082bc4 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 5626
diff changeset
40 #include <X11/Xutil.h>
5626
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
41
6900
a3fd3d082bc4 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 5626
diff changeset
42 #ifdef XlibSpecificationRelease
a3fd3d082bc4 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 5626
diff changeset
43 #if XlibSpecificationRelease >= 5
a3fd3d082bc4 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 5626
diff changeset
44 #define HAVE_X11R5
5626
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
45 #endif
6900
a3fd3d082bc4 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 5626
diff changeset
46 #endif
5626
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
47
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
48 /* ## All of the code on this page was copied from the X11R5 lib/Xt/Event.c,
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
49 ## but is compatible with X11R4; the code in Event.c is different, but
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
50 ## functionally equivalent for our purposes.
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
51 */
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
52
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
53 #if __STDC__
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
54 #define Const const
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
55 #else
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
56 #define Const /**/
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
57 #endif
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
58
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
59 #define NonMaskableMask ((EventMask)0x80000000L)
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
60
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
61 #define COMP_EXPOSE (widget->core.widget_class->core_class.compress_exposure)
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
62 #define COMP_EXPOSE_TYPE (COMP_EXPOSE & 0x0f)
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
63 #define GRAPHICS_EXPOSE ((XtExposeGraphicsExpose & COMP_EXPOSE) || \
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
64 (XtExposeGraphicsExposeMerged & COMP_EXPOSE))
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
65 #define NO_EXPOSE (XtExposeNoExpose & COMP_EXPOSE)
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
66
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
67
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
68 /* -- lots of stuff we don't need to copy, omitted -- */
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
69
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
70
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
71 static EventMask Const masks[] = {
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
72 0, /* Error, should never see */
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
73 0, /* Reply, should never see */
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
74 KeyPressMask, /* KeyPress */
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
75 KeyReleaseMask, /* KeyRelease */
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
76 ButtonPressMask, /* ButtonPress */
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
77 ButtonReleaseMask, /* ButtonRelease */
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
78 PointerMotionMask /* MotionNotify */
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
79 | ButtonMotionMask,
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
80 EnterWindowMask, /* EnterNotify */
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
81 LeaveWindowMask, /* LeaveNotify */
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
82 FocusChangeMask, /* FocusIn */
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
83 FocusChangeMask, /* FocusOut */
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
84 KeymapStateMask, /* KeymapNotify */
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
85 ExposureMask, /* Expose */
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
86 NonMaskableMask, /* GraphicsExpose, in GC */
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
87 NonMaskableMask, /* NoExpose, in GC */
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
88 VisibilityChangeMask, /* VisibilityNotify */
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
89 SubstructureNotifyMask, /* CreateNotify */
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
90 StructureNotifyMask /* DestroyNotify */
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
91 | SubstructureNotifyMask,
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
92 StructureNotifyMask /* UnmapNotify */
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
93 | SubstructureNotifyMask,
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
94 StructureNotifyMask /* MapNotify */
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
95 | SubstructureNotifyMask,
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
96 SubstructureRedirectMask, /* MapRequest */
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
97 StructureNotifyMask /* ReparentNotify */
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
98 | SubstructureNotifyMask,
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
99 StructureNotifyMask /* ConfigureNotify */
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
100 | SubstructureNotifyMask,
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
101 SubstructureRedirectMask, /* ConfigureRequest */
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
102 StructureNotifyMask /* GravityNotify */
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
103 | SubstructureNotifyMask,
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
104 ResizeRedirectMask, /* ResizeRequest */
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
105 StructureNotifyMask /* CirculateNotify */
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
106 | SubstructureNotifyMask,
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
107 SubstructureRedirectMask, /* CirculateRequest */
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
108 PropertyChangeMask, /* PropertyNotify */
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
109 NonMaskableMask, /* SelectionClear */
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
110 NonMaskableMask, /* SelectionRequest */
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
111 NonMaskableMask, /* SelectionNotify */
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
112 ColormapChangeMask, /* ColormapNotify */
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
113 NonMaskableMask, /* ClientMessage */
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
114 NonMaskableMask /* MappingNotify */
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
115 };
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
116
6900
a3fd3d082bc4 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 5626
diff changeset
117 #ifndef HAVE_X11R5
5626
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
118
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
119 static /* in R5, this is not static, so we don't need to define it at all */
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
120 EventMask _XtConvertTypeToMask (eventType)
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
121 int eventType;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
122 {
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
123 eventType &= 0x7f; /* Events sent with XSendEvent have high bit set. */
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
124 if (eventType < XtNumber(masks))
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
125 return masks[eventType];
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
126 else
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
127 return 0;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
128 }
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
129
6900
a3fd3d082bc4 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 5626
diff changeset
130 #endif /* not HAVE_X11R5 */
5626
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
131
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
132 /* -- _XtOnGrabList() omitted -- */
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
133
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
134
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
135 static Widget LookupSpringLoaded(grabList)
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
136 XtGrabList grabList;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
137 {
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
138 XtGrabList gl;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
139
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
140 for (gl = grabList; gl != NULL; gl = gl->next) {
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
141 if (gl->spring_loaded)
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
142 if (XtIsSensitive(gl->widget))
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
143 return gl->widget;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
144 else
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
145 return NULL;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
146 if (gl->exclusive) break;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
147 }
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
148 return NULL;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
149 }
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
150
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
151
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
152
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
153 /* This function is new. */
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
154
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
155 static Boolean WouldDispatchEvent(event, widget, mask, pd)
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
156 register XEvent *event;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
157 Widget widget;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
158 EventMask mask;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
159 XtPerDisplay pd;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
160 {
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
161 XtEventRec *p;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
162 Boolean would_dispatched = False;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
163
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
164 if ((mask == ExposureMask) ||
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
165 ((event->type == NoExpose) && NO_EXPOSE) ||
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
166 ((event->type == GraphicsExpose) && GRAPHICS_EXPOSE) )
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
167 if (widget->core.widget_class->core_class.expose != NULL )
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
168 return True;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
169
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
170
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
171 if ((mask == VisibilityChangeMask) &&
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
172 XtClass(widget)->core_class.visible_interest)
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
173 return True;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
174
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
175 for (p=widget->core.event_table; p != NULL; p = p->next)
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
176 if ((mask & p->mask) != 0
6900
a3fd3d082bc4 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 5626
diff changeset
177 #ifndef HAVE_X11R5
5626
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
178 || (mask == 0 && p->non_filter)
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
179 #endif
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
180 )
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
181 return True;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
182
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
183 return False;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
184 }
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
185
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
186
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
187 /* #### This function is mostly copied from DecideToDispatch().
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
188 */
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
189
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
190 typedef enum _GrabType {pass, ignore, remap} GrabType;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
191
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
192 Widget
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
193 XtWidgetToDispatchTo (XEvent* event)
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
194 {
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
195 register Widget widget;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
196 EventMask mask;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
197 GrabType grabType;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
198 Widget dspWidget;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
199 Time time = 0;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
200 XtPerDisplay pd;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
201 XtPerDisplayInput pdi;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
202 XtGrabList grabList;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
203
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
204 widget = XtWindowToWidget (event->xany.display, event->xany.window);
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
205 pd = _XtGetPerDisplay(event->xany.display);
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
206 pdi = _XtGetPerDisplayInput(event->xany.display);
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
207 grabList = *_XtGetGrabList(pdi);
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
208
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
209 mask = _XtConvertTypeToMask(event->xany.type);
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
210 grabType = pass;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
211 switch (event->xany.type & 0x7f) {
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
212 case KeyPress:
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
213 case KeyRelease: grabType = remap; break;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
214 case ButtonPress:
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
215 case ButtonRelease: grabType = remap; break;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
216 case MotionNotify: grabType = ignore;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
217 #define XKnownButtons (Button1MotionMask|Button2MotionMask|Button3MotionMask|\
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
218 Button4MotionMask|Button5MotionMask)
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
219 mask |= (event->xmotion.state & XKnownButtons);
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
220 #undef XKnownButtons
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
221 break;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
222 case EnterNotify: grabType = ignore; break;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
223 }
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
224
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
225 if (widget == NULL) {
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
226 if (grabType != remap) return False;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
227 /* event occurred in a non-widget window, but we've promised also
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
228 to dispatch it to the nearest accessible spring_loaded widget */
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
229 else if ((widget = LookupSpringLoaded(grabList)) != NULL)
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
230 return widget;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
231 return False;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
232 }
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
233
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
234 switch(grabType) {
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
235 case pass:
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
236 return widget;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
237
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
238 case ignore:
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
239 if ((grabList == NULL || _XtOnGrabList(widget,grabList))
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
240 && XtIsSensitive(widget)) {
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
241 return widget;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
242 }
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
243 return NULL;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
244
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
245 case remap:
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
246
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
247 {
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
248 Widget was_dispatched_to= NULL;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
249 extern Widget _XtFindRemapWidget();
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
250 extern void _XtUngrabBadGrabs();
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
251
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
252 dspWidget = _XtFindRemapWidget(event, widget, mask, pdi);
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
253
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
254 if ((grabList == NULL ||
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
255 _XtOnGrabList(dspWidget, grabList)) &&
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
256 XtIsSensitive(dspWidget)) {
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
257 if (WouldDispatchEvent (event, dspWidget, mask, pd))
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
258 was_dispatched_to = dspWidget;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
259 }
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
260
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
261 /* Also dispatch to nearest accessible spring_loaded. */
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
262 /* Fetch this afterward to reflect modal list changes */
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
263 grabList = *_XtGetGrabList(pdi);
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
264 widget = LookupSpringLoaded(grabList);
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
265 if (widget != NULL && widget != dspWidget) {
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
266 if (!was_dispatched_to)
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
267 was_dispatched_to = widget;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
268 }
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
269
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
270 return was_dispatched_to;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
271 }
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
272 }
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
273 /* should never reach here */
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
274 return NULL;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
275 }