dmxcb.c 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  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. * Authors:
  29. * Rickard E. (Rik) Faith <faith@redhat.com>
  30. *
  31. */
  32. /** \file
  33. * This code queries and modifies the connection block. */
  34. #ifdef HAVE_DMX_CONFIG_H
  35. #include <dmx-config.h>
  36. #endif
  37. #include "dmx.h"
  38. #include "dmxcb.h"
  39. #include "dmxinput.h"
  40. #include "dmxlog.h"
  41. extern int connBlockScreenStart;
  42. #ifdef PANORAMIX
  43. #include "panoramiXsrv.h"
  44. extern int PanoramiXPixWidth;
  45. extern int PanoramiXPixHeight;
  46. extern int PanoramiXNumScreens;
  47. #endif
  48. int dmxGlobalWidth, dmxGlobalHeight;
  49. /** We may want the wall dimensions to be different from the bounding
  50. * box dimensions that Xinerama computes, so save those and update them
  51. * here.
  52. */
  53. void
  54. dmxSetWidthHeight(int width, int height)
  55. {
  56. dmxGlobalWidth = width;
  57. dmxGlobalHeight = height;
  58. }
  59. /** Computes the global bounding box for DMX. This may be larger than
  60. * the one computed by Xinerama because of the DMX configuration
  61. * file. */
  62. void
  63. dmxComputeWidthHeight(DMXRecomputeFlag flag)
  64. {
  65. int i;
  66. DMXScreenInfo *dmxScreen;
  67. int w = 0;
  68. int h = 0;
  69. for (i = 0; i < dmxNumScreens; i++) {
  70. /* Don't use root* here because this is
  71. * the global bounding box. */
  72. dmxScreen = &dmxScreens[i];
  73. if (w < dmxScreen->scrnWidth + dmxScreen->rootXOrigin)
  74. w = dmxScreen->scrnWidth + dmxScreen->rootXOrigin;
  75. if (h < dmxScreen->scrnHeight + dmxScreen->rootYOrigin)
  76. h = dmxScreen->scrnHeight + dmxScreen->rootYOrigin;
  77. }
  78. if (!dmxGlobalWidth && !dmxGlobalHeight) {
  79. dmxLog(dmxInfo, "Using %dx%d as global bounding box\n", w, h);
  80. }
  81. else {
  82. switch (flag) {
  83. case DMX_NO_RECOMPUTE_BOUNDING_BOX:
  84. dmxLog(dmxInfo,
  85. "Using old bounding box (%dx%d) instead of new (%dx%d)\n",
  86. dmxGlobalWidth, dmxGlobalHeight, w, h);
  87. w = dmxGlobalWidth;
  88. h = dmxGlobalHeight;
  89. break;
  90. case DMX_RECOMPUTE_BOUNDING_BOX:
  91. dmxLog(dmxInfo,
  92. "Using %dx%d as global bounding box, instead of %dx%d\n",
  93. w, h, dmxGlobalWidth, dmxGlobalHeight);
  94. break;
  95. }
  96. }
  97. dmxGlobalWidth = w;
  98. dmxGlobalHeight = h;
  99. }
  100. /** A callback routine that hooks into Xinerama and provides a
  101. * convenient place to print summary log information during server
  102. * startup. This routine does not modify any values. */
  103. void
  104. dmxConnectionBlockCallback(void)
  105. {
  106. xWindowRoot *root = (xWindowRoot *) (ConnectionInfo + connBlockScreenStart);
  107. int offset = connBlockScreenStart + sizeof(xWindowRoot);
  108. int i;
  109. Bool *found = NULL;
  110. MAXSCREENSALLOC(found);
  111. if (!found)
  112. dmxLog(dmxFatal, "dmxConnectionBlockCallback: out of memory\n");
  113. dmxLog(dmxInfo, "===== Start of Summary =====\n");
  114. #ifdef PANORAMIX
  115. if (!noPanoramiXExtension) {
  116. if (dmxGlobalWidth && dmxGlobalHeight
  117. && (dmxGlobalWidth != PanoramiXPixWidth
  118. || dmxGlobalHeight != PanoramiXPixHeight)) {
  119. dmxLog(dmxInfo,
  120. "Changing Xinerama dimensions from %d %d to %d %d\n",
  121. PanoramiXPixWidth, PanoramiXPixHeight,
  122. dmxGlobalWidth, dmxGlobalHeight);
  123. PanoramiXPixWidth = root->pixWidth = dmxGlobalWidth;
  124. PanoramiXPixHeight = root->pixHeight = dmxGlobalHeight;
  125. }
  126. else {
  127. dmxGlobalWidth = PanoramiXPixWidth;
  128. dmxGlobalHeight = PanoramiXPixHeight;
  129. }
  130. dmxLog(dmxInfo, "%d screens configured with Xinerama (%d %d)\n",
  131. PanoramiXNumScreens, PanoramiXPixWidth, PanoramiXPixHeight);
  132. FOR_NSCREENS(i) found[i] = FALSE;
  133. }
  134. else {
  135. #endif
  136. /* This never happens because we're
  137. * either called from a Xinerama
  138. * callback or during reconfiguration
  139. * (which only works with Xinerama on).
  140. * In any case, be reasonable. */
  141. dmxLog(dmxInfo, "%d screens configured (%d %d)\n",
  142. screenInfo.numScreens, root->pixWidth, root->pixHeight);
  143. #ifdef PANORAMIX
  144. }
  145. #endif
  146. for (i = 0; i < root->nDepths; i++) {
  147. xDepth *depth = (xDepth *) (ConnectionInfo + offset);
  148. int voffset = offset + sizeof(xDepth);
  149. xVisualType *visual = (xVisualType *) (ConnectionInfo + voffset);
  150. int j;
  151. dmxLog(dmxInfo, "%d visuals at depth %d:\n",
  152. depth->nVisuals, depth->depth);
  153. for (j = 0; j < depth->nVisuals; j++, visual++) {
  154. XVisualInfo vi;
  155. vi.visual = NULL;
  156. vi.visualid = visual->visualID;
  157. vi.screen = 0;
  158. vi.depth = depth->depth;
  159. vi.class = visual->class;
  160. vi.red_mask = visual->redMask;
  161. vi.green_mask = visual->greenMask;
  162. vi.blue_mask = visual->blueMask;
  163. vi.colormap_size = visual->colormapEntries;
  164. vi.bits_per_rgb = visual->bitsPerRGB;
  165. dmxLogVisual(NULL, &vi, 0);
  166. #ifdef PANORAMIX
  167. if (!noPanoramiXExtension) {
  168. int k;
  169. FOR_NSCREENS(k) {
  170. DMXScreenInfo *dmxScreen = &dmxScreens[k];
  171. if (dmxScreen->beDisplay) {
  172. XVisualInfo *pvi =
  173. &dmxScreen->beVisuals[dmxScreen->beDefVisualIndex];
  174. if (pvi->depth == depth->depth &&
  175. pvi->class == visual->class)
  176. found[k] = TRUE;
  177. }
  178. else {
  179. /* Screen #k is detatched, so it always succeeds */
  180. found[k] = TRUE;
  181. }
  182. }
  183. }
  184. #endif
  185. }
  186. offset = voffset + depth->nVisuals * sizeof(xVisualType);
  187. }
  188. dmxInputLogDevices();
  189. dmxLog(dmxInfo, "===== End of Summary =====\n");
  190. #ifdef PANORAMIX
  191. if (!noPanoramiXExtension) {
  192. Bool fatal = FALSE;
  193. FOR_NSCREENS(i) {
  194. fatal |= !found[i];
  195. if (!found[i]) {
  196. dmxLog(dmxError,
  197. "The default visual for screen #%d does not match "
  198. "any of the\n", i);
  199. dmxLog(dmxError,
  200. "consolidated visuals from Xinerama (listed above)\n");
  201. }
  202. }
  203. if (fatal)
  204. dmxLog(dmxFatal,
  205. "dmxConnectionBlockCallback: invalid screen(s) found");
  206. }
  207. #endif
  208. MAXSCREENSFREE(found);
  209. }