]> code.delx.au - gnu-emacs/blobdiff - src/xfaces.c
Merge from emacs-24
[gnu-emacs] / src / xfaces.c
index 4571137a249b73ea472f0e3504835596bdc5e580..6afa0a2953d9bc39790c922965b700fe2f71c59b 100644 (file)
@@ -676,19 +676,9 @@ init_frame_faces (struct frame *f)
     }
 #endif /* HAVE_WINDOW_SYSTEM */
 
-  /* Realize basic faces.  Must have enough information in frame
-     parameters to realize basic faces at this point.  */
-#ifdef HAVE_X_WINDOWS
-  if (!FRAME_X_P (f) || FRAME_X_WINDOW (f))
-#endif
-#ifdef HAVE_NTGUI
-  if (!FRAME_WINDOW_P (f) || FRAME_W32_WINDOW (f))
-#endif
-#ifdef HAVE_NS
-  if (!FRAME_NS_P (f) || FRAME_NS_WINDOW (f))
-#endif
-    if (!realize_basic_faces (f))
-       emacs_abort ();
+  /* Realize faces early (Bug#17889).  */
+  if (!realize_basic_faces (f))
+    emacs_abort ();
 }
 
 
@@ -1078,7 +1068,7 @@ tty_color_name (struct frame *f, int idx)
        return XCAR (coldesc);
     }
 #ifdef MSDOS
-  /* We can have an MSDOG frame under -nw for a short window of
+  /* We can have an MS-DOS frame under -nw for a short window of
      opportunity before internal_terminal_init is called.  DTRT.  */
   if (FRAME_MSDOS_P (f) && !inhibit_window_system)
     return msdos_stdcolor_name (idx);
@@ -3122,17 +3112,26 @@ FRAME 0 means change the face on all frames, and change the default
                f = XFRAME (selected_frame);
              else
                f = XFRAME (frame);
-             if (! FONT_OBJECT_P (value))
-               {
-                 Lisp_Object *attrs = XVECTOR (lface)->contents;
-                 Lisp_Object font_object;
 
-                 font_object = font_load_for_lface (f, attrs, value);
-                 if (NILP (font_object))
-                   signal_error ("Font not available", value);
-                 value = font_object;
-               }
-             set_lface_from_font (f, lface, value, 1);
+              /* FIXME:
+                 If frame is t, and selected frame is a tty frame, the font
+                 can't be realized.  An improvement would be to loop over frames
+                 for a non-tty frame and use that.  See discussion in
+                 bug#18573.  */
+              if (f->terminal->type != output_termcap)
+                {
+                  if (! FONT_OBJECT_P (value))
+                    {
+                      Lisp_Object *attrs = XVECTOR (lface)->contents;
+                      Lisp_Object font_object;
+
+                      font_object = font_load_for_lface (f, attrs, value);
+                      if (NILP (font_object))
+                        signal_error ("Font not available", value);
+                      value = font_object;
+                    }
+                  set_lface_from_font (f, lface, value, 1);
+                }
            }
          else
            ASET (lface, LFACE_FONT_INDEX, value);
@@ -3408,7 +3407,8 @@ set_font_frame_param (Lisp_Object frame, Lisp_Object lface)
          ASET (lface, LFACE_FONT_INDEX, font);
        }
       f->default_face_done_p = 0;
-      Fmodify_frame_parameters (frame, list1 (Fcons (Qfont, font)));
+      AUTO_FRAME_ARG (arg, Qfont, font);
+      Fmodify_frame_parameters (frame, arg);
     }
 }
 
@@ -3797,18 +3797,23 @@ Default face attributes override any local face attributes.  */)
              && newface->font)
            {
              Lisp_Object name = newface->font->props[FONT_NAME_INDEX];
-             Fmodify_frame_parameters (frame, list1 (Fcons (Qfont, name)));
+             AUTO_FRAME_ARG (arg, Qfont, name);
+             Fmodify_frame_parameters (frame, arg);
            }
 
          if (STRINGP (gvec[LFACE_FOREGROUND_INDEX]))
-           Fmodify_frame_parameters (frame,
-                                     list1 (Fcons (Qforeground_color,
-                                                   gvec[LFACE_FOREGROUND_INDEX])));
+           {
+             AUTO_FRAME_ARG (arg, Qforeground_color,
+                             gvec[LFACE_FOREGROUND_INDEX]);
+             Fmodify_frame_parameters (frame, arg);
+           }
 
          if (STRINGP (gvec[LFACE_BACKGROUND_INDEX]))
-           Fmodify_frame_parameters (frame,
-                                     list1 (Fcons (Qbackground_color,
-                                                   gvec[LFACE_BACKGROUND_INDEX])));
+           {
+             AUTO_FRAME_ARG (arg, Qbackground_color,
+                             gvec[LFACE_BACKGROUND_INDEX]);
+             Fmodify_frame_parameters (frame, arg);
+           }
        }
     }
 
@@ -5557,7 +5562,7 @@ realize_x_face (struct face_cache *cache, Lisp_Object attrs[LFACE_VECTOR_SIZE])
        }
       if (! FONT_OBJECT_P (attrs[LFACE_FONT_INDEX]))
        attrs[LFACE_FONT_INDEX]
-         = font_load_for_lface (f, attrs, attrs[LFACE_FONT_INDEX]);
+         = font_load_for_lface (f, attrs, Ffont_spec (0, NULL));
       if (FONT_OBJECT_P (attrs[LFACE_FONT_INDEX]))
        {
          face->font = XFONT_OBJECT (attrs[LFACE_FONT_INDEX]);
@@ -5990,6 +5995,7 @@ face_at_buffer_position (struct window *w, ptrdiff_t pos,
     endpos = XINT (end);
 
   /* Look at properties from overlays.  */
+  USE_SAFE_ALLOCA;
   {
     ptrdiff_t next_overlay;
 
@@ -6016,7 +6022,10 @@ face_at_buffer_position (struct window *w, ptrdiff_t pos,
   /* Optimize common cases where we can use the default face.  */
   if (noverlays == 0
       && NILP (prop))
-    return default_face->id;
+    {
+      SAFE_FREE ();
+      return default_face->id;
+    }
 
   /* Begin with attributes from the default face.  */
   memcpy (attrs, default_face->lface, sizeof attrs);
@@ -6044,6 +6053,8 @@ face_at_buffer_position (struct window *w, ptrdiff_t pos,
 
   *endptr = endpos;
 
+  SAFE_FREE ();
+
   /* Look up a realized face with the given face attributes,
      or realize a new one for ASCII characters.  */
   return lookup_face (f, attrs);
@@ -6309,7 +6320,7 @@ dump_realized_face (struct face *face)
 {
   fprintf (stderr, "ID: %d\n", face->id);
 #ifdef HAVE_X_WINDOWS
-  fprintf (stderr, "gc: %ld\n", (long) face->gc);
+  fprintf (stderr, "gc: %p\n", face->gc);
 #endif
   fprintf (stderr, "foreground: 0x%lx (%s)\n",
           face->foreground,