Sophie

Sophie

distrib > Fedora > 14 > x86_64 > by-pkgid > 43be97ffa58d59d2c80c39f6a6f1c65e > files > 15

koules-1.4-9.fc14.src.rpm

From Debian: 108_use_right_visual.diff

diff -up koules1.4/xlib/init.c.use_right_visual koules1.4/xlib/init.c
--- koules1.4/xlib/init.c.use_right_visual	2009-04-13 21:21:50.639259228 +0200
+++ koules1.4/xlib/init.c	2009-04-13 21:27:57.082161986 +0200
@@ -95,7 +95,6 @@ extern Bool     XShmQueryVersion (Displa
                                   Bool * sharedpixmaps);
 static int      haderror;
 static int      (*origerrorhandler) (Display *, XErrorEvent *);
-static int      bpp;
 
 
 static int
@@ -179,14 +178,14 @@ GetImage (VScreenType * pixmap)	/*Work a
   VfTime = 1000000 / 25 * 12;
   pixmap->ximage = XCreateImage (dp, DefaultVisual (dp, screen),
 				 depth, ZPixmap, 0,
-				 NULL, Width, Height, bpp * 8, 0);
+				 NULL, Width, Height, depth, 0);
   if (!pixmap->ximage)
     {
       fprintf (stderr, "Can't get image\n");
       return 0;
     }
   /*Calculate size of shared memory */
-  memsize = ((Width + 1) * (Height + 1) * bpp);
+  memsize = ((Width + 1) * (Height + 1) * depth / 8);
   if ((data = malloc (memsize)) == NULL)
     {
       printf ("Can't malloc memory for image\n");
@@ -340,7 +339,6 @@ initialize (char **argv, int argc)
   char           *title1 = "Koules";
 
   Font            f;
-  XVisualInfo     vinfo_return;
   XGCValues       values;
 #ifndef NAS_SOUND
 #ifndef RSOUND
@@ -396,54 +394,46 @@ initialize (char **argv, int argc)
      XSynchronize (dp, 1);
   XSetCloseDownMode (dp, DestroyAll);
   screen = DefaultScreen (dp);
-  fadeenable = 1;
-  if (XMatchVisualInfo (dp, DefaultScreen (dp),
-			8, PseudoColor, &vinfo_return) == False)
-    {
-      fadeenable = 0;
-      printf ("X: Screen doesn't support PseudoColor!\n");
-      if (XMatchVisualInfo (dp, DefaultScreen (dp),
-			    32, TrueColor, &vinfo_return) == True)
-	{
-	  useprivate = 0;
-	  bpp = 4;
-	}
-      else if (XMatchVisualInfo (dp, DefaultScreen (dp),
-				 24, TrueColor, &vinfo_return) == True)
-	{
-	  useprivate = 0;
-	  bpp = 4;
-	}
-      else if (XMatchVisualInfo (dp, DefaultScreen (dp),
-				 16, TrueColor, &vinfo_return) == True)
-	{
-	  useprivate = 0;
-	  bpp = 2;
-	}
-      else if (XMatchVisualInfo (dp, DefaultScreen (dp),
-				 15, TrueColor, &vinfo_return) == True)
-	{
-	  useprivate = 0;
-	  bpp = 2;
-	}
-      else if (XMatchVisualInfo (dp, DefaultScreen (dp),
-				 8, GrayScale, &vinfo_return) == True)
-	{
-	  useprivate = 0;
-	  monochrome = 1;
-	  bpp = 2;
-	}
-      else
-	{
-	  printf ("Unsupported visual! Using slow and reliable mode\n");
+  {
+    XVisualInfo template;
+    XVisualInfo * vinfo;
+    int nitems_return;
+    template.visualid = XVisualIDFromVisual (DefaultVisual (dp, DefaultScreen (dp)));
+    vinfo = XGetVisualInfo (dp, VisualIDMask, &template, &nitems_return);
+    if (nitems_return == 0)
+      {
+        printf ("X server does not know about the default visual...");
+        exit (0);
+      }
+
+    if (vinfo->class == PseudoColor && vinfo->depth == 8)
+      {
+        fadeenable = 1;
+      }
+    else
+      {
+        fadeenable = 0;
+        printf ("X: Screen doesn't support PseudoColor!\n");
+        if (vinfo->class == TrueColor)
+          {
+            useprivate = 0;
+          }
+        else if (vinfo->class == GrayScale)
+          {
+            useprivate = 0;
+            monochrome = 1;
+          }
+        else
+          {
+            printf ("Unsupported visual! Using slow and reliable mode\n");
 #ifdef MITSHM
-	  shm = 0;
+            shm = 0;
 #endif
-	}
-    }
-  else
-    bpp = 1;
-  depth = vinfo_return.depth;
+          }
+      }
+    depth = vinfo->depth;
+    XFree(vinfo);
+  }
 #ifdef MITSHM
   /* Make sure all is destroyed if killed off */