changeset 5624:c39052c921b5

New "foreback" face property. -------------------- ChangeLog entries follow: -------------------- lisp/ChangeLog addition: 2011-12-27 Didier Verna <didier@xemacs.org> * cl-macs.el (face-foreback): New defsetf. * faces.el (set-face-property): Document the foreback property. * faces.el (face-foreback): * faces.el (face-foreback-instance): * faces.el (face-foreback-name): * faces.el (set-face-foreback): New functions. * faces.el (face-equal): * faces.el (init-other-random-faces): * cus-face.el (custom-face-attributes): * x-faces.el (x-init-face-from-resources): Handle the foreback property. src/ChangeLog addition: 2011-12-27 Didier Verna <didier@xemacs.org> * faces.h (struct Lisp_Face): New 'foreback slot. * faces.h (struct face_cachel): New 'foreback and 'foreback_specified slots. * faces.h (WINDOW_FACE_CACHEL_FOREBACK): * faces.h (FACE_FOREBACK): New macros. * faces.c: Declare Qforeback. * lisp.h: Externalize it. * faces.c (syms_of_faces): Define it. * faces.c (vars_of_faces): Update built-in face specifiers. * faces.c (complex_vars_of_faces): Update specifier fallbacks. * faces.c (mark_face): * faces.c (face_equal): * faces.c (face_getprop): * faces.c (face_putprop): * faces.c (face_remprop): * faces.c (face_plist): * faces.c (reset_face): * faces.c (update_face_inheritance_mapper): * faces.c (Fmake_face): * faces.c (mark_face_cachels): * faces.c (update_face_cachel_data): * faces.c (merge_face_cachel_data): * faces.c (reset_face_cachel): * faces.c (face_property_was_changed): * faces.c (Fcopy_face): * fontcolor.c (face_color_validate): Handle the foreback property. * redisplay-msw.c (mswindows_output_blank): * redisplay-msw.c (mswindows_output_string): * redisplay-output.c (redisplay_clear_region): * redisplay-xlike-inc.c (XLIKE_output_string): * redisplay-xlike-inc.c (XLIKE_output_blank): Use the face's foreback color instead of the foreground one for drawing a background bitmap.
author Didier Verna <didier@xemacs.org>
date Tue, 27 Dec 2011 17:07:23 +0100
parents 444713e89160
children 6fa0c5fb6154
files lisp/ChangeLog lisp/cl-macs.el lisp/cus-face.el lisp/faces.el lisp/x-faces.el src/ChangeLog src/faces.c src/faces.h src/fontcolor.c src/lisp.h src/redisplay-msw.c src/redisplay-output.c src/redisplay-xlike-inc.c
diffstat 13 files changed, 234 insertions(+), 46 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/ChangeLog	Tue Dec 27 15:37:03 2011 +0100
+++ b/lisp/ChangeLog	Tue Dec 27 17:07:23 2011 +0100
@@ -1,3 +1,17 @@
+2011-12-27  Didier Verna  <didier@xemacs.org>
+
+	* cl-macs.el (face-foreback): New defsetf.
+	* faces.el (set-face-property): Document the foreback property.
+	* faces.el (face-foreback):
+	* faces.el (face-foreback-instance):
+	* faces.el (face-foreback-name):
+	* faces.el (set-face-foreback): New functions.
+	* faces.el (face-equal):
+	* faces.el (init-other-random-faces):
+	* cus-face.el (custom-face-attributes):
+	* x-faces.el (x-init-face-from-resources): Handle the foreback
+	property.
+
 2011-12-27  Didier Verna  <didier@xemacs.org>
 
 	* faces.el (face-foreground-name): Fix docstring typo.
--- a/lisp/cl-macs.el	Tue Dec 27 15:37:03 2011 +0100
+++ b/lisp/cl-macs.el	Tue Dec 27 17:07:23 2011 +0100
@@ -2111,13 +2111,14 @@
 (defsetf extent-start-position (ext) (store)
   `(progn (set-extent-endpoints ,ext ,store (extent-end-position ,ext))
 	  ,store))
+(defsetf face-foreground (f &optional s) (x) (list 'set-face-foreground f x s))
+(defsetf face-foreback (f &optional s) (x) (list 'set-face-foreback f x s))
 (defsetf face-background (f &optional s) (x) (list 'set-face-background f x s))
 (defsetf face-background-pixmap (f &optional s) (x)
   (list 'set-face-background-pixmap f x s))
 (defsetf face-background-placement (f &optional s) (x)
   (list 'set-face-background-placement f x s))
 (defsetf face-font (f &optional s) (x) (list 'set-face-font f x s))
-(defsetf face-foreground (f &optional s) (x) (list 'set-face-foreground f x s))
 (defsetf face-underline-p (f &optional s) (x)
   (list 'set-face-underline-p f x s))
 (defsetf face-shrink-p (f &optional s) (x)
--- a/lisp/cus-face.el	Tue Dec 27 15:37:03 2011 +0100
+++ b/lisp/cus-face.el	Tue Dec 27 17:07:23 2011 +0100
@@ -83,6 +83,10 @@
 			:value ""
 			:help-echo "Set foreground color.")
 		 set-face-foreground face-foreground-name)
+    (:foreback (color :tag "Foreback"
+			:value ""
+			:help-echo "Set foreback color.")
+		 set-face-foreback face-foreback-name)
     (:background (color :tag "Background"
 			:value ""
 			:help-echo "Set background color.")
--- a/lisp/faces.el	Tue Dec 27 15:37:03 2011 +0100
+++ b/lisp/faces.el	Tue Dec 27 17:07:23 2011 +0100
@@ -322,6 +322,11 @@
  foreground         The foreground color of the face.
                     For valid instantiators, see `make-color-specifier'.
 
+ foreback           The foreground color of the face's background pixmap,
+                    when the pixmap is a bitmap.
+                    Only used by faces on X and MS Windows devices.
+                    For valid instantiators, see `make-color-specifier'.
+
  background         The background color of the face.
                     For valid instantiators, see `make-color-specifier'.
 
@@ -583,6 +588,72 @@
   (interactive (face-interactive "foreground"))
   (set-face-property face 'foreground color locale tag-set how-to-add))
 
+(defun face-foreback (face &optional locale tag-set exact-p)
+  "Return the foreback spec of FACE in LOCALE, or nil if it is unspecified.
+
+NOTE: This returns a locale-specific specification, not any sort of value
+corresponding to the actual foreback being used.  If you want to know the
+actual foreback color used in a particular domain, use
+`face-foreback-instance', or `face-foreback-name' for its name
+\(i.e. the instantiator used to create it).
+
+FACE may be either a face object or a symbol representing a face.
+
+LOCALE may be a locale (the instantiators for that particular locale
+  will be returned), a locale type (the specifications for all locales
+  of that type will be returned), `all' (all specifications will be
+  returned), or nil (the actual specifier object will be returned).
+
+See `face-property' for more information."
+  (face-property face 'foreback locale tag-set exact-p))
+
+(defun face-foreback-instance (face &optional domain default no-fallback)
+  "Return the instance of FACE's foreback in DOMAIN.
+
+Return value will be a color instance object; query its properties using
+`color-instance-name' or `color-instance-rgb-properties'.
+
+FACE may be either a face object or a symbol representing a face.
+
+Normally DOMAIN will be a window or nil (meaning the selected window),
+  and an instance object describing how the foreback appears in that
+  particular window and buffer will be returned.
+
+See `face-property-instance' for more information."
+  (face-property-instance face 'foreback domain default no-fallback))
+
+(defun face-foreback-name (face &optional domain default no-fallback)
+  "Return the name of FACE's foreback color in DOMAIN.
+
+FACE may be either a face object or a symbol representing a face.
+
+Normally DOMAIN will be a window or nil (meaning the selected window),
+  and an instance object describing how the foreback appears in that
+  particular window and buffer will be returned.
+
+See `face-property-instance' for more information."
+  (color-instance-name (face-foreback-instance
+			face domain default no-fallback)))
+
+(defun set-face-foreback (face color &optional locale tag-set how-to-add)
+  "Change the foreback color of FACE to COLOR in LOCALE.
+
+FACE may be either a face object or a symbol representing a face.
+
+COLOR should be an instantiator (see `make-color-specifier'), a list of
+  instantiators, an alist of specifications (each mapping a locale to
+  an instantiator list), or a color specifier object.
+
+If COLOR is an alist, LOCALE must be omitted.  If COLOR is a
+  specifier object, LOCALE can be a locale, a locale type, `all',
+  or nil; see `copy-specifier' for its semantics.  Otherwise LOCALE
+  specifies the locale under which the specified instantiator(s)
+  will be added, and defaults to `global'.
+
+See `set-face-property' for more information."
+  (interactive (face-interactive "foreback"))
+  (set-face-property face 'foreback color locale tag-set how-to-add))
+
 (defun face-background (face &optional locale tag-set exact-p)
   "Return the background color of FACE in LOCALE, or nil if it is unspecified.
 
@@ -935,9 +1006,11 @@
   (if (not (valid-specifier-domain-p domain))
       (error "Invalid specifier domain"))
   (let ((device (dfw-device domain))
-	(common-props '(foreground background font display-table underline
-				   dim inherit shrink))
-	(win-props '(background-pixmap background-placement strikethru))
+	(common-props '(foreground background
+			font display-table underline
+			dim inherit shrink))
+	(win-props '(foreback background-pixmap background-placement
+		     strikethru))
 	(tty-props '(highlight blinking reverse)))
 
     ;; First check the properties which are used in common between the
@@ -2005,7 +2078,7 @@
   ;; element faces. So take the modeline face information from its
   ;; fallbacks, themselves ultimately set up in faces.c:
   (loop
-    for face-property in '(foreground background 
+    for face-property in '(foreground foreback background 
 			   background-pixmap background-placement)
     do (when (and (setq face-property (face-property 'modeline face-property))
                   (null (specifier-instance face-property device nil t))
--- a/lisp/x-faces.el	Tue Dec 27 15:37:03 2011 +0100
+++ b/lisp/x-faces.el	Tue Dec 27 17:07:23 2011 +0100
@@ -698,6 +698,10 @@
 	      (concat name ".attributeForeground")
 	      "Face.AttributeForeground"
 	      'string locale))
+	 (fb (x-get-resource-and-maybe-bogosity-check
+	      (concat name ".attributeForeback")
+	      "Face.AttributeForeback"
+	      'string locale))
 	 (bg (x-get-resource-and-maybe-bogosity-check
 	      (concat name ".attributeBackground")
 	      "Face.AttributeBackground"
@@ -815,6 +819,13 @@
 							x-tag-set)
 	(remove-specifier (face-foreground face) locale x-tag-set nil))
       (set-face-foreground face fg locale our-tag-set append))
+    (when fb
+      (if device-class
+	  (remove-specifier-specs-matching-tag-set-cdrs (face-foreback face)
+							locale
+							x-tag-set)
+	(remove-specifier (face-foreback face) locale x-tag-set nil))
+      (set-face-foreback face fb locale our-tag-set append))
     (when bg
       (if device-class
 	  (remove-specifier-specs-matching-tag-set-cdrs (face-background face)
--- a/src/ChangeLog	Tue Dec 27 15:37:03 2011 +0100
+++ b/src/ChangeLog	Tue Dec 27 17:07:23 2011 +0100
@@ -1,3 +1,39 @@
+2011-12-27  Didier Verna  <didier@xemacs.org>
+
+	* faces.h (struct Lisp_Face): New 'foreback slot.
+	* faces.h (struct face_cachel): New 'foreback and
+	'foreback_specified slots.
+	* faces.h (WINDOW_FACE_CACHEL_FOREBACK):
+	* faces.h (FACE_FOREBACK): New macros.
+	* faces.c: Declare Qforeback.
+	* lisp.h: Externalize it.
+	* faces.c (syms_of_faces): Define it.
+	* faces.c (vars_of_faces): Update built-in face specifiers.
+	* faces.c (complex_vars_of_faces): Update specifier fallbacks.
+	* faces.c (mark_face):
+	* faces.c (face_equal):
+	* faces.c (face_getprop):
+	* faces.c (face_putprop):
+	* faces.c (face_remprop):
+	* faces.c (face_plist):
+	* faces.c (reset_face):
+	* faces.c (update_face_inheritance_mapper):
+	* faces.c (Fmake_face):
+	* faces.c (mark_face_cachels):
+	* faces.c (update_face_cachel_data):
+	* faces.c (merge_face_cachel_data):
+	* faces.c (reset_face_cachel):
+	* faces.c (face_property_was_changed):
+	* faces.c (Fcopy_face):
+	* fontcolor.c (face_color_validate): Handle the foreback property.
+	* redisplay-msw.c (mswindows_output_blank):
+	* redisplay-msw.c (mswindows_output_string):
+	* redisplay-output.c (redisplay_clear_region):
+	* redisplay-xlike-inc.c (XLIKE_output_string):
+	* redisplay-xlike-inc.c (XLIKE_output_blank): Use the face's
+	foreback color instead of the foreground one for drawing a
+	background bitmap.
+
 2011-12-27  Didier Verna  <didier@xemacs.org>
 
 	* redisplay-xlike-inc.c (XLIKE_output_blank): Fix comment typo.
--- a/src/faces.c	Tue Dec 27 15:37:03 2011 +0100
+++ b/src/faces.c	Tue Dec 27 17:07:23 2011 +0100
@@ -40,7 +40,7 @@
 #include "window.h"
 
 Lisp_Object Qfacep;
-Lisp_Object Qforeground, Qbackground, Qdisplay_table;
+Lisp_Object Qforeground, Qforeback, Qbackground, Qdisplay_table;
 Lisp_Object Qbackground_pixmap, Qbackground_placement, Qunderline, Qdim;
 Lisp_Object Qblinking, Qstrikethru, Qshrink, Q_name;
 
@@ -106,6 +106,7 @@
   mark_object (face->doc_string);
 
   mark_object (face->foreground);
+  mark_object (face->foreback);
   mark_object (face->background);
   mark_object (face->font);
   mark_object (face->display_table);
@@ -159,6 +160,7 @@
 
   return
     (internal_equal (f1->foreground,	     f2->foreground,	    depth) &&
+     internal_equal (f1->foreback,	     f2->foreback,	    depth) &&
      internal_equal (f1->background,	     f2->background,	    depth) &&
      internal_equal (f1->font,		     f2->font,		    depth) &&
      internal_equal (f1->display_table,	     f2->display_table,	    depth) &&
@@ -198,6 +200,7 @@
 
   return
     (EQ (prop, Qforeground)	      ? f->foreground           :
+     EQ (prop, Qforeback)	      ? f->foreback             :
      EQ (prop, Qbackground)	      ? f->background           :
      EQ (prop, Qfont)		      ? f->font                 :
      EQ (prop, Qdisplay_table)	      ? f->display_table        :
@@ -220,6 +223,7 @@
   Lisp_Face *f = XFACE (obj);
 
   if (EQ (prop, Qforeground)           ||
+      EQ (prop, Qforeback)             ||
       EQ (prop, Qbackground)           ||
       EQ (prop, Qfont)                 ||
       EQ (prop, Qdisplay_table)        ||
@@ -252,6 +256,7 @@
   Lisp_Face *f = XFACE (obj);
 
   if (EQ (prop, Qforeground)           ||
+      EQ (prop, Qforeback)             ||
       EQ (prop, Qbackground)           ||
       EQ (prop, Qfont)                 ||
       EQ (prop, Qdisplay_table)        ||
@@ -293,6 +298,7 @@
   result = cons3 (Qdisplay_table,        face->display_table,          result);
   result = cons3 (Qfont,	         face->font,                   result);
   result = cons3 (Qbackground,	         face->background,             result);
+  result = cons3 (Qforeback,	         face->foreback,               result);
   result = cons3 (Qforeground,	         face->foreground,             result);
 
   return result;
@@ -302,6 +308,7 @@
   { XD_LISP_OBJECT, offsetof (Lisp_Face, name) },
   { XD_LISP_OBJECT, offsetof (Lisp_Face, doc_string) },
   { XD_LISP_OBJECT, offsetof (Lisp_Face, foreground) },
+  { XD_LISP_OBJECT, offsetof (Lisp_Face, foreback) },
   { XD_LISP_OBJECT, offsetof (Lisp_Face, background) },
   { XD_LISP_OBJECT, offsetof (Lisp_Face, font) },
   { XD_LISP_OBJECT, offsetof (Lisp_Face, display_table) },
@@ -396,6 +403,7 @@
   f->doc_string = Qnil;
   f->dirty = 0;
   f->foreground = Qnil;
+  f->foreback = Qnil;
   f->background = Qnil;
   f->font = Qnil;
   f->display_table = Qnil;
@@ -552,9 +560,11 @@
       update_inheritance_mapper_internal (contents, fcl->face, Qfont);
     }
   else if (EQ (fcl->property, Qforeground) ||
+	   EQ (fcl->property, Qforeback)   ||
 	   EQ (fcl->property, Qbackground))
     {
       update_inheritance_mapper_internal (contents, fcl->face, Qforeground);
+      update_inheritance_mapper_internal (contents, fcl->face, Qforeback);
       update_inheritance_mapper_internal (contents, fcl->face, Qbackground);
     }
   else if (EQ (fcl->property, Qunderline)  ||
@@ -858,6 +868,8 @@
   f->doc_string = doc_string;
   f->foreground = Fmake_specifier (Qcolor);
   set_color_attached_to (f->foreground, face, Qforeground);
+  f->foreback = Fmake_specifier (Qcolor);
+  set_color_attached_to (f->foreback, face, Qforeback);
   f->background = Fmake_specifier (Qcolor);
   set_color_attached_to (f->background, face, Qbackground);
   f->font = Fmake_specifier (Qfont);
@@ -888,33 +900,35 @@
 	 just created.  This implements the standard "all faces
 	 inherit from default" behavior. */
       set_specifier_fallback (f->foreground,
-			     Fget (Vdefault_face, Qforeground, Qunbound));
+			      Fget (Vdefault_face, Qforeground, Qunbound));
+      set_specifier_fallback (f->foreback,
+			      Fget (Vdefault_face, Qforeback, Qunbound));
       set_specifier_fallback (f->background,
-			     Fget (Vdefault_face, Qbackground, Qunbound));
+			      Fget (Vdefault_face, Qbackground, Qunbound));
       set_specifier_fallback (f->font,
-			     Fget (Vdefault_face, Qfont, Qunbound));
+			      Fget (Vdefault_face, Qfont, Qunbound));
       set_specifier_fallback (f->background_pixmap,
-			     Fget (Vdefault_face, Qbackground_pixmap,
-				   Qunbound));
+			      Fget (Vdefault_face, Qbackground_pixmap,
+				    Qunbound));
       set_specifier_fallback (f->background_placement,
 			      Fget (Vdefault_face, Qbackground_placement,
 				    Qunbound));
       set_specifier_fallback (f->display_table,
-			     Fget (Vdefault_face, Qdisplay_table, Qunbound));
+			      Fget (Vdefault_face, Qdisplay_table, Qunbound));
       set_specifier_fallback (f->underline,
-			     Fget (Vdefault_face, Qunderline, Qunbound));
+			      Fget (Vdefault_face, Qunderline, Qunbound));
       set_specifier_fallback (f->strikethru,
-			     Fget (Vdefault_face, Qstrikethru, Qunbound));
+			      Fget (Vdefault_face, Qstrikethru, Qunbound));
       set_specifier_fallback (f->highlight,
-			     Fget (Vdefault_face, Qhighlight, Qunbound));
+			      Fget (Vdefault_face, Qhighlight, Qunbound));
       set_specifier_fallback (f->dim,
-			     Fget (Vdefault_face, Qdim, Qunbound));
+			      Fget (Vdefault_face, Qdim, Qunbound));
       set_specifier_fallback (f->blinking,
-			     Fget (Vdefault_face, Qblinking, Qunbound));
+			      Fget (Vdefault_face, Qblinking, Qunbound));
       set_specifier_fallback (f->reverse,
-			     Fget (Vdefault_face, Qreverse, Qunbound));
+			      Fget (Vdefault_face, Qreverse, Qunbound));
       set_specifier_fallback (f->shrink,
-			     Fget (Vdefault_face, Qshrink, Qunbound));
+			      Fget (Vdefault_face, Qshrink, Qunbound));
     }
 
   /* Add the face to the appropriate list. */
@@ -1092,6 +1106,7 @@
       }
       mark_object (cachel->face);
       mark_object (cachel->foreground);
+      mark_object (cachel->foreback);
       mark_object (cachel->background);
       mark_object (cachel->display_table);
       mark_object (cachel->background_pixmap);
@@ -1406,6 +1421,7 @@
 	 we always set it since it is the ultimate fallback. */
 
       FROB (foreground);
+      FROB (foreback);
       FROB (background);
       FROB (display_table);
 
@@ -1516,6 +1532,7 @@
   } while (0)
 
   FROB (foreground);
+  FROB (foreback);
   FROB (background);
   FROB (display_table);
   FROB (background_pixmap);
@@ -1562,6 +1579,7 @@
   cachel->nfaces = 0;
   cachel->merged_faces = 0;
   cachel->foreground = Qunbound;
+  cachel->foreback = Qunbound;
   cachel->background = Qunbound;
   {
     int i;
@@ -1937,8 +1955,8 @@
   /* If the locale could affect the frame value, then call
      update_EmacsFrames just in case. */
   if (default_face &&
-      (EQ (property, Qforeground)           ||
-       EQ (property, Qbackground)           ||
+      (EQ (property, Qforeground)	||
+       EQ (property, Qbackground)	||
        EQ (property, Qfont)))
     update_EmacsFrames (locale, property);
 
@@ -2028,6 +2046,7 @@
 		   locale, tag_set, exact_p, how_to_add);
 
   COPY_PROPERTY (foreground);
+  COPY_PROPERTY (foreback);
   COPY_PROPERTY (background);
   COPY_PROPERTY (font);
   COPY_PROPERTY (display_table);
@@ -2169,6 +2188,7 @@
 
   DEFSYMBOL (Qfacep);
   DEFSYMBOL (Qforeground);
+  DEFSYMBOL (Qforeback);
   DEFSYMBOL (Qbackground);
   /* Qfont defined in general.c */
   DEFSYMBOL (Qdisplay_table);
@@ -2244,8 +2264,9 @@
 #endif
 
   Vbuilt_in_face_specifiers =
-    listu (Qforeground, Qbackground, Qfont, Qdisplay_table, Qbackground_pixmap,
-	   Qbackground_placement, Qunderline, Qstrikethru, Qhighlight, Qdim,
+    listu (Qforeground, Qforeback, Qbackground,
+	   Qfont, Qdisplay_table, Qbackground_pixmap, Qbackground_placement,
+	   Qunderline, Qstrikethru, Qhighlight, Qdim,
 	   Qblinking, Qreverse, Qshrink, Qunbound);
   staticpro (&Vbuilt_in_face_specifiers);
 }
@@ -2264,27 +2285,33 @@
      someone provides invalid values for the global specifications. */
 
   {
-    Lisp_Object fg_fb = Qnil, bg_fb = Qnil;
+    Lisp_Object fg_fb = Qnil, bg_fb = Qnil, fb_fb = Qnil;
 
 #ifdef HAVE_GTK
-    fg_fb = Facons (list1 (Qgtk), build_ascstring ("black"), fg_fb);
-    bg_fb = Facons (list1 (Qgtk), build_ascstring ("white"), bg_fb);
+    fg_fb = Facons (list1 (Qgtk), build_ascstring ("black"),  fg_fb);
+    fb_fb = Facons (list1 (Qgtk), build_ascstring ("gray90"), fb_fb);
+    bg_fb = Facons (list1 (Qgtk), build_ascstring ("white"),  bg_fb);
 #endif
 #ifdef HAVE_X_WINDOWS
-    fg_fb = Facons (list1 (Qx), build_ascstring ("black"), fg_fb);
+    fg_fb = Facons (list1 (Qx), build_ascstring ("black"),  fg_fb);
+    fb_fb = Facons (list1 (Qx), build_ascstring ("gray70"), fb_fb);
     bg_fb = Facons (list1 (Qx), build_ascstring ("gray80"), bg_fb);
 #endif
 #ifdef HAVE_TTY
     fg_fb = Facons (list1 (Qtty), Fvector (0, 0), fg_fb);
+    fb_fb = Facons (list1 (Qtty), Fvector (0, 0), fb_fb);
     bg_fb = Facons (list1 (Qtty), Fvector (0, 0), bg_fb);
 #endif
 #ifdef HAVE_MS_WINDOWS
-    fg_fb = Facons (list1 (Qmsprinter), build_ascstring ("black"), fg_fb);
-    bg_fb = Facons (list1 (Qmsprinter), build_ascstring ("white"), bg_fb);
-    fg_fb = Facons (list1 (Qmswindows), build_ascstring ("black"), fg_fb);
-    bg_fb = Facons (list1 (Qmswindows), build_ascstring ("white"), bg_fb);
+    fg_fb = Facons (list1 (Qmsprinter), build_ascstring ("black"),  fg_fb);
+    fb_fb = Facons (list1 (Qmsprinter), build_ascstring ("gray90"), fb_fb);
+    bg_fb = Facons (list1 (Qmsprinter), build_ascstring ("white"),  bg_fb);
+    fg_fb = Facons (list1 (Qmswindows), build_ascstring ("black"),  fg_fb);
+    fb_fb = Facons (list1 (Qmswindows), build_ascstring ("gray90"), fb_fb);
+    bg_fb = Facons (list1 (Qmswindows), build_ascstring ("white"),  bg_fb);
 #endif
     set_specifier_fallback (Fget (Vdefault_face, Qforeground, Qnil), fg_fb);
+    set_specifier_fallback (Fget (Vdefault_face, Qforeback, Qnil), fb_fb);
     set_specifier_fallback (Fget (Vdefault_face, Qbackground, Qnil), bg_fb);
   }
 
@@ -2514,7 +2541,7 @@
   /* Provide some last-resort fallbacks for gui-element face which
      mustn't default to default. */
   {
-    Lisp_Object fg_fb = Qnil, bg_fb = Qnil;
+    Lisp_Object fg_fb = Qnil, bg_fb = Qnil, fb_fb = Qnil;
 
     /* #### gui-element face doesn't have a font property?
        But it gets referred to later! */
@@ -2539,8 +2566,12 @@
     fg_fb = Facons (list1 (Qmswindows), build_ascstring ("black"), fg_fb);
     bg_fb = Facons (list1 (Qmswindows), build_ascstring ("Gray75"), bg_fb);
 #endif
-    set_specifier_fallback (Fget (Vgui_element_face, Qforeground, Qnil), fg_fb);
-    set_specifier_fallback (Fget (Vgui_element_face, Qbackground, Qnil), bg_fb);
+    set_specifier_fallback (Fget (Vgui_element_face, Qforeground, Qnil),
+			    fg_fb);
+    set_specifier_fallback (Fget (Vgui_element_face, Qforeback, Qnil),
+			    fb_fb);
+    set_specifier_fallback (Fget (Vgui_element_face, Qbackground, Qnil),
+			    bg_fb);
   }
 
   /* Now create the other faces that redisplay needs to refer to
@@ -2553,6 +2584,8 @@
 
   set_specifier_fallback (Fget (Vmodeline_face, Qforeground, Qunbound),
 			  Fget (Vgui_element_face, Qforeground, Qunbound));
+  set_specifier_fallback (Fget (Vmodeline_face, Qforeback, Qunbound),
+			  Fget (Vgui_element_face, Qforeback, Qunbound));
   set_specifier_fallback (Fget (Vmodeline_face, Qbackground, Qunbound),
 			  Fget (Vgui_element_face, Qbackground, Qunbound));
   set_specifier_fallback (Fget (Vmodeline_face, Qbackground_pixmap, Qnil),
@@ -2568,6 +2601,8 @@
 			      Qnil);
   set_specifier_fallback (Fget (Vtoolbar_face, Qforeground, Qunbound),
 			  Fget (Vgui_element_face, Qforeground, Qunbound));
+  set_specifier_fallback (Fget (Vtoolbar_face, Qforeback, Qunbound),
+			  Fget (Vgui_element_face, Qforeback, Qunbound));
   set_specifier_fallback (Fget (Vtoolbar_face, Qbackground, Qunbound),
 			  Fget (Vgui_element_face, Qbackground, Qunbound));
   set_specifier_fallback (Fget (Vtoolbar_face, Qbackground_pixmap, Qnil),
@@ -2584,6 +2619,8 @@
 
   set_specifier_fallback (Fget (Vvertical_divider_face, Qforeground, Qunbound),
 			  Fget (Vgui_element_face, Qforeground, Qunbound));
+  set_specifier_fallback (Fget (Vvertical_divider_face, Qforeback, Qunbound),
+			  Fget (Vgui_element_face, Qforeback, Qunbound));
   set_specifier_fallback (Fget (Vvertical_divider_face, Qbackground, Qunbound),
 			  Fget (Vgui_element_face, Qbackground, Qunbound));
   set_specifier_fallback (Fget (Vvertical_divider_face, Qbackground_pixmap,
@@ -2604,6 +2641,8 @@
 			  Fget (Vgui_element_face, Qfont, Qunbound));
   set_specifier_fallback (Fget (Vwidget_face, Qforeground, Qunbound),
 			  Fget (Vgui_element_face, Qforeground, Qunbound));
+  set_specifier_fallback (Fget (Vwidget_face, Qforeback, Qunbound),
+			  Fget (Vgui_element_face, Qforeback, Qunbound));
   set_specifier_fallback (Fget (Vwidget_face, Qbackground, Qunbound),
 			  Fget (Vgui_element_face, Qbackground, Qunbound));
   /* We don't want widgets to have a default background pixmap. */
--- a/src/faces.h	Tue Dec 27 15:37:03 2011 +0100
+++ b/src/faces.h	Tue Dec 27 17:07:23 2011 +0100
@@ -41,6 +41,7 @@
 			    a face. */
 
   Lisp_Object foreground;
+  Lisp_Object foreback;
   Lisp_Object background;
   Lisp_Object font;
 
@@ -160,6 +161,7 @@
      faces.  This is what the _specified flags below are for. */
 
   Lisp_Object foreground;
+  Lisp_Object foreback;
   Lisp_Object background;
   /* There are currently 128 or 129 possible charsets under Mule.  For the
      moment we just take the easy way out and allocate space for each
@@ -188,6 +190,7 @@
   DECLARE_INLINE_LISP_BIT_VECTOR(NUM_LEADING_BYTES) font_specified;
 
   unsigned int foreground_specified :1;
+  unsigned int foreback_specified :1;
   unsigned int background_specified :1;
   unsigned int display_table_specified :1;
   unsigned int background_pixmap_specified :1;
@@ -331,6 +334,8 @@
   (WINDOW_FACE_CACHEL (window, index)->face)
 #define WINDOW_FACE_CACHEL_FOREGROUND(window, index)			\
   (WINDOW_FACE_CACHEL (window, index)->foreground)
+#define WINDOW_FACE_CACHEL_FOREBACK(window, index)			\
+  (WINDOW_FACE_CACHEL (window, index)->foreback)
 #define WINDOW_FACE_CACHEL_BACKGROUND(window, index)			\
   (WINDOW_FACE_CACHEL (window, index)->background)
 /* #### This can be referenced by various functions,
@@ -391,6 +396,8 @@
 
 #define FACE_FOREGROUND(face, domain)					\
   FACE_PROPERTY_INSTANCE (face, Qforeground, domain, 0, Qzero)
+#define FACE_FOREBACK(face, domain)					\
+  FACE_PROPERTY_INSTANCE (face, Qforeback, domain, 0, Qzero)
 #define FACE_BACKGROUND(face, domain)					\
   FACE_PROPERTY_INSTANCE (face, Qbackground, domain, 0, Qzero)
 
--- a/src/fontcolor.c	Tue Dec 27 15:37:03 2011 +0100
+++ b/src/fontcolor.c	Tue Dec 27 17:07:23 2011 +0100
@@ -694,10 +694,12 @@
 	  if (XVECTOR_LENGTH (instantiator) == 2)
 	    {
 	      Lisp_Object field = XVECTOR_DATA (instantiator)[1];
-	      if (!EQ (field, Qforeground) && !EQ (field, Qbackground))
+	      if (!EQ (field, Qforeground)
+		  && !EQ (field, Qforeback)
+		  && !EQ (field, Qbackground))
 		invalid_constant
-		  ("Inheritance field must be `foreground' or `background'",
-		   field);
+("Inheritance field must be `foreground', `foreback' or `background'",
+ field);
 	    }
 	}
     }
--- a/src/lisp.h	Tue Dec 27 15:37:03 2011 +0100
+++ b/src/lisp.h	Tue Dec 27 17:07:23 2011 +0100
@@ -5137,12 +5137,13 @@
 extern Lisp_Object Qstart_open;
 
 /* Defined in faces.c */
+extern Lisp_Object Qforeground;
+extern Lisp_Object Qforeback;
 extern Lisp_Object Qbackground;
 extern Lisp_Object Qbackground_pixmap;
 extern Lisp_Object Qblinking;
 extern Lisp_Object Qdim;
 extern Lisp_Object Qdisplay_table;
-extern Lisp_Object Qforeground;
 extern Lisp_Object Qunderline;
 extern Lisp_Object Qshrink;
 
--- a/src/redisplay-msw.c	Tue Dec 27 15:37:03 2011 +0100
+++ b/src/redisplay-msw.c	Tue Dec 27 17:07:23 2011 +0100
@@ -293,7 +293,7 @@
 					 start_pixpos, rb->width,
 					 &db, &dga);
       /* blank the background in the appropriate color */
-      mswindows_update_dc (hdc, cachel->foreground,
+      mswindows_update_dc (hdc, cachel->foreback,
 			   cachel->background, Qnil);
       redisplay_output_pixmap (w, bg_pmap, &db, &dga, rb->findex,
 			       0, 0, 0, TRUE);
@@ -507,8 +507,7 @@
       redisplay_calculate_display_boxes (dl, xpos + xoffset, 0, 0,
 					 clip_start, width, &db, &dga);
       /* blank the background in the appropriate color */
-      mswindows_update_dc (hdc,
-			   cachel->foreground, cachel->background, Qnil);
+      mswindows_update_dc (hdc, cachel->foreback, cachel->background, Qnil);
       redisplay_output_pixmap (w, bg_pmap, &db, &dga, findex,
 			       0, 0, 0, TRUE);
       /* output pixmap calls this so we have to recall to get correct
--- a/src/redisplay-output.c	Tue Dec 27 15:37:03 2011 +0100
+++ b/src/redisplay-output.c	Tue Dec 27 17:07:23 2011 +0100
@@ -1789,12 +1789,12 @@
     {
       if (w)
 	{
-	  fcolor = WINDOW_FACE_CACHEL_FOREGROUND (w, findex);
+	  fcolor = WINDOW_FACE_CACHEL_FOREBACK (w, findex);
 	  bcolor = WINDOW_FACE_CACHEL_BACKGROUND (w, findex);
 	}
       else
 	{
-	  fcolor = FACE_FOREGROUND (Vdefault_face, locale);
+	  fcolor = FACE_FOREBACK (Vdefault_face, locale);
 	  bcolor = FACE_BACKGROUND (Vdefault_face, locale);
 	}
     }
--- a/src/redisplay-xlike-inc.c	Tue Dec 27 15:37:03 2011 +0100
+++ b/src/redisplay-xlike-inc.c	Tue Dec 27 17:07:23 2011 +0100
@@ -1094,8 +1094,9 @@
        && !NILP (w->text_cursor_visible_p)) || NILP (bg_pmap))
     bgc = 0;
   else
-    bgc = XLIKE_get_gc (f, Qnil, cachel->foreground, cachel->background,
-			bg_pmap, cachel->background_placement, Qnil);
+    bgc = XLIKE_get_gc
+      (f, Qnil, NILP (bg_pmap) ? cachel->foreground : cachel->foreback,
+       cachel->background, bg_pmap, cachel->background_placement, Qnil);
 
   if (bgc)
     {
@@ -1895,7 +1896,7 @@
     gc = XLIKE_get_gc (f, Qnil, WINDOW_FACE_CACHEL_BACKGROUND (w, rb->findex),
 		       Qnil, Qnil, Qnil, Qnil);
   else
-    gc = XLIKE_get_gc (f, Qnil, WINDOW_FACE_CACHEL_FOREGROUND (w, rb->findex),
+    gc = XLIKE_get_gc (f, Qnil, WINDOW_FACE_CACHEL_FOREBACK (w, rb->findex),
 		       WINDOW_FACE_CACHEL_BACKGROUND (w, rb->findex),
 		       bg_pmap,
 		       WINDOW_FACE_CACHEL_BACKGROUND_PLACEMENT (w, rb->findex),