/*
 * Copyright (c) 1998 Rafal Wierzbicki <rafal@mcss.mcmaster.ca>
 * Copyright (c) 1997 Guylhem Aznar <guylhem@oeil.qc.ca>
 * Copyright (c) 1994 Mike Finger <mfinger@mermaid.micro.umn.edu>
 *                    or <Mike_Finger@atk.com>
 * Copyright (c) 1994 Robert Nation
 * Copyright (c) 1994 Nobutaka Suzuki
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

#include "../../configure.h"
#include <stdio.h>
#include <X11/Xlib.h>
#include "Colors.h"
#include "../../include/afterstep.h"
#include "../../include/stepgfx.h"
#include "../../include/screen.h"

#ifndef min
#define min(a,b) (((a)<(b)) ? (a) : (b))
#define max(a,b) (((a)>(b)) ? (a) : (b))
#endif

extern Display *dpy;
extern ScreenInfo Scr;
/**************************************************************************
  Loads a single color
*****************************************************************************/
Pixel
WLGetColor (char *name)
{
  XColor color;
  XWindowAttributes attributes;

  XGetWindowAttributes (dpy, Scr.Root, &attributes);
  color.pixel = 0;
  if (!XParseColor (dpy, attributes.colormap, name, &color))
    nocolor ("parse", name);
  else if (!XAllocColor (dpy, attributes.colormap, &color))
    nocolor ("alloc", name);
  return color.pixel;
}

void
nocolor (char *a, char *b)
{
  fprintf (stderr, "WinList: can't %s %s\n", a, b);
}
