/* Definitions and declarations. */
/* The number of face-id's in use (same for all frames). */
-int next_face_id;
+static int next_face_id;
/* The number of the face to use to indicate the region. */
-int region_face;
+static int region_face;
/* This is what appears in a slot in a face to signify that the face
does not specify that display aspect. */
else
xgcv.background = f->display.x->background_pixel;
- if (face->font && (int) face->font != FACE_DEFAULT)
+ if (face->font && face->font != (XFontStruct *) FACE_DEFAULT)
xgcv.font = face->font->fid;
else
xgcv.font = f->display.x->font->fid;
struct frame *f;
Lisp_Object name;
{
- Display *dpy = FRAME_X_DISPLAY (f);
- Colormap cmap;
XColor color;
int result;
if (NILP (name))
return FACE_DEFAULT;
- cmap = DefaultColormapOfScreen (DefaultScreenOfDisplay (dpy));
-
CHECK_STRING (name, 0);
- BLOCK_INPUT;
- result = XParseColor (dpy, cmap, (char *) XSTRING (name)->data, &color);
- UNBLOCK_INPUT;
+ /* if the colormap is full, defined_color will return a best match
+ to the values in an an existing cell. */
+ result = defined_color(f, (char *) XSTRING (name)->data, &color, 1);
if (! result)
Fsignal (Qerror, Fcons (build_string ("undefined color"),
Fcons (name, Qnil)));
- BLOCK_INPUT;
- result = XAllocColor (dpy, cmap, &color);
- UNBLOCK_INPUT;
- /* Ignore the return value of XallocColor, so that
- we use a color close to the one requested
- if we can't get the exact request. */
return (unsigned long) color.pixel;
}
{
Colormap cmap;
Display *dpy = FRAME_X_DISPLAY (f);
+ int class = FRAME_X_DISPLAY_INFO (f)->visual->class;
+
if (pixel == FACE_DEFAULT
|| pixel == BLACK_PIX_DEFAULT (f)
|| pixel == WHITE_PIX_DEFAULT (f))
return;
cmap = DefaultColormapOfScreen (DefaultScreenOfDisplay (dpy));
- BLOCK_INPUT;
- XFreeColors (dpy, cmap, &pixel, 1, 0);
- UNBLOCK_INPUT;
+
+ /* If display has an immutable color map, freeing colors is not
+ necessary and some servers don't allow it. So don't do it. */
+ if (! (class == StaticColor || class == StaticGray || class == TrueColor))
+ {
+ BLOCK_INPUT;
+ XFreeColors (dpy, cmap, &pixel, 1, (unsigned long)0);
+ UNBLOCK_INPUT;
+ }
}
DEFUN ("pixmap-spec-p", Fpixmap_spec_p, Spixmap_spec_p, 1, 1, 0,
/* No action. */
}
-static void
-build_face (f, face)
- struct frame *f;
- struct face *face;
-{
- face->gc = 1;
-}
-
#ifdef MSDOS
unsigned long
load_color (f, name)
len = 40;
overlay_vec = (Lisp_Object *) alloca (len * sizeof (Lisp_Object));
- noverlays = overlays_at (pos, 0, &overlay_vec, &len, &next_overlay, NULL);
+ noverlays = overlays_at (pos, 0, &overlay_vec, &len,
+ &next_overlay, (int *) 0);
/* If there are more than 40,
make enough space for all, and try again. */
len = noverlays;
overlay_vec = (Lisp_Object *) alloca (len * sizeof (Lisp_Object));
noverlays = overlays_at (pos, 0, &overlay_vec, &len,
- &next_overlay, NULL);
+ &next_overlay, (int *) 0);
}
if (next_overlay < endpos)
if (CONSP (prop))
{
/* We have a list of faces, merge them in reverse order */
- Lisp_Object length = Flength (prop);
- int len = XINT (length);
+ Lisp_Object length;
+ int len;
Lisp_Object *faces;
+ length = Fsafe_length (prop);
+ len = XFASTINT (length);
+
/* Put them into an array */
faces = (Lisp_Object *) alloca (len * sizeof (Lisp_Object));
for (j = 0; j < len; j++)
if (CONSP (prop))
{
/* We have a list of faces, merge them in reverse order */
- Lisp_Object length = Flength (prop);
- int len = XINT (length);
+ Lisp_Object length;
+ int len;
Lisp_Object *faces;
- int i;
+
+ length = Fsafe_length (prop);
+ len = XFASTINT (length);
/* Put them into an array */
faces = (Lisp_Object *) alloca (len * sizeof (Lisp_Object));