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

Re: Need some advice/comments on a potential patch for xbattle



Op 2007-12-11, Barry deFreese schreef <bddebian@comcast.net>:
> Hi folks,
>
> I'm looking at adopting xbattle for the games team also and have made 
> the following patch for bug #241334
>
[snip]
>
> Does this look reasonable? Especially the part where I comment out the
> check for xwindow->depth > 16. It seems to run fine.

As far as I can tell, most of that code can safely be deleted. I
believe it's purely paranoia. Note the game doesn't complain about
16bpp TrueColor, and I can't find any report of xbattle not working in
that mode. Other TrueColor mode's don't work any differently.

The following patch runs tutorial1 fine for me with both 8bpp and
32bpp color.

Index: xbattle-5.4.1/window.c
===================================================================
--- xbattle-5.4.1.orig/window.c	2007-12-12 00:43:42.000000000 +0100
+++ xbattle-5.4.1/window.c	2007-12-12 00:44:35.000000000 +0100
@@ -708,8 +708,7 @@
   unsigned long valuemask;
   XSetWindowAttributes attrib;
   XVisualInfo vinfo;
-  long event_mask,
-       full_depth;
+  long event_mask;
   Atom wm_delete_window;
 
   /** Open display and screen **/
@@ -742,36 +741,11 @@
   /** Set bitplane depth to default **/
 
   xwindow->depth = DefaultDepth (xwindow->display, xwindow->screen);
-  full_depth = xwindow->depth;
 
   /** Get a visual **/
 
   visual = DefaultVisual (xwindow->display, xwindow->screen);
 
-  /** Try to force the display to 8 planes **/
-
-  if (xwindow->depth != 8)
-  {
-    if (XMatchVisualInfo
-		(xwindow->display, xwindow->screen, 8, PseudoColor, &vinfo))
-    {
-      visual = vinfo.visual;
-      xwindow->depth = 8;
-    }
-  }
-
-  /** If couldn't find an 8 bit visual, try a 16 bit visual **/
-
-  if (xwindow->depth != 8)
-  {
-    if (XMatchVisualInfo
-		(xwindow->display, xwindow->screen, 16, PseudoColor, &vinfo))
-    {
-      visual = vinfo.visual;
-      xwindow->depth = 16;
-    }
-  }
-
   /** If have less than 8 planes, just use a single plane **/
 
   if (xwindow->depth < 8)
@@ -790,20 +764,8 @@
 #else
     /** Allocate existing colormap **/
 
-    if (full_depth > 8)
+    if (xwindow->depth > 8)
     {
-      /** XBattle won't work for 24 bit displays with no optional	**/
-      /** visuals with 8 or 16 bits.  This may be the case on some PCs.	**/
-      /** In these cases, it may be possible to reconfigure the display	**/
-      /** to 8 or 16 bits.						**/
-
-      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,



Reply to: