home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / X / mit / lib / Xt / Pointer.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-08-22  |  2.6 KB  |  89 lines

  1. /* $XConsortium: Pointer.c,v 1.4 91/08/21 16:39:18 converse Exp $ */
  2.  
  3. /********************************************************
  4.  
  5. Copyright (c) 1988 by Hewlett-Packard Company
  6. Copyright (c) 1987, 1988, 1989 by Digital Equipment Corporation, Maynard, 
  7.               Massachusetts, and the Massachusetts Institute of Technology, 
  8.               Cambridge, Massachusetts
  9.  
  10. Permission to use, copy, modify, and distribute this software 
  11. and its documentation for any purpose and without fee is hereby 
  12. granted, provided that the above copyright notice appear in all 
  13. copies and that both that copyright notice and this permission 
  14. notice appear in supporting documentation, and that the names of 
  15. Hewlett-Packard, Digital or  M.I.T.  not be used in advertising or 
  16. publicity pertaining to distribution of the software without specific, 
  17. written prior permission.
  18.  
  19. DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
  20. ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
  21. DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
  22. ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
  23. WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
  24. ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  25. SOFTWARE.
  26.  
  27. ********************************************************/
  28.  
  29. #include "IntrinsicI.h"
  30. #include "PassivGraI.h"
  31.  
  32.  
  33. #define AllButtonsMask (Button1Mask | Button2Mask | Button3Mask | Button4Mask | Button5Mask)
  34.  
  35. Widget _XtProcessPointerEvent(event, widget, pdi)
  36.     XButtonEvent      *event;
  37.     Widget         widget;
  38.     XtPerDisplayInput     pdi;
  39. {    
  40.     XtDevice        device = &pdi->pointer;
  41.     XtServerGrabPtr    newGrab = NULL, devGrab = &device->grab;
  42.     Widget        dspWidget = NULL;
  43.     Boolean        deactivateGrab = FALSE;
  44.  
  45.     switch (event->type)
  46.       {
  47.     case ButtonPress:
  48.       {
  49.           if (!IsServerGrab(device->grabType))
  50.         {
  51.             Cardinal        i;
  52.  
  53.             for (i = pdi->traceDepth; 
  54.              i > 0 && !newGrab; 
  55.              i--)
  56.               newGrab = _XtCheckServerGrabsOnWidget((XEvent*)event, 
  57.                                 pdi->trace[i-1],
  58.                                 POINTER);
  59.         }
  60.           if (newGrab)
  61.         {
  62.             /* Activate the grab */
  63.             device->grab = *newGrab;
  64.             device->grabType = XtPassiveServerGrab;
  65.         }
  66.       }
  67.       break;
  68.       
  69.     case ButtonRelease:
  70.       {
  71.           if ((device->grabType == XtPassiveServerGrab) && 
  72.           !(event->state & ~(Button1Mask << (event->button - 1)) &
  73.             AllButtonsMask))
  74.         deactivateGrab = TRUE;
  75.       }
  76.       break;
  77.       }
  78.     
  79.     if (IsServerGrab(device->grabType) && !(devGrab)->ownerEvents)
  80.       dspWidget = (devGrab)->widget;
  81.     else
  82.       dspWidget = widget;
  83.     
  84.     if (deactivateGrab)
  85.       device->grabType = XtNoServerGrab;
  86.  
  87.     return dspWidget;
  88. }
  89.