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 extern int PanoramiXPixWidth;
50 extern int PanoramiXPixHeight;
51 extern int PanoramiXNumScreens;
54 int dmxGlobalWidth, dmxGlobalHeight;
56 /** We may want the wall dimensions to be different from the bounding
57 * box dimensions that Xinerama computes, so save those and update them
60 void dmxSetWidthHeight(int width, int height)
62 dmxGlobalWidth = width;
63 dmxGlobalHeight = height;
66 /** Computes the global bounding box for DMX. This may be larger than
67 * the one computed by Xinerama because of the DMX configuration
69 void dmxComputeWidthHeight(DMXRecomputeFlag flag)
72 DMXScreenInfo *dmxScreen;
76 for (i = 0; i < dmxNumScreens; i++) {
77 /* Don't use root* here because this is
78 * the global bounding box. */
79 dmxScreen = &dmxScreens[i];
80 if (w < dmxScreen->scrnWidth + dmxScreen->rootXOrigin)
81 w = dmxScreen->scrnWidth + dmxScreen->rootXOrigin;
82 if (h < dmxScreen->scrnHeight + dmxScreen->rootYOrigin)
83 h = dmxScreen->scrnHeight + dmxScreen->rootYOrigin;
85 if (!dmxGlobalWidth && !dmxGlobalHeight) {
86 dmxLog(dmxInfo, "Using %dx%d as global bounding box\n", w, h);
89 case DMX_NO_RECOMPUTE_BOUNDING_BOX:
91 "Using old bounding box (%dx%d) instead of new (%dx%d)\n",
92 dmxGlobalWidth, dmxGlobalHeight, w, h);
96 case DMX_RECOMPUTE_BOUNDING_BOX:
98 "Using %dx%d as global bounding box, instead of %dx%d\n",
99 w, h, dmxGlobalWidth, dmxGlobalHeight);
108 /** A callback routine that hooks into Xinerama and provides a
109 * convenient place to print summary log information during server
110 * startup. This routine does not modify any values. */
111 void dmxConnectionBlockCallback(void)
113 xWindowRoot *root = (xWindowRoot *)(ConnectionInfo+connBlockScreenStart);
114 int offset = connBlockScreenStart + sizeof(xWindowRoot);
118 MAXSCREENSALLOC(found);
120 dmxLog(dmxFatal, "dmxConnectionBlockCallback: out of memory\n");
122 dmxLog(dmxInfo, "===== Start of Summary =====\n");
124 if (!noPanoramiXExtension) {
125 if (dmxGlobalWidth && dmxGlobalHeight
126 && (dmxGlobalWidth != PanoramiXPixWidth
127 || dmxGlobalHeight != PanoramiXPixHeight)) {
129 "Changing Xinerama dimensions from %d %d to %d %d\n",
130 PanoramiXPixWidth, PanoramiXPixHeight,
131 dmxGlobalWidth, dmxGlobalHeight);
132 PanoramiXPixWidth = root->pixWidth = dmxGlobalWidth;
133 PanoramiXPixHeight = root->pixHeight = dmxGlobalHeight;
135 dmxGlobalWidth = PanoramiXPixWidth;
136 dmxGlobalHeight = PanoramiXPixHeight;
138 dmxLog(dmxInfo, "%d screens configured with Xinerama (%d %d)\n",
139 PanoramiXNumScreens, PanoramiXPixWidth, PanoramiXPixHeight);
140 for (i = 0; i < PanoramiXNumScreens; i++) found[i] = FALSE;
143 /* This never happens because we're
144 * either called from a Xinerama
145 * callback or during reconfiguration
146 * (which only works with Xinerama on).
147 * In any case, be reasonable. */
148 dmxLog(dmxInfo, "%d screens configured (%d %d)\n",
149 screenInfo.numScreens, root->pixWidth, root->pixHeight);
154 for (i = 0; i < root->nDepths; i++) {
155 xDepth *depth = (xDepth *)(ConnectionInfo + offset);
156 int voffset = offset + sizeof(xDepth);
157 xVisualType *visual = (xVisualType *)(ConnectionInfo + voffset);
160 dmxLog(dmxInfo, "%d visuals at depth %d:\n",
161 depth->nVisuals, depth->depth);
162 for (j = 0; j < depth->nVisuals; j++, visual++) {
166 vi.visualid = visual->visualID;
168 vi.depth = depth->depth;
169 vi.class = visual->class;
170 vi.red_mask = visual->redMask;
171 vi.green_mask = visual->greenMask;
172 vi.blue_mask = visual->blueMask;
173 vi.colormap_size = visual->colormapEntries;
174 vi.bits_per_rgb = visual->bitsPerRGB;
175 dmxLogVisual(NULL, &vi, 0);
178 if (!noPanoramiXExtension) {
180 for (k = 0; k < PanoramiXNumScreens; k++) {
181 DMXScreenInfo *dmxScreen = &dmxScreens[k];
183 if (dmxScreen->beDisplay) {
185 &dmxScreen->beVisuals[dmxScreen->beDefVisualIndex];
186 if (pvi->depth == depth->depth &&
187 pvi->class == visual->class)
190 /* Screen #k is detatched, so it always succeeds */
197 offset = voffset + depth->nVisuals * sizeof(xVisualType);
200 dmxInputLogDevices();
201 dmxLog(dmxInfo, "===== End of Summary =====\n");
204 if (!noPanoramiXExtension) {
206 for (i = 0; i < PanoramiXNumScreens; i++) {
210 "The default visual for screen #%d does not match "
213 "consolidated visuals from Xinerama (listed above)\n");
218 "dmxConnectionBlockCallback: invalid screen(s) found");
221 MAXSCREENSFREE(found);