comparison src/xfaces.c @ 91531:24d3fbc119ce

Revert 2008-02-01 change to src/xfaces.c by cyd@stupidchicken.com Revision: emacs@sv.gnu.org/emacs--devo--0--patch-1051
author Miles Bader <miles@gnu.org>
date Tue, 05 Feb 2008 02:36:40 +0000
parents ee9cba23cf9d
children 7d8392863f85
comparison
equal deleted inserted replaced
91530:678a84aa5ccd 91531:24d3fbc119ce
490 static int better_font_p P_ ((int *, struct font_name *, struct font_name *, 490 static int better_font_p P_ ((int *, struct font_name *, struct font_name *,
491 int, int)); 491 int, int));
492 static int x_face_list_fonts P_ ((struct frame *, char *, 492 static int x_face_list_fonts P_ ((struct frame *, char *,
493 struct font_name **, int, int)); 493 struct font_name **, int, int));
494 static int font_scalable_p P_ ((struct font_name *)); 494 static int font_scalable_p P_ ((struct font_name *));
495 static int get_lface_attributes P_ ((struct frame *, Lisp_Object, Lisp_Object *, int));
495 static int load_pixmap P_ ((struct frame *, Lisp_Object, unsigned *, unsigned *)); 496 static int load_pixmap P_ ((struct frame *, Lisp_Object, unsigned *, unsigned *));
496 static unsigned char *xstrlwr P_ ((unsigned char *)); 497 static unsigned char *xstrlwr P_ ((unsigned char *));
497 static struct frame *frame_or_selected_frame P_ ((Lisp_Object, int)); 498 static struct frame *frame_or_selected_frame P_ ((Lisp_Object, int));
498 static void load_face_font P_ ((struct frame *, struct face *)); 499 static void load_face_font P_ ((struct frame *, struct face *));
499 static void load_face_colors P_ ((struct frame *, struct face *, Lisp_Object *)); 500 static void load_face_colors P_ ((struct frame *, struct face *, Lisp_Object *));
3436 check_lface (lface); 3437 check_lface (lface);
3437 return lface; 3438 return lface;
3438 } 3439 }
3439 3440
3440 3441
3442 /* Get face attributes of face FACE_NAME from frame-local faces on
3443 frame F. Store the resulting attributes in ATTRS which must point
3444 to a vector of Lisp_Objects of size LFACE_VECTOR_SIZE. If SIGNAL_P
3445 is non-zero, signal an error if FACE_NAME does not name a face.
3446 Otherwise, value is zero if FACE_NAME is not a face. */
3447
3448 static INLINE int
3449 get_lface_attributes (f, face_name, attrs, signal_p)
3450 struct frame *f;
3451 Lisp_Object face_name;
3452 Lisp_Object *attrs;
3453 int signal_p;
3454 {
3455 Lisp_Object lface;
3456 int success_p;
3457
3458 lface = lface_from_face_name (f, face_name, signal_p);
3459 if (!NILP (lface))
3460 {
3461 bcopy (XVECTOR (lface)->contents, attrs,
3462 LFACE_VECTOR_SIZE * sizeof *attrs);
3463 success_p = 1;
3464 }
3465 else
3466 success_p = 0;
3467
3468 return success_p;
3469 }
3470
3471
3441 /* Non-zero if all attributes in face attribute vector ATTRS are 3472 /* Non-zero if all attributes in face attribute vector ATTRS are
3442 specified, i.e. are non-nil. */ 3473 specified, i.e. are non-nil. */
3443 3474
3444 static int 3475 static int
3445 lface_fully_specified_p (attrs) 3476 lface_fully_specified_p (attrs)
3721 } 3752 }
3722 3753
3723 3754
3724 /* Merge two Lisp face attribute vectors on frame F, FROM and TO, and 3755 /* Merge two Lisp face attribute vectors on frame F, FROM and TO, and
3725 store the resulting attributes in TO, which must be already be 3756 store the resulting attributes in TO, which must be already be
3726 completely specified and contain only absolute attributes. The 3757 completely specified and contain only absolute attributes. Every
3727 contents of FROM are not altered. 3758 specified attribute of FROM overrides the corresponding attribute of
3728 3759 TO; relative attributes in FROM are merged with the absolute value in
3729 Every specified attribute of FROM overrides the corresponding 3760 TO and replace it. NAMED_MERGE_POINTS is used internally to detect
3730 attribute of TO; relative attributes in FROM are merged with the 3761 loops in face inheritance; it should be 0 when called from other
3731 absolute value in TO and replace it. NAMED_MERGE_POINTS is used 3762 places. */
3732 internally to detect loops in face inheritance; it should be 0 when
3733 called from other places. */
3734 3763
3735 static INLINE void 3764 static INLINE void
3736 merge_face_vectors (f, from, to, named_merge_points) 3765 merge_face_vectors (f, from, to, named_merge_points)
3737 struct frame *f; 3766 struct frame *f;
3738 Lisp_Object *from, *to; 3767 Lisp_Object *from, *to;
3792 3821
3793 if (push_named_merge_point (&named_merge_point, 3822 if (push_named_merge_point (&named_merge_point,
3794 face_name, &named_merge_points)) 3823 face_name, &named_merge_points))
3795 { 3824 {
3796 struct gcpro gcpro1; 3825 struct gcpro gcpro1;
3797 Lisp_Object lface = lface_from_face_name (f, face_name, 0); 3826 Lisp_Object from[LFACE_VECTOR_SIZE];
3798 if (NILP (lface)) 3827 int ok = get_lface_attributes (f, face_name, from, 0);
3799 return 0; 3828
3800 3829 if (ok)
3801 GCPRO1 (named_merge_point.face_name); 3830 {
3802 merge_face_vectors (f, XVECTOR (lface)->contents, to, 3831 GCPRO1 (named_merge_point.face_name);
3803 named_merge_points); 3832 merge_face_vectors (f, from, to, named_merge_points);
3804 UNGCPRO; 3833 UNGCPRO;
3805 return 1; 3834 }
3835
3836 return ok;
3806 } 3837 }
3807 else 3838 else
3808 return 0; 3839 return 0;
3809 } 3840 }
3810 3841
3826 for that attribute. 3857 for that attribute.
3827 3858
3828 3. Conses or the form (FOREGROUND-COLOR . COLOR) or 3859 3. Conses or the form (FOREGROUND-COLOR . COLOR) or
3829 (BACKGROUND-COLOR . COLOR) where COLOR is a color name. This is 3860 (BACKGROUND-COLOR . COLOR) where COLOR is a color name. This is
3830 for compatibility with 20.2. 3861 for compatibility with 20.2.
3831
3832 The contents of FACE_REF is not altered by this function.
3833 3862
3834 Face specifications earlier in lists take precedence over later 3863 Face specifications earlier in lists take precedence over later
3835 specifications. */ 3864 specifications. */
3836 3865
3837 static int 3866 static int
6086 lookup_named_face (f, symbol, signal_p) 6115 lookup_named_face (f, symbol, signal_p)
6087 struct frame *f; 6116 struct frame *f;
6088 Lisp_Object symbol; 6117 Lisp_Object symbol;
6089 int signal_p; 6118 int signal_p;
6090 { 6119 {
6091 Lisp_Object lface, attrs[LFACE_VECTOR_SIZE]; 6120 Lisp_Object attrs[LFACE_VECTOR_SIZE];
6121 Lisp_Object symbol_attrs[LFACE_VECTOR_SIZE];
6092 struct face *default_face = FACE_FROM_ID (f, DEFAULT_FACE_ID); 6122 struct face *default_face = FACE_FROM_ID (f, DEFAULT_FACE_ID);
6093 6123
6094 if (default_face == NULL) 6124 if (default_face == NULL)
6095 { 6125 {
6096 if (!realize_basic_faces (f)) 6126 if (!realize_basic_faces (f))
6098 default_face = FACE_FROM_ID (f, DEFAULT_FACE_ID); 6128 default_face = FACE_FROM_ID (f, DEFAULT_FACE_ID);
6099 if (default_face == NULL) 6129 if (default_face == NULL)
6100 abort (); /* realize_basic_faces must have set it up */ 6130 abort (); /* realize_basic_faces must have set it up */
6101 } 6131 }
6102 6132
6103 lface = lface_from_face_name (f, symbol, signal_p); 6133 if (!get_lface_attributes (f, symbol, symbol_attrs, signal_p))
6104 if (NILP (lface))
6105 return -1; 6134 return -1;
6106 6135
6107 bcopy (default_face->lface, attrs, sizeof attrs); 6136 bcopy (default_face->lface, attrs, sizeof attrs);
6108 merge_face_vectors (f, XVECTOR (lface)->contents, attrs, 0); 6137 merge_face_vectors (f, symbol_attrs, attrs, 0);
6109 6138
6110 return lookup_face (f, attrs); 6139 return lookup_face (f, attrs);
6111 } 6140 }
6112 6141
6113 6142
6234 struct frame *f; 6263 struct frame *f;
6235 Lisp_Object symbol; 6264 Lisp_Object symbol;
6236 int face_id; 6265 int face_id;
6237 int signal_p; 6266 int signal_p;
6238 { 6267 {
6239 Lisp_Object lface, attrs[LFACE_VECTOR_SIZE]; 6268 Lisp_Object attrs[LFACE_VECTOR_SIZE];
6240 Lisp_Object symbol_attrs[LFACE_VECTOR_SIZE]; 6269 Lisp_Object symbol_attrs[LFACE_VECTOR_SIZE];
6241 struct face *default_face = FACE_FROM_ID (f, face_id); 6270 struct face *default_face = FACE_FROM_ID (f, face_id);
6242 6271
6243 if (!default_face) 6272 if (!default_face)
6244 abort (); 6273 abort ();
6245 6274
6246 lface = lface_from_face_name (f, symbol, signal_p); 6275 get_lface_attributes (f, symbol, symbol_attrs, signal_p);
6247 bcopy (default_face->lface, attrs, sizeof attrs); 6276 bcopy (default_face->lface, attrs, sizeof attrs);
6248 merge_face_vectors (f, XVECTOR (lface)->contents, attrs, 0); 6277 merge_face_vectors (f, symbol_attrs, attrs, 0);
6249 return lookup_face (f, attrs); 6278 return lookup_face (f, attrs);
6250 } 6279 }
6251 6280
6252 DEFUN ("face-attributes-as-vector", Fface_attributes_as_vector, 6281 DEFUN ("face-attributes-as-vector", Fface_attributes_as_vector,
6253 Sface_attributes_as_vector, 1, 1, 0, 6282 Sface_attributes_as_vector, 1, 1, 0,
7534 realize_named_face (f, symbol, id) 7563 realize_named_face (f, symbol, id)
7535 struct frame *f; 7564 struct frame *f;
7536 Lisp_Object symbol; 7565 Lisp_Object symbol;
7537 int id; 7566 int id;
7538 { 7567 {
7568 struct face_cache *c = FRAME_FACE_CACHE (f);
7539 Lisp_Object lface = lface_from_face_name (f, symbol, 0); 7569 Lisp_Object lface = lface_from_face_name (f, symbol, 0);
7540 Lisp_Object attrs[LFACE_VECTOR_SIZE]; 7570 Lisp_Object attrs[LFACE_VECTOR_SIZE];
7541 struct face *default_face = FACE_FROM_ID (f, DEFAULT_FACE_ID); 7571 Lisp_Object symbol_attrs[LFACE_VECTOR_SIZE];
7572 struct face *new_face;
7542 7573
7543 /* The default face must exist and be fully specified. */ 7574 /* The default face must exist and be fully specified. */
7544 bcopy (default_face->lface, attrs, LFACE_VECTOR_SIZE * sizeof *attrs); 7575 get_lface_attributes (f, Qdefault, attrs, 1);
7545 check_lface_attrs (attrs); 7576 check_lface_attrs (attrs);
7546 xassert (lface_fully_specified_p (attrs)); 7577 xassert (lface_fully_specified_p (attrs));
7547 7578
7548 /* If SYMBOL isn't known as a face, create it. */ 7579 /* If SYMBOL isn't know as a face, create it. */
7549 if (NILP (lface)) 7580 if (NILP (lface))
7550 { 7581 {
7551 Lisp_Object frame; 7582 Lisp_Object frame;
7552 XSETFRAME (frame, f); 7583 XSETFRAME (frame, f);
7553 lface = Finternal_make_lisp_face (symbol, frame); 7584 lface = Finternal_make_lisp_face (symbol, frame);
7554 } 7585 }
7555 7586
7556 /* Merge SYMBOL's face with the default face. */ 7587 /* Merge SYMBOL's face with the default face. */
7557 merge_face_vectors (f, XVECTOR (lface)->contents, attrs, 0); 7588 get_lface_attributes (f, symbol, symbol_attrs, 1);
7558 realize_face (FRAME_FACE_CACHE (f), attrs, id); 7589 merge_face_vectors (f, symbol_attrs, attrs, 0);
7590
7591 /* Realize the face. */
7592 new_face = realize_face (c, attrs, id);
7559 } 7593 }
7560 7594
7561 7595
7562 /* Realize the fully-specified face with attributes ATTRS in face 7596 /* Realize the fully-specified face with attributes ATTRS in face
7563 cache CACHE for ASCII characters. If FORMER_FACE_ID is 7597 cache CACHE for ASCII characters. If FORMER_FACE_ID is