home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-385-Vol-1of3.iso / x / xtrapv33.zip / extensions / server / xtrap / xtrapddmi.c < prev    next >
C/C++ Source or Header  |  1992-09-14  |  6KB  |  198 lines

  1. /*****************************************************************************
  2. Copyright 1987, 1988, 1989, 1990, 1991 by Digital Equipment Corp., Maynard, MA
  3.  
  4. Permission to use, copy, modify, and distribute this software and its 
  5. documentation for any purpose and without fee is hereby granted, 
  6. provided that the above copyright notice appear in all copies and that
  7. both that copyright notice and this permission notice appear in 
  8. supporting documentation, and that the name of Digital not be
  9. used in advertising or publicity pertaining to distribution of the
  10. software without specific, written prior permission.  
  11.  
  12. DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
  13. ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
  14. DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
  15. ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
  16. WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
  17. ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  18. SOFTWARE.
  19.  
  20. *****************************************************************************/
  21. /*
  22.  *  ABSTRACT:
  23.  *
  24.  *      This module is the platform-specific but conditionally independent
  25.  *      code for the XTrap extension (usually I/O or platform setup).
  26.  *      This is shared code and is subject to change only by team approval.
  27.  *
  28.  *  CONTRIBUTORS:
  29.  *
  30.  *      Dick Annicchiarico
  31.  *      Robert Chesler
  32.  *      Gene Durso
  33.  *      Marc Evans
  34.  *      Alan Jamison
  35.  *      Mark Henry
  36.  *      Ken Miller
  37.  *
  38.  */
  39. #ifndef lint
  40. static char RCSID[] = "$Header$";
  41. #endif
  42.  
  43. #include <errno.h>
  44. #include "Xos.h"
  45. #ifdef PC
  46. # include "fcntl.h"
  47. # include "io.h"
  48. # define O_NDELAY 0L
  49. #endif
  50.  
  51. #define NEED_REPLIES
  52. #define NEED_EVENTS
  53. #include "X.h"        /* From library include environment */
  54. #include "input.h"    /* From server include env. (must be before Xlib.h!) */
  55. #ifdef PC
  56. # include "scrninst.h"
  57. #else
  58. # include "scrnintstr.h"
  59. #endif
  60.  
  61. #include "xtrapdi.h"
  62. #include "xtrapddmi.h"
  63. #include "xtrapproto.h"
  64.  
  65. extern int XETrapErrorBase;
  66. extern xXTrapGetAvailReply XETrap_avail;
  67. extern DevicePtr XETrapKbdDev;
  68. extern DevicePtr XETrapPtrDev;
  69.  
  70. /*
  71.  *  DESCRIPTION:
  72.  *
  73.  *      This function performs the platform specific setup for server
  74.  *      extension implementations.
  75.  */
  76. void XETrapPlatformSetup()
  77. {
  78. }
  79.  
  80.  
  81. #if !defined _XINPUT
  82. /*
  83.  *  DESCRIPTION:
  84.  *
  85.  *  This routine processes the simulation of some input event.
  86.  *
  87.  */
  88. #ifdef FUNCTION_PROTOS
  89. int XETrapSimulateXEvent(register xXTrapInputReq *request,
  90.     register ClientPtr client)
  91. #else
  92. int XETrapSimulateXEvent(request, client)
  93.     register xXTrapInputReq *request;
  94.     register ClientPtr client;
  95. #endif
  96. {
  97.     ScreenPtr pScr;
  98.     int status = Success;
  99.     xEvent xev;
  100.     register int x = request->input.x;
  101.     register int y = request->input.y;
  102.     DevicePtr keydev = LookupKeyboardDevice();
  103.     DevicePtr ptrdev = LookupPointerDevice();
  104.  
  105.     if (request->input.screen < screenInfo.numScreens)
  106.     {
  107. #if (!defined X11R3 || defined MITR5)
  108.         pScr = screenInfo.screens[request->input.screen];
  109. #else
  110.         pScr = &screenInfo.screen[request->input.screen];
  111. #endif
  112.     }
  113.     else
  114.     {   /* Trying to play bogus events to this WS! */
  115. #ifdef VERBOSE
  116.         ErrorF("%s:  Trying to send events to screen %d!\n", XTrapExtName,
  117.             request->input.screen);
  118. #endif
  119.         status = XETrapErrorBase + BadScreen;
  120.     }
  121.     /* Fill in the event structure with the information
  122.      * Note:  root, event, child, eventX, eventY, state, and sameScreen
  123.      *        are all updated by FixUpEventFromWindow() when the events
  124.      *        are delivered via DeliverDeviceEvents() or whatever.  XTrap
  125.      *        needs to only concern itself with type, detail, time, rootX, 
  126.      *        and rootY.
  127.      */
  128.     if (status == Success)
  129.     {
  130.         xev.u.u.type   = request->input.type;
  131.         xev.u.u.detail = request->input.detail;
  132.         xev.u.keyButtonPointer.time   = GetTimeInMillis();
  133.         xev.u.keyButtonPointer.rootX = x;
  134.         xev.u.keyButtonPointer.rootY = y;
  135.  
  136.         if (request->input.type == MotionNotify)
  137.         {   /* Set new cursor position on screen */
  138.             XETrap_avail.data.cur_x = x;
  139.             XETrap_avail.data.cur_y = y;
  140.             if (!(*pScr->SetCursorPosition)(pScr, x, y, xFalse))
  141.             {
  142.                 status = BadImplementation;
  143.             }
  144.         }
  145.     }
  146.     if (status == Success)
  147.     {
  148.         switch(request->input.type)
  149.         {   /* Now process the event appropriately */
  150.             case KeyPress:
  151.             case KeyRelease:
  152. #if !defined X11R3 || defined VMSDW_V3
  153.                 (*XETrapKbdDev->realInputProc)(&xev,keydev, 1L);
  154. #else
  155.                 (*XETrapKbdDev->processInputProc)(&xev,keydev);
  156. #endif
  157.                 break;
  158.             case MotionNotify:
  159.             case ButtonPress:
  160.             case ButtonRelease:
  161. #if !defined X11R3 || defined VMSDW_V3
  162.                 (*XETrapPtrDev->realInputProc)(&xev,ptrdev, 1L);
  163. #else
  164.                 (*XETrapPtrDev->processInputProc)(&xev,ptrdev);
  165. #endif
  166.                 break;
  167.             default:
  168.                 status = BadValue;
  169.                 break;
  170.         }
  171.     }
  172.     return(status);
  173. }
  174. #endif /* _XINPUT */
  175.  
  176. #if defined vms && !defined LINKED_IN
  177. /* Used by swapping code not visible from VMS (from main.c) */
  178. #ifndef BLADE
  179. void
  180. NotImplemented()
  181. {
  182.     FatalError("Not implemented");
  183. }
  184. #endif
  185.  
  186. int
  187. #ifdef __STDC__
  188. ProcBadRequest( ClientPtr client)
  189. #else
  190. ProcBadRequest(client)
  191.     ClientPtr client;
  192. #endif
  193. {
  194.     return (BadRequest);
  195. }
  196.  
  197. #endif /* vms && ! LINKED_IN */
  198.