1 /************************************************************
3 Copyright 1987, 1998 The Open Group
5 Permission to use, copy, modify, distribute, and sell this software and its
6 documentation for any purpose is hereby granted without fee, provided that
7 the above copyright notice appear in all copies and that both that
8 copyright notice and this permission notice appear in supporting
11 The above copyright notice and this permission notice shall be included in
12 all copies or substantial portions of the Software.
14 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
18 AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
19 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21 Except as contained in this notice, the name of The Open Group shall not be
22 used in advertising or otherwise to promote the sale, use or other dealings
23 in this Software without prior written authorization from The Open Group.
25 Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
29 Permission to use, copy, modify, and distribute this software and its
30 documentation for any purpose and without fee is hereby granted,
31 provided that the above copyright notice appear in all copies and that
32 both that copyright notice and this permission notice appear in
33 supporting documentation, and that the name of Digital not be
34 used in advertising or publicity pertaining to distribution of the
35 software without specific, written prior permission.
37 DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
38 ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
39 DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
40 ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
41 WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
42 ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
45 ********************************************************/
47 #ifdef HAVE_DIX_CONFIG_H
48 #include <dix-config.h>
52 #include <X11/Xproto.h>
54 #include "dixstruct.h"
55 #include <X11/fonts/fontstruct.h>
56 #include "scrnintstr.h"
60 static void SwapFontInfo(xQueryFontReply
* pr
);
62 static void SwapCharInfo(xCharInfo
* pInfo
);
64 static void SwapFont(xQueryFontReply
* pr
, Bool hasGlyphs
);
67 * Thanks to Jack Palevich for testing and subsequently rewriting all this
69 * \param size size in bytes
72 Swap32Write(ClientPtr pClient
, int size
, CARD32
*pbuf
)
77 for (i
= 0; i
< size
; i
++)
78 /* brackets are mandatory here, because "swapl" macro expands
79 to several statements */
83 WriteToClient(pClient
, size
<< 2, pbuf
);
88 * \param size size in bytes
91 CopySwap32Write(ClientPtr pClient
, int size
, CARD32
*pbuf
)
95 CARD32
*from
, *to
, *fromLast
, *toLast
;
98 /* Allocate as big a buffer as we can... */
99 while (!(pbufT
= malloc(bufsize
))) {
107 /* convert lengths from # of bytes to # of longs */
112 fromLast
= from
+ size
;
113 while (from
< fromLast
) {
117 toLast
= to
+ min(bufsize
, fromLast
- from
);
118 nbytes
= (toLast
- to
) << 2;
119 while (to
< toLast
) {
120 /* can't write "cpswapl(*from++, *to++)" because cpswapl is a macro
121 that evaulates its args more than once */
126 WriteToClient(pClient
, nbytes
, pbufT
);
135 * \param size size in bytes
138 CopySwap16Write(ClientPtr pClient
, int size
, short *pbuf
)
142 short *from
, *to
, *fromLast
, *toLast
;
145 /* Allocate as big a buffer as we can... */
146 while (!(pbufT
= malloc(bufsize
))) {
154 /* convert lengths from # of bytes to # of shorts */
159 fromLast
= from
+ size
;
160 while (from
< fromLast
) {
164 toLast
= to
+ min(bufsize
, fromLast
- from
);
165 nbytes
= (toLast
- to
) << 1;
166 while (to
< toLast
) {
167 /* can't write "cpswaps(*from++, *to++)" because cpswaps is a macro
168 that evaulates its args more than once */
173 WriteToClient(pClient
, nbytes
, pbufT
);
180 /* Extra-small reply */
182 SGenericReply(ClientPtr pClient
, int size
, xGenericReply
* pRep
)
184 swaps(&pRep
->sequenceNumber
);
185 WriteToClient(pClient
, size
, pRep
);
188 /* Extra-large reply */
190 SGetWindowAttributesReply(ClientPtr pClient
, int size
,
191 xGetWindowAttributesReply
* pRep
)
193 swaps(&pRep
->sequenceNumber
);
194 swapl(&pRep
->length
);
195 swapl(&pRep
->visualID
);
197 swapl(&pRep
->backingBitPlanes
);
198 swapl(&pRep
->backingPixel
);
199 swapl(&pRep
->colormap
);
200 swapl(&pRep
->allEventMasks
);
201 swapl(&pRep
->yourEventMask
);
202 swaps(&pRep
->doNotPropagateMask
);
203 WriteToClient(pClient
, size
, pRep
);
207 SGetGeometryReply(ClientPtr pClient
, int size
, xGetGeometryReply
* pRep
)
209 swaps(&pRep
->sequenceNumber
);
214 swaps(&pRep
->height
);
215 swaps(&pRep
->borderWidth
);
216 WriteToClient(pClient
, size
, pRep
);
220 SQueryTreeReply(ClientPtr pClient
, int size
, xQueryTreeReply
* pRep
)
222 swaps(&pRep
->sequenceNumber
);
223 swapl(&pRep
->length
);
225 swapl(&pRep
->parent
);
226 swaps(&pRep
->nChildren
);
227 WriteToClient(pClient
, size
, pRep
);
231 SInternAtomReply(ClientPtr pClient
, int size
, xInternAtomReply
* pRep
)
233 swaps(&pRep
->sequenceNumber
);
235 WriteToClient(pClient
, size
, pRep
);
239 SGetAtomNameReply(ClientPtr pClient
, int size
, xGetAtomNameReply
* pRep
)
241 swaps(&pRep
->sequenceNumber
);
242 swapl(&pRep
->length
);
243 swaps(&pRep
->nameLength
);
244 WriteToClient(pClient
, size
, pRep
);
248 SGetPropertyReply(ClientPtr pClient
, int size
, xGetPropertyReply
* pRep
)
250 swaps(&pRep
->sequenceNumber
);
251 swapl(&pRep
->length
);
252 swapl(&pRep
->propertyType
);
253 swapl(&pRep
->bytesAfter
);
254 swapl(&pRep
->nItems
);
255 WriteToClient(pClient
, size
, pRep
);
259 SListPropertiesReply(ClientPtr pClient
, int size
, xListPropertiesReply
* pRep
)
261 swaps(&pRep
->sequenceNumber
);
262 swapl(&pRep
->length
);
263 swaps(&pRep
->nProperties
);
264 WriteToClient(pClient
, size
, pRep
);
268 SGetSelectionOwnerReply(ClientPtr pClient
, int size
,
269 xGetSelectionOwnerReply
* pRep
)
271 swaps(&pRep
->sequenceNumber
);
273 WriteToClient(pClient
, size
, pRep
);
277 SQueryPointerReply(ClientPtr pClient
, int size
, xQueryPointerReply
* pRep
)
279 swaps(&pRep
->sequenceNumber
);
287 WriteToClient(pClient
, size
, pRep
);
291 SwapTimecoord(xTimecoord
* pCoord
)
293 swapl(&pCoord
->time
);
299 SwapTimeCoordWrite(ClientPtr pClient
, int size
, xTimecoord
* pRep
)
304 n
= size
/ sizeof(xTimecoord
);
306 for (i
= 0; i
< n
; i
++) {
307 SwapTimecoord(pRepT
);
310 WriteToClient(pClient
, size
, pRep
);
315 SGetMotionEventsReply(ClientPtr pClient
, int size
, xGetMotionEventsReply
* pRep
)
317 swaps(&pRep
->sequenceNumber
);
318 swapl(&pRep
->length
);
319 swapl(&pRep
->nEvents
);
320 WriteToClient(pClient
, size
, pRep
);
324 STranslateCoordsReply(ClientPtr pClient
, int size
, xTranslateCoordsReply
* pRep
)
326 swaps(&pRep
->sequenceNumber
);
330 WriteToClient(pClient
, size
, pRep
);
334 SGetInputFocusReply(ClientPtr pClient
, int size
, xGetInputFocusReply
* pRep
)
336 swaps(&pRep
->sequenceNumber
);
338 WriteToClient(pClient
, size
, pRep
);
341 /* extra long reply */
343 SQueryKeymapReply(ClientPtr pClient
, int size
, xQueryKeymapReply
* pRep
)
345 swaps(&pRep
->sequenceNumber
);
346 swapl(&pRep
->length
);
347 WriteToClient(pClient
, size
, pRep
);
351 SwapCharInfo(xCharInfo
* pInfo
)
353 swaps(&pInfo
->leftSideBearing
);
354 swaps(&pInfo
->rightSideBearing
);
355 swaps(&pInfo
->characterWidth
);
356 swaps(&pInfo
->ascent
);
357 swaps(&pInfo
->descent
);
358 swaps(&pInfo
->attributes
);
362 SwapFontInfo(xQueryFontReply
* pr
)
364 swaps(&pr
->minCharOrByte2
);
365 swaps(&pr
->maxCharOrByte2
);
366 swaps(&pr
->defaultChar
);
367 swaps(&pr
->nFontProps
);
368 swaps(&pr
->fontAscent
);
369 swaps(&pr
->fontDescent
);
370 SwapCharInfo(&pr
->minBounds
);
371 SwapCharInfo(&pr
->maxBounds
);
372 swapl(&pr
->nCharInfos
);
376 SwapFont(xQueryFontReply
* pr
, Bool hasGlyphs
)
380 unsigned nchars
, nprops
;
383 swaps(&pr
->sequenceNumber
);
385 nchars
= pr
->nCharInfos
;
386 nprops
= pr
->nFontProps
;
388 pby
= (char *) &pr
[1];
389 /* Font properties are an atom and either an int32 or a CARD32, so
390 * they are always 2 4 byte values */
391 for (i
= 0; i
< nprops
; i
++) {
398 pxci
= (xCharInfo
*) pby
;
399 for (i
= 0; i
< nchars
; i
++, pxci
++)
405 SQueryFontReply(ClientPtr pClient
, int size
, xQueryFontReply
* pRep
)
407 SwapFont(pRep
, TRUE
);
408 WriteToClient(pClient
, size
, pRep
);
412 SQueryTextExtentsReply(ClientPtr pClient
, int size
,
413 xQueryTextExtentsReply
* pRep
)
415 swaps(&pRep
->sequenceNumber
);
416 swaps(&pRep
->fontAscent
);
417 swaps(&pRep
->fontDescent
);
418 swaps(&pRep
->overallAscent
);
419 swaps(&pRep
->overallDescent
);
420 swapl(&pRep
->overallWidth
);
421 swapl(&pRep
->overallLeft
);
422 swapl(&pRep
->overallRight
);
423 WriteToClient(pClient
, size
, pRep
);
427 SListFontsReply(ClientPtr pClient
, int size
, xListFontsReply
* pRep
)
429 swaps(&pRep
->sequenceNumber
);
430 swapl(&pRep
->length
);
431 swaps(&pRep
->nFonts
);
432 WriteToClient(pClient
, size
, pRep
);
436 SListFontsWithInfoReply(ClientPtr pClient
, int size
,
437 xListFontsWithInfoReply
* pRep
)
439 SwapFont((xQueryFontReply
*) pRep
, FALSE
);
440 WriteToClient(pClient
, size
, pRep
);
444 SGetFontPathReply(ClientPtr pClient
, int size
, xGetFontPathReply
* pRep
)
446 swaps(&pRep
->sequenceNumber
);
447 swapl(&pRep
->length
);
448 swaps(&pRep
->nPaths
);
449 WriteToClient(pClient
, size
, pRep
);
453 SGetImageReply(ClientPtr pClient
, int size
, xGetImageReply
* pRep
)
455 swaps(&pRep
->sequenceNumber
);
456 swapl(&pRep
->length
);
457 swapl(&pRep
->visual
);
458 WriteToClient(pClient
, size
, pRep
);
459 /* Fortunately, image doesn't need swapping */
463 SListInstalledColormapsReply(ClientPtr pClient
, int size
,
464 xListInstalledColormapsReply
* pRep
)
466 swaps(&pRep
->sequenceNumber
);
467 swapl(&pRep
->length
);
468 swaps(&pRep
->nColormaps
);
469 WriteToClient(pClient
, size
, pRep
);
473 SAllocColorReply(ClientPtr pClient
, int size
, xAllocColorReply
* pRep
)
475 swaps(&pRep
->sequenceNumber
);
480 WriteToClient(pClient
, size
, pRep
);
484 SAllocNamedColorReply(ClientPtr pClient
, int size
, xAllocNamedColorReply
* pRep
)
486 swaps(&pRep
->sequenceNumber
);
488 swaps(&pRep
->exactRed
);
489 swaps(&pRep
->exactGreen
);
490 swaps(&pRep
->exactBlue
);
491 swaps(&pRep
->screenRed
);
492 swaps(&pRep
->screenGreen
);
493 swaps(&pRep
->screenBlue
);
494 WriteToClient(pClient
, size
, pRep
);
498 SAllocColorCellsReply(ClientPtr pClient
, int size
, xAllocColorCellsReply
* pRep
)
500 swaps(&pRep
->sequenceNumber
);
501 swapl(&pRep
->length
);
502 swaps(&pRep
->nPixels
);
503 swaps(&pRep
->nMasks
);
504 WriteToClient(pClient
, size
, pRep
);
508 SAllocColorPlanesReply(ClientPtr pClient
, int size
,
509 xAllocColorPlanesReply
* pRep
)
511 swaps(&pRep
->sequenceNumber
);
512 swapl(&pRep
->length
);
513 swaps(&pRep
->nPixels
);
514 swapl(&pRep
->redMask
);
515 swapl(&pRep
->greenMask
);
516 swapl(&pRep
->blueMask
);
517 WriteToClient(pClient
, size
, pRep
);
529 SQColorsExtend(ClientPtr pClient
, int size
, xrgb
* prgb
)
534 n
= size
/ sizeof(xrgb
);
536 for (i
= 0; i
< n
; i
++) {
540 WriteToClient(pClient
, size
, prgb
);
544 SQueryColorsReply(ClientPtr pClient
, int size
, xQueryColorsReply
* pRep
)
546 swaps(&pRep
->sequenceNumber
);
547 swapl(&pRep
->length
);
548 swaps(&pRep
->nColors
);
549 WriteToClient(pClient
, size
, pRep
);
553 SLookupColorReply(ClientPtr pClient
, int size
, xLookupColorReply
* pRep
)
555 swaps(&pRep
->sequenceNumber
);
556 swaps(&pRep
->exactRed
);
557 swaps(&pRep
->exactGreen
);
558 swaps(&pRep
->exactBlue
);
559 swaps(&pRep
->screenRed
);
560 swaps(&pRep
->screenGreen
);
561 swaps(&pRep
->screenBlue
);
562 WriteToClient(pClient
, size
, pRep
);
566 SQueryBestSizeReply(ClientPtr pClient
, int size
, xQueryBestSizeReply
* pRep
)
568 swaps(&pRep
->sequenceNumber
);
570 swaps(&pRep
->height
);
571 WriteToClient(pClient
, size
, pRep
);
575 SListExtensionsReply(ClientPtr pClient
, int size
, xListExtensionsReply
* pRep
)
577 swaps(&pRep
->sequenceNumber
);
578 swapl(&pRep
->length
);
579 WriteToClient(pClient
, size
, pRep
);
583 SGetKeyboardMappingReply(ClientPtr pClient
, int size
,
584 xGetKeyboardMappingReply
* pRep
)
586 swaps(&pRep
->sequenceNumber
);
587 swapl(&pRep
->length
);
588 WriteToClient(pClient
, size
, pRep
);
592 SGetPointerMappingReply(ClientPtr pClient
, int size
,
593 xGetPointerMappingReply
* pRep
)
595 swaps(&pRep
->sequenceNumber
);
596 swapl(&pRep
->length
);
597 WriteToClient(pClient
, size
, pRep
);
601 SGetModifierMappingReply(ClientPtr pClient
, int size
,
602 xGetModifierMappingReply
* pRep
)
604 swaps(&pRep
->sequenceNumber
);
605 swapl(&pRep
->length
);
606 WriteToClient(pClient
, size
, pRep
);
610 SGetKeyboardControlReply(ClientPtr pClient
, int size
,
611 xGetKeyboardControlReply
* pRep
)
613 swaps(&pRep
->sequenceNumber
);
614 swapl(&pRep
->length
);
615 swapl(&pRep
->ledMask
);
616 swaps(&pRep
->bellPitch
);
617 swaps(&pRep
->bellDuration
);
618 WriteToClient(pClient
, size
, pRep
);
622 SGetPointerControlReply(ClientPtr pClient
, int size
,
623 xGetPointerControlReply
* pRep
)
625 swaps(&pRep
->sequenceNumber
);
626 swaps(&pRep
->accelNumerator
);
627 swaps(&pRep
->accelDenominator
);
628 swaps(&pRep
->threshold
);
629 WriteToClient(pClient
, size
, pRep
);
633 SGetScreenSaverReply(ClientPtr pClient
, int size
, xGetScreenSaverReply
* pRep
)
635 swaps(&pRep
->sequenceNumber
);
636 swaps(&pRep
->timeout
);
637 swaps(&pRep
->interval
);
638 WriteToClient(pClient
, size
, pRep
);
642 SLHostsExtend(ClientPtr pClient
, int size
, char *buf
)
645 char *endbuf
= buf
+ size
;
647 while (bufT
< endbuf
) {
648 xHostEntry
*host
= (xHostEntry
*) bufT
;
649 int len
= host
->length
;
651 swaps(&host
->length
);
652 bufT
+= sizeof(xHostEntry
) + pad_to_int32(len
);
654 WriteToClient(pClient
, size
, buf
);
658 SListHostsReply(ClientPtr pClient
, int size
, xListHostsReply
* pRep
)
660 swaps(&pRep
->sequenceNumber
);
661 swapl(&pRep
->length
);
662 swaps(&pRep
->nHosts
);
663 WriteToClient(pClient
, size
, pRep
);
667 SErrorEvent(xError
* from
, xError
* to
)
670 to
->errorCode
= from
->errorCode
;
671 cpswaps(from
->sequenceNumber
, to
->sequenceNumber
);
672 cpswapl(from
->resourceID
, to
->resourceID
);
673 cpswaps(from
->minorCode
, to
->minorCode
);
674 to
->majorCode
= from
->majorCode
;
678 SKeyButtonPtrEvent(xEvent
*from
, xEvent
*to
)
680 to
->u
.u
.type
= from
->u
.u
.type
;
681 to
->u
.u
.detail
= from
->u
.u
.detail
;
682 cpswaps(from
->u
.u
.sequenceNumber
, to
->u
.u
.sequenceNumber
);
683 cpswapl(from
->u
.keyButtonPointer
.time
, to
->u
.keyButtonPointer
.time
);
684 cpswapl(from
->u
.keyButtonPointer
.root
, to
->u
.keyButtonPointer
.root
);
685 cpswapl(from
->u
.keyButtonPointer
.event
, to
->u
.keyButtonPointer
.event
);
686 cpswapl(from
->u
.keyButtonPointer
.child
, to
->u
.keyButtonPointer
.child
);
687 cpswaps(from
->u
.keyButtonPointer
.rootX
, to
->u
.keyButtonPointer
.rootX
);
688 cpswaps(from
->u
.keyButtonPointer
.rootY
, to
->u
.keyButtonPointer
.rootY
);
689 cpswaps(from
->u
.keyButtonPointer
.eventX
, to
->u
.keyButtonPointer
.eventX
);
690 cpswaps(from
->u
.keyButtonPointer
.eventY
, to
->u
.keyButtonPointer
.eventY
);
691 cpswaps(from
->u
.keyButtonPointer
.state
, to
->u
.keyButtonPointer
.state
);
692 to
->u
.keyButtonPointer
.sameScreen
= from
->u
.keyButtonPointer
.sameScreen
;
696 SEnterLeaveEvent(xEvent
*from
, xEvent
*to
)
698 to
->u
.u
.type
= from
->u
.u
.type
;
699 to
->u
.u
.detail
= from
->u
.u
.detail
;
700 cpswaps(from
->u
.u
.sequenceNumber
, to
->u
.u
.sequenceNumber
);
701 cpswapl(from
->u
.enterLeave
.time
, to
->u
.enterLeave
.time
);
702 cpswapl(from
->u
.enterLeave
.root
, to
->u
.enterLeave
.root
);
703 cpswapl(from
->u
.enterLeave
.event
, to
->u
.enterLeave
.event
);
704 cpswapl(from
->u
.enterLeave
.child
, to
->u
.enterLeave
.child
);
705 cpswaps(from
->u
.enterLeave
.rootX
, to
->u
.enterLeave
.rootX
);
706 cpswaps(from
->u
.enterLeave
.rootY
, to
->u
.enterLeave
.rootY
);
707 cpswaps(from
->u
.enterLeave
.eventX
, to
->u
.enterLeave
.eventX
);
708 cpswaps(from
->u
.enterLeave
.eventY
, to
->u
.enterLeave
.eventY
);
709 cpswaps(from
->u
.enterLeave
.state
, to
->u
.enterLeave
.state
);
710 to
->u
.enterLeave
.mode
= from
->u
.enterLeave
.mode
;
711 to
->u
.enterLeave
.flags
= from
->u
.enterLeave
.flags
;
715 SFocusEvent(xEvent
*from
, xEvent
*to
)
717 to
->u
.u
.type
= from
->u
.u
.type
;
718 to
->u
.u
.detail
= from
->u
.u
.detail
;
719 cpswaps(from
->u
.u
.sequenceNumber
, to
->u
.u
.sequenceNumber
);
720 cpswapl(from
->u
.focus
.window
, to
->u
.focus
.window
);
721 to
->u
.focus
.mode
= from
->u
.focus
.mode
;
725 SExposeEvent(xEvent
*from
, xEvent
*to
)
727 to
->u
.u
.type
= from
->u
.u
.type
;
728 cpswaps(from
->u
.u
.sequenceNumber
, to
->u
.u
.sequenceNumber
);
729 cpswapl(from
->u
.expose
.window
, to
->u
.expose
.window
);
730 cpswaps(from
->u
.expose
.x
, to
->u
.expose
.x
);
731 cpswaps(from
->u
.expose
.y
, to
->u
.expose
.y
);
732 cpswaps(from
->u
.expose
.width
, to
->u
.expose
.width
);
733 cpswaps(from
->u
.expose
.height
, to
->u
.expose
.height
);
734 cpswaps(from
->u
.expose
.count
, to
->u
.expose
.count
);
738 SGraphicsExposureEvent(xEvent
*from
, xEvent
*to
)
740 to
->u
.u
.type
= from
->u
.u
.type
;
741 cpswaps(from
->u
.u
.sequenceNumber
, to
->u
.u
.sequenceNumber
);
742 cpswapl(from
->u
.graphicsExposure
.drawable
, to
->u
.graphicsExposure
.drawable
);
743 cpswaps(from
->u
.graphicsExposure
.x
, to
->u
.graphicsExposure
.x
);
744 cpswaps(from
->u
.graphicsExposure
.y
, to
->u
.graphicsExposure
.y
);
745 cpswaps(from
->u
.graphicsExposure
.width
, to
->u
.graphicsExposure
.width
);
746 cpswaps(from
->u
.graphicsExposure
.height
, to
->u
.graphicsExposure
.height
);
747 cpswaps(from
->u
.graphicsExposure
.minorEvent
,
748 to
->u
.graphicsExposure
.minorEvent
);
749 cpswaps(from
->u
.graphicsExposure
.count
, to
->u
.graphicsExposure
.count
);
750 to
->u
.graphicsExposure
.majorEvent
= from
->u
.graphicsExposure
.majorEvent
;
754 SNoExposureEvent(xEvent
*from
, xEvent
*to
)
756 to
->u
.u
.type
= from
->u
.u
.type
;
757 cpswaps(from
->u
.u
.sequenceNumber
, to
->u
.u
.sequenceNumber
);
758 cpswapl(from
->u
.noExposure
.drawable
, to
->u
.noExposure
.drawable
);
759 cpswaps(from
->u
.noExposure
.minorEvent
, to
->u
.noExposure
.minorEvent
);
760 to
->u
.noExposure
.majorEvent
= from
->u
.noExposure
.majorEvent
;
764 SVisibilityEvent(xEvent
*from
, xEvent
*to
)
766 to
->u
.u
.type
= from
->u
.u
.type
;
767 cpswaps(from
->u
.u
.sequenceNumber
, to
->u
.u
.sequenceNumber
);
768 cpswapl(from
->u
.visibility
.window
, to
->u
.visibility
.window
);
769 to
->u
.visibility
.state
= from
->u
.visibility
.state
;
773 SCreateNotifyEvent(xEvent
*from
, xEvent
*to
)
775 to
->u
.u
.type
= from
->u
.u
.type
;
776 cpswaps(from
->u
.u
.sequenceNumber
, to
->u
.u
.sequenceNumber
);
777 cpswapl(from
->u
.createNotify
.window
, to
->u
.createNotify
.window
);
778 cpswapl(from
->u
.createNotify
.parent
, to
->u
.createNotify
.parent
);
779 cpswaps(from
->u
.createNotify
.x
, to
->u
.createNotify
.x
);
780 cpswaps(from
->u
.createNotify
.y
, to
->u
.createNotify
.y
);
781 cpswaps(from
->u
.createNotify
.width
, to
->u
.createNotify
.width
);
782 cpswaps(from
->u
.createNotify
.height
, to
->u
.createNotify
.height
);
783 cpswaps(from
->u
.createNotify
.borderWidth
, to
->u
.createNotify
.borderWidth
);
784 to
->u
.createNotify
.override
= from
->u
.createNotify
.override
;
788 SDestroyNotifyEvent(xEvent
*from
, xEvent
*to
)
790 to
->u
.u
.type
= from
->u
.u
.type
;
791 cpswaps(from
->u
.u
.sequenceNumber
, to
->u
.u
.sequenceNumber
);
792 cpswapl(from
->u
.destroyNotify
.event
, to
->u
.destroyNotify
.event
);
793 cpswapl(from
->u
.destroyNotify
.window
, to
->u
.destroyNotify
.window
);
797 SUnmapNotifyEvent(xEvent
*from
, xEvent
*to
)
799 to
->u
.u
.type
= from
->u
.u
.type
;
800 cpswaps(from
->u
.u
.sequenceNumber
, to
->u
.u
.sequenceNumber
);
801 cpswapl(from
->u
.unmapNotify
.event
, to
->u
.unmapNotify
.event
);
802 cpswapl(from
->u
.unmapNotify
.window
, to
->u
.unmapNotify
.window
);
803 to
->u
.unmapNotify
.fromConfigure
= from
->u
.unmapNotify
.fromConfigure
;
807 SMapNotifyEvent(xEvent
*from
, xEvent
*to
)
809 to
->u
.u
.type
= from
->u
.u
.type
;
810 cpswaps(from
->u
.u
.sequenceNumber
, to
->u
.u
.sequenceNumber
);
811 cpswapl(from
->u
.mapNotify
.event
, to
->u
.mapNotify
.event
);
812 cpswapl(from
->u
.mapNotify
.window
, to
->u
.mapNotify
.window
);
813 to
->u
.mapNotify
.override
= from
->u
.mapNotify
.override
;
817 SMapRequestEvent(xEvent
*from
, xEvent
*to
)
819 to
->u
.u
.type
= from
->u
.u
.type
;
820 cpswaps(from
->u
.u
.sequenceNumber
, to
->u
.u
.sequenceNumber
);
821 cpswapl(from
->u
.mapRequest
.parent
, to
->u
.mapRequest
.parent
);
822 cpswapl(from
->u
.mapRequest
.window
, to
->u
.mapRequest
.window
);
826 SReparentEvent(xEvent
*from
, xEvent
*to
)
828 to
->u
.u
.type
= from
->u
.u
.type
;
829 cpswaps(from
->u
.u
.sequenceNumber
, to
->u
.u
.sequenceNumber
);
830 cpswapl(from
->u
.reparent
.event
, to
->u
.reparent
.event
);
831 cpswapl(from
->u
.reparent
.window
, to
->u
.reparent
.window
);
832 cpswapl(from
->u
.reparent
.parent
, to
->u
.reparent
.parent
);
833 cpswaps(from
->u
.reparent
.x
, to
->u
.reparent
.x
);
834 cpswaps(from
->u
.reparent
.y
, to
->u
.reparent
.y
);
835 to
->u
.reparent
.override
= from
->u
.reparent
.override
;
839 SConfigureNotifyEvent(xEvent
*from
, xEvent
*to
)
841 to
->u
.u
.type
= from
->u
.u
.type
;
842 cpswaps(from
->u
.u
.sequenceNumber
, to
->u
.u
.sequenceNumber
);
843 cpswapl(from
->u
.configureNotify
.event
, to
->u
.configureNotify
.event
);
844 cpswapl(from
->u
.configureNotify
.window
, to
->u
.configureNotify
.window
);
845 cpswapl(from
->u
.configureNotify
.aboveSibling
,
846 to
->u
.configureNotify
.aboveSibling
);
847 cpswaps(from
->u
.configureNotify
.x
, to
->u
.configureNotify
.x
);
848 cpswaps(from
->u
.configureNotify
.y
, to
->u
.configureNotify
.y
);
849 cpswaps(from
->u
.configureNotify
.width
, to
->u
.configureNotify
.width
);
850 cpswaps(from
->u
.configureNotify
.height
, to
->u
.configureNotify
.height
);
851 cpswaps(from
->u
.configureNotify
.borderWidth
,
852 to
->u
.configureNotify
.borderWidth
);
853 to
->u
.configureNotify
.override
= from
->u
.configureNotify
.override
;
857 SConfigureRequestEvent(xEvent
*from
, xEvent
*to
)
859 to
->u
.u
.type
= from
->u
.u
.type
;
860 to
->u
.u
.detail
= from
->u
.u
.detail
; /* actually stack-mode */
861 cpswaps(from
->u
.u
.sequenceNumber
, to
->u
.u
.sequenceNumber
);
862 cpswapl(from
->u
.configureRequest
.parent
, to
->u
.configureRequest
.parent
);
863 cpswapl(from
->u
.configureRequest
.window
, to
->u
.configureRequest
.window
);
864 cpswapl(from
->u
.configureRequest
.sibling
, to
->u
.configureRequest
.sibling
);
865 cpswaps(from
->u
.configureRequest
.x
, to
->u
.configureRequest
.x
);
866 cpswaps(from
->u
.configureRequest
.y
, to
->u
.configureRequest
.y
);
867 cpswaps(from
->u
.configureRequest
.width
, to
->u
.configureRequest
.width
);
868 cpswaps(from
->u
.configureRequest
.height
, to
->u
.configureRequest
.height
);
869 cpswaps(from
->u
.configureRequest
.borderWidth
,
870 to
->u
.configureRequest
.borderWidth
);
871 cpswaps(from
->u
.configureRequest
.valueMask
,
872 to
->u
.configureRequest
.valueMask
);
876 SGravityEvent(xEvent
*from
, xEvent
*to
)
878 to
->u
.u
.type
= from
->u
.u
.type
;
879 cpswaps(from
->u
.u
.sequenceNumber
, to
->u
.u
.sequenceNumber
);
880 cpswapl(from
->u
.gravity
.event
, to
->u
.gravity
.event
);
881 cpswapl(from
->u
.gravity
.window
, to
->u
.gravity
.window
);
882 cpswaps(from
->u
.gravity
.x
, to
->u
.gravity
.x
);
883 cpswaps(from
->u
.gravity
.y
, to
->u
.gravity
.y
);
887 SResizeRequestEvent(xEvent
*from
, xEvent
*to
)
889 to
->u
.u
.type
= from
->u
.u
.type
;
890 cpswaps(from
->u
.u
.sequenceNumber
, to
->u
.u
.sequenceNumber
);
891 cpswapl(from
->u
.resizeRequest
.window
, to
->u
.resizeRequest
.window
);
892 cpswaps(from
->u
.resizeRequest
.width
, to
->u
.resizeRequest
.width
);
893 cpswaps(from
->u
.resizeRequest
.height
, to
->u
.resizeRequest
.height
);
897 SCirculateEvent(xEvent
*from
, xEvent
*to
)
899 to
->u
.u
.type
= from
->u
.u
.type
;
900 to
->u
.u
.detail
= from
->u
.u
.detail
;
901 cpswaps(from
->u
.u
.sequenceNumber
, to
->u
.u
.sequenceNumber
);
902 cpswapl(from
->u
.circulate
.event
, to
->u
.circulate
.event
);
903 cpswapl(from
->u
.circulate
.window
, to
->u
.circulate
.window
);
904 cpswapl(from
->u
.circulate
.parent
, to
->u
.circulate
.parent
);
905 to
->u
.circulate
.place
= from
->u
.circulate
.place
;
909 SPropertyEvent(xEvent
*from
, xEvent
*to
)
911 to
->u
.u
.type
= from
->u
.u
.type
;
912 cpswaps(from
->u
.u
.sequenceNumber
, to
->u
.u
.sequenceNumber
);
913 cpswapl(from
->u
.property
.window
, to
->u
.property
.window
);
914 cpswapl(from
->u
.property
.atom
, to
->u
.property
.atom
);
915 cpswapl(from
->u
.property
.time
, to
->u
.property
.time
);
916 to
->u
.property
.state
= from
->u
.property
.state
;
920 SSelectionClearEvent(xEvent
*from
, xEvent
*to
)
922 to
->u
.u
.type
= from
->u
.u
.type
;
923 cpswaps(from
->u
.u
.sequenceNumber
, to
->u
.u
.sequenceNumber
);
924 cpswapl(from
->u
.selectionClear
.time
, to
->u
.selectionClear
.time
);
925 cpswapl(from
->u
.selectionClear
.window
, to
->u
.selectionClear
.window
);
926 cpswapl(from
->u
.selectionClear
.atom
, to
->u
.selectionClear
.atom
);
930 SSelectionRequestEvent(xEvent
*from
, xEvent
*to
)
932 to
->u
.u
.type
= from
->u
.u
.type
;
933 cpswaps(from
->u
.u
.sequenceNumber
, to
->u
.u
.sequenceNumber
);
934 cpswapl(from
->u
.selectionRequest
.time
, to
->u
.selectionRequest
.time
);
935 cpswapl(from
->u
.selectionRequest
.owner
, to
->u
.selectionRequest
.owner
);
936 cpswapl(from
->u
.selectionRequest
.requestor
,
937 to
->u
.selectionRequest
.requestor
);
938 cpswapl(from
->u
.selectionRequest
.selection
,
939 to
->u
.selectionRequest
.selection
);
940 cpswapl(from
->u
.selectionRequest
.target
, to
->u
.selectionRequest
.target
);
941 cpswapl(from
->u
.selectionRequest
.property
, to
->u
.selectionRequest
.property
);
945 SSelectionNotifyEvent(xEvent
*from
, xEvent
*to
)
947 to
->u
.u
.type
= from
->u
.u
.type
;
948 cpswaps(from
->u
.u
.sequenceNumber
, to
->u
.u
.sequenceNumber
);
949 cpswapl(from
->u
.selectionNotify
.time
, to
->u
.selectionNotify
.time
);
950 cpswapl(from
->u
.selectionNotify
.requestor
, to
->u
.selectionNotify
.requestor
);
951 cpswapl(from
->u
.selectionNotify
.selection
, to
->u
.selectionNotify
.selection
);
952 cpswapl(from
->u
.selectionNotify
.target
, to
->u
.selectionNotify
.target
);
953 cpswapl(from
->u
.selectionNotify
.property
, to
->u
.selectionNotify
.property
);
957 SColormapEvent(xEvent
*from
, xEvent
*to
)
959 to
->u
.u
.type
= from
->u
.u
.type
;
960 cpswaps(from
->u
.u
.sequenceNumber
, to
->u
.u
.sequenceNumber
);
961 cpswapl(from
->u
.colormap
.window
, to
->u
.colormap
.window
);
962 cpswapl(from
->u
.colormap
.colormap
, to
->u
.colormap
.colormap
);
963 to
->u
.colormap
.new = from
->u
.colormap
.new;
964 to
->u
.colormap
.state
= from
->u
.colormap
.state
;
968 SMappingEvent(xEvent
*from
, xEvent
*to
)
970 to
->u
.u
.type
= from
->u
.u
.type
;
971 cpswaps(from
->u
.u
.sequenceNumber
, to
->u
.u
.sequenceNumber
);
972 to
->u
.mappingNotify
.request
= from
->u
.mappingNotify
.request
;
973 to
->u
.mappingNotify
.firstKeyCode
= from
->u
.mappingNotify
.firstKeyCode
;
974 to
->u
.mappingNotify
.count
= from
->u
.mappingNotify
.count
;
978 SClientMessageEvent(xEvent
*from
, xEvent
*to
)
980 to
->u
.u
.type
= from
->u
.u
.type
;
981 to
->u
.u
.detail
= from
->u
.u
.detail
; /* actually format */
982 cpswaps(from
->u
.u
.sequenceNumber
, to
->u
.u
.sequenceNumber
);
983 cpswapl(from
->u
.clientMessage
.window
, to
->u
.clientMessage
.window
);
984 cpswapl(from
->u
.clientMessage
.u
.l
.type
, to
->u
.clientMessage
.u
.l
.type
);
985 switch (from
->u
.u
.detail
) {
987 memmove(to
->u
.clientMessage
.u
.b
.bytes
,
988 from
->u
.clientMessage
.u
.b
.bytes
, 20);
991 cpswaps(from
->u
.clientMessage
.u
.s
.shorts0
,
992 to
->u
.clientMessage
.u
.s
.shorts0
);
993 cpswaps(from
->u
.clientMessage
.u
.s
.shorts1
,
994 to
->u
.clientMessage
.u
.s
.shorts1
);
995 cpswaps(from
->u
.clientMessage
.u
.s
.shorts2
,
996 to
->u
.clientMessage
.u
.s
.shorts2
);
997 cpswaps(from
->u
.clientMessage
.u
.s
.shorts3
,
998 to
->u
.clientMessage
.u
.s
.shorts3
);
999 cpswaps(from
->u
.clientMessage
.u
.s
.shorts4
,
1000 to
->u
.clientMessage
.u
.s
.shorts4
);
1001 cpswaps(from
->u
.clientMessage
.u
.s
.shorts5
,
1002 to
->u
.clientMessage
.u
.s
.shorts5
);
1003 cpswaps(from
->u
.clientMessage
.u
.s
.shorts6
,
1004 to
->u
.clientMessage
.u
.s
.shorts6
);
1005 cpswaps(from
->u
.clientMessage
.u
.s
.shorts7
,
1006 to
->u
.clientMessage
.u
.s
.shorts7
);
1007 cpswaps(from
->u
.clientMessage
.u
.s
.shorts8
,
1008 to
->u
.clientMessage
.u
.s
.shorts8
);
1009 cpswaps(from
->u
.clientMessage
.u
.s
.shorts9
,
1010 to
->u
.clientMessage
.u
.s
.shorts9
);
1013 cpswapl(from
->u
.clientMessage
.u
.l
.longs0
,
1014 to
->u
.clientMessage
.u
.l
.longs0
);
1015 cpswapl(from
->u
.clientMessage
.u
.l
.longs1
,
1016 to
->u
.clientMessage
.u
.l
.longs1
);
1017 cpswapl(from
->u
.clientMessage
.u
.l
.longs2
,
1018 to
->u
.clientMessage
.u
.l
.longs2
);
1019 cpswapl(from
->u
.clientMessage
.u
.l
.longs3
,
1020 to
->u
.clientMessage
.u
.l
.longs3
);
1021 cpswapl(from
->u
.clientMessage
.u
.l
.longs4
,
1022 to
->u
.clientMessage
.u
.l
.longs4
);
1028 SKeymapNotifyEvent(xEvent
*from
, xEvent
*to
)
1030 /* Keymap notify events are special; they have no
1031 sequence number field, and contain entirely 8-bit data */
1036 SwapConnSetup(xConnSetup
* pConnSetup
, xConnSetup
* pConnSetupT
)
1038 cpswapl(pConnSetup
->release
, pConnSetupT
->release
);
1039 cpswapl(pConnSetup
->ridBase
, pConnSetupT
->ridBase
);
1040 cpswapl(pConnSetup
->ridMask
, pConnSetupT
->ridMask
);
1041 cpswapl(pConnSetup
->motionBufferSize
, pConnSetupT
->motionBufferSize
);
1042 cpswaps(pConnSetup
->nbytesVendor
, pConnSetupT
->nbytesVendor
);
1043 cpswaps(pConnSetup
->maxRequestSize
, pConnSetupT
->maxRequestSize
);
1044 pConnSetupT
->minKeyCode
= pConnSetup
->minKeyCode
;
1045 pConnSetupT
->maxKeyCode
= pConnSetup
->maxKeyCode
;
1046 pConnSetupT
->numRoots
= pConnSetup
->numRoots
;
1047 pConnSetupT
->numFormats
= pConnSetup
->numFormats
;
1048 pConnSetupT
->imageByteOrder
= pConnSetup
->imageByteOrder
;
1049 pConnSetupT
->bitmapBitOrder
= pConnSetup
->bitmapBitOrder
;
1050 pConnSetupT
->bitmapScanlineUnit
= pConnSetup
->bitmapScanlineUnit
;
1051 pConnSetupT
->bitmapScanlinePad
= pConnSetup
->bitmapScanlinePad
;
1055 SwapWinRoot(xWindowRoot
* pRoot
, xWindowRoot
* pRootT
)
1057 cpswapl(pRoot
->windowId
, pRootT
->windowId
);
1058 cpswapl(pRoot
->defaultColormap
, pRootT
->defaultColormap
);
1059 cpswapl(pRoot
->whitePixel
, pRootT
->whitePixel
);
1060 cpswapl(pRoot
->blackPixel
, pRootT
->blackPixel
);
1061 cpswapl(pRoot
->currentInputMask
, pRootT
->currentInputMask
);
1062 cpswaps(pRoot
->pixWidth
, pRootT
->pixWidth
);
1063 cpswaps(pRoot
->pixHeight
, pRootT
->pixHeight
);
1064 cpswaps(pRoot
->mmWidth
, pRootT
->mmWidth
);
1065 cpswaps(pRoot
->mmHeight
, pRootT
->mmHeight
);
1066 cpswaps(pRoot
->minInstalledMaps
, pRootT
->minInstalledMaps
);
1067 cpswaps(pRoot
->maxInstalledMaps
, pRootT
->maxInstalledMaps
);
1068 cpswapl(pRoot
->rootVisualID
, pRootT
->rootVisualID
);
1069 pRootT
->backingStore
= pRoot
->backingStore
;
1070 pRootT
->saveUnders
= pRoot
->saveUnders
;
1071 pRootT
->rootDepth
= pRoot
->rootDepth
;
1072 pRootT
->nDepths
= pRoot
->nDepths
;
1076 SwapVisual(xVisualType
* pVis
, xVisualType
* pVisT
)
1078 cpswapl(pVis
->visualID
, pVisT
->visualID
);
1079 pVisT
->class = pVis
->class;
1080 pVisT
->bitsPerRGB
= pVis
->bitsPerRGB
;
1081 cpswaps(pVis
->colormapEntries
, pVisT
->colormapEntries
);
1082 cpswapl(pVis
->redMask
, pVisT
->redMask
);
1083 cpswapl(pVis
->greenMask
, pVisT
->greenMask
);
1084 cpswapl(pVis
->blueMask
, pVisT
->blueMask
);
1088 SwapConnSetupInfo(char *pInfo
, char *pInfoT
)
1091 xConnSetup
*pConnSetup
= (xConnSetup
*) pInfo
;
1095 SwapConnSetup(pConnSetup
, (xConnSetup
*) pInfoT
);
1096 pInfo
+= sizeof(xConnSetup
);
1097 pInfoT
+= sizeof(xConnSetup
);
1099 /* Copy the vendor string */
1100 i
= pad_to_int32(pConnSetup
->nbytesVendor
);
1101 memcpy(pInfoT
, pInfo
, i
);
1105 /* The Pixmap formats don't need to be swapped, just copied. */
1106 i
= sizeof(xPixmapFormat
) * pConnSetup
->numFormats
;
1107 memcpy(pInfoT
, pInfo
, i
);
1111 for (i
= 0; i
< pConnSetup
->numRoots
; i
++) {
1112 root
= (xWindowRoot
*) pInfo
;
1113 SwapWinRoot(root
, (xWindowRoot
*) pInfoT
);
1114 pInfo
+= sizeof(xWindowRoot
);
1115 pInfoT
+= sizeof(xWindowRoot
);
1117 for (j
= 0; j
< root
->nDepths
; j
++) {
1118 depth
= (xDepth
*) pInfo
;
1119 ((xDepth
*) pInfoT
)->depth
= depth
->depth
;
1120 cpswaps(depth
->nVisuals
, ((xDepth
*) pInfoT
)->nVisuals
);
1121 pInfo
+= sizeof(xDepth
);
1122 pInfoT
+= sizeof(xDepth
);
1123 for (k
= 0; k
< depth
->nVisuals
; k
++) {
1124 SwapVisual((xVisualType
*) pInfo
, (xVisualType
*) pInfoT
);
1125 pInfo
+= sizeof(xVisualType
);
1126 pInfoT
+= sizeof(xVisualType
);
1133 WriteSConnectionInfo(ClientPtr pClient
, unsigned long size
, char *pInfo
)
1137 pInfoTBase
= malloc(size
);
1139 pClient
->noClientException
= -1;
1142 SwapConnSetupInfo(pInfo
, pInfoTBase
);
1143 WriteToClient(pClient
, (int) size
, pInfoTBase
);
1148 SwapConnSetupPrefix(xConnSetupPrefix
* pcspFrom
, xConnSetupPrefix
* pcspTo
)
1150 pcspTo
->success
= pcspFrom
->success
;
1151 pcspTo
->lengthReason
= pcspFrom
->lengthReason
;
1152 cpswaps(pcspFrom
->majorVersion
, pcspTo
->majorVersion
);
1153 cpswaps(pcspFrom
->minorVersion
, pcspTo
->minorVersion
);
1154 cpswaps(pcspFrom
->length
, pcspTo
->length
);
1158 WriteSConnSetupPrefix(ClientPtr pClient
, xConnSetupPrefix
* pcsp
)
1160 xConnSetupPrefix cspT
;
1162 SwapConnSetupPrefix(pcsp
, &cspT
);
1163 WriteToClient(pClient
, sizeof(cspT
), &cspT
);
1167 * Dummy entry for ReplySwapVector[]
1171 ReplyNotSwappd(ClientPtr pClient
, int size
, void *pbuf
)
1173 FatalError("Not implemented");