changeset 25661:a6e2ae7964fb

(Fx_family_fonts): Replaces Fx_font_list. (syms_of_xfaces): Defsubr accordingly. (lface_from_face_name): Resolve face aliases. (Qmode_line): Replaces Qmodeline. (realize_basic_faces): Use Qmode_line. (syms_of_xfaces): Initialize Qmode_line. (Qframe_update_face_colors): New. (syms_of_xfaces): Initialize call. (update_face_from_frame_parameter): Call that function when the frame's background changes.
author Gerd Moellmann <gerd@gnu.org>
date Sun, 12 Sep 1999 20:22:02 +0000
parents 0072098f54df
children 0a7261c1d487
files src/xfaces.c
diffstat 1 files changed, 44 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/src/xfaces.c	Sun Sep 12 20:21:58 1999 +0000
+++ b/src/xfaces.c	Sun Sep 12 20:22:02 1999 +0000
@@ -278,11 +278,22 @@
 
 Lisp_Object Qx_charset_registry;
 
+/* The name of the function to call when the background of the frame
+   has changed, frame_update_face_colors.  */
+
+Lisp_Object Qframe_update_face_colors;
+
 /* Names of basic faces.  */
 
-Lisp_Object Qdefault, Qmodeline, Qtool_bar, Qregion, Qfringe;
+Lisp_Object Qdefault, Qmode_line, Qtool_bar, Qregion, Qfringe;
 Lisp_Object Qheader_line, Qscroll_bar, Qcursor, Qborder, Qmouse;;
 
+/* The symbol `face-alias'.  A symbols having that property is an
+   alias for another face.  Value of the property is the name of
+   the aliased face.  */
+
+Lisp_Object Qface_alias;
+
 /* Names of frame parameters related to faces.  */
 
 extern Lisp_Object Qscroll_bar_foreground, Qscroll_bar_background;
@@ -2274,7 +2285,7 @@
 
 
 /* Remove elements from LIST whose cars are `equal'.  Called from
-   x-font-list and x-font-family-list to remove duplicate font
+   x-family-fonts and x-font-family-list to remove duplicate font
    entries.  */
 
 static void
@@ -2294,7 +2305,7 @@
 }
 
 
-DEFUN ("x-font-list", Fxfont_list, Sx_font_list, 0, 2, 0,
+DEFUN ("x-family-fonts", Fx_family_fonts, Sx_family_fonts, 0, 2, 0,
   "Return a list of available fonts of family FAMILY on FRAME.\n\
 If FAMILY is omitted or nil, list all families.\n\
 Otherwise, FAMILY must be a string, possibly containing wildcards\n\
@@ -2610,9 +2621,11 @@
 /* Return the face definition of FACE_NAME on frame F.  F null means
    return the global definition.  FACE_NAME may be a string or a
    symbol (apparently Emacs 20.2 allows strings as face names in face
-   text properties; ediff uses that).  If SIGNAL_P is non-zero, signal
-   an error if FACE_NAME is not a valid face name.  If SIGNAL_P is
-   zero, value is nil if FACE_NAME is not a valid face name.  */
+   text properties; ediff uses that).  If FACE_NAME is an alias for
+   another face, return that face's definition.  If SIGNAL_P is
+   non-zero, signal an error if FACE_NAME is not a valid face name.
+   If SIGNAL_P is zero, value is nil if FACE_NAME is not a valid face
+   name.  */
 
 static INLINE Lisp_Object
 lface_from_face_name (f, face_name, signal_p)
@@ -2620,11 +2633,17 @@
      Lisp_Object face_name;
      int signal_p;
 {
-  Lisp_Object lface;
+  Lisp_Object lface, alias;
 
   if (STRINGP (face_name))
     face_name = intern (XSTRING (face_name)->data);
 
+  /* If FACE_NAME is an alias for another face, return the definition
+     of the aliased face.  */
+  alias = Fget (face_name, Qface_alias);
+  if (!NILP (alias))
+    face_name = alias;
+
   if (f)
     lface = assq_no_quit (face_name, f->face_alist);
   else
@@ -3557,7 +3576,7 @@
 
   /* If there are no faces yet, give up.  This is the case when called
      from Fx_create_frame, and we do the necessary things later in
-     face-set-after-frame-defaults. */
+     face-set-after-frame-defaults.  */
   if (NILP (f->face_alist))
     return;
   
@@ -3570,6 +3589,14 @@
     }
   else if (EQ (param, Qbackground_color))
     {
+      Lisp_Object frame;
+
+      /* Changing the background color might change the background
+	 mode, so that we have to load new defface specs.  Call
+	 frame-update-face-colors to do that.  */
+      XSETFRAME (frame, f);
+      call1 (Qframe_update_face_colors, frame);
+      
       lface = lface_from_face_name (f, Qdefault, 1);
       LFACE_BACKGROUND (lface) = (STRINGP (new_value)
 				  ? new_value : Qunspecified);
@@ -5235,7 +5262,7 @@
   
   if (realize_default_face (f))
     {
-      realize_named_face (f, Qmodeline, MODE_LINE_FACE_ID);
+      realize_named_face (f, Qmode_line, MODE_LINE_FACE_ID);
       realize_named_face (f, Qtool_bar, TOOL_BAR_FACE_ID);
       realize_named_face (f, Qfringe, BITMAP_AREA_FACE_ID);
       realize_named_face (f, Qheader_line, HEADER_LINE_FACE_ID);
@@ -6249,7 +6276,9 @@
   staticpro (&Qface);
   Qpixmap_spec_p = intern ("pixmap-spec-p");
   staticpro (&Qpixmap_spec_p);
-
+  Qframe_update_face_colors = intern ("frame-update-face-colors");
+  staticpro (&Qframe_update_face_colors);
+  
   /* Lisp face attribute keywords.  */
   QCfamily = intern (":family");
   staticpro (&QCfamily);
@@ -6348,10 +6377,12 @@
 
   Qx_charset_registry = intern ("x-charset-registry");
   staticpro (&Qx_charset_registry);
+  Qface_alias = intern ("face-alias");
+  staticpro (&Qface_alias);
   Qdefault = intern ("default");
   staticpro (&Qdefault);
-  Qmodeline = intern ("modeline");
-  staticpro (&Qmodeline);
+  Qmode_line = intern ("mode-line");
+  staticpro (&Qmode_line);
   Qtool_bar = intern ("tool-bar");
   staticpro (&Qtool_bar);
   Qregion = intern ("region");
@@ -6436,7 +6467,7 @@
   defsubr (&Spixmap_spec_p);
   defsubr (&Sx_list_fonts);
   defsubr (&Sinternal_face_x_get_resource);
-  defsubr (&Sx_font_list);
+  defsubr (&Sx_family_fonts);
   defsubr (&Sx_font_family_list);
 #endif /* HAVE_X_WINDOWS */