Pointer.c revision a3bd7f05
1444c061aSmrg/******************************************************** 2444c061aSmrg 3444c061aSmrgCopyright 1988 by Hewlett-Packard Company 4444c061aSmrgCopyright 1987, 1988, 1989 by Digital Equipment Corporation, Maynard 5444c061aSmrg 6444c061aSmrgPermission to use, copy, modify, and distribute this software 7444c061aSmrgand its documentation for any purpose and without fee is hereby 8444c061aSmrggranted, provided that the above copyright notice appear in all 9444c061aSmrgcopies and that both that copyright notice and this permission 10444c061aSmrgnotice appear in supporting documentation, and that the names of 11444c061aSmrgHewlett-Packard or Digital not be used in advertising or 12444c061aSmrgpublicity pertaining to distribution of the software without specific, 13444c061aSmrgwritten prior permission. 14444c061aSmrg 15444c061aSmrgDIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING 16444c061aSmrgALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL 17444c061aSmrgDIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR 18444c061aSmrgANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, 19444c061aSmrgWHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, 20444c061aSmrgARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS 21444c061aSmrgSOFTWARE. 22444c061aSmrg 23444c061aSmrg********************************************************/ 24444c061aSmrg 25444c061aSmrg/* 26444c061aSmrg 27444c061aSmrgCopyright 1987, 1988, 1989, 1998 The Open Group 28444c061aSmrg 29444c061aSmrgPermission to use, copy, modify, distribute, and sell this software and its 30444c061aSmrgdocumentation for any purpose is hereby granted without fee, provided that 31444c061aSmrgthe above copyright notice appear in all copies and that both that 32444c061aSmrgcopyright notice and this permission notice appear in supporting 33444c061aSmrgdocumentation. 34444c061aSmrg 35444c061aSmrgThe above copyright notice and this permission notice shall be included in 36444c061aSmrgall copies or substantial portions of the Software. 37444c061aSmrg 38444c061aSmrgTHE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 39444c061aSmrgIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 40444c061aSmrgFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 41444c061aSmrgOPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 42444c061aSmrgAN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 43444c061aSmrgCONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 44444c061aSmrg 45444c061aSmrgExcept as contained in this notice, the name of The Open Group shall not be 46444c061aSmrgused in advertising or otherwise to promote the sale, use or other dealings 47444c061aSmrgin this Software without prior written authorization from The Open Group. 48444c061aSmrg 49444c061aSmrg*/ 50444c061aSmrg 51444c061aSmrg#ifdef HAVE_CONFIG_H 52444c061aSmrg#include <config.h> 53444c061aSmrg#endif 54444c061aSmrg#include "IntrinsicI.h" 55444c061aSmrg#include "PassivGraI.h" 56444c061aSmrg 57444c061aSmrg#define AllButtonsMask (Button1Mask | Button2Mask | Button3Mask | Button4Mask | Button5Mask) 58444c061aSmrg 59a3bd7f05SmrgWidget 60a3bd7f05Smrg_XtProcessPointerEvent(XButtonEvent *event, 61a3bd7f05Smrg Widget widget, 62a3bd7f05Smrg XtPerDisplayInput pdi) 63444c061aSmrg{ 64a3bd7f05Smrg XtDevice device = &pdi->pointer; 65a3bd7f05Smrg XtServerGrabPtr newGrab = NULL, devGrab = &device->grab; 66a3bd7f05Smrg Widget dspWidget = NULL; 67a3bd7f05Smrg Boolean deactivateGrab = FALSE; 68a3bd7f05Smrg 69a3bd7f05Smrg switch (event->type) { 70a3bd7f05Smrg case ButtonPress: 71a3bd7f05Smrg { 72a3bd7f05Smrg if (!IsServerGrab(device->grabType)) { 73a3bd7f05Smrg Cardinal i; 74a3bd7f05Smrg 75a3bd7f05Smrg for (i = (Cardinal) pdi->traceDepth; i > 0 && !newGrab; i--) 76a3bd7f05Smrg newGrab = _XtCheckServerGrabsOnWidget((XEvent *) event, 77a3bd7f05Smrg pdi->trace[i - 1], 78a3bd7f05Smrg POINTER); 79a3bd7f05Smrg } 80a3bd7f05Smrg if (newGrab) { 81a3bd7f05Smrg /* Activate the grab */ 82a3bd7f05Smrg device->grab = *newGrab; 83a3bd7f05Smrg device->grabType = XtPassiveServerGrab; 84a3bd7f05Smrg } 85a3bd7f05Smrg } 86a3bd7f05Smrg break; 87a3bd7f05Smrg 88a3bd7f05Smrg case ButtonRelease: 89a3bd7f05Smrg { 90a3bd7f05Smrg if ((device->grabType == XtPassiveServerGrab) && 91a3bd7f05Smrg !(event->state & (unsigned) (~(Button1Mask << (event->button - 1))) 92a3bd7f05Smrg & AllButtonsMask)) 93a3bd7f05Smrg deactivateGrab = TRUE; 94a3bd7f05Smrg } 95a3bd7f05Smrg break; 96a3bd7f05Smrg } 97444c061aSmrg 98444c061aSmrg if (IsServerGrab(device->grabType) && !(devGrab)->ownerEvents) 99a3bd7f05Smrg dspWidget = (devGrab)->widget; 100444c061aSmrg else 101a3bd7f05Smrg dspWidget = widget; 102444c061aSmrg 103444c061aSmrg if (deactivateGrab) 104a3bd7f05Smrg device->grabType = XtNoServerGrab; 105444c061aSmrg 106444c061aSmrg return dspWidget; 107444c061aSmrg} 108