(internal_terminal_init): Initialize the_only_x_display.font.
[bpt/emacs.git] / src / xfaces.c
CommitLineData
cb637678 1/* "Face" primitives.
3a22ee35 2 Copyright (C) 1993, 1994 Free Software Foundation.
7b7739b1 3
c115973b
JB
4This file is part of GNU Emacs.
5
6GNU Emacs is free software; you can redistribute it and/or modify
7it under the terms of the GNU General Public License as published by
7b7739b1 8the Free Software Foundation; either version 2, or (at your option)
c115973b
JB
9any later version.
10
11GNU Emacs is distributed in the hope that it will be useful,
12but WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14GNU General Public License for more details.
15
16You should have received a copy of the GNU General Public License
17along with GNU Emacs; see the file COPYING. If not, write to
18the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
19
357f32fc 20/* This is derived from work by Lucid (some parts very loosely so). */
7b7739b1 21
c115973b
JB
22#include <sys/types.h>
23#include <sys/stat.h>
24
18160b98 25#include <config.h>
c115973b
JB
26#include "lisp.h"
27
87485d6f 28#ifdef HAVE_FACES
cb637678 29
87485d6f 30#ifdef HAVE_X_WINDOWS
c115973b 31#include "xterm.h"
87485d6f
MW
32#endif
33#ifdef MSDOS
34#include "dosfns.h"
35#endif
c115973b 36#include "buffer.h"
f211082d 37#include "dispextern.h"
7b7739b1 38#include "frame.h"
357f32fc 39#include "blockinput.h"
b6d40e46 40#include "window.h"
bde7c500 41#include "intervals.h"
c115973b 42
87485d6f 43#ifdef HAVE_X_WINDOWS
657070ac
JB
44/* Compensate for bug in Xos.h on some systems, on which it requires
45 time.h. On some such systems, Xos.h tries to redefine struct
46 timeval and struct timezone if USG is #defined while it is
47 #included. */
6233db35 48#ifdef XOS_NEEDS_TIME_H
657070ac 49
e11d186d 50#include <time.h>
657070ac
JB
51#undef USG
52#include <X11/Xos.h>
53#define USG
e11d186d 54#define __TIMEVAL__
e11d186d 55
657070ac 56#else
7a4d2269 57
c115973b
JB
58#include <X11/Xos.h>
59
657070ac 60#endif
87485d6f 61#endif /* HAVE_X_WINDOWS */
cb637678
JB
62\f
63/* An explanation of the face data structures. */
64
65/* ========================= Face Data Structures =========================
66
7b00de84 67 Let FACE-NAME be a symbol naming a face.
cb637678 68
7b00de84
JB
69 Let FACE-VECTOR be (assq FACE-NAME (frame-face-alist FRAME))
70 FACE-VECTOR is either nil, or a vector of the form
cb637678
JB
71 [face NAME ID FONT FOREGROUND BACKGROUND BACKGROUND-PIXMAP UNDERLINE-P]
72 where
73 face is the symbol `face',
74 NAME is the symbol with which this vector is associated (a backpointer),
75 ID is the face ID, an integer used internally by the C code to identify
76 the face,
77 FONT, FOREGROUND, and BACKGROUND are strings naming the fonts and colors
78 to use with the face,
79 BACKGROUND-PIXMAP is the name of an x bitmap filename, which we don't
80 use right now, and
81 UNDERLINE-P is non-nil if the face should be underlined.
7b00de84
JB
82 If any of these elements are nil, that parameter is considered
83 unspecified; parameters from faces specified by lower-priority
84 overlays or text properties, or the parameters of the frame itself,
85 can show through. (lisp/faces.el maintains these lists.)
86
87 (assq FACE-NAME global-face-data) returns a vector describing the
88 global parameters for that face.
89
7556890b 90 Let PARAM-FACE be FRAME->output_data.x->param_faces[Faref (FACE-VECTOR, 2)].
7b00de84
JB
91 PARAM_FACE is a struct face whose members are the Xlib analogues of
92 the parameters in FACE-VECTOR. If an element of FACE-VECTOR is
93 nil, then the corresponding member of PARAM_FACE is FACE_DEFAULT.
94 These faces are called "parameter faces", because they're the ones
95 lisp manipulates to control what gets displayed. Elements 0 and 1
7556890b 96 of FRAME->output_data.x->param_faces are special - they describe the
7b00de84
JB
97 default and mode line faces. None of the faces in param_faces have
98 GC's. (See src/dispextern.h for the definiton of struct face.
99 lisp/faces.el maintains the isomorphism between face_alist and
100 param_faces.)
101
102 The functions compute_char_face and compute_glyph_face find and
103 combine the parameter faces associated with overlays and text
104 properties. The resulting faces are called "computed faces"; none
105 of their members are FACE_DEFAULT; they are completely specified.
106 They then call intern_compute_face to search
7556890b 107 FRAME->output_data.x->computed_faces for a matching face, add one if
7b00de84 108 none is found, and return the index into
7556890b 109 FRAME->output_data.x->computed_faces. FRAME's glyph matrices use these
7b00de84
JB
110 indices to record the faces of the matrix characters, and the X
111 display hooks consult compute_faces to decide how to display these
112 characters. Elements 0 and 1 of computed_faces always describe the
113 default and mode-line faces.
114
cd0bb842
RS
115 Each computed face belongs to a particular frame.
116
42120bc7
RS
117 Computed faces have graphics contexts some of the time.
118 intern_face builds a GC for a specified computed face
119 if it doesn't have one already.
120 clear_face_cache clears out the GCs of all computed faces.
121 This is done from time to time so that we don't hold on to
122 lots of GCs that are no longer needed.
7b00de84 123
195f798e
RS
124 If a computed face has 0 as its font,
125 it is unused, and can be reused by new_computed_face.
126
7b00de84
JB
127 Constraints:
128
129 Symbols naming faces must have associations on all frames; for any
130 FRAME, for all FACE-NAME, if (assq FACE-NAME (frame-face-alist
131 FRAME)) is non-nil, it must be non-nil for all frames.
132
133 Analogously, indices into param_faces must be valid on all frames;
134 if param_faces[i] is a non-zero face pointer on one frame, then it
135 must be filled in on all frames. Code assumes that face ID's can
136 be used on any frame.
cb637678
JB
137
138 Some subtleties:
7b7739b1 139
7b00de84
JB
140 Why do we keep param_faces and computed_faces separate?
141 computed_faces contains an element for every combination of facial
142 parameters we have ever displayed. indices into param_faces have
143 to be valid on all frames. If they were the same array, then that
144 array would grow very large on all frames, because any facial
145 combination displayed on any frame would need to be a valid entry
42120bc7 146 on all frames. */
cb637678
JB
147\f
148/* Definitions and declarations. */
149
c115973b 150/* The number of face-id's in use (same for all frames). */
f8758da5 151static int next_face_id;
c115973b 152
bc0db68d 153/* The number of the face to use to indicate the region. */
f8758da5 154static int region_face;
bc0db68d 155
9516fe94
RS
156/* This is what appears in a slot in a face to signify that the face
157 does not specify that display aspect. */
7b7739b1
JB
158#define FACE_DEFAULT (~0)
159
6f134486 160Lisp_Object Qface, Qmouse_face;
cd0bb842 161Lisp_Object Qpixmap_spec_p;
f211082d 162
415445e2 163int face_name_id_number ( /* FRAME_PTR, Lisp_Object name */ );
cb637678 164
415445e2 165struct face *intern_face ( /* FRAME_PTR, struct face * */ );
7b00de84
JB
166static int new_computed_face ( /* FRAME_PTR, struct face * */ );
167static int intern_computed_face ( /* FRAME_PTR, struct face * */ );
415445e2 168static void ensure_face_ready ( /* FRAME_PTR, int id */ );
254a1b66 169void recompute_basic_faces ( /* FRAME_PTR f */ );
c115973b 170\f
cb637678
JB
171/* Allocating, copying, and comparing struct faces. */
172
173/* Allocate a new face */
174static struct face *
175allocate_face ()
176{
177 struct face *result = (struct face *) xmalloc (sizeof (struct face));
178 bzero (result, sizeof (struct face));
179 result->font = (XFontStruct *) FACE_DEFAULT;
180 result->foreground = FACE_DEFAULT;
181 result->background = FACE_DEFAULT;
182 result->stipple = FACE_DEFAULT;
183 return result;
184}
c115973b 185
cb637678 186/* Make a new face that's a copy of an existing one. */
c115973b
JB
187static struct face *
188copy_face (face)
189 struct face *face;
190{
191 struct face *result = allocate_face ();
192
193 result->font = face->font;
194 result->foreground = face->foreground;
195 result->background = face->background;
f211082d 196 result->stipple = face->stipple;
c115973b 197 result->underline = face->underline;
cd0bb842
RS
198 result->pixmap_h = face->pixmap_h;
199 result->pixmap_w = face->pixmap_w;
c115973b
JB
200
201 return result;
202}
203
204static int
205face_eql (face1, face2)
206 struct face *face1, *face2;
207{
cb637678 208 return ( face1->font == face2->font
c115973b
JB
209 && face1->foreground == face2->foreground
210 && face1->background == face2->background
cb637678
JB
211 && face1->stipple == face2->stipple
212 && face1->underline == face2->underline);
c115973b 213}
cb637678 214\f
42120bc7 215/* Managing graphics contexts of faces. */
c115973b 216
87485d6f 217#ifdef HAVE_X_WINDOWS
42120bc7 218/* Given a computed face, construct its graphics context if necessary. */
cb637678
JB
219
220struct face *
221intern_face (f, face)
222 struct frame *f;
223 struct face *face;
c115973b
JB
224{
225 GC gc;
226 XGCValues xgcv;
227 unsigned long mask;
228
42120bc7
RS
229 if (face->gc)
230 return face;
231
660ed669
JB
232 BLOCK_INPUT;
233
f211082d
JB
234 if (face->foreground != FACE_DEFAULT)
235 xgcv.foreground = face->foreground;
236 else
7556890b 237 xgcv.foreground = f->output_data.x->foreground_pixel;
660ed669 238
f211082d
JB
239 if (face->background != FACE_DEFAULT)
240 xgcv.background = face->background;
241 else
7556890b 242 xgcv.background = f->output_data.x->background_pixel;
660ed669 243
3f000d8c 244 if (face->font && face->font != (XFontStruct *) FACE_DEFAULT)
f211082d
JB
245 xgcv.font = face->font->fid;
246 else
7556890b 247 xgcv.font = f->output_data.x->font->fid;
660ed669 248
c115973b 249 xgcv.graphics_exposures = 0;
660ed669 250
c115973b 251 mask = GCForeground | GCBackground | GCFont | GCGraphicsExposures;
cd0bb842 252 if (face->stipple && face->stipple != FACE_DEFAULT)
95887807
RS
253 {
254 xgcv.fill_style = FillStippled;
255 xgcv.stipple = x_bitmap_pixmap (f, face->stipple);
256 mask |= GCFillStyle | GCStipple;
257 }
cd0bb842 258
42120bc7 259 gc = XCreateGC (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
c115973b 260 mask, &xgcv);
660ed669 261
f211082d 262 face->gc = gc;
660ed669
JB
263
264 UNBLOCK_INPUT;
42120bc7
RS
265
266 return face;
c115973b 267}
cb637678 268
42120bc7
RS
269/* Clear out all graphics contexts for all computed faces
270 except for the default and mode line faces.
271 This should be done from time to time just to avoid
272 keeping too many graphics contexts that are no longer needed. */
273
274void
275clear_face_cache ()
276{
277 Lisp_Object tail, frame;
278
279 BLOCK_INPUT;
280 FOR_EACH_FRAME (tail, frame)
281 {
282 FRAME_PTR f = XFRAME (frame);
283 if (FRAME_X_P (f))
284 {
285 int i;
286 Display *dpy = FRAME_X_DISPLAY (f);
287
288 for (i = 2; i < FRAME_N_COMPUTED_FACES (f); i++)
289 {
290 struct face *face = FRAME_COMPUTED_FACES (f) [i];
291 if (face->gc)
292 XFreeGC (dpy, face->gc);
293 face->gc = 0;
294 }
295 }
296 }
297
298 UNBLOCK_INPUT;
299}
300\f
cd0bb842
RS
301/* Allocating, freeing, and duplicating fonts, colors, and pixmaps.
302
303 These functions operate on param faces only.
304 Computed faces get their fonts, colors and pixmaps
305 by merging param faces. */
cb637678
JB
306
307static XFontStruct *
308load_font (f, name)
309 struct frame *f;
310 Lisp_Object name;
311{
312 XFontStruct *font;
313
314 if (NILP (name))
315 return (XFontStruct *) FACE_DEFAULT;
316
317 CHECK_STRING (name, 0);
318 BLOCK_INPUT;
42120bc7 319 font = XLoadQueryFont (FRAME_X_DISPLAY (f), (char *) XSTRING (name)->data);
cb637678
JB
320 UNBLOCK_INPUT;
321
322 if (! font)
323 Fsignal (Qerror, Fcons (build_string ("undefined font"),
324 Fcons (name, Qnil)));
325 return font;
326}
327
328static void
329unload_font (f, font)
330 struct frame *f;
331 XFontStruct *font;
332{
195f798e
RS
333 int len = FRAME_N_COMPUTED_FACES (f);
334 int i;
335
cb637678
JB
336 if (!font || font == ((XFontStruct *) FACE_DEFAULT))
337 return;
660ed669
JB
338
339 BLOCK_INPUT;
195f798e
RS
340 /* Invalidate any computed faces which use this font,
341 and free their GC's if they have any. */
f3400cf9 342 for (i = 2; i < len; i++)
195f798e
RS
343 {
344 struct face *face = FRAME_COMPUTED_FACES (f)[i];
345 if (face->font == font)
346 {
347 Display *dpy = FRAME_X_DISPLAY (f);
348 if (face->gc)
349 XFreeGC (dpy, face->gc);
350 face->gc = 0;
f3400cf9 351 /* This marks the computed face as available to reuse. */
195f798e
RS
352 face->font = 0;
353 }
354 }
355
42120bc7 356 XFreeFont (FRAME_X_DISPLAY (f), font);
660ed669 357 UNBLOCK_INPUT;
cb637678
JB
358}
359
360static unsigned long
361load_color (f, name)
362 struct frame *f;
363 Lisp_Object name;
364{
cb637678
JB
365 XColor color;
366 int result;
367
368 if (NILP (name))
369 return FACE_DEFAULT;
370
cb637678 371 CHECK_STRING (name, 0);
34dda5f4
KH
372 /* if the colormap is full, defined_color will return a best match
373 to the values in an an existing cell. */
a992f9d9 374 result = defined_color(f, (char *) XSTRING (name)->data, &color, 1);
cb637678
JB
375 if (! result)
376 Fsignal (Qerror, Fcons (build_string ("undefined color"),
377 Fcons (name, Qnil)));
cb637678
JB
378 return (unsigned long) color.pixel;
379}
380
381static void
382unload_color (f, pixel)
383 struct frame *f;
7a4d2269 384 unsigned long pixel;
cb637678
JB
385{
386 Colormap cmap;
42120bc7 387 Display *dpy = FRAME_X_DISPLAY (f);
828e66d1
RS
388 int class = FRAME_X_DISPLAY_INFO (f)->visual->class;
389
32dc0866 390 if (pixel == FACE_DEFAULT
0704eec9
RS
391 || pixel == BLACK_PIX_DEFAULT (f)
392 || pixel == WHITE_PIX_DEFAULT (f))
cb637678 393 return;
42120bc7 394 cmap = DefaultColormapOfScreen (DefaultScreenOfDisplay (dpy));
828e66d1
RS
395
396 /* If display has an immutable color map, freeing colors is not
397 necessary and some servers don't allow it. So don't do it. */
398 if (! (class == StaticColor || class == StaticGray || class == TrueColor))
399 {
195f798e
RS
400 int len = FRAME_N_COMPUTED_FACES (f);
401 int i;
402
828e66d1 403 BLOCK_INPUT;
195f798e
RS
404 /* Invalidate any computed faces which use this color,
405 and free their GC's if they have any. */
f3400cf9 406 for (i = 2; i < len; i++)
195f798e
RS
407 {
408 struct face *face = FRAME_COMPUTED_FACES (f)[i];
409 if (face->foreground == pixel
410 || face->background == pixel)
411 {
412 Display *dpy = FRAME_X_DISPLAY (f);
413 if (face->gc)
414 XFreeGC (dpy, face->gc);
415 face->gc = 0;
f3400cf9 416 /* This marks the computed face as available to reuse. */
195f798e
RS
417 face->font = 0;
418 }
419 }
420
828e66d1
RS
421 XFreeColors (dpy, cmap, &pixel, 1, (unsigned long)0);
422 UNBLOCK_INPUT;
423 }
cd0bb842
RS
424}
425
426DEFUN ("pixmap-spec-p", Fpixmap_spec_p, Spixmap_spec_p, 1, 1, 0,
427 "Return t if ARG is a valid pixmap specification.")
428 (arg)
429 Lisp_Object arg;
430{
431 Lisp_Object height, width;
432
433 return ((STRINGP (arg)
434 || (CONSP (arg)
e1befa75
KH
435 && CONSP (XCONS (arg)->cdr)
436 && CONSP (XCONS (XCONS (arg)->cdr)->cdr)
437 && NILP (XCONS (XCONS (XCONS (arg)->cdr)->cdr)->cdr)
438 && (width = XCONS (arg)->car, INTEGERP (width))
439 && (height = XCONS (XCONS (arg)->cdr)->car, INTEGERP (height))
440 && STRINGP (XCONS (XCONS (XCONS (arg)->cdr)->cdr)->car)
cd0bb842
RS
441 && XINT (width) > 0
442 && XINT (height) > 0
443 /* The string must have enough bits for width * height. */
e1befa75 444 && ((XSTRING (XCONS (XCONS (XCONS (arg)->cdr)->cdr)->car)->size
68be917d 445 * (BITS_PER_INT / sizeof (int)))
e1befa75 446 >= XFASTINT (width) * XFASTINT (height))))
cd0bb842
RS
447 ? Qt : Qnil);
448}
449
450/* Load a bitmap according to NAME (which is either a file name
451 or a pixmap spec). Return the bitmap_id (see xfns.c)
452 or get an error if NAME is invalid.
453
454 Store the bitmap width in *W_PTR and height in *H_PTR. */
455
456static long
457load_pixmap (f, name, w_ptr, h_ptr)
7812a96f 458 FRAME_PTR f;
cd0bb842
RS
459 Lisp_Object name;
460 unsigned int *w_ptr, *h_ptr;
461{
462 int bitmap_id;
463 Lisp_Object tem;
464
465 if (NILP (name))
466 return FACE_DEFAULT;
467
468 tem = Fpixmap_spec_p (name);
469 if (NILP (tem))
470 wrong_type_argument (Qpixmap_spec_p, name);
471
472 BLOCK_INPUT;
473
474 if (CONSP (name))
475 {
476 /* Decode a bitmap spec into a bitmap. */
477
478 int h, w;
479 Lisp_Object bits;
480
481 w = XINT (Fcar (name));
482 h = XINT (Fcar (Fcdr (name)));
483 bits = Fcar (Fcdr (Fcdr (name)));
484
485 bitmap_id = x_create_bitmap_from_data (f, XSTRING (bits)->data,
486 w, h);
487 }
488 else
489 {
490 /* It must be a string -- a file name. */
491 bitmap_id = x_create_bitmap_from_file (f, name);
492 }
493 UNBLOCK_INPUT;
494
7812a96f
RS
495 if (bitmap_id < 0)
496 Fsignal (Qerror, Fcons (build_string ("invalid or undefined bitmap"),
cd0bb842
RS
497 Fcons (name, Qnil)));
498
499 *w_ptr = x_bitmap_width (f, bitmap_id);
500 *h_ptr = x_bitmap_height (f, bitmap_id);
501
502 return bitmap_id;
cb637678 503}
87485d6f
MW
504
505#else /* !HAVE_X_WINDOWS */
506
507/* Stubs for MSDOS when not under X. */
508
509struct face *
510intern_face (f, face)
511 struct frame *f;
512 struct face *face;
513{
514 return face;
515}
516
517void
518clear_face_cache ()
519{
520 /* No action. */
521}
522
87485d6f
MW
523#ifdef MSDOS
524unsigned long
525load_color (f, name)
526 FRAME_PTR f;
527 Lisp_Object name;
528{
529 Lisp_Object result;
530
531 if (NILP (name))
532 return FACE_DEFAULT;
533
534 CHECK_STRING (name, 0);
535 result = call1 (Qmsdos_color_translate, name);
536 if (INTEGERP (result))
537 return XINT (result);
538 else
539 Fsignal (Qerror, Fcons (build_string ("undefined color"),
540 Fcons (name, Qnil)));
541}
542#endif
543#endif /* !HAVE_X_WINDOWS */
544
cb637678 545\f
7b00de84 546/* Managing parameter face arrays for frames. */
cb637678 547
cb637678
JB
548void
549init_frame_faces (f)
660ed669 550 FRAME_PTR f;
cb637678
JB
551{
552 ensure_face_ready (f, 0);
cb637678 553 ensure_face_ready (f, 1);
660ed669 554
fffc2367
RS
555 FRAME_N_COMPUTED_FACES (f) = 0;
556 FRAME_SIZE_COMPUTED_FACES (f) = 0;
557
7b00de84
JB
558 new_computed_face (f, FRAME_PARAM_FACES (f)[0]);
559 new_computed_face (f, FRAME_PARAM_FACES (f)[1]);
660ed669 560 recompute_basic_faces (f);
7b37f67b 561
87485d6f 562#ifdef MULTI_FRAME
1120eb5e
JB
563 /* Find another X frame. */
564 {
565 Lisp_Object tail, frame, result;
566
567 result = Qnil;
568 FOR_EACH_FRAME (tail, frame)
569 if (FRAME_X_P (XFRAME (frame))
570 && XFRAME (frame) != f)
571 {
572 result = frame;
573 break;
574 }
575
576 /* If we didn't find any X frames other than f, then we don't need
577 any faces other than 0 and 1, so we're okay. Otherwise, make
578 sure that all faces valid on the selected frame are also valid
579 on this new frame. */
580 if (FRAMEP (result))
581 {
582 int i;
7b00de84
JB
583 int n_faces = FRAME_N_PARAM_FACES (XFRAME (result));
584 struct face **faces = FRAME_PARAM_FACES (XFRAME (result));
1120eb5e
JB
585
586 for (i = 2; i < n_faces; i++)
587 if (faces[i])
588 ensure_face_ready (f, i);
589 }
590 }
87485d6f 591#endif /* MULTI_FRAME */
cb637678
JB
592}
593
660ed669 594
cb637678 595/* Called from Fdelete_frame. */
cd0bb842 596
cb637678
JB
597void
598free_frame_faces (f)
599 struct frame *f;
600{
42120bc7 601 Display *dpy = FRAME_X_DISPLAY (f);
cb637678
JB
602 int i;
603
660ed669
JB
604 BLOCK_INPUT;
605
7b00de84 606 for (i = 0; i < FRAME_N_PARAM_FACES (f); i++)
cb637678 607 {
7b00de84 608 struct face *face = FRAME_PARAM_FACES (f) [i];
660ed669
JB
609 if (face)
610 {
7b00de84
JB
611 unload_font (f, face->font);
612 unload_color (f, face->foreground);
613 unload_color (f, face->background);
cd0bb842 614 x_destroy_bitmap (f, face->stipple);
660ed669
JB
615 xfree (face);
616 }
cb637678 617 }
7b00de84
JB
618 xfree (FRAME_PARAM_FACES (f));
619 FRAME_PARAM_FACES (f) = 0;
620 FRAME_N_PARAM_FACES (f) = 0;
621
622 /* All faces in FRAME_COMPUTED_FACES use resources copied from
42120bc7
RS
623 FRAME_PARAM_FACES; we can free them without fuss.
624 But we do free the GCs and the face objects themselves. */
625 for (i = 0; i < FRAME_N_COMPUTED_FACES (f); i++)
626 {
627 struct face *face = FRAME_COMPUTED_FACES (f) [i];
628 if (face)
629 {
630 if (face->gc)
631 XFreeGC (dpy, face->gc);
632 xfree (face);
633 }
634 }
7b00de84
JB
635 xfree (FRAME_COMPUTED_FACES (f));
636 FRAME_COMPUTED_FACES (f) = 0;
637 FRAME_N_COMPUTED_FACES (f) = 0;
660ed669
JB
638
639 UNBLOCK_INPUT;
cb637678 640}
c115973b 641\f
cb637678
JB
642/* Interning faces in a frame's face array. */
643
660ed669 644static int
7b00de84
JB
645new_computed_face (f, new_face)
646 struct frame *f;
647 struct face *new_face;
648{
195f798e
RS
649 int len = FRAME_N_COMPUTED_FACES (f);
650 int i;
651
652 /* Search for an unused computed face in the middle of the table. */
653 for (i = 0; i < len; i++)
654 {
655 struct face *face = FRAME_COMPUTED_FACES (f)[i];
656 if (face->font == 0)
657 {
658 FRAME_COMPUTED_FACES (f)[i] = copy_face (new_face);
659 return i;
660 }
661 }
7b00de84
JB
662
663 if (i >= FRAME_SIZE_COMPUTED_FACES (f))
664 {
665 int new_size = i + 32;
666
667 FRAME_COMPUTED_FACES (f)
fffc2367
RS
668 = (struct face **) (FRAME_SIZE_COMPUTED_FACES (f) == 0
669 ? xmalloc (new_size * sizeof (struct face *))
670 : xrealloc (FRAME_COMPUTED_FACES (f),
671 new_size * sizeof (struct face *)));
7b00de84
JB
672 FRAME_SIZE_COMPUTED_FACES (f) = new_size;
673 }
674
675 i = FRAME_N_COMPUTED_FACES (f)++;
676 FRAME_COMPUTED_FACES (f)[i] = copy_face (new_face);
677 return i;
678}
679
680
681/* Find a match for NEW_FACE in a FRAME's computed face array, and add
682 it if we don't find one. */
683static int
684intern_computed_face (f, new_face)
685 struct frame *f;
b6d40e46 686 struct face *new_face;
cb637678 687{
7b00de84 688 int len = FRAME_N_COMPUTED_FACES (f);
cb637678
JB
689 int i;
690
7b00de84 691 /* Search for a computed face already on F equivalent to FACE. */
cb637678
JB
692 for (i = 0; i < len; i++)
693 {
7b00de84
JB
694 if (! FRAME_COMPUTED_FACES (f)[i])
695 abort ();
696 if (face_eql (new_face, FRAME_COMPUTED_FACES (f)[i]))
cb637678
JB
697 return i;
698 }
699
700 /* We didn't find one; add a new one. */
7b00de84 701 return new_computed_face (f, new_face);
cb637678
JB
702}
703
7b00de84 704/* Make parameter face id ID valid on frame F. */
cb637678
JB
705
706static void
707ensure_face_ready (f, id)
708 struct frame *f;
709 int id;
710{
7b00de84 711 if (FRAME_N_PARAM_FACES (f) <= id)
cb637678
JB
712 {
713 int n = id + 10;
714 int i;
7b00de84
JB
715 if (!FRAME_N_PARAM_FACES (f))
716 FRAME_PARAM_FACES (f)
cb637678
JB
717 = (struct face **) xmalloc (sizeof (struct face *) * n);
718 else
7b00de84
JB
719 FRAME_PARAM_FACES (f)
720 = (struct face **) xrealloc (FRAME_PARAM_FACES (f),
cb637678
JB
721 sizeof (struct face *) * n);
722
7b00de84
JB
723 bzero (FRAME_PARAM_FACES (f) + FRAME_N_PARAM_FACES (f),
724 (n - FRAME_N_PARAM_FACES (f)) * sizeof (struct face *));
725 FRAME_N_PARAM_FACES (f) = n;
cb637678
JB
726 }
727
7b00de84
JB
728 if (FRAME_PARAM_FACES (f) [id] == 0)
729 FRAME_PARAM_FACES (f) [id] = allocate_face ();
cb637678
JB
730}
731\f
87485d6f 732#ifdef HAVE_X_WINDOWS
867dd159
RS
733/* Return non-zero if FONT1 and FONT2 have the same width.
734 We do not check the height, because we can now deal with
735 different heights.
660ed669 736 We assume that they're both character-cell fonts. */
867dd159 737
660ed669
JB
738int
739same_size_fonts (font1, font2)
740 XFontStruct *font1, *font2;
741{
742 XCharStruct *bounds1 = &font1->min_bounds;
743 XCharStruct *bounds2 = &font2->min_bounds;
744
46407861 745 return (bounds1->width == bounds2->width);
660ed669
JB
746}
747
729425b1 748/* Update the line_height of frame F according to the biggest font in
6717f691 749 any face. Return nonzero if if line_height changes. */
729425b1 750
6717f691 751int
729425b1
RS
752frame_update_line_height (f)
753 FRAME_PTR f;
754{
755 int i;
7556890b 756 int biggest = FONT_HEIGHT (f->output_data.x->font);
729425b1 757
7556890b
RS
758 for (i = 0; i < f->output_data.x->n_param_faces; i++)
759 if (f->output_data.x->param_faces[i] != 0
760 && f->output_data.x->param_faces[i]->font != (XFontStruct *) FACE_DEFAULT)
729425b1 761 {
7556890b 762 int height = FONT_HEIGHT (f->output_data.x->param_faces[i]->font);
729425b1
RS
763 if (height > biggest)
764 biggest = height;
765 }
766
7556890b 767 if (biggest == f->output_data.x->line_height)
6717f691 768 return 0;
729425b1 769
7556890b 770 f->output_data.x->line_height = biggest;
6717f691 771 return 1;
729425b1 772}
87485d6f 773#endif /* not HAVE_X_WINDOWS */
867dd159 774\f
7b7739b1
JB
775/* Modify face TO by copying from FROM all properties which have
776 nondefault settings. */
867dd159 777
7b7739b1
JB
778static void
779merge_faces (from, to)
780 struct face *from, *to;
781{
867dd159
RS
782 /* Only merge the font if it's the same width as the base font.
783 Otherwise ignore it, since we can't handle it properly. */
68a97335 784 if (from->font != (XFontStruct *) FACE_DEFAULT
68a97335
JB
785 && same_size_fonts (from->font, to->font))
786 to->font = from->font;
7b7739b1
JB
787 if (from->foreground != FACE_DEFAULT)
788 to->foreground = from->foreground;
789 if (from->background != FACE_DEFAULT)
790 to->background = from->background;
f211082d 791 if (from->stipple != FACE_DEFAULT)
cd0bb842
RS
792 {
793 to->stipple = from->stipple;
794 to->pixmap_h = from->pixmap_h;
795 to->pixmap_w = from->pixmap_w;
796 }
7b7739b1
JB
797 if (from->underline)
798 to->underline = from->underline;
799}
800
660ed669
JB
801/* Set up the basic set of facial parameters, based on the frame's
802 data; all faces are deltas applied to this. */
867dd159 803
660ed669
JB
804static void
805compute_base_face (f, face)
806 FRAME_PTR f;
807 struct face *face;
808{
660ed669 809 face->gc = 0;
cd0bb842
RS
810 face->foreground = FRAME_FOREGROUND_PIXEL (f);
811 face->background = FRAME_BACKGROUND_PIXEL (f);
812 face->font = FRAME_FONT (f);
582080c1 813 face->stipple = 0;
660ed669
JB
814 face->underline = 0;
815}
816
867dd159
RS
817/* Return the face ID to use to display a special glyph which selects
818 FACE_CODE as the face ID, assuming that ordinarily the face would
819 be CURRENT_FACE. F is the frame. */
820
821int
822compute_glyph_face (f, face_code, current_face)
823 struct frame *f;
824 int face_code, current_face;
825{
826 struct face face;
827
828 face = *FRAME_COMPUTED_FACES (f)[current_face];
829
830 if (face_code >= 0 && face_code < FRAME_N_PARAM_FACES (f)
831 && FRAME_PARAM_FACES (f) [face_code] != 0)
832 merge_faces (FRAME_PARAM_FACES (f) [face_code], &face);
660ed669 833
867dd159
RS
834 return intern_computed_face (f, &face);
835}
2e16580f
RS
836
837/* Return the face ID to use to display a special glyph which selects
838 FACE_CODE as the face ID, assuming that ordinarily the face would
839 be CURRENT_FACE. F is the frame. */
840
841int
842compute_glyph_face_1 (f, face_name, current_face)
843 struct frame *f;
844 Lisp_Object face_name;
845 int current_face;
846{
847 struct face face;
848
849 face = *FRAME_COMPUTED_FACES (f)[current_face];
850
851 if (!NILP (face_name))
852 {
853 int facecode = face_name_id_number (f, face_name);
854 if (facecode >= 0 && facecode < FRAME_N_PARAM_FACES (f)
855 && FRAME_PARAM_FACES (f) [facecode] != 0)
856 merge_faces (FRAME_PARAM_FACES (f) [facecode], &face);
857 }
858
859 return intern_computed_face (f, &face);
860}
867dd159 861\f
cb637678 862/* Return the face ID associated with a buffer position POS.
7b7739b1
JB
863 Store into *ENDPTR the position at which a different face is needed.
864 This does not take account of glyphs that specify their own face codes.
f6b98e0b 865 F is the frame in use for display, and W is a window displaying
bc0db68d
RS
866 the current buffer.
867
b349f4fb
RS
868 REGION_BEG, REGION_END delimit the region, so it can be highlighted.
869
870 LIMIT is a position not to scan beyond. That is to limit
6f134486
RS
871 the time this function can take.
872
873 If MOUSE is nonzero, use the character's mouse-face, not its face. */
bc0db68d 874
cb637678 875int
6f134486 876compute_char_face (f, w, pos, region_beg, region_end, endptr, limit, mouse)
7b7739b1 877 struct frame *f;
f211082d 878 struct window *w;
7b7739b1 879 int pos;
bc0db68d 880 int region_beg, region_end;
7b7739b1 881 int *endptr;
b349f4fb 882 int limit;
6f134486 883 int mouse;
7b7739b1
JB
884{
885 struct face face;
b6d40e46 886 Lisp_Object prop, position;
7b7739b1
JB
887 int i, j, noverlays;
888 int facecode;
7b7739b1 889 Lisp_Object *overlay_vec;
f211082d 890 Lisp_Object frame;
f6b98e0b 891 int endpos;
6f134486 892 Lisp_Object propname;
f6b98e0b
JB
893
894 /* W must display the current buffer. We could write this function
895 to use the frame and buffer of W, but right now it doesn't. */
896 if (XBUFFER (w->buffer) != current_buffer)
897 abort ();
f211082d 898
ac22a6c4 899 XSETFRAME (frame, f);
7b7739b1 900
f6b98e0b 901 endpos = ZV;
bc0db68d
RS
902 if (pos < region_beg && region_beg < endpos)
903 endpos = region_beg;
f6b98e0b 904
e0979810 905 XSETFASTINT (position, pos);
6f134486
RS
906
907 if (mouse)
908 propname = Qmouse_face;
909 else
910 propname = Qface;
911
912 prop = Fget_text_property (position, propname, w->buffer);
913
b6d40e46 914 {
b349f4fb 915 Lisp_Object limit1, end;
7b7739b1 916
e0979810 917 XSETFASTINT (limit1, (limit < endpos ? limit : endpos));
6f134486 918 end = Fnext_single_property_change (position, propname, w->buffer, limit1);
b6d40e46
JB
919 if (INTEGERP (end))
920 endpos = XINT (end);
921 }
922
923 {
f6b98e0b 924 int next_overlay;
9516fe94
RS
925 int len;
926
927 /* First try with room for 40 overlays. */
928 len = 40;
929 overlay_vec = (Lisp_Object *) alloca (len * sizeof (Lisp_Object));
930
7af31819
RS
931 noverlays = overlays_at (pos, 0, &overlay_vec, &len,
932 &next_overlay, (int *) 0);
9516fe94
RS
933
934 /* If there are more than 40,
935 make enough space for all, and try again. */
936 if (noverlays > len)
937 {
938 len = noverlays;
939 overlay_vec = (Lisp_Object *) alloca (len * sizeof (Lisp_Object));
82277c2f 940 noverlays = overlays_at (pos, 0, &overlay_vec, &len,
7af31819 941 &next_overlay, (int *) 0);
9516fe94 942 }
b6d40e46 943
f6b98e0b
JB
944 if (next_overlay < endpos)
945 endpos = next_overlay;
b6d40e46
JB
946 }
947
948 *endptr = endpos;
7b7739b1
JB
949
950 /* Optimize the default case. */
bc0db68d
RS
951 if (noverlays == 0 && NILP (prop)
952 && !(pos >= region_beg && pos < region_end))
cb637678 953 return 0;
7b7739b1 954
660ed669 955 compute_base_face (f, &face);
7b7739b1 956
4699e6d2
RS
957 if (CONSP (prop))
958 {
959 /* We have a list of faces, merge them in reverse order */
60573a90
RS
960 Lisp_Object length;
961 int len;
4699e6d2
RS
962 Lisp_Object *faces;
963
60573a90
RS
964 length = Fsafe_length (prop);
965 len = XFASTINT (length);
966
4699e6d2
RS
967 /* Put them into an array */
968 faces = (Lisp_Object *) alloca (len * sizeof (Lisp_Object));
969 for (j = 0; j < len; j++)
970 {
971 faces[j] = Fcar (prop);
972 prop = Fcdr (prop);
973 }
974 /* So that we can merge them in the reverse order */
975 for (j = len - 1; j >= 0; j--)
976 {
977 facecode = face_name_id_number (f, faces[j]);
978 if (facecode >= 0 && facecode < FRAME_N_PARAM_FACES (f)
979 && FRAME_PARAM_FACES (f) [facecode] != 0)
980 merge_faces (FRAME_PARAM_FACES (f) [facecode], &face);
981 }
982 }
983 else if (!NILP (prop))
7b7739b1 984 {
1d9fd7fe 985 facecode = face_name_id_number (f, prop);
7b00de84
JB
986 if (facecode >= 0 && facecode < FRAME_N_PARAM_FACES (f)
987 && FRAME_PARAM_FACES (f) [facecode] != 0)
988 merge_faces (FRAME_PARAM_FACES (f) [facecode], &face);
7b7739b1
JB
989 }
990
4d6ebff8 991 noverlays = sort_overlays (overlay_vec, noverlays, w);
7b7739b1
JB
992
993 /* Now merge the overlay data in that order. */
7b7739b1
JB
994 for (i = 0; i < noverlays; i++)
995 {
6f134486 996 prop = Foverlay_get (overlay_vec[i], propname);
4699e6d2
RS
997 if (CONSP (prop))
998 {
999 /* We have a list of faces, merge them in reverse order */
60573a90
RS
1000 Lisp_Object length;
1001 int len;
4699e6d2 1002 Lisp_Object *faces;
60573a90
RS
1003
1004 length = Fsafe_length (prop);
1005 len = XFASTINT (length);
4699e6d2
RS
1006
1007 /* Put them into an array */
1008 faces = (Lisp_Object *) alloca (len * sizeof (Lisp_Object));
1009 for (j = 0; j < len; j++)
1010 {
1011 faces[j] = Fcar (prop);
1012 prop = Fcdr (prop);
1013 }
1014 /* So that we can merge them in the reverse order */
1015 for (j = len - 1; j >= 0; j--)
1016 {
1017 facecode = face_name_id_number (f, faces[j]);
1018 if (facecode >= 0 && facecode < FRAME_N_PARAM_FACES (f)
1019 && FRAME_PARAM_FACES (f) [facecode] != 0)
1020 merge_faces (FRAME_PARAM_FACES (f) [facecode], &face);
1021 }
1022 }
1023 else if (!NILP (prop))
7b7739b1
JB
1024 {
1025 Lisp_Object oend;
1026 int oendpos;
1027
1d9fd7fe 1028 facecode = face_name_id_number (f, prop);
7b00de84
JB
1029 if (facecode >= 0 && facecode < FRAME_N_PARAM_FACES (f)
1030 && FRAME_PARAM_FACES (f) [facecode] != 0)
6f134486 1031 merge_faces (FRAME_PARAM_FACES (f)[facecode], &face);
7b7739b1 1032
4d6ebff8 1033 oend = OVERLAY_END (overlay_vec[i]);
7b7739b1 1034 oendpos = OVERLAY_POSITION (oend);
f6b98e0b 1035 if (oendpos < endpos)
7b7739b1
JB
1036 endpos = oendpos;
1037 }
1038 }
1039
bc0db68d
RS
1040 if (pos >= region_beg && pos < region_end)
1041 {
1042 if (region_end < endpos)
1043 endpos = region_end;
1044 if (region_face >= 0 && region_face < next_face_id)
6f134486 1045 merge_faces (FRAME_PARAM_FACES (f)[region_face], &face);
bc0db68d
RS
1046 }
1047
7b7739b1
JB
1048 *endptr = endpos;
1049
7b00de84 1050 return intern_computed_face (f, &face);
f211082d 1051}
867dd159 1052\f
660ed669
JB
1053/* Recompute the GC's for the default and modeline faces.
1054 We call this after changing frame parameters on which those GC's
1055 depend. */
fffc2367 1056
660ed669
JB
1057void
1058recompute_basic_faces (f)
1059 FRAME_PTR f;
1060{
1061 /* If the frame's faces haven't been initialized yet, don't worry about
1062 this stuff. */
7b00de84 1063 if (FRAME_N_PARAM_FACES (f) < 2)
660ed669
JB
1064 return;
1065
1066 BLOCK_INPUT;
1067
1068 if (FRAME_DEFAULT_FACE (f)->gc)
42120bc7 1069 XFreeGC (FRAME_X_DISPLAY (f), FRAME_DEFAULT_FACE (f)->gc);
660ed669 1070 if (FRAME_MODE_LINE_FACE (f)->gc)
42120bc7 1071 XFreeGC (FRAME_X_DISPLAY (f), FRAME_MODE_LINE_FACE (f)->gc);
7b00de84
JB
1072
1073 compute_base_face (f, FRAME_DEFAULT_FACE (f));
1074 compute_base_face (f, FRAME_MODE_LINE_FACE (f));
1075
1076 merge_faces (FRAME_DEFAULT_PARAM_FACE (f), FRAME_DEFAULT_FACE (f));
1077 merge_faces (FRAME_MODE_LINE_PARAM_FACE (f), FRAME_MODE_LINE_FACE (f));
1078
42120bc7
RS
1079 intern_face (f, FRAME_DEFAULT_FACE (f));
1080 intern_face (f, FRAME_MODE_LINE_FACE (f));
660ed669
JB
1081
1082 UNBLOCK_INPUT;
1083}
1084
1085
c115973b 1086\f
cb637678 1087/* Lisp interface. */
c115973b
JB
1088
1089DEFUN ("frame-face-alist", Fframe_face_alist, Sframe_face_alist, 1, 1, 0,
1090 "")
1091 (frame)
1092 Lisp_Object frame;
1093{
1094 CHECK_FRAME (frame, 0);
1095 return XFRAME (frame)->face_alist;
1096}
1097
1098DEFUN ("set-frame-face-alist", Fset_frame_face_alist, Sset_frame_face_alist,
1099 2, 2, 0, "")
1100 (frame, value)
1101 Lisp_Object frame, value;
1102{
1103 CHECK_FRAME (frame, 0);
1104 XFRAME (frame)->face_alist = value;
1105 return value;
1106}
1107
1108
1109DEFUN ("make-face-internal", Fmake_face_internal, Smake_face_internal, 1, 1, 0,
1110 "Create face number FACE-ID on all frames.")
1111 (face_id)
1112 Lisp_Object face_id;
1113{
87485d6f 1114 Lisp_Object rest, frame;
c115973b
JB
1115 int id = XINT (face_id);
1116
f211082d
JB
1117 CHECK_NUMBER (face_id, 0);
1118 if (id < 0 || id >= next_face_id)
1119 error ("Face id out of range");
c115973b 1120
87485d6f 1121 FOR_EACH_FRAME (rest, frame)
c115973b 1122 {
87485d6f
MW
1123 if (FRAME_X_P (XFRAME (frame)))
1124 ensure_face_ready (XFRAME (frame), id);
c115973b
JB
1125 }
1126 return Qnil;
1127}
1128
1129
1130DEFUN ("set-face-attribute-internal", Fset_face_attribute_internal,
1131 Sset_face_attribute_internal, 4, 4, 0, "")
1132 (face_id, attr_name, attr_value, frame)
1133 Lisp_Object face_id, attr_name, attr_value, frame;
1134{
1135 struct face *face;
1136 struct frame *f;
1137 int magic_p;
1138 int id;
53dfb388 1139 int garbaged = 0;
c115973b
JB
1140
1141 CHECK_FRAME (frame, 0);
f211082d 1142 CHECK_NUMBER (face_id, 0);
c115973b
JB
1143 CHECK_SYMBOL (attr_name, 0);
1144
1145 f = XFRAME (frame);
1146 id = XINT (face_id);
f211082d
JB
1147 if (id < 0 || id >= next_face_id)
1148 error ("Face id out of range");
c115973b 1149
b6d40e46 1150 if (! FRAME_X_P (f))
b839cea0 1151 return Qnil;
b6d40e46 1152
c115973b 1153 ensure_face_ready (f, id);
7b00de84 1154 face = FRAME_PARAM_FACES (f) [XFASTINT (face_id)];
c115973b
JB
1155
1156 if (EQ (attr_name, intern ("font")))
1157 {
87485d6f
MW
1158#if defined (MSDOS) && !defined (HAVE_X_WINDOWS)
1159 face->font = 0; /* The one and only font. */
1160#else
f211082d 1161 XFontStruct *font = load_font (f, attr_value);
7556890b 1162 if (face->font != f->output_data.x->font)
ebc64af3 1163 unload_font (f, face->font);
c115973b 1164 face->font = font;
6717f691
RS
1165 if (frame_update_line_height (f))
1166 x_set_window_size (f, 0, f->width, f->height);
53dfb388
RS
1167 /* Must clear cache, since it might contain the font
1168 we just got rid of. */
1169 garbaged = 1;
87485d6f 1170#endif
c115973b
JB
1171 }
1172 else if (EQ (attr_name, intern ("foreground")))
1173 {
f211082d 1174 unsigned long new_color = load_color (f, attr_value);
c115973b
JB
1175 unload_color (f, face->foreground);
1176 face->foreground = new_color;
53dfb388 1177 garbaged = 1;
c115973b
JB
1178 }
1179 else if (EQ (attr_name, intern ("background")))
1180 {
f211082d 1181 unsigned long new_color = load_color (f, attr_value);
c115973b 1182 unload_color (f, face->background);
87485d6f
MW
1183#if defined (MSDOS) && !defined (HAVE_X_WINDOWS)
1184 new_color &= ~8; /* Bright would give blinking characters. */
1185#endif
c115973b 1186 face->background = new_color;
53dfb388 1187 garbaged = 1;
c115973b 1188 }
c115973b
JB
1189 else if (EQ (attr_name, intern ("background-pixmap")))
1190 {
cd0bb842
RS
1191 unsigned int w, h;
1192 unsigned long new_pixmap = load_pixmap (f, attr_value, &w, &h);
1193 x_destroy_bitmap (f, face->stipple);
f211082d 1194 face->stipple = new_pixmap;
c115973b
JB
1195 face->pixmap_w = w;
1196 face->pixmap_h = h;
cd0bb842 1197 garbaged = 1;
c115973b 1198 }
c115973b
JB
1199 else if (EQ (attr_name, intern ("underline")))
1200 {
1201 int new = !NILP (attr_value);
1202 face->underline = new;
1203 }
1204 else
1205 error ("unknown face attribute");
1206
7b00de84
JB
1207 if (id == 0 || id == 1)
1208 recompute_basic_faces (f);
c115973b 1209
53dfb388
RS
1210 /* We must redraw the frame whenever any face font or color changes,
1211 because it's possible that a merged (display) face
1212 contains the font or color we just replaced.
1213 And we must inhibit any Expose events until the redraw is done,
1214 since they would try to use the invalid display faces. */
1215 if (garbaged)
584d0634 1216 SET_FRAME_GARBAGED (f);
584d0634 1217
c115973b
JB
1218 return Qnil;
1219}
1220
1221DEFUN ("internal-next-face-id", Finternal_next_face_id, Sinternal_next_face_id,
1222 0, 0, 0, "")
1223 ()
1224{
1225 return make_number (next_face_id++);
1226}
f211082d
JB
1227
1228/* Return the face id for name NAME on frame FRAME.
1229 (It should be the same for all frames,
1230 but it's as easy to use the "right" frame to look it up
1231 as to use any other one.) */
1232
1d9fd7fe
JB
1233int
1234face_name_id_number (f, name)
1235 FRAME_PTR f;
1236 Lisp_Object name;
f211082d
JB
1237{
1238 Lisp_Object tem;
1239
82411f65 1240 tem = Fcdr (assq_no_quit (name, f->face_alist));
b6d40e46
JB
1241 if (NILP (tem))
1242 return 0;
f211082d
JB
1243 CHECK_VECTOR (tem, 0);
1244 tem = XVECTOR (tem)->contents[2];
1245 CHECK_NUMBER (tem, 0);
1246 return XINT (tem);
1247}
c115973b 1248\f
cb637678
JB
1249/* Emacs initialization. */
1250
c115973b 1251void
f211082d 1252syms_of_xfaces ()
c115973b 1253{
f211082d
JB
1254 Qface = intern ("face");
1255 staticpro (&Qface);
6f134486
RS
1256 Qmouse_face = intern ("mouse-face");
1257 staticpro (&Qmouse_face);
cd0bb842
RS
1258 Qpixmap_spec_p = intern ("pixmap-spec-p");
1259 staticpro (&Qpixmap_spec_p);
f211082d 1260
bc0db68d
RS
1261 DEFVAR_INT ("region-face", &region_face,
1262 "Face number to use to highlight the region\n\
1263The region is highlighted with this face\n\
1264when Transient Mark mode is enabled and the mark is active.");
1265
87485d6f 1266#ifdef HAVE_X_WINDOWS
cd0bb842 1267 defsubr (&Spixmap_spec_p);
87485d6f 1268#endif
c115973b
JB
1269 defsubr (&Sframe_face_alist);
1270 defsubr (&Sset_frame_face_alist);
1271 defsubr (&Smake_face_internal);
1272 defsubr (&Sset_face_attribute_internal);
1273 defsubr (&Sinternal_next_face_id);
1274}
cb637678 1275
87485d6f 1276#endif /* HAVE_FACES */