1 /*****************************************************************************
2 Copyright 1987, 1988, 1989, 1990, 1991 by Digital Equipment Corp., Maynard, MA
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.
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
20 *****************************************************************************/
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.
40 #ifdef HAVE_DIX_CONFIG_H
41 #include <dix-config.h>
54 #include <X11/X.h> /* From library include environment */
55 #include "input.h" /* From server include env. (must be before Xlib.h!) */
57 # include "scrintst.h" /* Screen struct */
58 # include "extnsist.h"
60 # include "extnsionst.h" /* Server ExtensionEntry definitions */
61 # include "scrnintstr.h" /* Screen struct */
64 #include <X11/extensions/xtrapdi.h>
65 #include <X11/extensions/xtrapddmi.h>
66 #include <X11/extensions/xtrapproto.h>
68 extern int XETrapErrorBase
;
69 extern xXTrapGetAvailReply XETrap_avail
;
70 extern DevicePtr XETrapKbdDev
;
71 extern DevicePtr XETrapPtrDev
;
76 * This function performs the platform specific setup for server
77 * extension implementations.
79 void XETrapPlatformSetup()
88 * This routine processes the simulation of some input event.
91 int XETrapSimulateXEvent(register xXTrapInputReq
*request
,
92 register ClientPtr client
)
94 ScreenPtr pScr
= NULL
;
97 register int x
= request
->input
.x
;
98 register int y
= request
->input
.y
;
99 DevicePtr keydev
= LookupKeyboardDevice();
100 DevicePtr ptrdev
= LookupPointerDevice();
102 if (request
->input
.screen
< screenInfo
.numScreens
)
104 pScr
= screenInfo
.screens
[request
->input
.screen
];
107 { /* Trying to play bogus events to this WS! */
109 ErrorF("%s: Trying to send events to screen %d!\n", XTrapExtName
,
110 request
->input
.screen
);
112 status
= XETrapErrorBase
+ BadScreen
;
114 /* Fill in the event structure with the information
115 * Note: root, event, child, eventX, eventY, state, and sameScreen
116 * are all updated by FixUpEventFromWindow() when the events
117 * are delivered via DeliverDeviceEvents() or whatever. XTrap
118 * needs to only concern itself with type, detail, time, rootX,
121 if (status
== Success
)
123 xev
.u
.u
.type
= request
->input
.type
;
124 xev
.u
.u
.detail
= request
->input
.detail
;
125 xev
.u
.keyButtonPointer
.time
= GetTimeInMillis();
126 xev
.u
.keyButtonPointer
.rootX
= x
;
127 xev
.u
.keyButtonPointer
.rootY
= y
;
129 if (request
->input
.type
== MotionNotify
)
130 { /* Set new cursor position on screen */
131 XETrap_avail
.data
.cur_x
= x
;
132 XETrap_avail
.data
.cur_y
= y
;
133 NewCurrentScreen (pScr
, x
, y
); /* fix from amnonc@mercury.co.il */
134 if (!(*pScr
->SetCursorPosition
)(pScr
, x
, y
, xFalse
))
136 status
= BadImplementation
;
140 if (status
== Success
)
142 switch(request
->input
.type
)
143 { /* Now process the event appropriately */
146 (*XETrapKbdDev
->realInputProc
)(&xev
,(DeviceIntPtr
)keydev
, 1L);
151 (*XETrapPtrDev
->realInputProc
)(&xev
,(DeviceIntPtr
)ptrdev
, 1L);