annotate lwlib/dispatch.c @ 7166:4110118519d6

Drop the trailing slash.
author Karl Heuer <kwzh@gnu.org>
date Thu, 28 Apr 1994 07:32:21 +0000
parents a3fd3d082bc4
children ee40177f6c68
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
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
18 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
19
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 * The function XtWidgetToDispatchTo(), given an XEvent, returns the
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
22 * widget that XtDispatchEvent() would send that event to if called now.
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
23 * 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
24 * portability problem. It also requires data structures defined in
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
25 * 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
26 * compile this file unless you have the Xt sources online.
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
27 */
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 #include <IntrinsicI.h> /* Don't change this: see comments in Imakefile. */
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
30 #include <X11/Xatom.h>
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
31 #include "dispatch.h"
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
32
6900
a3fd3d082bc4 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 5626
diff changeset
33 #include <X11/Xlib.h>
a3fd3d082bc4 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 5626
diff changeset
34 #include <X11/cursorfont.h>
a3fd3d082bc4 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 5626
diff changeset
35 #include <X11/Xutil.h>
5626
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
36
6900
a3fd3d082bc4 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 5626
diff changeset
37 #ifdef XlibSpecificationRelease
a3fd3d082bc4 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 5626
diff changeset
38 #if XlibSpecificationRelease >= 5
a3fd3d082bc4 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 5626
diff changeset
39 #define HAVE_X11R5
5626
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
40 #endif
6900
a3fd3d082bc4 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 5626
diff changeset
41 #endif
5626
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
42
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
43 /* ## 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
44 ## 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
45 ## functionally equivalent for our purposes.
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
46 */
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 #if __STDC__
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
49 #define Const const
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
50 #else
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
51 #define Const /**/
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
52 #endif
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
53
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
54 #define NonMaskableMask ((EventMask)0x80000000L)
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
55
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
56 #define COMP_EXPOSE (widget->core.widget_class->core_class.compress_exposure)
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
57 #define COMP_EXPOSE_TYPE (COMP_EXPOSE & 0x0f)
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
58 #define GRAPHICS_EXPOSE ((XtExposeGraphicsExpose & COMP_EXPOSE) || \
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
59 (XtExposeGraphicsExposeMerged & COMP_EXPOSE))
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
60 #define NO_EXPOSE (XtExposeNoExpose & COMP_EXPOSE)
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
61
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
62
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
63 /* -- lots of stuff we don't need to copy, omitted -- */
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
64
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
65
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
66 static EventMask Const masks[] = {
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
67 0, /* Error, should never see */
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
68 0, /* Reply, should never see */
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
69 KeyPressMask, /* KeyPress */
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
70 KeyReleaseMask, /* KeyRelease */
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
71 ButtonPressMask, /* ButtonPress */
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
72 ButtonReleaseMask, /* ButtonRelease */
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
73 PointerMotionMask /* MotionNotify */
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
74 | ButtonMotionMask,
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
75 EnterWindowMask, /* EnterNotify */
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
76 LeaveWindowMask, /* LeaveNotify */
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
77 FocusChangeMask, /* FocusIn */
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
78 FocusChangeMask, /* FocusOut */
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
79 KeymapStateMask, /* KeymapNotify */
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
80 ExposureMask, /* Expose */
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
81 NonMaskableMask, /* GraphicsExpose, in GC */
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
82 NonMaskableMask, /* NoExpose, in GC */
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
83 VisibilityChangeMask, /* VisibilityNotify */
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
84 SubstructureNotifyMask, /* CreateNotify */
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
85 StructureNotifyMask /* DestroyNotify */
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
86 | SubstructureNotifyMask,
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
87 StructureNotifyMask /* UnmapNotify */
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
88 | SubstructureNotifyMask,
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
89 StructureNotifyMask /* MapNotify */
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
90 | SubstructureNotifyMask,
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
91 SubstructureRedirectMask, /* MapRequest */
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
92 StructureNotifyMask /* ReparentNotify */
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 /* ConfigureNotify */
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, /* ConfigureRequest */
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
97 StructureNotifyMask /* GravityNotify */
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 ResizeRedirectMask, /* ResizeRequest */
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
100 StructureNotifyMask /* CirculateNotify */
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
101 | SubstructureNotifyMask,
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
102 SubstructureRedirectMask, /* CirculateRequest */
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
103 PropertyChangeMask, /* PropertyNotify */
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
104 NonMaskableMask, /* SelectionClear */
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
105 NonMaskableMask, /* SelectionRequest */
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
106 NonMaskableMask, /* SelectionNotify */
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
107 ColormapChangeMask, /* ColormapNotify */
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
108 NonMaskableMask, /* ClientMessage */
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
109 NonMaskableMask /* MappingNotify */
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
110 };
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
111
6900
a3fd3d082bc4 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 5626
diff changeset
112 #ifndef HAVE_X11R5
5626
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
113
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
114 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
115 EventMask _XtConvertTypeToMask (eventType)
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
116 int eventType;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
117 {
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
118 eventType &= 0x7f; /* Events sent with XSendEvent have high bit set. */
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
119 if (eventType < XtNumber(masks))
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
120 return masks[eventType];
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
121 else
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
122 return 0;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
123 }
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
124
6900
a3fd3d082bc4 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 5626
diff changeset
125 #endif /* not HAVE_X11R5 */
5626
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
126
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
127 /* -- _XtOnGrabList() omitted -- */
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
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
130 static Widget LookupSpringLoaded(grabList)
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
131 XtGrabList grabList;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
132 {
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
133 XtGrabList gl;
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 for (gl = grabList; gl != NULL; gl = gl->next) {
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
136 if (gl->spring_loaded)
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
137 if (XtIsSensitive(gl->widget))
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
138 return gl->widget;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
139 else
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
140 return NULL;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
141 if (gl->exclusive) break;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
142 }
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
143 return NULL;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
144 }
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
145
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
146
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 /* This function is new. */
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 static Boolean WouldDispatchEvent(event, widget, mask, pd)
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
151 register XEvent *event;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
152 Widget widget;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
153 EventMask mask;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
154 XtPerDisplay pd;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
155 {
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
156 XtEventRec *p;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
157 Boolean would_dispatched = False;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
158
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
159 if ((mask == ExposureMask) ||
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
160 ((event->type == NoExpose) && NO_EXPOSE) ||
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
161 ((event->type == GraphicsExpose) && GRAPHICS_EXPOSE) )
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
162 if (widget->core.widget_class->core_class.expose != NULL )
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
163 return True;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
164
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
165
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
166 if ((mask == VisibilityChangeMask) &&
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
167 XtClass(widget)->core_class.visible_interest)
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 for (p=widget->core.event_table; p != NULL; p = p->next)
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
171 if ((mask & p->mask) != 0
6900
a3fd3d082bc4 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 5626
diff changeset
172 #ifndef HAVE_X11R5
5626
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
173 || (mask == 0 && p->non_filter)
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
174 #endif
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
175 )
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
176 return True;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
177
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
178 return False;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
179 }
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
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
182 /* #### This function is mostly copied from DecideToDispatch().
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
183 */
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 typedef enum _GrabType {pass, ignore, remap} GrabType;
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 Widget
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
188 XtWidgetToDispatchTo (XEvent* event)
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 register Widget widget;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
191 EventMask mask;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
192 GrabType grabType;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
193 Widget dspWidget;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
194 Time time = 0;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
195 XtPerDisplay pd;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
196 XtPerDisplayInput pdi;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
197 XtGrabList grabList;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
198
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
199 widget = XtWindowToWidget (event->xany.display, event->xany.window);
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
200 pd = _XtGetPerDisplay(event->xany.display);
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
201 pdi = _XtGetPerDisplayInput(event->xany.display);
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
202 grabList = *_XtGetGrabList(pdi);
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 mask = _XtConvertTypeToMask(event->xany.type);
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
205 grabType = pass;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
206 switch (event->xany.type & 0x7f) {
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
207 case KeyPress:
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
208 case KeyRelease: grabType = remap; break;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
209 case ButtonPress:
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
210 case ButtonRelease: grabType = remap; break;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
211 case MotionNotify: grabType = ignore;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
212 #define XKnownButtons (Button1MotionMask|Button2MotionMask|Button3MotionMask|\
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
213 Button4MotionMask|Button5MotionMask)
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
214 mask |= (event->xmotion.state & XKnownButtons);
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
215 #undef XKnownButtons
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
216 break;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
217 case EnterNotify: grabType = ignore; break;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
218 }
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
219
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
220 if (widget == NULL) {
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
221 if (grabType != remap) return False;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
222 /* event occurred in a non-widget window, but we've promised also
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
223 to dispatch it to the nearest accessible spring_loaded widget */
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
224 else if ((widget = LookupSpringLoaded(grabList)) != NULL)
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
225 return widget;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
226 return False;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
227 }
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
228
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
229 switch(grabType) {
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
230 case pass:
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
231 return widget;
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 case ignore:
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
234 if ((grabList == NULL || _XtOnGrabList(widget,grabList))
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
235 && XtIsSensitive(widget)) {
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 return NULL;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
239
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
240 case remap:
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
241
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 Widget was_dispatched_to= NULL;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
244 extern Widget _XtFindRemapWidget();
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
245 extern void _XtUngrabBadGrabs();
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 dspWidget = _XtFindRemapWidget(event, widget, mask, pdi);
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
248
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
249 if ((grabList == NULL ||
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
250 _XtOnGrabList(dspWidget, grabList)) &&
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
251 XtIsSensitive(dspWidget)) {
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
252 if (WouldDispatchEvent (event, dspWidget, mask, pd))
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
253 was_dispatched_to = dspWidget;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
254 }
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
255
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
256 /* Also dispatch to nearest accessible spring_loaded. */
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
257 /* Fetch this afterward to reflect modal list changes */
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
258 grabList = *_XtGetGrabList(pdi);
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
259 widget = LookupSpringLoaded(grabList);
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
260 if (widget != NULL && widget != dspWidget) {
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
261 if (!was_dispatched_to)
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
262 was_dispatched_to = widget;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
263 }
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
264
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
265 return was_dispatched_to;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
266 }
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
267 }
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
268 /* should never reach here */
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
269 return NULL;
93bb7e0935ba Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
270 }