home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / X / mit / extensions / server / xinput / xallowev.c < prev    next >
Encoding:
C/C++ Source or Header  |  1989-12-02  |  3.4 KB  |  117 lines

  1. /* $XConsortium: xallowev.c,v 1.6 89/12/02 15:20:24 rws Exp $ */
  2.  
  3. /************************************************************
  4. Copyright (c) 1989 by Hewlett-Packard Company, Palo Alto, California, and the 
  5. Massachusetts Institute of Technology, Cambridge, Massachusetts.
  6.  
  7.             All Rights Reserved
  8.  
  9. Permission to use, copy, modify, and distribute this software and its
  10. documentation for any purpose and without fee is hereby granted,
  11. provided that the above copyright notice appear in all copies and that
  12. both that copyright notice and this permission notice appear in
  13. supporting documentation, and that the names of Hewlett-Packard or MIT not be
  14. used in advertising or publicity pertaining to distribution of the
  15. software without specific, written prior permission.
  16.  
  17. HEWLETT-PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
  18. ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
  19. HEWLETT-PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
  20. ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
  21. WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
  22. ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  23. SOFTWARE.
  24.  
  25. ********************************************************/
  26.  
  27. /***********************************************************************
  28.  *
  29.  * Function to allow frozen events to be routed from extension input devices.
  30.  *
  31.  */
  32.  
  33. #define     NEED_EVENTS
  34. #define     NEED_REPLIES
  35. #include "X.h"                /* for inputstr.h    */
  36. #include "Xproto.h"            /* Request macro     */
  37. #include "inputstr.h"            /* DeviceIntPtr         */
  38. #include "XI.h"
  39. #include "XIproto.h"
  40.  
  41. extern    int         IReqCode;
  42. extern    int         BadDevice;
  43. extern    void        (* ReplySwapVector[256]) ();
  44. DeviceIntPtr        LookupDeviceIntRec();
  45.  
  46. /***********************************************************************
  47.  *
  48.  * This procedure allows frozen events to be routed.
  49.  *
  50.  */
  51.  
  52. int
  53. SProcXAllowDeviceEvents(client)
  54.     register ClientPtr client;
  55.     {
  56.     register char n;
  57.  
  58.     REQUEST(xAllowDeviceEventsReq);
  59.     swapl(&stuff->time, n);
  60.     swaps(&stuff->length, n);
  61.     return(ProcXAllowDeviceEvents(client));
  62.     }
  63.  
  64. /***********************************************************************
  65.  *
  66.  * This procedure allows frozen events to be routed.
  67.  *
  68.  */
  69.  
  70. int
  71. ProcXAllowDeviceEvents(client)
  72.     register ClientPtr client;
  73.     {
  74.     TimeStamp        time;
  75.     DeviceIntPtr    thisdev;
  76.     void AllowSome ();
  77.  
  78.     REQUEST(xAllowDeviceEventsReq);
  79.     REQUEST_SIZE_MATCH(xAllowDeviceEventsReq);
  80.  
  81.     thisdev = LookupDeviceIntRec (stuff->deviceid);
  82.     if (thisdev == NULL)
  83.     {
  84.     SendErrorToClient(client, IReqCode, X_AllowDeviceEvents, 0, BadDevice);
  85.     return Success;
  86.     }
  87.     time = ClientTimeToServerTime(stuff->time);
  88.  
  89.     switch (stuff->mode)
  90.         {
  91.     case ReplayThisDevice:
  92.         AllowSome(client, time, thisdev, NOT_GRABBED);
  93.         break;
  94.     case SyncThisDevice: 
  95.         AllowSome(client, time, thisdev, FREEZE_NEXT_EVENT);
  96.         break;
  97.     case AsyncThisDevice: 
  98.         AllowSome(client, time, thisdev, THAWED);
  99.         break;
  100.     case AsyncOtherDevices: 
  101.         AllowSome(client, time, thisdev, THAW_OTHERS);
  102.         break;
  103.     case SyncAll:
  104.         AllowSome(client, time, thisdev, FREEZE_BOTH_NEXT_EVENT);
  105.         break;
  106.     case AsyncAll:
  107.         AllowSome(client, time, thisdev, THAWED_BOTH);
  108.         break;
  109.     default: 
  110.         SendErrorToClient(client, IReqCode, X_AllowDeviceEvents, 0, 
  111.         BadValue);
  112.         client->errorValue = stuff->mode;
  113.         return Success;
  114.         }
  115.     return Success;
  116.     }
  117.