Pointer.c revision a3bd7f05
1/******************************************************** 2 3Copyright 1988 by Hewlett-Packard Company 4Copyright 1987, 1988, 1989 by Digital Equipment Corporation, Maynard 5 6Permission to use, copy, modify, and distribute this software 7and its documentation for any purpose and without fee is hereby 8granted, provided that the above copyright notice appear in all 9copies and that both that copyright notice and this permission 10notice appear in supporting documentation, and that the names of 11Hewlett-Packard or Digital not be used in advertising or 12publicity pertaining to distribution of the software without specific, 13written prior permission. 14 15DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING 16ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL 17DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR 18ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, 19WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, 20ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS 21SOFTWARE. 22 23********************************************************/ 24 25/* 26 27Copyright 1987, 1988, 1989, 1998 The Open Group 28 29Permission to use, copy, modify, distribute, and sell this software and its 30documentation for any purpose is hereby granted without fee, provided that 31the above copyright notice appear in all copies and that both that 32copyright notice and this permission notice appear in supporting 33documentation. 34 35The above copyright notice and this permission notice shall be included in 36all copies or substantial portions of the Software. 37 38THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 39IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 40FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 41OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 42AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 43CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 44 45Except as contained in this notice, the name of The Open Group shall not be 46used in advertising or otherwise to promote the sale, use or other dealings 47in this Software without prior written authorization from The Open Group. 48 49*/ 50 51#ifdef HAVE_CONFIG_H 52#include <config.h> 53#endif 54#include "IntrinsicI.h" 55#include "PassivGraI.h" 56 57#define AllButtonsMask (Button1Mask | Button2Mask | Button3Mask | Button4Mask | Button5Mask) 58 59Widget 60_XtProcessPointerEvent(XButtonEvent *event, 61 Widget widget, 62 XtPerDisplayInput pdi) 63{ 64 XtDevice device = &pdi->pointer; 65 XtServerGrabPtr newGrab = NULL, devGrab = &device->grab; 66 Widget dspWidget = NULL; 67 Boolean deactivateGrab = FALSE; 68 69 switch (event->type) { 70 case ButtonPress: 71 { 72 if (!IsServerGrab(device->grabType)) { 73 Cardinal i; 74 75 for (i = (Cardinal) pdi->traceDepth; i > 0 && !newGrab; i--) 76 newGrab = _XtCheckServerGrabsOnWidget((XEvent *) event, 77 pdi->trace[i - 1], 78 POINTER); 79 } 80 if (newGrab) { 81 /* Activate the grab */ 82 device->grab = *newGrab; 83 device->grabType = XtPassiveServerGrab; 84 } 85 } 86 break; 87 88 case ButtonRelease: 89 { 90 if ((device->grabType == XtPassiveServerGrab) && 91 !(event->state & (unsigned) (~(Button1Mask << (event->button - 1))) 92 & AllButtonsMask)) 93 deactivateGrab = TRUE; 94 } 95 break; 96 } 97 98 if (IsServerGrab(device->grabType) && !(devGrab)->ownerEvents) 99 dspWidget = (devGrab)->widget; 100 else 101 dspWidget = widget; 102 103 if (deactivateGrab) 104 device->grabType = XtNoServerGrab; 105 106 return dspWidget; 107} 108