OSDN Git Service

v3.0.0 Alpha5 OSDN最終版
[hengband/hengband.git] / src / maid-x11.c
index 1c6d6d2..1ec8cb2 100644 (file)
@@ -11,7 +11,7 @@
 #ifdef USE_X11
 
 #include <math.h>
-
+#include "main/x11-gamma-builder.h"
 
 /*
  * This file defines some "XImage" manipulation functions for X11.
   ((unsigned)(keysym) >= 0xFF00)
 
 
-#ifdef SUPPORT_GAMMA
 static bool gamma_table_ready = FALSE;
 static int gamma_val = 0;
-#endif /* SUPPORT_GAMMA */
 
 
 /*
  * Hack -- Convert an RGB value to an X11 Pixel, or die.
  */
+#ifdef USE_XFT
+static XftColor create_pixel(Display *dpy, byte red, byte green, byte blue)
+#else
 static unsigned long create_pixel(Display *dpy, byte red, byte green, byte blue)
+#endif
 {
        Colormap cmap = DefaultColormapOfScreen(DefaultScreenOfDisplay(dpy));
        XColor xcolour;
-
-#ifdef SUPPORT_GAMMA
-
        if (!gamma_table_ready)
        {
-               cptr str = getenv("ANGBAND_X11_GAMMA");
+               concptr str = getenv("ANGBAND_X11_GAMMA");
                if (str != NULL) gamma_val = atoi(str);
                
                gamma_table_ready = TRUE;
@@ -103,8 +102,6 @@ static unsigned long create_pixel(Display *dpy, byte red, byte green, byte blue)
                blue = gamma_table[blue];
        }
 
-#endif /* SUPPORT_GAMMA */
-
        /* Build the color */
        
        xcolour.red = red * 255;
@@ -112,6 +109,20 @@ static unsigned long create_pixel(Display *dpy, byte red, byte green, byte blue)
        xcolour.blue = blue * 255;
        xcolour.flags = DoRed | DoGreen | DoBlue;
 
+#ifdef USE_XFT
+       XftColor color;
+       XRenderColor xcol;
+       xcol.red = xcolour.red;
+       xcol.green = xcolour.green;
+       xcol.blue = xcolour.blue;
+       if (!XftColorAllocValue(dpy, DefaultVisual(dpy, 0), cmap, &xcol, &color))
+       {
+               quit_fmt("Couldn't allocate bitmap color '#%02x%02x%02x'\n",
+                        red, green, blue);
+       }
+
+       return color;
+#else
        /* Attempt to Allocate the Parsed color */
        if (!(XAllocColor(dpy, cmap, &xcolour)))
        {
@@ -120,11 +131,11 @@ static unsigned long create_pixel(Display *dpy, byte red, byte green, byte blue)
        }
 
        return (xcolour.pixel);
+#endif
 }
 
 
-
-#ifdef USE_GRAPHICS
+#ifndef USE_XFT
 
 /*
  * The Win32 "BITMAPFILEHEADER" type.
@@ -879,7 +890,6 @@ static XImage *ResizeImage(Display *dpy, XImage *Im,
        return Tmp;
 }
 
-#endif /* USE_GRAPHICS */
-
+#endif /* !USE_XFT */
 
 #endif /* USE_X11 */