3 Copyright (c) 1993, Oracle and/or its affiliates. All rights reserved.
5 Permission is hereby granted, free of charge, to any person obtaining a
6 copy of this software and associated documentation files (the "Software"),
7 to deal in the Software without restriction, including without limitation
8 the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 and/or sell copies of the Software, and to permit persons to whom the
10 Software is furnished to do so, subject to the following conditions:
12 The above copyright notice and this permission notice (including the next
13 paragraph) shall be included in all copies or substantial portions of the
16 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 DEALINGS IN THE SOFTWARE.
25 /********************************************************
27 Copyright 1988 by Hewlett-Packard Company
28 Copyright 1987, 1988, 1989 by Digital Equipment Corporation, Maynard, Massachusetts
30 Permission to use, copy, modify, and distribute this software
31 and its documentation for any purpose and without fee is hereby
32 granted, provided that the above copyright notice appear in all
33 copies and that both that copyright notice and this permission
34 notice appear in supporting documentation, and that the names of
35 Hewlett-Packard or Digital not be used in advertising or
36 publicity pertaining to distribution of the software without specific,
37 written prior permission.
39 DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
40 ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
41 DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
42 ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
43 WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
44 ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
47 ********************************************************/
51 Copyright 1987, 1988, 1989, 1998 The Open Group
53 Permission to use, copy, modify, distribute, and sell this software and its
54 documentation for any purpose is hereby granted without fee, provided that
55 the above copyright notice appear in all copies and that both that
56 copyright notice and this permission notice appear in supporting
59 The above copyright notice and this permission notice shall be included in
60 all copies or substantial portions of the Software.
62 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
63 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
64 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
65 OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
66 AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
67 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
69 Except as contained in this notice, the name of The Open Group shall not be
70 used in advertising or otherwise to promote the sale, use or other dealings
71 in this Software without prior written authorization from The Open Group.
78 #include "IntrinsicI.h"
79 #include "PassivGraI.h"
80 #include "StringDefs.h"
83 static XContext perWidgetInputContext = 0;
85 void _XtFreePerWidgetInput(
90 XDeleteContext(XtDisplay(w),
92 perWidgetInputContext);
99 * This routine gets the passive list associated with the widget
100 * from the context manager.
102 XtPerWidgetInput _XtGetPerWidgetInput(
106 XtPerWidgetInput pwi = NULL;
107 Display *dpy = widget->core.screen->display;
110 if (! perWidgetInputContext)
111 perWidgetInputContext = XUniqueContext();
113 if (XFindContext(dpy,
115 perWidgetInputContext,
119 pwi = (XtPerWidgetInput)
120 __XtMalloc((unsigned) sizeof(XtPerWidgetInputRec));
122 pwi->focusKid = NULL;
123 pwi->queryEventDescendant = NULL;
124 pwi->focalPoint = XtUnrelated;
129 pwi->map_handler_added =
130 pwi->realize_handler_added =
131 pwi->active_handler_added = FALSE;
133 XtAddCallback(widget, XtNdestroyCallback,
134 _XtDestroyServerGrabs, (XtPointer)pwi);
136 (void) XSaveContext(dpy,
138 perWidgetInputContext,
146 void _XtFillAncestorList(
156 Widget *trace = *listPtr;
158 /* First time in, allocate the ancestor list */
161 trace = (Widget *) __XtMalloc(CACHESIZE * sizeof(Widget));
162 *maxElemsPtr = CACHESIZE;
164 /* First fill in the ancestor list */
168 for (i = 1, w = XtParent(start);
169 w != NULL && !XtIsShell(trace[i-1]) && trace[i-1] != breakWidget;
170 w = XtParent(w), i++) {
171 if (i == (Cardinal) *maxElemsPtr) {
172 /* This should rarely happen, but if it does it'll probably
173 happen again, so grow the ancestor list */
174 *maxElemsPtr += CACHESIZE;
175 trace = (Widget *) XtRealloc((char*)trace,
176 sizeof(Widget) * (*maxElemsPtr));
186 Widget _XtFindRemapWidget(
190 XtPerDisplayInput pdi)
192 Widget dspWidget = widget;
194 if (!pdi->traceDepth || !(widget == pdi->trace[0]))
196 _XtFillAncestorList(&pdi->trace, &pdi->traceMax,
197 &pdi->traceDepth, widget, NULL);
198 pdi->focusWidget = NULL; /* invalidate the focus
201 if (mask & (KeyPressMask | KeyReleaseMask))
202 dspWidget = _XtProcessKeyboardEvent((XKeyEvent*)event, widget, pdi);
203 else if (mask &(ButtonPressMask | ButtonReleaseMask))
204 dspWidget = _XtProcessPointerEvent((XButtonEvent*)event, widget,pdi);
209 void _XtUngrabBadGrabs(
213 XtPerDisplayInput pdi)
215 XKeyEvent * ke = (XKeyEvent *) event;
217 if (mask & (KeyPressMask | KeyReleaseMask))
219 if (IsServerGrab(pdi->keyboard.grabType) &&
220 !_XtOnGrabList(pdi->keyboard.grab.widget,
222 XtUngrabKeyboard(widget, ke->time);
227 if (IsServerGrab(pdi->pointer.grabType) &&
228 !_XtOnGrabList(pdi->pointer.grab.widget,
230 XtUngrabPointer(widget, ke->time);