home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / X / mit / extensions / server / xinput / xsetfocus.c < prev    next >
Encoding:
C/C++ Source or Header  |  1990-05-18  |  2.9 KB  |  97 lines

  1. /* $XConsortium: xsetfocus.c,v 1.5 90/05/18 14:15:11 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.  * Request to set the focus for an extension device.
  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 "windowstr.h"            /* focus struct      */
  38. #include "inputstr.h"            /* DeviceIntPtr         */
  39. #include "XI.h"
  40. #include "XIproto.h"
  41.  
  42. extern    int         IReqCode;
  43. extern    int        BadDevice;
  44. extern    InputInfo    inputInfo;
  45. extern    void        (* ReplySwapVector[256]) ();
  46. DeviceIntPtr        LookupDeviceIntRec();
  47.  
  48. /***********************************************************************
  49.  *
  50.  * This procedure sets the focus for a device.
  51.  *
  52.  */
  53.  
  54. int
  55. SProcXSetDeviceFocus(client)
  56.     register ClientPtr client;
  57.     {
  58.     register char n;
  59.  
  60.     REQUEST(xSetDeviceFocusReq);
  61.     swaps(&stuff->length, n);
  62.     swapl(&stuff->focus, n);
  63.     swapl(&stuff->time, n);
  64.     return(ProcXSetDeviceFocus(client));
  65.     }
  66.  
  67. /***********************************************************************
  68.  *
  69.  * This procedure sets the focus for a device.
  70.  *
  71.  */
  72.  
  73. int
  74. ProcXSetDeviceFocus(client)
  75.     register ClientPtr client;
  76.     {
  77.     int                ret;
  78.     register DeviceIntPtr    dev;
  79.  
  80.     REQUEST(xSetDeviceFocusReq);
  81.     REQUEST_SIZE_MATCH(xSetDeviceFocusReq);
  82.  
  83.     dev = LookupDeviceIntRec (stuff->device);
  84.     if (dev==NULL || !dev->focus)
  85.     {
  86.     SendErrorToClient(client, IReqCode, X_SetDeviceFocus, 0, BadDevice);
  87.     return Success;
  88.     }
  89.  
  90.     ret = SetInputFocus (client, dev, stuff->focus, stuff->revertTo, 
  91.     stuff->time, TRUE);
  92.     if (ret != Success)
  93.     SendErrorToClient(client, IReqCode, X_SetDeviceFocus, 0, ret);
  94.  
  95.     return Success;
  96.     }
  97.