2 * Copyright 2001-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 code queries and modifies the connection block. */
37 #ifdef HAVE_DMX_CONFIG_H
38 #include <dmx-config.h>
46 extern int connBlockScreenStart
;
49 #include "panoramiXsrv.h"
50 extern int PanoramiXPixWidth
;
51 extern int PanoramiXPixHeight
;
52 extern int PanoramiXNumScreens
;
55 int dmxGlobalWidth
, dmxGlobalHeight
;
57 /** We may want the wall dimensions to be different from the bounding
58 * box dimensions that Xinerama computes, so save those and update them
62 dmxSetWidthHeight(int width
, int height
)
64 dmxGlobalWidth
= width
;
65 dmxGlobalHeight
= height
;
68 /** Computes the global bounding box for DMX. This may be larger than
69 * the one computed by Xinerama because of the DMX configuration
72 dmxComputeWidthHeight(DMXRecomputeFlag flag
)
75 DMXScreenInfo
*dmxScreen
;
79 for (i
= 0; i
< dmxNumScreens
; i
++) {
80 /* Don't use root* here because this is
81 * the global bounding box. */
82 dmxScreen
= &dmxScreens
[i
];
83 if (w
< dmxScreen
->scrnWidth
+ dmxScreen
->rootXOrigin
)
84 w
= dmxScreen
->scrnWidth
+ dmxScreen
->rootXOrigin
;
85 if (h
< dmxScreen
->scrnHeight
+ dmxScreen
->rootYOrigin
)
86 h
= dmxScreen
->scrnHeight
+ dmxScreen
->rootYOrigin
;
88 if (!dmxGlobalWidth
&& !dmxGlobalHeight
) {
89 dmxLog(dmxInfo
, "Using %dx%d as global bounding box\n", w
, h
);
93 case DMX_NO_RECOMPUTE_BOUNDING_BOX
:
95 "Using old bounding box (%dx%d) instead of new (%dx%d)\n",
96 dmxGlobalWidth
, dmxGlobalHeight
, w
, h
);
100 case DMX_RECOMPUTE_BOUNDING_BOX
:
102 "Using %dx%d as global bounding box, instead of %dx%d\n",
103 w
, h
, dmxGlobalWidth
, dmxGlobalHeight
);
112 /** A callback routine that hooks into Xinerama and provides a
113 * convenient place to print summary log information during server
114 * startup. This routine does not modify any values. */
116 dmxConnectionBlockCallback(void)
118 xWindowRoot
*root
= (xWindowRoot
*) (ConnectionInfo
+ connBlockScreenStart
);
119 int offset
= connBlockScreenStart
+ sizeof(xWindowRoot
);
123 MAXSCREENSALLOC(found
);
125 dmxLog(dmxFatal
, "dmxConnectionBlockCallback: out of memory\n");
127 dmxLog(dmxInfo
, "===== Start of Summary =====\n");
129 if (!noPanoramiXExtension
) {
130 if (dmxGlobalWidth
&& dmxGlobalHeight
131 && (dmxGlobalWidth
!= PanoramiXPixWidth
132 || dmxGlobalHeight
!= PanoramiXPixHeight
)) {
134 "Changing Xinerama dimensions from %d %d to %d %d\n",
135 PanoramiXPixWidth
, PanoramiXPixHeight
,
136 dmxGlobalWidth
, dmxGlobalHeight
);
137 PanoramiXPixWidth
= root
->pixWidth
= dmxGlobalWidth
;
138 PanoramiXPixHeight
= root
->pixHeight
= dmxGlobalHeight
;
141 dmxGlobalWidth
= PanoramiXPixWidth
;
142 dmxGlobalHeight
= PanoramiXPixHeight
;
144 dmxLog(dmxInfo
, "%d screens configured with Xinerama (%d %d)\n",
145 PanoramiXNumScreens
, PanoramiXPixWidth
, PanoramiXPixHeight
);
146 FOR_NSCREENS(i
) found
[i
] = FALSE
;
150 /* This never happens because we're
151 * either called from a Xinerama
152 * callback or during reconfiguration
153 * (which only works with Xinerama on).
154 * In any case, be reasonable. */
155 dmxLog(dmxInfo
, "%d screens configured (%d %d)\n",
156 screenInfo
.numScreens
, root
->pixWidth
, root
->pixHeight
);
161 for (i
= 0; i
< root
->nDepths
; i
++) {
162 xDepth
*depth
= (xDepth
*) (ConnectionInfo
+ offset
);
163 int voffset
= offset
+ sizeof(xDepth
);
164 xVisualType
*visual
= (xVisualType
*) (ConnectionInfo
+ voffset
);
167 dmxLog(dmxInfo
, "%d visuals at depth %d:\n",
168 depth
->nVisuals
, depth
->depth
);
169 for (j
= 0; j
< depth
->nVisuals
; j
++, visual
++) {
173 vi
.visualid
= visual
->visualID
;
175 vi
.depth
= depth
->depth
;
176 vi
.class = visual
->class;
177 vi
.red_mask
= visual
->redMask
;
178 vi
.green_mask
= visual
->greenMask
;
179 vi
.blue_mask
= visual
->blueMask
;
180 vi
.colormap_size
= visual
->colormapEntries
;
181 vi
.bits_per_rgb
= visual
->bitsPerRGB
;
182 dmxLogVisual(NULL
, &vi
, 0);
185 if (!noPanoramiXExtension
) {
189 DMXScreenInfo
*dmxScreen
= &dmxScreens
[k
];
191 if (dmxScreen
->beDisplay
) {
193 &dmxScreen
->beVisuals
[dmxScreen
->beDefVisualIndex
];
194 if (pvi
->depth
== depth
->depth
&&
195 pvi
->class == visual
->class)
199 /* Screen #k is detatched, so it always succeeds */
206 offset
= voffset
+ depth
->nVisuals
* sizeof(xVisualType
);
209 dmxInputLogDevices();
210 dmxLog(dmxInfo
, "===== End of Summary =====\n");
213 if (!noPanoramiXExtension
) {
220 "The default visual for screen #%d does not match "
223 "consolidated visuals from Xinerama (listed above)\n");
228 "dmxConnectionBlockCallback: invalid screen(s) found");
231 MAXSCREENSFREE(found
);