OSDN Git Service

Merge remote-tracking branch 'remotes/origin/feature/Fix-Sanity-Blast-by-AutoSave...
[hengband/hengband.git] / src / maid-x11.c
index f1fd1ac..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.
@@ -75,7 +75,11 @@ static int gamma_val = 0;
 /*
  * 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;
@@ -105,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)))
        {
@@ -113,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.
@@ -872,7 +890,6 @@ static XImage *ResizeImage(Display *dpy, XImage *Im,
        return Tmp;
 }
 
-#endif /* USE_GRAPHICS */
-
+#endif /* !USE_XFT */
 
 #endif /* USE_X11 */