2 * Copyright 2002-2004 Red Hat Inc., Durham, North Carolina.
6 * Permission is hereby granted, free of charge, to any person obtaining
7 * a copy of this software and associated documentation files (the
8 * "Software"), to deal in the Software without restriction, including
9 * without limitation on the rights to use, copy, modify, merge,
10 * publish, distribute, sublicense, and/or sell copies of the Software,
11 * and to permit persons to whom the Software is furnished to do so,
12 * subject to the following conditions:
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial
16 * portions of the Software.
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21 * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS
22 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
23 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
24 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
30 * Rickard E. (Rik) Faith <faith@redhat.com>
35 * This file implements the server-side part of the DMX protocol. A
36 * vector of fucntions is provided at extension initialization time, so
37 * most all of the useful functions in this file are declared static and
38 * do not appear in the doxygen documentation.
40 * Much of the low-level work is done by functions in \a dmxextension.c
42 * Please see the Client-to-Server DMX Extension to the X Protocol
43 * document for details about the protocol. */
45 #ifdef HAVE_DMX_CONFIG_H
46 #include <dmx-config.h>
50 #include <X11/Xproto.h>
53 #include "dixstruct.h"
54 #include "extnsionst.h"
58 #include "dmxextension.h"
59 #include <X11/extensions/dmxproto.h>
60 #include <X11/extensions/dmx.h>
61 #include "protocol-versions.h"
64 #include "panoramiX.h"
65 extern unsigned long XRT_WINDOW
;
66 extern int PanoramiXNumScreens
;
69 static unsigned char DMXCode
;
72 _DMXXineramaActive(void)
75 return !noPanoramiXExtension
;
82 dmxSetScreenAttribute(int bit
, DMXScreenAttributesPtr attr
, CARD32 value
)
85 case DMXScreenWindowWidth
:
86 attr
->screenWindowWidth
= value
;
88 case DMXScreenWindowHeight
:
89 attr
->screenWindowHeight
= value
;
91 case DMXScreenWindowXoffset
:
92 attr
->screenWindowXoffset
= value
;
94 case DMXScreenWindowYoffset
:
95 attr
->screenWindowYoffset
= value
;
97 case DMXRootWindowWidth
:
98 attr
->rootWindowWidth
= value
;
100 case DMXRootWindowHeight
:
101 attr
->rootWindowHeight
= value
;
103 case DMXRootWindowXoffset
:
104 attr
->rootWindowXoffset
= value
;
106 case DMXRootWindowYoffset
:
107 attr
->rootWindowYoffset
= value
;
109 case DMXRootWindowXorigin
:
110 attr
->rootWindowXorigin
= value
;
112 case DMXRootWindowYorigin
:
113 attr
->rootWindowYorigin
= value
;
119 dmxFetchScreenAttributes(unsigned int mask
,
120 DMXScreenAttributesPtr attr
, CARD32
*value_list
)
123 CARD32
*value
= value_list
;
126 for (i
= 0; i
< 32; i
++) {
127 if (mask
& (1 << i
)) {
128 dmxSetScreenAttribute(i
, attr
, *value
);
137 dmxSetDesktopAttribute(int bit
, DMXDesktopAttributesPtr attr
, CARD32 value
)
140 case DMXDesktopWidth
:
143 case DMXDesktopHeight
:
144 attr
->height
= value
;
146 case DMXDesktopShiftX
:
147 attr
->shiftX
= value
;
149 case DMXDesktopShiftY
:
150 attr
->shiftY
= value
;
156 dmxFetchDesktopAttributes(unsigned int mask
,
157 DMXDesktopAttributesPtr attr
, CARD32
*value_list
)
160 CARD32
*value
= value_list
;
163 for (i
= 0; i
< 32; i
++) {
164 if (mask
& (1 << i
)) {
165 dmxSetDesktopAttribute(i
, attr
, *value
);
174 dmxSetInputAttribute(int bit
, DMXInputAttributesPtr attr
, CARD32 value
)
178 attr
->inputType
= value
;
180 case DMXInputPhysicalScreen
:
181 attr
->physicalScreen
= value
;
183 case DMXInputSendsCore
:
184 attr
->sendsCore
= ! !value
;
190 dmxFetchInputAttributes(unsigned int mask
,
191 DMXInputAttributesPtr attr
, CARD32
*value_list
)
194 CARD32
*value
= value_list
;
197 for (i
= 0; i
< 32; i
++) {
198 if (mask
& (1 << i
)) {
199 dmxSetInputAttribute(i
, attr
, *value
);
208 ProcDMXQueryVersion(ClientPtr client
)
210 xDMXQueryVersionReply rep
= {
212 .sequenceNumber
= client
->sequence
,
214 .majorVersion
= SERVER_DMX_MAJOR_VERSION
,
215 .minorVersion
= SERVER_DMX_MINOR_VERSION
,
216 .patchVersion
= SERVER_DMX_PATCH_VERSION
219 REQUEST_SIZE_MATCH(xDMXQueryVersionReq
);
221 if (client
->swapped
) {
222 swaps(&rep
.sequenceNumber
);
224 swapl(&rep
.majorVersion
);
225 swapl(&rep
.minorVersion
);
226 swapl(&rep
.patchVersion
);
228 WriteToClient(client
, sizeof(xDMXQueryVersionReply
), &rep
);
233 ProcDMXSync(ClientPtr client
)
237 REQUEST_SIZE_MATCH(xDMXSyncReq
);
239 dmxFlushPendingSyncs();
241 rep
= (xDMXSyncReply
) {
243 .sequenceNumber
= client
->sequence
,
247 if (client
->swapped
) {
248 swaps(&rep
.sequenceNumber
);
252 WriteToClient(client
, sizeof(xDMXSyncReply
), &rep
);
257 ProcDMXForceWindowCreation(ClientPtr client
)
259 xDMXForceWindowCreationReply rep
;
261 REQUEST(xDMXForceWindowCreationReq
);
264 REQUEST_SIZE_MATCH(xDMXForceWindowCreationReq
);
267 if (!noPanoramiXExtension
) {
271 if (Success
!= dixLookupResourceByType((pointer
*) &win
,
272 stuff
->window
, XRT_WINDOW
,
273 client
, DixReadAccess
))
274 return -1; /* BadWindow */
277 if (Success
!= dixLookupWindow(&pWin
, win
->info
[i
].id
, client
,
279 return -1; /* BadWindow */
281 dmxForceWindowCreation(pWin
);
287 if (Success
!= dixLookupWindow(&pWin
, stuff
->window
, client
, DixReadAccess
))
288 return -1; /* BadWindow */
290 dmxForceWindowCreation(pWin
);
292 dmxFlushPendingSyncs();
293 rep
= (xDMXForceWindowCreationReply
) {
295 .sequenceNumber
= client
->sequence
,
299 if (client
->swapped
) {
300 swaps(&rep
.sequenceNumber
);
304 WriteToClient(client
, sizeof(xDMXForceWindowCreationReply
), &rep
);
309 ProcDMXGetScreenCount(ClientPtr client
)
311 xDMXGetScreenCountReply rep
;
313 REQUEST_SIZE_MATCH(xDMXGetScreenCountReq
);
315 rep
= (xDMXGetScreenCountReply
) {
317 .sequenceNumber
= client
->sequence
,
319 .screenCount
= dmxGetNumScreens()
321 if (client
->swapped
) {
322 swaps(&rep
.sequenceNumber
);
324 swapl(&rep
.screenCount
);
326 WriteToClient(client
, sizeof(xDMXGetScreenCountReply
), &rep
);
331 ProcDMXGetScreenAttributes(ClientPtr client
)
333 REQUEST(xDMXGetScreenAttributesReq
);
334 xDMXGetScreenAttributesReply rep
;
337 DMXScreenAttributesRec attr
;
339 REQUEST_SIZE_MATCH(xDMXGetScreenAttributesReq
);
341 if (stuff
->physicalScreen
< 0
342 || stuff
->physicalScreen
>= dmxGetNumScreens())
345 if (!dmxGetScreenAttributes(stuff
->physicalScreen
, &attr
))
348 length
= attr
.displayName
? strlen(attr
.displayName
) : 0;
349 paddedLength
= pad_to_int32(length
);
351 rep
= (xDMXGetScreenAttributesReply
) {
353 .sequenceNumber
= client
->sequence
,
355 bytes_to_int32((sizeof(xDMXGetScreenAttributesReply
) -
356 sizeof(xGenericReply
))
358 .displayNameLength
= length
,
359 .logicalScreen
= attr
.logicalScreen
,
360 .screenWindowWidth
= attr
.screenWindowWidth
,
361 .screenWindowHeight
= attr
.screenWindowHeight
,
362 .screenWindowXoffset
= attr
.screenWindowXoffset
,
363 .screenWindowYoffset
= attr
.screenWindowYoffset
,
364 .rootWindowWidth
= attr
.rootWindowWidth
,
365 .rootWindowHeight
= attr
.rootWindowHeight
,
366 .rootWindowXoffset
= attr
.rootWindowXoffset
,
367 .rootWindowYoffset
= attr
.rootWindowYoffset
,
368 .rootWindowXorigin
= attr
.rootWindowXorigin
,
369 .rootWindowYorigin
= attr
.rootWindowYorigin
372 if (client
->swapped
) {
373 swaps(&rep
.sequenceNumber
);
375 swapl(&rep
.displayNameLength
);
376 swapl(&rep
.logicalScreen
);
377 swaps(&rep
.screenWindowWidth
);
378 swaps(&rep
.screenWindowHeight
);
379 swaps(&rep
.screenWindowXoffset
);
380 swaps(&rep
.screenWindowYoffset
);
381 swaps(&rep
.rootWindowWidth
);
382 swaps(&rep
.rootWindowHeight
);
383 swaps(&rep
.rootWindowXoffset
);
384 swaps(&rep
.rootWindowYoffset
);
385 swaps(&rep
.rootWindowXorigin
);
386 swaps(&rep
.rootWindowYorigin
);
388 WriteToClient(client
, sizeof(xDMXGetScreenAttributesReply
), &rep
);
390 WriteToClient(client
, length
, attr
.displayName
);
395 ProcDMXChangeScreensAttributes(ClientPtr client
)
397 REQUEST(xDMXChangeScreensAttributesReq
);
398 xDMXChangeScreensAttributesReply rep
;
399 int status
= DMX_BAD_XINERAMA
;
400 unsigned int mask
= 0;
405 DMXScreenAttributesPtr attribs
;
410 REQUEST_AT_LEAST_SIZE(xDMXChangeScreensAttributesReq
);
413 bytes_to_int32(sizeof(xDMXChangeScreensAttributesReq
));
414 if (len
< stuff
->screenCount
+ stuff
->maskCount
)
417 screen_list
= (CARD32
*) (stuff
+ 1);
418 mask_list
= &screen_list
[stuff
->screenCount
];
419 value_list
= &mask_list
[stuff
->maskCount
];
421 for (i
= 0; i
< stuff
->maskCount
; i
++)
422 ones
+= Ones(mask_list
[i
]);
423 if (len
!= stuff
->screenCount
+ stuff
->maskCount
+ ones
)
426 if (!_DMXXineramaActive())
429 if (!(attribs
= malloc(stuff
->screenCount
* sizeof(*attribs
))))
432 for (i
= 0; i
< stuff
->screenCount
; i
++) {
435 if (i
< stuff
->maskCount
)
437 dmxGetScreenAttributes(screen_list
[i
], &attribs
[i
]);
438 count
= dmxFetchScreenAttributes(mask
, &attribs
[i
], value_list
);
443 status
= dmxConfigureScreenWindows(stuff
->screenCount
,
444 screen_list
, attribs
, &errorScreen
);
449 if (status
== BadValue
)
453 rep
= (xDMXChangeScreensAttributesReply
) {
455 .sequenceNumber
= client
->sequence
,
458 .errorScreen
= errorScreen
460 if (client
->swapped
) {
461 swaps(&rep
.sequenceNumber
);
464 swapl(&rep
.errorScreen
);
466 WriteToClient(client
, sizeof(xDMXChangeScreensAttributesReply
), &rep
);
471 ProcDMXAddScreen(ClientPtr client
)
473 REQUEST(xDMXAddScreenReq
);
474 xDMXAddScreenReply rep
;
477 DMXScreenAttributesRec attr
;
483 REQUEST_AT_LEAST_SIZE(xDMXAddScreenReq
);
484 paddedLength
= pad_to_int32(stuff
->displayNameLength
);
485 len
= client
->req_len
- bytes_to_int32(sizeof(xDMXAddScreenReq
));
486 if (len
!= Ones(stuff
->valueMask
) + paddedLength
/ 4)
489 memset(&attr
, 0, sizeof(attr
));
490 dmxGetScreenAttributes(stuff
->physicalScreen
, &attr
);
491 value_list
= (CARD32
*) (stuff
+ 1);
492 count
= dmxFetchScreenAttributes(stuff
->valueMask
, &attr
, value_list
);
494 if (!(name
= malloc(stuff
->displayNameLength
+ 1 + 4)))
496 memcpy(name
, &value_list
[count
], stuff
->displayNameLength
);
497 name
[stuff
->displayNameLength
] = '\0';
498 attr
.displayName
= name
;
500 status
= dmxAttachScreen(stuff
->physicalScreen
, &attr
);
504 rep
= (xDMXAddScreenReply
) {
506 .sequenceNumber
= client
->sequence
,
509 .physicalScreen
= stuff
->physicalScreen
511 if (client
->swapped
) {
512 swaps(&rep
.sequenceNumber
);
515 swapl(&rep
.physicalScreen
);
517 WriteToClient(client
, sizeof(xDMXAddScreenReply
), &rep
);
522 ProcDMXRemoveScreen(ClientPtr client
)
524 REQUEST(xDMXRemoveScreenReq
);
525 xDMXRemoveScreenReply rep
;
528 REQUEST_SIZE_MATCH(xDMXRemoveScreenReq
);
530 status
= dmxDetachScreen(stuff
->physicalScreen
);
532 rep
= (xDMXRemoveScreenReply
) {
534 .sequenceNumber
= client
->sequence
,
538 if (client
->swapped
) {
539 swaps(&rep
.sequenceNumber
);
543 WriteToClient(client
, sizeof(xDMXRemoveScreenReply
), &rep
);
549 dmxPopulatePanoramiX(ClientPtr client
, Window window
,
550 CARD32
*screens
, CARD32
*windows
,
551 xRectangle
*pos
, xRectangle
*vis
)
557 DMXWindowAttributesRec attr
;
559 if (Success
!= dixLookupResourceByType((pointer
*) &win
,
561 client
, DixReadAccess
))
562 return -1; /* BadWindow */
565 if (Success
!= dixLookupWindow(&pWin
, win
->info
[i
].id
, client
,
567 return -1; /* BadWindow */
568 if (dmxGetWindowAttributes(pWin
, &attr
)) {
569 screens
[count
] = attr
.screen
;
570 windows
[count
] = attr
.window
;
571 pos
[count
] = attr
.pos
;
572 vis
[count
] = attr
.vis
;
573 ++count
; /* Only count existing windows */
581 dmxPopulate(ClientPtr client
, Window window
, CARD32
*screens
,
582 CARD32
*windows
, xRectangle
*pos
, xRectangle
*vis
)
585 DMXWindowAttributesRec attr
;
588 if (!noPanoramiXExtension
)
589 return dmxPopulatePanoramiX(client
, window
, screens
, windows
, pos
, vis
);
592 if (Success
!= dixLookupWindow(&pWin
, window
, client
, DixReadAccess
))
593 return -1; /* BadWindow */
595 dmxGetWindowAttributes(pWin
, &attr
);
596 *screens
= attr
.screen
;
597 *windows
= attr
.window
;
604 dmxMaxNumScreens(void)
607 if (!noPanoramiXExtension
)
608 return PanoramiXNumScreens
;
614 ProcDMXGetWindowAttributes(ClientPtr client
)
616 REQUEST(xDMXGetWindowAttributesReq
);
617 xDMXGetWindowAttributesReply rep
;
621 xRectangle
*pos
, *vis
;
622 int count
= dmxMaxNumScreens();
624 REQUEST_SIZE_MATCH(xDMXGetWindowAttributesReq
);
626 if (!(screens
= malloc(count
* sizeof(*screens
))))
628 if (!(windows
= malloc(count
* sizeof(*windows
)))) {
632 if (!(pos
= malloc(count
* sizeof(*pos
)))) {
637 if (!(vis
= malloc(count
* sizeof(*vis
)))) {
644 if ((count
= dmxPopulate(client
, stuff
->window
, screens
, windows
,
653 rep
= (xDMXGetWindowAttributesReply
) {
655 .sequenceNumber
= client
->sequence
,
659 if (client
->swapped
) {
660 swaps(&rep
.sequenceNumber
);
662 swapl(&rep
.screenCount
);
663 for (i
= 0; i
< count
; i
++) {
669 swaps(&pos
[i
].width
);
670 swaps(&pos
[i
].height
);
674 swaps(&vis
[i
].width
);
675 swaps(&vis
[i
].height
);
679 dmxFlushPendingSyncs();
681 WriteToClient(client
, sizeof(xDMXGetWindowAttributesReply
), &rep
);
683 WriteToClient(client
, count
* sizeof(*screens
), screens
);
684 WriteToClient(client
, count
* sizeof(*windows
), windows
);
685 WriteToClient(client
, count
* sizeof(*pos
), pos
);
686 WriteToClient(client
, count
* sizeof(*vis
), vis
);
698 ProcDMXGetDesktopAttributes(ClientPtr client
)
700 xDMXGetDesktopAttributesReply rep
;
701 DMXDesktopAttributesRec attr
;
703 REQUEST_SIZE_MATCH(xDMXGetDesktopAttributesReq
);
705 dmxGetDesktopAttributes(&attr
);
707 rep
= (xDMXGetDesktopAttributesReply
) {
709 .sequenceNumber
= client
->sequence
,
712 .height
= attr
.height
,
713 .shiftX
= attr
.shiftX
,
714 .shiftY
= attr
.shiftY
717 if (client
->swapped
) {
718 swaps(&rep
.sequenceNumber
);
725 WriteToClient(client
, sizeof(xDMXGetDesktopAttributesReply
), &rep
);
730 ProcDMXChangeDesktopAttributes(ClientPtr client
)
732 REQUEST(xDMXChangeDesktopAttributesReq
);
733 xDMXChangeDesktopAttributesReply rep
;
734 int status
= DMX_BAD_XINERAMA
;
736 DMXDesktopAttributesRec attr
;
739 REQUEST_AT_LEAST_SIZE(xDMXChangeDesktopAttributesReq
);
740 len
= client
->req_len
- (sizeof(xDMXChangeDesktopAttributesReq
) >> 2);
741 if (len
!= Ones(stuff
->valueMask
))
744 if (!_DMXXineramaActive())
747 value_list
= (CARD32
*) (stuff
+ 1);
749 dmxGetDesktopAttributes(&attr
);
750 dmxFetchDesktopAttributes(stuff
->valueMask
, &attr
, value_list
);
753 status
= dmxConfigureDesktop(&attr
);
755 if (status
== BadValue
)
759 rep
= (xDMXChangeDesktopAttributesReply
) {
761 .sequenceNumber
= client
->sequence
,
765 if (client
->swapped
) {
766 swaps(&rep
.sequenceNumber
);
770 WriteToClient(client
, sizeof(xDMXChangeDesktopAttributesReply
), &rep
);
775 ProcDMXGetInputCount(ClientPtr client
)
777 xDMXGetInputCountReply rep
;
779 REQUEST_SIZE_MATCH(xDMXGetInputCountReq
);
781 rep
= (xDMXGetInputCountReply
) {
783 .sequenceNumber
= client
->sequence
,
785 .inputCount
= dmxGetInputCount()
787 if (client
->swapped
) {
788 swaps(&rep
.sequenceNumber
);
790 swapl(&rep
.inputCount
);
792 WriteToClient(client
, sizeof(xDMXGetInputCountReply
), &rep
);
797 ProcDMXGetInputAttributes(ClientPtr client
)
799 REQUEST(xDMXGetInputAttributesReq
);
800 xDMXGetInputAttributesReply rep
;
803 DMXInputAttributesRec attr
;
805 REQUEST_SIZE_MATCH(xDMXGetInputAttributesReq
);
807 if (dmxGetInputAttributes(stuff
->deviceId
, &attr
))
810 length
= attr
.name
? strlen(attr
.name
) : 0;
811 paddedLength
= pad_to_int32(length
);
813 rep
= (xDMXGetInputAttributesReply
) {
815 .sequenceNumber
= client
->sequence
,
816 .length
= bytes_to_int32(paddedLength
),
818 .inputType
= attr
.inputType
,
819 .physicalScreen
= attr
.physicalScreen
,
820 .physicalId
= attr
.physicalId
,
821 .nameLength
= length
,
822 .isCore
= attr
.isCore
,
823 .sendsCore
= attr
.sendsCore
,
824 .detached
= attr
.detached
827 if (client
->swapped
) {
828 swaps(&rep
.sequenceNumber
);
830 swapl(&rep
.inputType
);
831 swapl(&rep
.physicalScreen
);
832 swapl(&rep
.physicalId
);
833 swapl(&rep
.nameLength
);
835 WriteToClient(client
, sizeof(xDMXGetInputAttributesReply
), &rep
);
837 WriteToClient(client
, length
, attr
.name
);
842 ProcDMXAddInput(ClientPtr client
)
844 REQUEST(xDMXAddInputReq
);
845 xDMXAddInputReply rep
;
848 DMXInputAttributesRec attr
;
855 REQUEST_AT_LEAST_SIZE(xDMXAddInputReq
);
856 paddedLength
= pad_to_int32(stuff
->displayNameLength
);
857 len
= client
->req_len
- (sizeof(xDMXAddInputReq
) >> 2);
858 if (len
!= Ones(stuff
->valueMask
) + paddedLength
/ 4)
861 memset(&attr
, 0, sizeof(attr
));
862 value_list
= (CARD32
*) (stuff
+ 1);
863 count
= dmxFetchInputAttributes(stuff
->valueMask
, &attr
, value_list
);
865 if (!(name
= malloc(stuff
->displayNameLength
+ 1 + 4)))
867 memcpy(name
, &value_list
[count
], stuff
->displayNameLength
);
868 name
[stuff
->displayNameLength
] = '\0';
871 status
= dmxAddInput(&attr
, &id
);
878 rep
= (xDMXAddInputReply
) {
880 .sequenceNumber
= client
->sequence
,
885 if (client
->swapped
) {
886 swaps(&rep
.sequenceNumber
);
889 swapl(&rep
.physicalId
);
891 WriteToClient(client
, sizeof(xDMXAddInputReply
), &rep
);
896 ProcDMXRemoveInput(ClientPtr client
)
898 REQUEST(xDMXRemoveInputReq
);
899 xDMXRemoveInputReply rep
;
902 REQUEST_SIZE_MATCH(xDMXRemoveInputReq
);
904 status
= dmxRemoveInput(stuff
->physicalId
);
909 rep
= (xDMXRemoveInputReply
) {
911 .sequenceNumber
= client
->sequence
,
915 if (client
->swapped
) {
916 swaps(&rep
.sequenceNumber
);
920 WriteToClient(client
, sizeof(xDMXRemoveInputReply
), &rep
);
925 ProcDMXDispatch(ClientPtr client
)
929 switch (stuff
->data
) {
930 case X_DMXQueryVersion
:
931 return ProcDMXQueryVersion(client
);
933 return ProcDMXSync(client
);
934 case X_DMXForceWindowCreation
:
935 return ProcDMXForceWindowCreation(client
);
936 case X_DMXGetScreenCount
:
937 return ProcDMXGetScreenCount(client
);
938 case X_DMXGetScreenAttributes
:
939 return ProcDMXGetScreenAttributes(client
);
940 case X_DMXChangeScreensAttributes
:
941 return ProcDMXChangeScreensAttributes(client
);
943 return ProcDMXAddScreen(client
);
944 case X_DMXRemoveScreen
:
945 return ProcDMXRemoveScreen(client
);
946 case X_DMXGetWindowAttributes
:
947 return ProcDMXGetWindowAttributes(client
);
948 case X_DMXGetDesktopAttributes
:
949 return ProcDMXGetDesktopAttributes(client
);
950 case X_DMXChangeDesktopAttributes
:
951 return ProcDMXChangeDesktopAttributes(client
);
952 case X_DMXGetInputCount
:
953 return ProcDMXGetInputCount(client
);
954 case X_DMXGetInputAttributes
:
955 return ProcDMXGetInputAttributes(client
);
957 return ProcDMXAddInput(client
);
958 case X_DMXRemoveInput
:
959 return ProcDMXRemoveInput(client
);
961 case X_DMXGetScreenInformationDEPRECATED
:
962 case X_DMXForceWindowCreationDEPRECATED
:
963 case X_DMXReconfigureScreenDEPRECATED
:
964 return BadImplementation
;
972 SProcDMXQueryVersion(ClientPtr client
)
974 REQUEST(xDMXQueryVersionReq
);
976 swaps(&stuff
->length
);
977 REQUEST_SIZE_MATCH(xDMXQueryVersionReq
);
978 return ProcDMXQueryVersion(client
);
982 SProcDMXSync(ClientPtr client
)
984 REQUEST(xDMXSyncReq
);
986 swaps(&stuff
->length
);
987 REQUEST_SIZE_MATCH(xDMXSyncReq
);
988 return ProcDMXSync(client
);
992 SProcDMXForceWindowCreation(ClientPtr client
)
994 REQUEST(xDMXForceWindowCreationReq
);
996 swaps(&stuff
->length
);
997 REQUEST_SIZE_MATCH(xDMXForceWindowCreationReq
);
998 swapl(&stuff
->window
);
999 return ProcDMXForceWindowCreation(client
);
1003 SProcDMXGetScreenCount(ClientPtr client
)
1005 REQUEST(xDMXGetScreenCountReq
);
1007 swaps(&stuff
->length
);
1008 REQUEST_SIZE_MATCH(xDMXGetScreenCountReq
);
1009 return ProcDMXGetScreenCount(client
);
1013 SProcDMXGetScreenAttributes(ClientPtr client
)
1015 REQUEST(xDMXGetScreenAttributesReq
);
1017 swaps(&stuff
->length
);
1018 REQUEST_SIZE_MATCH(xDMXGetScreenAttributesReq
);
1019 swapl(&stuff
->physicalScreen
);
1020 return ProcDMXGetScreenAttributes(client
);
1024 SProcDMXChangeScreensAttributes(ClientPtr client
)
1026 REQUEST(xDMXChangeScreensAttributesReq
);
1028 swaps(&stuff
->length
);
1029 REQUEST_AT_LEAST_SIZE(xDMXGetScreenAttributesReq
);
1030 swapl(&stuff
->screenCount
);
1031 swapl(&stuff
->maskCount
);
1033 return ProcDMXGetScreenAttributes(client
);
1037 SProcDMXAddScreen(ClientPtr client
)
1041 REQUEST(xDMXAddScreenReq
);
1043 swaps(&stuff
->length
);
1044 REQUEST_AT_LEAST_SIZE(xDMXAddScreenReq
);
1045 swapl(&stuff
->displayNameLength
);
1046 swapl(&stuff
->valueMask
);
1047 paddedLength
= pad_to_int32(stuff
->displayNameLength
);
1048 SwapLongs((CARD32
*) (stuff
+ 1), LengthRestL(stuff
) - paddedLength
/ 4);
1049 return ProcDMXAddScreen(client
);
1053 SProcDMXRemoveScreen(ClientPtr client
)
1055 REQUEST(xDMXRemoveScreenReq
);
1057 swaps(&stuff
->length
);
1058 REQUEST_SIZE_MATCH(xDMXRemoveScreenReq
);
1059 swapl(&stuff
->physicalScreen
);
1060 return ProcDMXRemoveScreen(client
);
1064 SProcDMXGetWindowAttributes(ClientPtr client
)
1066 REQUEST(xDMXGetWindowAttributesReq
);
1068 swaps(&stuff
->length
);
1069 REQUEST_SIZE_MATCH(xDMXGetWindowAttributesReq
);
1070 swapl(&stuff
->window
);
1071 return ProcDMXGetWindowAttributes(client
);
1075 SProcDMXGetDesktopAttributes(ClientPtr client
)
1077 REQUEST(xDMXGetDesktopAttributesReq
);
1079 swaps(&stuff
->length
);
1080 REQUEST_SIZE_MATCH(xDMXGetDesktopAttributesReq
);
1081 return ProcDMXGetDesktopAttributes(client
);
1085 SProcDMXChangeDesktopAttributes(ClientPtr client
)
1087 REQUEST(xDMXChangeDesktopAttributesReq
);
1089 swaps(&stuff
->length
);
1090 REQUEST_AT_LEAST_SIZE(xDMXChangeDesktopAttributesReq
);
1091 swapl(&stuff
->valueMask
);
1093 return ProcDMXChangeDesktopAttributes(client
);
1097 SProcDMXGetInputCount(ClientPtr client
)
1099 REQUEST(xDMXGetInputCountReq
);
1101 swaps(&stuff
->length
);
1102 REQUEST_SIZE_MATCH(xDMXGetInputCountReq
);
1103 return ProcDMXGetInputCount(client
);
1107 SProcDMXGetInputAttributes(ClientPtr client
)
1109 REQUEST(xDMXGetInputAttributesReq
);
1111 swaps(&stuff
->length
);
1112 REQUEST_SIZE_MATCH(xDMXGetInputAttributesReq
);
1113 swapl(&stuff
->deviceId
);
1114 return ProcDMXGetInputAttributes(client
);
1118 SProcDMXAddInput(ClientPtr client
)
1122 REQUEST(xDMXAddInputReq
);
1124 swaps(&stuff
->length
);
1125 REQUEST_AT_LEAST_SIZE(xDMXAddInputReq
);
1126 swapl(&stuff
->displayNameLength
);
1127 swapl(&stuff
->valueMask
);
1128 paddedLength
= pad_to_int32(stuff
->displayNameLength
);
1129 SwapLongs((CARD32
*) (stuff
+ 1), LengthRestL(stuff
) - paddedLength
/ 4);
1130 return ProcDMXAddInput(client
);
1134 SProcDMXRemoveInput(ClientPtr client
)
1136 REQUEST(xDMXRemoveInputReq
);
1138 swaps(&stuff
->length
);
1139 REQUEST_SIZE_MATCH(xDMXRemoveInputReq
);
1140 swapl(&stuff
->physicalId
);
1141 return ProcDMXRemoveInput(client
);
1145 SProcDMXDispatch(ClientPtr client
)
1149 switch (stuff
->data
) {
1150 case X_DMXQueryVersion
:
1151 return SProcDMXQueryVersion(client
);
1153 return SProcDMXSync(client
);
1154 case X_DMXForceWindowCreation
:
1155 return SProcDMXForceWindowCreation(client
);
1156 case X_DMXGetScreenCount
:
1157 return SProcDMXGetScreenCount(client
);
1158 case X_DMXGetScreenAttributes
:
1159 return SProcDMXGetScreenAttributes(client
);
1160 case X_DMXChangeScreensAttributes
:
1161 return SProcDMXChangeScreensAttributes(client
);
1162 case X_DMXAddScreen
:
1163 return SProcDMXAddScreen(client
);
1164 case X_DMXRemoveScreen
:
1165 return SProcDMXRemoveScreen(client
);
1166 case X_DMXGetWindowAttributes
:
1167 return SProcDMXGetWindowAttributes(client
);
1168 case X_DMXGetDesktopAttributes
:
1169 return SProcDMXGetDesktopAttributes(client
);
1170 case X_DMXChangeDesktopAttributes
:
1171 return SProcDMXChangeDesktopAttributes(client
);
1172 case X_DMXGetInputCount
:
1173 return SProcDMXGetInputCount(client
);
1174 case X_DMXGetInputAttributes
:
1175 return SProcDMXGetInputAttributes(client
);
1177 return SProcDMXAddInput(client
);
1178 case X_DMXRemoveInput
:
1179 return SProcDMXRemoveInput(client
);
1181 case X_DMXGetScreenInformationDEPRECATED
:
1182 case X_DMXForceWindowCreationDEPRECATED
:
1183 case X_DMXReconfigureScreenDEPRECATED
:
1184 return BadImplementation
;
1191 /** Initialize the extension. */
1193 DMXExtensionInit(void)
1195 ExtensionEntry
*extEntry
;
1197 if ((extEntry
= AddExtension(DMX_EXTENSION_NAME
, 0, 0,
1198 ProcDMXDispatch
, SProcDMXDispatch
,
1199 NULL
, StandardMinorOpcode
)))
1200 DMXCode
= extEntry
->base
;