added the initial version of the XOrg support. still lots of cleaning up that needs...
[openwrt/svn-archive/archive.git] / XOrg / server / xorg-kdrive-X11R7.2 / patches / xcalibrate.patch
1 --- xorg-server-X11R7.1-1.1.0/mi/miinitext.c.orig 2006-06-22 14:11:46.000000000 +0200
2 +++ xorg-server-X11R7.1-1.1.0/mi/miinitext.c 2006-06-22 15:26:17.000000000 +0200
3 @@ -385,6 +385,9 @@
4 #ifdef DMXEXT
5 extern void DMXExtensionInit(INITARGS);
6 #endif
7 +#ifdef XCALIBRATE
8 +extern void XCalibrateExtensionInit(INITARGS);
9 +#endif
10 #ifdef XEVIE
11 extern void XevieExtensionInit(INITARGS);
12 #endif
13 @@ -679,6 +682,9 @@
14 #ifdef DAMAGE
15 if (!noDamageExtension) DamageExtensionInit();
16 #endif
17 +#ifdef XCALIBRATE
18 + XCalibrateExtensionInit ();
19 +#endif
20 }
21
22 void
23 --- xorg-server-X11R7.1-1.1.0/configure.ac.orig 2006-06-15 17:03:14.000000000 +0200
24 +++ xorg-server-X11R7.1-1.1.0/configure.ac 2006-06-24 08:21:25.000000000 +0200
25 @@ -407,6 +407,7 @@
26 AC_ARG_ENABLE(xf86vidmode, AS_HELP_STRING([--disable-xf86vidmode], [Build XF86VidMode extension (default: enabled)]), [XF86VIDMODE=$enableval], [XF86VIDMODE=yes])
27 AC_ARG_ENABLE(xf86misc, AS_HELP_STRING([--disable-xf86misc], [Build XF86Misc extension (default: enabled)]), [XF86MISC=$enableval], [XF86MISC=yes])
28 AC_ARG_ENABLE(xcsecurity, AS_HELP_STRING([--disable-xcsecurity], [Build Security extension (default: enabled)]), [XCSECURITY=$enableval], [XCSECURITY=yes])
29 +AC_ARG_ENABLE(xcalibrate, AS_HELP_STRING([--enable-xcalibrate], [Build XCalibrate extension (default: disabled)]), [XCALIBRATE=$enableval], [XCALIBRATE=no])
30 AC_ARG_ENABLE(xevie, AS_HELP_STRING([--disable-xevie], [Build XEvIE extension (default: enabled)]), [XEVIE=$enableval], [XEVIE=yes])
31 AC_ARG_ENABLE(lbx, AS_HELP_STRING([--disable-lbx], [Build LBX extension (default: no)]), [LBX=$enableval], [LBX=no])
32 AC_ARG_ENABLE(appgroup, AS_HELP_STRING([--disable-appgroup], [Build XC-APPGROUP extension (default: enabled)]), [APPGROUP=$enableval], [APPGROUP=yes])
33 @@ -641,6 +642,12 @@
34 AC_DEFINE(XCSECURITY, 1, [Build Security extension])
35 fi
36
37 +AM_CONDITIONAL(XCALIBRATE, [test "x$XCALIBRATE" = xyes])
38 +if test "x$XCALIBRATE" = xyes; then
39 + AC_DEFINE(XCALIBRATE, 1, [Build XCalibrate extension])
40 + REQUIRED_MODULES="$REQUIRED_MODULES xcalibrateproto"
41 +fi
42 +
43 AM_CONDITIONAL(XEVIE, [test "x$XEVIE" = xyes])
44 if test "x$XEVIE" = xyes; then
45 AC_DEFINE(XEVIE, 1, [Build XEvIE extension])
46 @@ -1466,7 +1473,7 @@
47 KDRIVE_LIB='$(top_builddir)/hw/kdrive/src/libkdrive.a'
48 KDRIVE_OS_LIB='$(top_builddir)/hw/kdrive/linux/liblinux.a'
49 KDRIVE_STUB_LIB='$(top_builddir)/hw/kdrive/src/libkdrivestubs.a'
50 - KDRIVE_LIBS="$DIX_LIB $KDRIVE_LIB $KDRIVE_OS_LIB $KDRIVE_PURE_LIBS $KDRIVE_STUB_LIB"
51 + KDRIVE_LIBS="$DIX_LIB $KDRIVE_LIB $KDRIVE_PURE_LIBS $KDRIVE_OS_LIB $KDRIVE_STUB_LIB"
52
53 # check if we can build Xephyr
54 PKG_CHECK_MODULES(XEPHYR, x11 xext xfont xau xdmcp, [xephyr="yes"], [xephyr="no"])
55 --- xorg-server-X11R7.1-1.1.0/include/kdrive-config.h.in.orig 2006-06-22 14:22:07.000000000 +0200
56 +++ xorg-server-X11R7.1-1.1.0/include/kdrive-config.h.in 2006-06-22 14:33:29.000000000 +0200
57 @@ -22,4 +22,7 @@
58 /* Support tslib touchscreen abstraction library */
59 #undef TSLIB
60
61 +/* Enable XCalibrate extension */
62 +#undef XCALIBRATE
63 +
64 #endif /* _KDRIVE_CONFIG_H_ */
65 --- xorg-server-X11R7.1-1.1.0/Xext/Makefile.am.orig 2006-06-15 17:06:43.000000000 +0200
66 +++ xorg-server-X11R7.1-1.1.0/Xext/Makefile.am 2006-06-15 18:12:40.000000000 +0200
67 @@ -78,6 +78,11 @@
68 AM_CFLAGS += -DDEFAULTPOLICYFILE=\"$(SERVERCONFIGdir)/SecurityPolicy\"
69 endif
70
71 +XCALIBRATE_SRCS = xcalibrate.c
72 +if XCALIBRATE
73 +BUILTIN_SRCS += $(XCALIBRATE_SRCS)
74 +endif
75 +
76 # X EVent Interception Extension: allows accessibility helpers & composite
77 # managers to intercept events from input devices and transform as needed
78 # before the clients see them.
79 @@ -155,6 +160,7 @@
80 $(SCREENSAVER_SRCS) \
81 $(XCSECURITY_SRCS) \
82 $(XINERAMA_SRCS) \
83 + $(XCALIBRATE_SRCS) \
84 $(XEVIE_SRCS) \
85 $(XPRINT_SRCS) \
86 $(APPGROUP_SRCS) \
87 --- xorg-server-X11R7.1-1.1.0/Xext/xcalibrate.c.orig 2006-06-15 17:05:19.000000000 +0200
88 +++ xorg-server-X11R7.1-1.1.0/Xext/xcalibrate.c 2006-06-22 15:15:09.000000000 +0200
89 @@ -0,0 +1,262 @@
90 +/*
91 + * $Id: xcalibrate.c,v 3.1 2004/06/02 20:49:50 pb Exp $
92 + *
93 + * Copyright © 2003 Philip Blundell
94 + *
95 + * Permission to use, copy, modify, distribute, and sell this software and its
96 + * documentation for any purpose is hereby granted without fee, provided that
97 + * the above copyright notice appear in all copies and that both that
98 + * copyright notice and this permission notice appear in supporting
99 + * documentation, and that the name of Philip Blundell not be used in
100 + * advertising or publicity pertaining to distribution of the software without
101 + * specific, written prior permission. Philip Blundell makes no
102 + * representations about the suitability of this software for any purpose. It
103 + * is provided "as is" without express or implied warranty.
104 + *
105 + * PHILIP BLUNDELL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
106 + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
107 + * EVENT SHALL PHILIP BLUNDELL BE LIABLE FOR ANY SPECIAL, INDIRECT OR
108 + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
109 + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
110 + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
111 + * PERFORMANCE OF THIS SOFTWARE.
112 + */
113 +
114 +#ifdef HAVE_KDRIVE_CONFIG_H
115 +#include <kdrive-config.h>
116 +#endif
117 +
118 +#define NEED_EVENTS
119 +#define NEED_REPLIES
120 +
121 +#include <X11/X.h>
122 +#include <X11/Xproto.h>
123 +#include "misc.h"
124 +#include "os.h"
125 +#include "dixstruct.h"
126 +#include "extnsionst.h"
127 +#include "swaprep.h"
128 +
129 +#include <X11/extensions/xcalibrateproto.h>
130 +#include <X11/extensions/xcalibratewire.h>
131 +
132 +extern void (*tslib_raw_event_hook)(int x, int y, int pressure, void *closure);
133 +extern void *tslib_raw_event_closure;
134 +
135 +static CARD8 XCalibrateReqCode;
136 +int XCalibrateEventBase;
137 +int XCalibrateReqBase;
138 +int XCalibrateErrorBase;
139 +
140 +static ClientPtr xcalibrate_client;
141 +
142 +static void
143 +xcalibrate_event_hook (int x, int y, int pressure, void *closure)
144 +{
145 + ClientPtr pClient = (ClientPtr) closure;
146 + xXCalibrateRawTouchscreenEvent ev;
147 +
148 + ev.type = XCalibrateEventBase + X_XCalibrateRawTouchscreen;
149 + ev.sequenceNumber = pClient->sequence;
150 + ev.x = x;
151 + ev.y = y;
152 + ev.pressure = pressure;
153 +
154 + if (!pClient->clientGone)
155 + WriteEventsToClient (pClient, 1, (xEvent *) &ev);
156 +}
157 +
158 +static int
159 +ProcXCalibrateQueryVersion (ClientPtr client)
160 +{
161 + REQUEST(xXCalibrateQueryVersionReq);
162 + xXCalibrateQueryVersionReply rep;
163 + CARD16 client_major, client_minor; /* not used */
164 +
165 + REQUEST_SIZE_MATCH (xXCalibrateQueryVersionReq);
166 +
167 + client_major = stuff->majorVersion;
168 + client_minor = stuff->minorVersion;
169 +
170 + fprintf(stderr, "%s(): called\n", __func__);
171 +
172 + rep.type = X_Reply;
173 + rep.length = 0;
174 + rep.sequenceNumber = client->sequence;
175 + rep.majorVersion = XCALIBRATE_MAJOR_VERSION;
176 + rep.minorVersion = XCALIBRATE_MINOR_VERSION;
177 + if (client->swapped) {
178 + int n;
179 + swaps(&rep.sequenceNumber, n);
180 + swapl(&rep.length, n);
181 + swaps(&rep.majorVersion, n);
182 + swaps(&rep.minorVersion, n);
183 + }
184 + WriteToClient(client, sizeof (xXCalibrateQueryVersionReply), (char *)&rep);
185 + return (client->noClientException);
186 +}
187 +
188 +static int
189 +SProcXCalibrateQueryVersion (ClientPtr client)
190 +{
191 + REQUEST(xXCalibrateQueryVersionReq);
192 + int n;
193 +
194 + REQUEST_SIZE_MATCH (xXCalibrateQueryVersionReq);
195 + swaps(&stuff->majorVersion,n);
196 + swaps(&stuff->minorVersion,n);
197 + return ProcXCalibrateQueryVersion(client);
198 +}
199 +
200 +static int
201 +ProcXCalibrateSetRawMode (ClientPtr client)
202 +{
203 + REQUEST(xXCalibrateRawModeReq);
204 + xXCalibrateRawModeReply rep;
205 +
206 + REQUEST_SIZE_MATCH (xXCalibrateRawModeReq);
207 +
208 + memset (&rep, 0, sizeof (rep));
209 + rep.type = X_Reply;
210 + rep.sequenceNumber = client->sequence;
211 +
212 + if (stuff->on)
213 + {
214 + if (xcalibrate_client == NULL)
215 + {
216 + /* Start calibrating. */
217 + xcalibrate_client = client;
218 + tslib_raw_event_hook = xcalibrate_event_hook;
219 + tslib_raw_event_closure = client;
220 + rep.status = GrabSuccess;
221 + }
222 + else
223 + {
224 + rep.status = AlreadyGrabbed;
225 + }
226 + }
227 + else
228 + {
229 + if (xcalibrate_client == client)
230 + {
231 + /* Stop calibrating. */
232 + xcalibrate_client = NULL;
233 + tslib_raw_event_hook = NULL;
234 + tslib_raw_event_closure = NULL;
235 + rep.status = GrabSuccess;
236 +
237 + /* Cycle input off and on to reload configuration. */
238 + KdDisableInput ();
239 + KdEnableInput ();
240 + }
241 + else
242 + {
243 + rep.status = AlreadyGrabbed;
244 + }
245 + }
246 +
247 + if (client->swapped)
248 + {
249 + int n;
250 +
251 + swaps (&rep.sequenceNumber, n);
252 + swaps (&rep.status, n);
253 + }
254 + WriteToClient(client, sizeof (rep), (char *) &rep);
255 + return (client->noClientException);
256 +}
257 +
258 +
259 +static int
260 +SProcXCalibrateSetRawMode (ClientPtr client)
261 +{
262 + REQUEST(xXCalibrateRawModeReq);
263 + int n;
264 +
265 + REQUEST_SIZE_MATCH (xXCalibrateRawModeReq);
266 +
267 + swaps(&stuff->on, n);
268 +
269 + return ProcXCalibrateSetRawMode(client);
270 +}
271 +
272 +static void
273 +XCalibrateResetProc (ExtensionEntry *extEntry)
274 +{
275 +}
276 +
277 +static int
278 +ProcXCalibrateDispatch (ClientPtr client)
279 +{
280 + REQUEST(xReq);
281 + switch (stuff->data) {
282 + case X_XCalibrateQueryVersion:
283 + return ProcXCalibrateQueryVersion(client);
284 + case X_XCalibrateRawMode:
285 + return ProcXCalibrateSetRawMode(client);
286 + default: break;
287 + }
288 +
289 + return BadRequest;
290 +}
291 +
292 +static int
293 +SProcXCalibrateDispatch (ClientPtr client)
294 +{
295 + REQUEST(xReq);
296 + int n;
297 +
298 + swaps(&stuff->length,n);
299 +
300 + switch (stuff->data) {
301 + case X_XCalibrateQueryVersion:
302 + return SProcXCalibrateQueryVersion(client);
303 + case X_XCalibrateRawMode:
304 + return SProcXCalibrateSetRawMode(client);
305 +
306 + default: break;
307 + }
308 +
309 + return BadRequest;
310 +}
311 +
312 +static void
313 +XCalibrateClientCallback (CallbackListPtr *list,
314 + pointer closure,
315 + pointer data)
316 +{
317 + NewClientInfoRec *clientinfo = (NewClientInfoRec *) data;
318 + ClientPtr pClient = clientinfo->client;
319 +
320 + if (clientinfo->setup == NULL
321 + && xcalibrate_client != NULL
322 + && xcalibrate_client == pClient)
323 + {
324 + /* Stop calibrating. */
325 + xcalibrate_client = NULL;
326 + tslib_raw_event_hook = NULL;
327 + tslib_raw_event_closure = NULL;
328 + }
329 +}
330 +
331 +void
332 +XCalibrateExtensionInit(void)
333 +{
334 + ExtensionEntry *extEntry;
335 +
336 + if (!AddCallback (&ClientStateCallback, XCalibrateClientCallback, 0))
337 + return;
338 +
339 + extEntry = AddExtension(XCALIBRATE_NAME, XCalibrateNumberEvents, XCalibrateNumberErrors,
340 + ProcXCalibrateDispatch, SProcXCalibrateDispatch,
341 + XCalibrateResetProc, StandardMinorOpcode);
342 +
343 + if (!extEntry)
344 + return;
345 +
346 + XCalibrateReqCode = (unsigned char)extEntry->base;
347 + XCalibrateEventBase = extEntry->eventBase;
348 + XCalibrateErrorBase = extEntry->errorBase;
349 +
350 + xcalibrate_client = 0;
351 +}