Add patch that contain Mali fixes.
[deb_xorg-server.git] / hw / dmx / dmxcb.c
1 /*
2 * Copyright 2001-2004 Red Hat Inc., Durham, North Carolina.
3 *
4 * All Rights Reserved.
5 *
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:
13 *
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.
17 *
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
25 * SOFTWARE.
26 */
27
28 /*
29 * Authors:
30 * Rickard E. (Rik) Faith <faith@redhat.com>
31 *
32 */
33
34 /** \file
35 * This code queries and modifies the connection block. */
36
37 #ifdef HAVE_DMX_CONFIG_H
38 #include <dmx-config.h>
39 #endif
40
41 #include "dmx.h"
42 #include "dmxcb.h"
43 #include "dmxinput.h"
44 #include "dmxlog.h"
45
46 extern int connBlockScreenStart;
47
48 #ifdef PANORAMIX
49 #include "panoramiXsrv.h"
50 extern int PanoramiXPixWidth;
51 extern int PanoramiXPixHeight;
52 extern int PanoramiXNumScreens;
53 #endif
54
55 int dmxGlobalWidth, dmxGlobalHeight;
56
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
59 * here.
60 */
61 void
62 dmxSetWidthHeight(int width, int height)
63 {
64 dmxGlobalWidth = width;
65 dmxGlobalHeight = height;
66 }
67
68 /** Computes the global bounding box for DMX. This may be larger than
69 * the one computed by Xinerama because of the DMX configuration
70 * file. */
71 void
72 dmxComputeWidthHeight(DMXRecomputeFlag flag)
73 {
74 int i;
75 DMXScreenInfo *dmxScreen;
76 int w = 0;
77 int h = 0;
78
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;
87 }
88 if (!dmxGlobalWidth && !dmxGlobalHeight) {
89 dmxLog(dmxInfo, "Using %dx%d as global bounding box\n", w, h);
90 }
91 else {
92 switch (flag) {
93 case DMX_NO_RECOMPUTE_BOUNDING_BOX:
94 dmxLog(dmxInfo,
95 "Using old bounding box (%dx%d) instead of new (%dx%d)\n",
96 dmxGlobalWidth, dmxGlobalHeight, w, h);
97 w = dmxGlobalWidth;
98 h = dmxGlobalHeight;
99 break;
100 case DMX_RECOMPUTE_BOUNDING_BOX:
101 dmxLog(dmxInfo,
102 "Using %dx%d as global bounding box, instead of %dx%d\n",
103 w, h, dmxGlobalWidth, dmxGlobalHeight);
104 break;
105 }
106 }
107
108 dmxGlobalWidth = w;
109 dmxGlobalHeight = h;
110 }
111
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. */
115 void
116 dmxConnectionBlockCallback(void)
117 {
118 xWindowRoot *root = (xWindowRoot *) (ConnectionInfo + connBlockScreenStart);
119 int offset = connBlockScreenStart + sizeof(xWindowRoot);
120 int i;
121 Bool *found = NULL;
122
123 MAXSCREENSALLOC(found);
124 if (!found)
125 dmxLog(dmxFatal, "dmxConnectionBlockCallback: out of memory\n");
126
127 dmxLog(dmxInfo, "===== Start of Summary =====\n");
128 #ifdef PANORAMIX
129 if (!noPanoramiXExtension) {
130 if (dmxGlobalWidth && dmxGlobalHeight
131 && (dmxGlobalWidth != PanoramiXPixWidth
132 || dmxGlobalHeight != PanoramiXPixHeight)) {
133 dmxLog(dmxInfo,
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;
139 }
140 else {
141 dmxGlobalWidth = PanoramiXPixWidth;
142 dmxGlobalHeight = PanoramiXPixHeight;
143 }
144 dmxLog(dmxInfo, "%d screens configured with Xinerama (%d %d)\n",
145 PanoramiXNumScreens, PanoramiXPixWidth, PanoramiXPixHeight);
146 FOR_NSCREENS(i) found[i] = FALSE;
147 }
148 else {
149 #endif
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);
157 #ifdef PANORAMIX
158 }
159 #endif
160
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);
165 int j;
166
167 dmxLog(dmxInfo, "%d visuals at depth %d:\n",
168 depth->nVisuals, depth->depth);
169 for (j = 0; j < depth->nVisuals; j++, visual++) {
170 XVisualInfo vi;
171
172 vi.visual = NULL;
173 vi.visualid = visual->visualID;
174 vi.screen = 0;
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);
183
184 #ifdef PANORAMIX
185 if (!noPanoramiXExtension) {
186 int k;
187
188 FOR_NSCREENS(k) {
189 DMXScreenInfo *dmxScreen = &dmxScreens[k];
190
191 if (dmxScreen->beDisplay) {
192 XVisualInfo *pvi =
193 &dmxScreen->beVisuals[dmxScreen->beDefVisualIndex];
194 if (pvi->depth == depth->depth &&
195 pvi->class == visual->class)
196 found[k] = TRUE;
197 }
198 else {
199 /* Screen #k is detatched, so it always succeeds */
200 found[k] = TRUE;
201 }
202 }
203 }
204 #endif
205 }
206 offset = voffset + depth->nVisuals * sizeof(xVisualType);
207 }
208
209 dmxInputLogDevices();
210 dmxLog(dmxInfo, "===== End of Summary =====\n");
211
212 #ifdef PANORAMIX
213 if (!noPanoramiXExtension) {
214 Bool fatal = FALSE;
215
216 FOR_NSCREENS(i) {
217 fatal |= !found[i];
218 if (!found[i]) {
219 dmxLog(dmxError,
220 "The default visual for screen #%d does not match "
221 "any of the\n", i);
222 dmxLog(dmxError,
223 "consolidated visuals from Xinerama (listed above)\n");
224 }
225 }
226 if (fatal)
227 dmxLog(dmxFatal,
228 "dmxConnectionBlockCallback: invalid screen(s) found");
229 }
230 #endif
231 MAXSCREENSFREE(found);
232 }