[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Need some advice/comments on a potential patch for xbattle



Hi folks,

I'm looking at adopting xbattle for the games team also and have made the following patch for bug #241334

diff -urN xbattle-5.4.1.orig/window.c xbattle-5.4.1.test/window.c
--- xbattle-5.4.1.orig/window.c 1995-12-19 17:21:51.000000000 -0500
+++ xbattle-5.4.1.test/window.c 2007-12-11 09:00:46.000000000 -0500
@@ -744,34 +744,46 @@
  xwindow->depth = DefaultDepth (xwindow->display, xwindow->screen);
  full_depth = xwindow->depth;

+  printf("Found xwindow depth: %d\n", xwindow->depth);
  /** Get a visual **/

  visual = DefaultVisual (xwindow->display, xwindow->screen);

  /** Try to force the display to 8 planes **/

-  if (xwindow->depth != 8)
+  int foo;
+  for (foo = 4; foo < 33; foo = foo * 2)
  {
    if (XMatchVisualInfo
-               (xwindow->display, xwindow->screen, 8, PseudoColor, &vinfo))
+ (xwindow->display, xwindow->screen, foo, PseudoColor, &vinfo))
    {
      visual = vinfo.visual;
-      xwindow->depth = 8;
+      xwindow->depth = foo;
+    }
+    else
+    {
+      xwindow->depth = 0;
    }
  }

-  /** If couldn't find an 8 bit visual, try a 16 bit visual **/
+  /** Try TrueColor **/

-  if (xwindow->depth != 8)
+  int foo2;
+  for (foo2 = 4; foo2 < 33; foo2 = foo2 * 2)
  {
    if (XMatchVisualInfo
- (xwindow->display, xwindow->screen, 16, PseudoColor, &vinfo)) + (xwindow->display, xwindow->screen, foo2, TrueColor, &vinfo))
    {
      visual = vinfo.visual;
-      xwindow->depth = 16;
+      xwindow->depth = foo2;
+    }
+    else
+    {
+      xwindow->depth = 0;
    }
  }

+
  /** If have less than 8 planes, just use a single plane **/

  if (xwindow->depth < 8)
@@ -797,13 +809,15 @@
/** In these cases, it may be possible to reconfigure the display **/
      /** to 8 or 16 bits.                                             **/

+/** Not sure what to do with this **/
+/**
      if (xwindow->depth > 16)
      {
        throw_warning ("No PseudoColor visual available\n%s",
               "         Try changing display to <= 16 bits");
        throw_error ("Unable to continue without colormap", NULL);
      }
-
+**/
      /** If display is 24 bit, have to create a dedicated colormap **/

      xwindow->cmap = XCreateColormap (xwindow->display,


Does this look reasonable? Especially the part where I comment out the check for xwindow->depth > 16. It seems to run fine.

Thanks,

Barry deFreese



Reply to: