dpsXcmu.c revision 824
1450N/A * dpsXcmu.c -- Simple color management/allocation utility
#include <stdio.h>
#include <pwd.h>
#include "dpsassert.h"
#include "cslibint.h"
#include <stddef.h>
typedef struct _dpyRec {
} DpyRec;
unsigned long *pixels;
int npixels;
} PixelRec;
static Bool AllocateColormap(Display *, XStandardColormap *, XVisualInfo *, int *, PixelRec *, int *, int *, unsigned long);
static Bool GetColorCubeFromProperty(Display *, XVisualInfo *, XStandardColormap *, XStandardColormap **, int *);
static Bool GetGrayRampFromProperty(Display *, XVisualInfo *, XStandardColormap *, XStandardColormap **, int *);
Status XDPSCreateStandardColormaps(Display *, Drawable, Visual *, int, int, int, int, XStandardColormap *, XStandardColormap *, Bool);
static long NumColors(char *, char *, char *);
static void AllocateGrayRamp(Display *, XVisualInfo *, XStandardColormap *, XStandardColormap *, PixelRec *);
static void ColorValuesFromMask(unsigned long, unsigned long *, unsigned long *);
static void DefineProperty(Display *, XStandardColormap *, XVisualInfo *, XStandardColormap *, int, Atom);
static void GetHomeDir(char *);
#define ABS(x) ((x) < 0 ? -(x) : (x))
void XDPSGetDefaultColorMaps(
int nvis;
if (nvis == 0) return 0;
if (retain) {
if (retain) {
Pixmap p;
if (retain) {
DpyRec *d;
dpyRec = d;
register int screen_number;
if (def_cmap) {
for (i = 0; i < n; i++, vlist++) {
return vlist;
int maxdepth = 0;
XVisualInfo *v = 0;
for (i = 0; i < n; i++, vlist++) {
v = vlist;
unsigned long pixel;
return True;
unsigned long pixel;
return True;
int *ncube)
int gotCube;
register XStandardColormap *c;
if (gotCube) {
c = *cube;
for (i = 0; i < *ncube; i++) {
return gotCube;
int *nramp)
int gotRamp;
register XStandardColormap *c;
if (gotRamp) {
c = *ramp;
for (i = 0; i < *nramp; i++) {
return gotRamp;
static void GetDatabaseValues(
unsigned long max;
case StaticGray:
case GrayScale:
case TrueColor:
case DirectColor:
case PseudoColor:
case StaticColor:
case GrayScale:
case PseudoColor:
case DirectColor:
case TrueColor:
case StaticColor:
case StaticGray:
static void ColorValuesFromMask(
unsigned long mask,
unsigned long *maxColor,
unsigned long *mult)
#ifndef X_NOT_POSIX
int uid;
extern int getuid();
#ifndef SYSV386
if (ptr)
buf++;
char *rtnType;
long value;
return value;
static void FindStaticColorCube(
int i, entries;
for (i = 0; i < entries; i++) {
unsigned int found = 0;
int size;
if (b + g != c) return False;
if (r + b != m) return False;
if (r + g != y) return False;
if (r + g + b != w) return False;
if (backwards) {
w = ABS(w);
r = ABS(r);
g = ABS(g);
b = ABS(b);
if (small == r) {
if (middle == b) {
} else if (small == g) {
if (middle == b) {
if (middle == r) {
if (backwards) {
return True;
#undef R
#undef G
#undef B
#undef C
#undef M
#undef Y
static void FindStaticGrayRamp(
unsigned long base;
for (i = 0; i < entries; i++) {
XColor *c;
int i, size;
return size;
static void SetRamp(
int size,
int *mult,
unsigned long *base)
static unsigned long shiftdown(unsigned long x)
static void AllocateColorCube(
unsigned long delta;
for (j = 0; j < remain; j++) {
static void AllocateGrayRamp(
unsigned long delta;
for (i = 0; i < remain; i++) {
int *count,
unsigned long delta)
int total;
if (ok) {
else npixels = 0;
if (success) {
sizeof(unsigned long), compare);
return success;
unsigned long delta,
int maxstart = 0;
*first = 0;
*first = i;
return False;
} return True;
int ok;
return False;
return True;
static void ShrinkMapToFit(
int *space,
if (which == 0) {
which = 0;
static void DefineProperty(
int nProp,
if (nProp == 0) {