1
0
mirror of https://github.com/gryf/wmaker.git synced 2025-12-20 21:08:08 +01:00

Added wGetColorForColormap().

Abstract the wGetColor() function to operate on any colormap not just
the screen colormap.
This commit is contained in:
Iain Patterson
2013-03-25 21:28:21 +00:00
committed by Carlos R. Mafra
parent 4222204abc
commit 69ff0d72cc
2 changed files with 9 additions and 3 deletions

View File

@@ -35,19 +35,24 @@
#include "resources.h" #include "resources.h"
#include "screen.h" #include "screen.h"
int wGetColor(WScreen * scr, char *color_name, XColor * color) int wGetColorForColormap(Colormap colormap, char *color_name, XColor * color)
{ {
if (!XParseColor(dpy, scr->w_colormap, color_name, color)) { if (!XParseColor(dpy, colormap, color_name, color)) {
wwarning(_("could not parse color \"%s\""), color_name); wwarning(_("could not parse color \"%s\""), color_name);
return False; return False;
} }
if (!XAllocColor(dpy, scr->w_colormap, color)) { if (!XAllocColor(dpy, colormap, color)) {
wwarning(_("could not allocate color \"%s\""), color_name); wwarning(_("could not allocate color \"%s\""), color_name);
return False; return False;
} }
return True; return True;
} }
int wGetColor(WScreen * scr, char *color_name, XColor * color)
{
return wGetColorForColormap(scr->w_colormap, color_name, color);
}
void wFreeColor(WScreen * scr, unsigned long pixel) void wFreeColor(WScreen * scr, unsigned long pixel)
{ {
if (pixel != scr->white_pixel && pixel != scr->black_pixel) { if (pixel != scr->white_pixel && pixel != scr->black_pixel) {

View File

@@ -21,6 +21,7 @@
#ifndef WMRESOURCES_H_ #ifndef WMRESOURCES_H_
#define WMRESOURCES_H_ #define WMRESOURCES_H_
int wGetColorForColormap(Colormap colormap, char *color_name, XColor *color);
int wGetColor(WScreen *scr, char *color_name, XColor *color); int wGetColor(WScreen *scr, char *color_name, XColor *color);
void wFreeColor(WScreen *scr, unsigned long pixel); void wFreeColor(WScreen *scr, unsigned long pixel);