Changes for automatic remapping of X colors on terminal frames:
authorEli Zaretskii <eliz@gnu.org>
Mon, 6 Dec 1999 16:54:09 +0000 (16:54 +0000)
committerEli Zaretskii <eliz@gnu.org>
Mon, 6 Dec 1999 16:54:09 +0000 (16:54 +0000)
* xfaces.c (XColor) [!HAVE_X_WINDOWS]: Provide a typedef for non-X
frames.
(Vface_tty_color_alist): Remove.
(tty_defined_color): New function.
(defined_color): Rewrite to support any type of frame.
(tty_color_name): New function.
(face_color_supported_p, Fface_color_gray_p,
Fface_color_supported_p): Support non-X frames.
(load_color): Enclose the color name in quotes, in the log
messages.  Remove DOS-specific version of load_color.
(realize_tty_face): Take the supported colors from
tty-color-alist.  Support translation of X colors to the closest
tty color, for both MSDOS and tty frames.
[MSDOS]: Don't invert face colors if they were taken from the
frame colors.
(Fface_register_tty_color, Fface_clear_tty_colors): Remove.

* frame.h (struct x_output) [!MSDOS, !WINDOWSNT, !HAVE_X_WINDOWS]:
Define a mostly empty surrogate.
(tty_display): Declare.

* frame.c (make_terminal_frame) [!macintosh]: Don't use
tty_display.
(Fframe_parameters): Don't invert colors of non-FRAME_WINDOW_P
frames when the frame's param_alist includes 'reverse.
(tty_display): Define.
(make_terminal_frame) [!MSDOS]: Assign &tty_display to the
output_data.x member.
(Fframe_parameters): Return foreground and background color names
on tty frames as well, in addition to MSDOS frames.

* msdos.h (DisplayWidth, DisplayHeight): Changes for Lisp_Object
selected_frame.
(struct x_output): Remove unused members; document who uses each
member.
(FRAME_PARAM_FACES, FRAME_N_PARAM_FACES, FRAME_DEFAULT_PARAM_FACE,
FRAME_MODE_LINE_PARAM_FACE, FRAME_COMPUTED_FACES,
FRAME_N_COMPUTED_FACES, FRAME_SIZE_COMPUTED_FACES,
FRAME_DEFAULT_FACE, FRAME_MODE_LINE_FACE, unload_color): Remove
unused macro definintions.

* msdos.c (IT_set_frame_parameters): Don't call
recompute_basic_faces, the next redisplay will, anyway.
(x_current_display): Remove unused variable.
Many functions: changes for Lisp_object selected_frame.
(IT_set_face): If the tty_reverse_p flag is set for the face,
reverse the foreground and background colors.
(Fmsdos_remember_default_colors): New function.
(syms_of_msdos): Defsubr it.
(IT_set_frame_parameters): Use initial_screen_colors[] when
creating a new frame.  If the frame parameters include 'reverse,
swap the foreground and background colors.
(internal_terminal_init): Initialize initial_screen_colors to -1.
(syms_of_msdos): Add DEFVAR_BOOL for x-stretch-cursor, to shut up
cus-start.el.

* Makefile.in (lisp, shortlisp): Add lisp/term/tty-colors.elc.

* xfns.c (x_defined_color): Rename from defined_color.  All
callers changed.
(Fxw_color_defined_p): Renamed from Fx_color_defined_p;
all callers changed.
(Fxw_color_values): Renamed from Fx_color_values; all callers
changed.
(Fxw_display_color_p): Renamed from Fx_display_color_p; all
callers changed.
(x_window_to_frame, x_any_window_to_frame,
x_non_menubar_window_to_frame, x_menubar_window_to_frame,
x_top_window_to_frame): Use !FRAME_X_P instead of
f->output_data.nothing.
* xterm.h (x_defined_color): Rename from defined_color.

* w32fns.c (x_window_to_frame): Use FRAME_W32_P instead of
f->output_data.nothing.
(Fxw_color_defined_p): Renamed from Fx_color_defined_p;
all callers changed.
(Fxw_color_values): Renamed from Fx_color_values; all callers
changed.
(Fxw_display_color_p): Renamed from Fx_display_color_p; all
callers changed.

* dispextern.h (tty_color_name): Add prototype.

* xmenu.c (menubar_id_to_frame): Use FRAME_WINDOW_P instead of
f->output_data.nothing.
* w32menu.c (menubar_id_to_frame): Likewise.
* w32term.h (w32_output): Declare.

* dosfns.c (Qmsdos_color_translate): Remove.
(msdos_stdcolor_name): Now returns a Lisp_Object.
* dosfns.h (Qmsdos_color_translate): Remove.

* s/msdos.h (INTERNAL_TERMINAL): Add entries for color support.

15 files changed:
src/ChangeLog
src/Makefile.in
src/dispnew.c
src/dosfns.c
src/dosfns.h
src/frame.c
src/frame.h
src/msdos.c
src/msdos.h
src/w32fns.c
src/w32menu.c
src/w32term.h
src/xfaces.c
src/xfns.c
src/xmenu.c

index 9d8bfaf..01a5e27 100644 (file)
@@ -1,3 +1,101 @@
+1999-12-06  Eli Zaretskii  <eliz@is.elta.co.il>
+
+       Changes for automatic remapping of X colors on terminal frames:
+
+       * xfaces.c (XColor) [!HAVE_X_WINDOWS]: Provide a typedef for non-X
+       frames.
+       (Vface_tty_color_alist): Remove.
+       (tty_defined_color): New function.
+       (defined_color): Rewrite to support any type of frame.
+       (tty_color_name): New function.
+       (face_color_supported_p, Fface_color_gray_p,
+       Fface_color_supported_p): Support non-X frames.
+       (load_color): Enclose the color name in quotes, in the log
+       messages.  Remove DOS-specific version of load_color.
+       (realize_tty_face): Take the supported colors from
+       tty-color-alist.  Support translation of X colors to the closest
+       tty color, for both MSDOS and tty frames.
+       [MSDOS]: Don't invert face colors if they were taken from the
+       frame colors.
+       (Fface_register_tty_color, Fface_clear_tty_colors): Remove.
+
+       * frame.h (struct x_output) [!MSDOS, !WINDOWSNT, !HAVE_X_WINDOWS]:
+       Define a mostly empty surrogate.
+       (tty_display): Declare.
+
+       * frame.c (make_terminal_frame) [!macintosh]: Don't use
+       tty_display.
+       (Fframe_parameters): Don't invert colors of non-FRAME_WINDOW_P
+       frames when the frame's param_alist includes 'reverse.
+       (tty_display): Define.
+       (make_terminal_frame) [!MSDOS]: Assign &tty_display to the
+       output_data.x member.
+       (Fframe_parameters): Return foreground and background color names
+       on tty frames as well, in addition to MSDOS frames.
+
+       * msdos.h (DisplayWidth, DisplayHeight): Changes for Lisp_Object
+       selected_frame.
+       (struct x_output): Remove unused members; document who uses each
+       member.
+       (FRAME_PARAM_FACES, FRAME_N_PARAM_FACES, FRAME_DEFAULT_PARAM_FACE,
+       FRAME_MODE_LINE_PARAM_FACE, FRAME_COMPUTED_FACES,
+       FRAME_N_COMPUTED_FACES, FRAME_SIZE_COMPUTED_FACES,
+       FRAME_DEFAULT_FACE, FRAME_MODE_LINE_FACE, unload_color): Remove
+       unused macro definintions.
+
+       * msdos.c (IT_set_frame_parameters): Don't call
+       recompute_basic_faces, the next redisplay will, anyway.
+       (x_current_display): Remove unused variable.
+       Many functions: changes for Lisp_object selected_frame.
+       (IT_set_face): If the tty_reverse_p flag is set for the face,
+       reverse the foreground and background colors.
+       (Fmsdos_remember_default_colors): New function.
+       (syms_of_msdos): Defsubr it.
+       (IT_set_frame_parameters): Use initial_screen_colors[] when
+       creating a new frame.  If the frame parameters include 'reverse,
+       swap the foreground and background colors.
+       (internal_terminal_init): Initialize initial_screen_colors to -1.
+       (syms_of_msdos): Add DEFVAR_BOOL for x-stretch-cursor, to shut up
+       cus-start.el.
+
+       * Makefile.in (lisp, shortlisp): Add lisp/term/tty-colors.elc.
+
+       * xfns.c (x_defined_color): Rename from defined_color.  All
+       callers changed.
+       (Fxw_color_defined_p): Renamed from Fx_color_defined_p;
+       all callers changed.
+       (Fxw_color_values): Renamed from Fx_color_values; all callers
+       changed.
+       (Fxw_display_color_p): Renamed from Fx_display_color_p; all
+       callers changed.
+       (x_window_to_frame, x_any_window_to_frame,
+       x_non_menubar_window_to_frame, x_menubar_window_to_frame,
+       x_top_window_to_frame): Use !FRAME_X_P instead of
+       f->output_data.nothing.
+       * xterm.h (x_defined_color): Rename from defined_color.
+
+       * w32fns.c (x_window_to_frame): Use FRAME_W32_P instead of
+       f->output_data.nothing.
+       (Fxw_color_defined_p): Renamed from Fx_color_defined_p;
+       all callers changed.
+       (Fxw_color_values): Renamed from Fx_color_values; all callers
+       changed.
+       (Fxw_display_color_p): Renamed from Fx_display_color_p; all
+       callers changed.
+
+       * dispextern.h (tty_color_name): Add prototype.
+
+       * xmenu.c (menubar_id_to_frame): Use FRAME_WINDOW_P instead of
+       f->output_data.nothing.
+       * w32menu.c (menubar_id_to_frame): Likewise.
+       * w32term.h (w32_output): Declare.
+
+       * dosfns.c (Qmsdos_color_translate): Remove.
+       (msdos_stdcolor_name): Now returns a Lisp_Object.
+       * dosfns.h (Qmsdos_color_translate): Remove.
+
+       * s/msdos.h (INTERNAL_TERMINAL): Add entries for color support.
+
 1999-12-06  Kenichi Handa  <handa@etl.go.jp>
 
        * fileio.c (decide_coding_unwind): Renamed from
index 05d2ddc..452fac0 100644 (file)
@@ -733,6 +733,7 @@ lisp= \
        ${lispsource}simple.elc \
        ${lispsource}startup.elc \
        ${lispsource}subr.elc \
+       ${lispsource}term/tty-colors.elc \
        ${lispsource}textmodes/fill.elc \
        ${lispsource}textmodes/page.elc \
        ${lispsource}textmodes/paragraphs.elc \
@@ -798,6 +799,7 @@ shortlisp= \
        ../lisp/simple.elc \
        ../lisp/startup.elc \
        ../lisp/subr.elc \
+       ../lisp/term/tty-colors.elc \
        ../lisp/textmodes/fill.elc \
        ../lisp/textmodes/page.elc \
        ../lisp/textmodes/paragraphs.elc \
index 3d5797d..9cdf01e 100644 (file)
@@ -5915,7 +5915,15 @@ For types not defined in VMS, use  define emacs_term \"TYPE\".\n\
       && (strcmp (terminal_type, "internal") != 0 || inhibit_window_system)
 #endif
       && NILP (Vwindow_system))
-    call0 (intern ("tty-set-up-initial-frame-faces"));
+    {
+      /* For the initial frame, we don't have any way of knowing what
+        are the foreground and background colors of the terminal.  */
+      struct frame *sf = SELECTED_FRAME();
+
+      FRAME_FOREGROUND_PIXEL (sf) = -1;
+      FRAME_BACKGROUND_PIXEL (sf) = -1;
+      call0 (intern ("tty-set-up-initial-frame-faces"));
+    }
 }
 
 
index 59fdd67..857d16b 100644 (file)
@@ -173,11 +173,6 @@ Report whether a mouse is present.")
   else
     return Qnil;
 }
-
-/* Function to translate colour names to integers.  See lisp/term/pc-win.el
-   for its definition.  */
-
-Lisp_Object Qmsdos_color_translate;
 #endif
 
 
@@ -418,8 +413,8 @@ static char *vga_colors[16] = {
    that this only performs case-insensitive comparison against the
    standard names.  For anything more sophisticated, like matching
    "gray" with "grey" or translating X color names into their MSDOS
-   equivalents, call the Lisp function Qmsdos_color_translate (defined
-   on lisp/term/pc-win.el).  */
+   equivalents, call the Lisp function Qtty_color_desc (defined
+   on lisp/term/tty-colors.el).  */
 int
 msdos_stdcolor_idx (const char *name)
 {
@@ -433,12 +428,14 @@ msdos_stdcolor_idx (const char *name)
 }
 
 /* Given a color index, return its standard name.  */
-char *
+Lisp_Object
 msdos_stdcolor_name (int idx)
 {
+  extern Lisp_Object Qunspecified;
+
   if (idx < 0 || idx >= sizeof (vga_colors) / sizeof (vga_colors[0]))
-    return ""; /* meaning the default */
-  return vga_colors[idx];
+    return Qunspecified;       /* meaning the default */
+  return build_string (vga_colors[idx]);
 }
 
 /* Support for features that are available when we run in a DOS box
@@ -533,8 +530,6 @@ syms_of_dosfns ()
   defsubr (&Smsdos_mouse_disable);
 #ifndef HAVE_X_WINDOWS
   defsubr (&Smsdos_mouse_p);
-  Qmsdos_color_translate = intern ("msdos-color-translate");
-  staticpro (&Qmsdos_color_translate);
 #endif
 
   DEFVAR_INT ("dos-country-code", &dos_country_code,
index 61145c0..2ec01bf 100644 (file)
@@ -36,8 +36,7 @@ extern Lisp_Object Vdos_version;
 extern Lisp_Object Vdos_windows_version;
 #ifndef HAVE_X_WINDOWS
 extern Lisp_Object Vdos_display_scancodes;
-extern Lisp_Object Qmsdos_color_translate;
 
 extern int         msdos_stdcolor_idx  P_ ((const char *));
-extern char       *msdos_stdcolor_name P_ ((int));
+extern Lisp_Object msdos_stdcolor_name P_ ((int));
 #endif
index 8298a01..aaaf03a 100644 (file)
@@ -222,6 +222,8 @@ set_menu_bar_lines (f, value, oldval)
 Lisp_Object Vemacs_iconified;
 Lisp_Object Vframe_list;
 
+struct x_output tty_display;
+
 extern Lisp_Object Vminibuffer_list;
 extern Lisp_Object get_minibuffer ();
 extern Lisp_Object Fhandle_switch_frame ();
@@ -232,6 +234,8 @@ DEFUN ("framep", Fframep, Sframep, 1, 1, 0,
   "Return non-nil if OBJECT is a frame.\n\
 Value is t for a termcap frame (a character-only terminal),\n\
 `x' for an Emacs frame that is really an X window,\n\
+`w32' for an Emacs frame that is a window on MS-Windows display,\n\
+`mac' for an Emacs frame on a Macintosh display,\n\
 `pc' for a direct-write MS-DOS frame.\n\
 See also `frame-live-p'.")
   (object)
@@ -545,9 +549,13 @@ make_terminal_frame ()
   f->async_visible = 1;                /* Don't let visible be cleared later. */
 #ifdef MSDOS
   f->output_data.x = &the_only_x_display;
-  f->output_method = output_msdos_raw;
-#endif /* MSDOS */
-
+  if (!inhibit_window_system
+      && (!FRAMEP (selected_frame) || !FRAME_LIVE_P (XFRAME (selected_frame))
+         || XFRAME (selected_frame)->output_method == output_msdos_raw))
+    f->output_method = output_msdos_raw;
+  else
+    f->output_method = output_termcap;
+#else
 #ifdef macintosh
   f->output_data.mac = NewMacWindow(f);
   f->output_data.mac->background_pixel = 0xffffff;
@@ -559,16 +567,15 @@ make_terminal_frame ()
   f->auto_raise = 1;
   f->auto_lower = 1;
   init_frame_faces (f);
-#endif /* macintosh */
+#else  /* !macintosh */
+  f->output_data.x = &tty_display;
+#endif /* !macintosh */
+#endif /* MSDOS */
 
-#ifndef MSDOS
 #ifndef macintosh
-  f->output_data.nothing = 1;  /* Nonzero means frame isn't deleted.  */
-#endif
-#endif
-
   if (!noninteractive)
     init_frame_faces (f);
+#endif
   return f;
 }
 
@@ -587,7 +594,8 @@ Note that changing the size of one terminal frame automatically affects all.")
   struct frame *sf = SELECTED_FRAME ();
 
 #ifdef MSDOS
-  if (sf->output_method != output_msdos_raw)
+  if (sf->output_method != output_msdos_raw
+      && sf->output_method != output_termcap)
     abort ();
 #else /* not MSDOS */
 
@@ -1994,23 +2002,20 @@ If FRAME is omitted, return information on the currently selected frame.")
     return Qnil;
 
   alist = Fcopy_alist (f->param_alist);
-#ifdef MSDOS
-  if (FRAME_MSDOS_P (f))
+  if (!FRAME_WINDOW_P (f))
     {
       int fg = FRAME_FOREGROUND_PIXEL (f);
       int bg = FRAME_BACKGROUND_PIXEL (f);
-      Lisp_Object qreverse = intern ("reverse");
-      int rv =
-       !NILP (Fassq (qreverse, alist))
-       || !NILP (Fassq (qreverse, Vdefault_frame_alist));
 
       store_in_alist (&alist, intern ("foreground-color"),
-                     build_string (msdos_stdcolor_name (rv ? bg : fg)));
+                     tty_color_name (f, fg));
       store_in_alist (&alist, intern ("background-color"),
-                     build_string (msdos_stdcolor_name (rv ? fg : bg)));
+                     tty_color_name (f, bg));
+      store_in_alist (&alist, intern ("font"),
+                     build_string (FRAME_MSDOS_P (f)
+                                   ? "ms-dos"
+                                   : FRAME_W32_P (f) ? "w32term" : "tty"));
     }
-  store_in_alist (&alist, intern ("font"), build_string ("ms-dos"));
-#endif
   store_in_alist (&alist, Qname, f->name);
   height = (FRAME_NEW_HEIGHT (f) ? FRAME_NEW_HEIGHT (f) : FRAME_HEIGHT (f));
   store_in_alist (&alist, Qheight, make_number (height));
index 4985911..06d1e18 100644 (file)
@@ -55,6 +55,25 @@ enum vertical_scroll_bar_type
   vertical_scroll_bar_right
 };
 
+#if !defined(MSDOS) && !defined(WINDOWSNT) && !defined(macintosh)
+
+#if !defined(HAVE_X_WINDOWS)
+
+/* A (mostly empty) x_output structure definition for building Emacs
+   on Unix and GNU/Linux without X support.  */
+struct x_output
+{
+  PIX_TYPE background_pixel;
+  PIX_TYPE foreground_pixel;
+};
+
+#endif /* ! HAVE_X_WINDOWS */
+
+/* A structure describing a termcap frame display.  */
+extern struct x_output tty_display;
+
+#endif /* ! MSDOS && ! WINDOWSNT && ! macintosh */
+
 struct frame
 {
   EMACS_INT size;
index 7b8d74d..450d127 100644 (file)
@@ -253,7 +253,7 @@ mouse_get_pos (f, insist, bar_window, part, x, y, time)
   FOR_EACH_FRAME (tail, frame)
     XFRAME (frame)->mouse_moved = 0;
 
-  *f = selected_frame;
+  *f = SELECTED_FRAME();
   *bar_window = Qnil;
   mouse_get_xy (&ix, &iy);
   *time = event_timestamp ();
@@ -267,7 +267,7 @@ mouse_check_moved ()
   int x, y;
 
   mouse_get_xy (&x, &y);
-  selected_frame->mouse_moved |= (x != mouse_last_x || y != mouse_last_y);
+  SELECTED_FRAME()->mouse_moved |= (x != mouse_last_x || y != mouse_last_y);
   mouse_last_x = x;
   mouse_last_y = y;
 }
@@ -344,9 +344,6 @@ static int term_setup_done;
 /* Similar to the_only_frame.  */
 struct x_output the_only_x_display;
 
-/* This is never dereferenced.  */
-Display *x_current_display;
-
 /* Support for DOS/V (allows Japanese characters to be displayed on
    standard, non-Japanese, ATs).  Only supported for DJGPP v2 and later.  */
 
@@ -666,12 +663,13 @@ IT_ring_bell (void)
 static void
 IT_set_face (int face)
 {
-  struct face *fp = FACE_FROM_ID (selected_frame, face);
+  struct frame *sf = SELECTED_FRAME();
+  struct face *fp = FACE_FROM_ID (sf, face);
   unsigned long fg, bg;
 
   if (!fp)
     {
-      fp = FACE_FROM_ID (selected_frame, DEFAULT_FACE_ID);
+      fp = FACE_FROM_ID (sf, DEFAULT_FACE_ID);
       /* The default face for the frame should always be realized and
         cached.  */
       if (!fp)
@@ -688,11 +686,11 @@ IT_set_face (int face)
      switches on this mode (and loses the blinking attribute) at
      startup.  */
   if (fg == (unsigned long)-1)
-    fg = highlight ? FRAME_BACKGROUND_PIXEL (selected_frame)
-                  : FRAME_FOREGROUND_PIXEL (selected_frame);
+    fg = highlight || fp->tty_reverse_p ? FRAME_BACKGROUND_PIXEL (sf)
+                                       : FRAME_FOREGROUND_PIXEL (sf);
   if (bg == (unsigned long)-1)
-    bg = highlight ? FRAME_FOREGROUND_PIXEL (selected_frame)
-                  : FRAME_BACKGROUND_PIXEL (selected_frame);
+    bg = highlight || fp->tty_reverse_p ? FRAME_FOREGROUND_PIXEL (sf)
+                                       : FRAME_BACKGROUND_PIXEL (sf);
   if (termscript)
     fprintf (termscript, "<FACE %d%s: %d/%d>",
             face, highlight ? "H" : "", fp->foreground, fp->background);
@@ -724,6 +722,7 @@ IT_write_glyphs (struct glyph *str, int str_len)
   struct coding_system *coding = (CODING_REQUIRE_ENCODING (&terminal_coding)
                                  ? &terminal_coding
                                  : &safe_terminal_coding);
+  struct frame *sf;
 
   /* Do we need to consider conversion of unibyte characters to
      multibyte?  */
@@ -735,6 +734,7 @@ IT_write_glyphs (struct glyph *str, int str_len)
   
   screen_buf = screen_bp = alloca (str_len * 2);
   screen_buf_end = screen_buf + str_len * 2;
+  sf = SELECTED_FRAME();
 
   /* Since faces get cached and uncached behind our back, we can't
      rely on their indices in the cache being consistent across
@@ -783,8 +783,7 @@ IT_write_glyphs (struct glyph *str, int str_len)
            {
              g = !NILP (Vdos_unsupported_char_glyph)
                ? Vdos_unsupported_char_glyph
-               : MAKE_GLYPH (selected_frame, '\177',
-                             GLYPH_FACE (selected_frame, g));
+               : MAKE_GLYPH (sf, '\177', GLYPH_FACE (sf, g));
              ch = FAST_GLYPH_CHAR (g);
            }
          if (COMPOSITE_CHAR_P (ch))
@@ -792,7 +791,7 @@ IT_write_glyphs (struct glyph *str, int str_len)
              /* If CH is a composite character, we can display
                 only the first component.  */
              g = cmpchar_table[COMPOSITE_CHAR_ID (ch)]->glyph[0],
-             ch = GLYPH_CHAR (selected_frame, g);
+             ch = GLYPH_CHAR (sf, g);
              cf = FAST_GLYPH_FACE (g);
            }
 
@@ -931,13 +930,13 @@ IT_clear_end_of_line (int first_unused)
   int offset = 2 * (new_pos_X + screen_size_X * new_pos_Y);
   extern int fatal_error_in_progress;
 
-  if (fatal_error_in_progress)
+  if (new_pos_X >= first_unused || fatal_error_in_progress)
     return;
 
   IT_set_face (0);
   if (termscript)
     fprintf (termscript, "<CLR:EOL>");
-  i = (j = screen_size_X - new_pos_X) * 2;
+  i = (j = first_unused - new_pos_X) * 2;
   spaces = sp = alloca (i);
   
   while (--j >= 0)
@@ -950,6 +949,10 @@ IT_clear_end_of_line (int first_unused)
   dosmemput (spaces, i, (int)ScreenPrimary + offset);
   if (screen_virtual_segment)
     dosv_refresh_virtual_screen (offset, i / 2);
+
+  /* clear_end_of_line_raw on term.c leaves the cursor at first_unused.
+     Let's follow their lead, in case someone relies on this.  */
+  new_pos_X = first_unused;
 }
 
 static void
@@ -1028,9 +1031,15 @@ IT_cmgoto (FRAME_PTR f)
 {
   /* Only set the cursor to where it should be if the display is
      already in sync with the window contents.  */
-  int update_cursor_pos = MODIFF == unchanged_modified;
+  int update_cursor_pos = 1; /* MODIFF == unchanged_modified; */
+
+  /* FIXME: This needs to be rewritten for the new redisplay, or
+     removed.  */
+#if 0
   static int previous_pos_X = -1;
 
+  update_cursor_pos = 1;       /* temporary!!! */
+
   /* If the display is in sync, forget any previous knowledge about
      cursor position.  This is primarily for unexpected events like
      C-g in the minibuffer.  */
@@ -1066,6 +1075,7 @@ IT_cmgoto (FRAME_PTR f)
          update_cursor_pos = 1;
        }
     }
+#endif
 
   if (update_cursor_pos
       && (current_pos_X != new_pos_X || current_pos_Y != new_pos_Y))
@@ -1088,14 +1098,12 @@ static void
 IT_reassert_line_highlight (int new, int vpos)
 {
   highlight = new;
-  IT_set_face (0); /* To possibly clear the highlighting.  */
 }
 
 static void
 IT_change_line_highlight (int new_highlight, int y, int vpos, int first_unused_hpos)
 {
   highlight = new_highlight;
-  IT_set_face (0); /* To possibly clear the highlighting.  */
   IT_cursor_to (vpos, 0);
   IT_clear_end_of_line (first_unused_hpos);
 }
@@ -1104,8 +1112,6 @@ static void
 IT_update_begin (struct frame *foo)
 {
   highlight = 0;
-  IT_set_face (0); /* To possibly clear the highlighting.  */
-  screen_face = -1;
 }
 
 static void
@@ -1341,6 +1347,30 @@ IT_set_terminal_window (int foo)
 {
 }
 
+/* Remember the screen colors of the curent frame, to serve as the
+   default colors for newly-created frames.  */
+
+static int initial_screen_colors[2];
+
+DEFUN ("msdos-remember-default-colors", Fmsdos_remember_default_colors,
+       Smsdos_remember_default_colors, 1, 1, 0,
+  "Remember the screen colors of the current frame.")
+     (frame)
+     Lisp_Object frame;
+{
+  int reverse;
+  struct frame *f;
+
+  CHECK_FRAME (frame, 0);
+  f= XFRAME (frame);
+  reverse = EQ (Fcdr (Fassq (intern ("reverse"), f->param_alist)), Qt);
+
+  initial_screen_colors[0]
+    = reverse ? FRAME_BACKGROUND_PIXEL (f) : FRAME_FOREGROUND_PIXEL (f);
+  initial_screen_colors[1]
+    = reverse ? FRAME_FOREGROUND_PIXEL (f) : FRAME_BACKGROUND_PIXEL (f);
+}
+
 void
 IT_set_frame_parameters (f, alist)
      struct frame *f;
@@ -1348,18 +1378,29 @@ IT_set_frame_parameters (f, alist)
 {
   Lisp_Object tail;
   int length = XINT (Flength (alist));
-  int i;
+  int i, j;
   Lisp_Object *parms
     = (Lisp_Object *) alloca (length * sizeof (Lisp_Object));
   Lisp_Object *values
     = (Lisp_Object *) alloca (length * sizeof (Lisp_Object));
-  int redraw;
-  struct face *dflt = NULL;
-
-  if (FRAME_FACE_CACHE (f))
-    dflt = FACE_FROM_ID (f, DEFAULT_FACE_ID);
-
-  redraw = 0;
+  Lisp_Object qreverse = intern ("reverse");
+  /* Do we have to reverse the foreground and background colors?  */
+  int reverse = EQ (Fcdr (Fassq (qreverse, f->param_alist)), Qt);
+  int was_reverse = reverse;
+  int redraw = 0, fg_set = 0, bg_set = 0;
+  unsigned long orig_fg;
+  unsigned long orig_bg;
+
+  /* If we are creating a new frame, begin with the original screen colors
+     used for the initial frame.  */
+  if (alist == Vdefault_frame_alist
+      && initial_screen_colors[0] != -1 && initial_screen_colors[1] != -1)
+    {
+      FRAME_FOREGROUND_PIXEL (f) = initial_screen_colors[0];
+      FRAME_BACKGROUND_PIXEL (f) = initial_screen_colors[1];
+    }
+  orig_fg = FRAME_FOREGROUND_PIXEL (f);
+  orig_bg = FRAME_BACKGROUND_PIXEL (f);
 
   /* Extract parm names and values into those vectors.  */
   i = 0;
@@ -1374,8 +1415,21 @@ IT_set_frame_parameters (f, alist)
       i++;
     }
 
+  j = i;
 
-  /* Now process them in reverse of specified order.  */
+  for (i = 0; i < j; i++)
+    {
+      Lisp_Object prop = parms[i];
+      Lisp_Object val  = values[i];
+
+      if (EQ (prop, qreverse))
+       reverse = EQ (val, Qt);
+    }
+       
+  if (termscript && reverse && !was_reverse)
+    fprintf (termscript, "<INVERSE-VIDEO>\n");
+
+  /* Now process the alist elements in reverse of specified order.  */
   for (i--; i >= 0; i--)
     {
       Lisp_Object prop = parms[i];
@@ -1383,30 +1437,36 @@ IT_set_frame_parameters (f, alist)
 
       if (EQ (prop, Qforeground_color))
        {
-         unsigned long new_color = load_color (f, NULL, val,
-                                               LFACE_FOREGROUND_INDEX);
+         unsigned long new_color = load_color (f, NULL, val, reverse
+                                               ? LFACE_BACKGROUND_INDEX
+                                               : LFACE_FOREGROUND_INDEX);
          if (new_color != ~0)
            {
-             if (!dflt)
-               abort ();
-             FRAME_FOREGROUND_PIXEL (f) = new_color;
-             dflt->foreground = new_color;
+             if (reverse)
+               /* FIXME: should the fore-/background of the default
+                  face change here as well?  */
+               FRAME_BACKGROUND_PIXEL (f) = new_color;
+             else
+               FRAME_FOREGROUND_PIXEL (f) = new_color;
              redraw = 1;
+             fg_set = 1;
              if (termscript)
                fprintf (termscript, "<FGCOLOR %lu>\n", new_color);
            }
        }
       else if (EQ (prop, Qbackground_color))
        {
-         unsigned long new_color = load_color (f, NULL, val,
-                                               LFACE_BACKGROUND_INDEX);
+         unsigned long new_color = load_color (f, NULL, val, reverse
+                                               ? LFACE_FOREGROUND_INDEX
+                                               : LFACE_BACKGROUND_INDEX);
          if (new_color != ~0)
            {
-             if (!dflt)
-               abort ();
-             FRAME_BACKGROUND_PIXEL (f) = new_color;
-             dflt->background = new_color;
+             if (reverse)
+               FRAME_FOREGROUND_PIXEL (f) = new_color;
+             else
+               FRAME_BACKGROUND_PIXEL (f) = new_color;
              redraw = 1;
+             bg_set = 1;
              if (termscript)
                fprintf (termscript, "<BGCOLOR %lu>\n", new_color);
            }
@@ -1417,27 +1477,29 @@ IT_set_frame_parameters (f, alist)
          if (termscript)
            fprintf (termscript, "<TITLE: %s>\n", XSTRING (val)->data);
        }
-      else if (EQ (prop, intern ("reverse")) && EQ (val, Qt))
-       {
-         unsigned long fg = FRAME_FOREGROUND_PIXEL (f);
-
-         if (!dflt)
-           abort ();
-         FRAME_FOREGROUND_PIXEL (f) = FRAME_BACKGROUND_PIXEL (f); /* FIXME! */
-         FRAME_BACKGROUND_PIXEL (f) = fg;
-         dflt->foreground = FRAME_FOREGROUND_PIXEL (f);
-         dflt->foreground = fg;
-         if (termscript)
-           fprintf (termscript, "<INVERSE-VIDEO>\n");
-       }
       store_frame_param (f, prop, val);
+    }
 
+  /* If they specified "reverse", but not the colors, we need to swap
+     the current frame colors.  */
+  if (reverse && !was_reverse)
+    {
+      if (!fg_set)
+       {
+         FRAME_BACKGROUND_PIXEL (f) = orig_fg;
+         redraw = 1;
+       }
+      if (!bg_set)
+       {
+         FRAME_FOREGROUND_PIXEL (f) = orig_bg;
+         redraw = 1;
+       }
     }
 
   if (redraw)
     {
-      recompute_basic_faces (f);
-      if (f == selected_frame)
+      face_change_count++;     /* forces xdisp.c to recompute basic faces */
+      if (f == SELECTED_FRAME())
        redraw_frame (f);
     }
 }
@@ -1454,6 +1516,7 @@ internal_terminal_init ()
 {
   char *term = getenv ("TERM");
   char *colors;
+  struct frame *sf = SELECTED_FRAME();
 
 #ifdef HAVE_X_WINDOWS
   if (!inhibit_window_system)
@@ -1469,16 +1532,20 @@ internal_terminal_init ()
 #ifndef HAVE_X_WINDOWS
   if (!internal_terminal || inhibit_window_system)
     {
-      selected_frame->output_method = output_termcap;
+      sf->output_method = output_termcap;
       return;
     }
 
   Vwindow_system = intern ("pc");
   Vwindow_system_version = make_number (1);
+  sf->output_method = output_msdos_raw;
 
   /* If Emacs was dumped on DOS/V machine, forget the stale VRAM address.  */
   screen_old_address = 0;
 
+  /* Forget the stale screen colors as well.  */
+  initial_screen_colors[0] = initial_screen_colors[1] = -1;
+
   bzero (&the_only_x_display, sizeof the_only_x_display);
   the_only_x_display.background_pixel = 7; /* White */
   the_only_x_display.foreground_pixel = 0; /* Black */
@@ -1503,7 +1570,7 @@ internal_terminal_init ()
   the_only_x_display.line_height = 1;
   the_only_x_display.font = (XFontStruct *)1;   /* must *not* be zero */
 
-  init_frame_faces (selected_frame);
+  init_frame_faces (sf);
 
   ring_bell_hook = IT_ring_bell;
   insert_glyphs_hook = IT_insert_glyphs;
@@ -1548,8 +1615,8 @@ dos_get_saved_screen (screen, rows, cols)
 void
 check_x (void)
 {
-  if (! FRAME_MSDOS_P (selected_frame))
-    error ("Not running under a windows system");
+  if (! FRAME_MSDOS_P (SELECTED_FRAME()))
+    error ("Not running under a window system");
 }
 
 #endif
@@ -2081,7 +2148,7 @@ dos_rawgetc ()
   
 #ifndef HAVE_X_WINDOWS
   /* Maybe put the cursor where it should be.  */
-  IT_cmgoto (selected_frame);
+  IT_cmgoto (SELECTED_FRAME());
 #endif
 
   /* The following condition is equivalent to `kbhit ()', except that
@@ -2294,7 +2361,7 @@ dos_rawgetc ()
        event.kind = ascii_keystroke;
       event.code = code;
       event.modifiers =        modifiers;
-      XSETFRAME (event.frame_or_window, selected_frame);
+      event.frame_or_window = selected_frame;
       event.timestamp = event_timestamp ();
       kbd_buffer_store_event (&event);
     }
@@ -2344,7 +2411,7 @@ dos_rawgetc ()
                  | (press ? down_modifier : up_modifier);
                event.x = x;
                event.y = y;
-               XSETFRAME (event.frame_or_window, selected_frame);
+               event.frame_or_window = selected_frame;
                event.timestamp = event_timestamp ();
                kbd_buffer_store_event (&event);
              }
@@ -2503,12 +2570,13 @@ IT_menu_display (XMenu *menu, int y, int x, int *faces)
   int mx, my;
   int enabled, mousehere;
   int row, col;
+  struct frame *sf = SELECTED_FRAME();
 
   width = menu->width;
   text = (struct glyph *) xmalloc ((width + 2) * sizeof (struct glyph));
   ScreenGetCursor (&row, &col);
   mouse_get_xy (&mx, &my);
-  IT_update_begin (selected_frame);
+  IT_update_begin (sf);
   for (i = 0; i < menu->count; i++)
     {
       IT_cursor_to (y + i, x);
@@ -2543,7 +2611,7 @@ IT_menu_display (XMenu *menu, int y, int x, int *faces)
       p++;
       IT_write_glyphs (text, width + 2);
     }
-  IT_update_end (selected_frame);
+  IT_update_end (sf);
   IT_cursor_to (row, col);
   xfree (text);
 }
@@ -2663,6 +2731,7 @@ XMenuActivate (Display *foo, XMenu *menu, int *pane, int *selidx,
   int leave, result, onepane;
   int title_faces[4];          /* face to display the menu title */
   int buffers_num_deleted = 0;
+  struct frame *sf = SELECTED_FRAME();
 
   /* Just in case we got here without a mouse present...  */
   if (have_mouse <= 0)
@@ -2681,15 +2750,15 @@ XMenuActivate (Display *foo, XMenu *menu, int *pane, int *selidx,
   state = alloca (menu->panecount * sizeof (struct IT_menu_state));
   screensize = screen_size * 2;
   faces[0]
-    = lookup_derived_face (selected_frame, intern ("msdos-menu-passive-face"),
+    = lookup_derived_face (sf, intern ("msdos-menu-passive-face"),
                           CHARSET_ASCII, DEFAULT_FACE_ID);
   faces[1]
-    = lookup_derived_face (selected_frame, intern ("msdos-menu-active-face"),
+    = lookup_derived_face (sf, intern ("msdos-menu-active-face"),
                           CHARSET_ASCII, DEFAULT_FACE_ID);
   selectface = intern ("msdos-menu-select-face");
-  faces[2] = lookup_derived_face (selected_frame, selectface,
+  faces[2] = lookup_derived_face (sf, selectface,
                                  CHARSET_ASCII, faces[0]);
-  faces[3] = lookup_derived_face (selected_frame, selectface,
+  faces[3] = lookup_derived_face (sf, selectface,
                                  CHARSET_ASCII, faces[1]);
 
   /* Make sure the menu title is always displayed with
@@ -2740,9 +2809,9 @@ XMenuActivate (Display *foo, XMenu *menu, int *pane, int *selidx,
     {
       if (!mouse_visible) mouse_on ();
       mouse_check_moved ();
-      if (selected_frame->mouse_moved)
+      if (sf->mouse_moved)
        {
-         selected_frame->mouse_moved = 0;
+         sf->mouse_moved = 0;
          result = XM_IA_SELECT;
          mouse_get_xy (&x, &y);
          for (i = 0; i < statecount; i++)
@@ -2924,8 +2993,8 @@ getdefdir (drive, dst)
   *p = '\0';
   errno = 0;
   _fixpath (in_path, dst);
-  /* _fixpath can set errno to ENOSYS on non-LFN systems because
-     it queries the LFN support, so ignore that error.  */
+    /* _fixpath can set errno to ENOSYS on non-LFN systems because
+       it queries the LFN support, so ignore that error.  */
   if ((errno && errno != ENOSYS) || *dst == '\0')
     return 0;
 
@@ -4075,11 +4144,12 @@ abort ()
 }
 #endif
 
-/* The following two are required so that customization feature
-   won't complain about unbound variables.  */
+/* The following variables are required so that cus-start.el won't
+   complain about unbound variables.  */
 #ifndef HAVE_X_WINDOWS
 /* Search path for bitmap files (xfns.c).  */
 Lisp_Object Vx_bitmap_file_path;
+int x_stretch_cursor_p;
 #endif
 #ifndef subprocesses
 /* Nonzero means delete a process right away if it exits (process.c).  */
@@ -4095,6 +4165,12 @@ syms_of_msdos ()
     "List of directories to search for bitmap files for X.");
   Vx_bitmap_file_path = decode_env_path ((char *) 0, ".");
 
+  DEFVAR_BOOL ("x-stretch-cursor", &x_stretch_cursor_p,
+    "*Non-nil means draw block cursor as wide as the glyph under it.\n\
+For example, if a block cursor is over a tab, it will be drawn as\n\
+wide as that tab on the display.  (No effect on MS-DOS.)");
+  x_stretch_cursor_p = 0;
+
   /* The following three are from xfns.c:  */
   Qbackground_color = intern ("background-color");
   staticpro (&Qbackground_color);
@@ -4117,6 +4193,7 @@ nil means don't delete them until `list-processes' is run.");
   defsubr (&Srecent_doskeys);
   defsubr (&Smsdos_long_file_names);
   defsubr (&Smsdos_downcase_filename);
+  defsubr (&Smsdos_remember_default_colors);
 }
 
 #endif /* MSDOS */
index c8ff29c..87e88dd 100644 (file)
@@ -58,33 +58,18 @@ typedef int XRectangle;
 /* This is a cut-down version of the one in xterm.h, which see.  */
 struct x_output
 {
-  int left_pos;
-  int top_pos;
-  int line_height;
-  PIX_TYPE background_pixel;
-  PIX_TYPE foreground_pixel;
-  XFontStruct *font;
-  Window busy_window;
-  unsigned busy_p : 1;
-  struct face **param_faces;
-  int n_param_faces;
-  struct face **computed_faces;
-  int n_computed_faces;
-  int size_computed_faces;
+  int left_pos;                        /* used in xmenu_show (xmenu.c) */
+  int top_pos;                 /* ditto */
+  int line_height;             /* used in x-popup-menu (xmenu.c) */
+  PIX_TYPE background_pixel;   /* used in xfaces.c and lots of other places */
+  PIX_TYPE foreground_pixel;   /* ditto */
+  XFontStruct *font;           /* used in x-popup-menu (xmenu.c) */
+  Window busy_window;          /* currently unused (but maybe some day) */
+  unsigned busy_p : 1;         /* ditto */
 };
 
 extern struct x_output the_only_x_display;
-extern Display *x_current_display;
-
-#define FRAME_PARAM_FACES(f) (the_only_x_display.param_faces)
-#define FRAME_N_PARAM_FACES(f) (the_only_x_display.n_param_faces)
-#define FRAME_DEFAULT_PARAM_FACE(f) (FRAME_PARAM_FACES (f)[0])
-#define FRAME_MODE_LINE_PARAM_FACE(f) (FRAME_PARAM_FACES (f)[1])
-#define FRAME_COMPUTED_FACES(f) (the_only_x_display.computed_faces)
-#define FRAME_N_COMPUTED_FACES(f) (the_only_x_display.n_computed_faces)
-#define FRAME_SIZE_COMPUTED_FACES(f) (the_only_x_display.size_computed_faces)
-#define FRAME_DEFAULT_FACE(f) (the_only_x_display.computed_faces[0])
-#define FRAME_MODE_LINE_FACE(f) (the_only_x_display.computed_faces[1])
+
 #define FRAME_X_DISPLAY(f) ((Display *) 0)
 #define FRAME_FOREGROUND_PIXEL(f) (the_only_x_display.foreground_pixel)
 #define FRAME_BACKGROUND_PIXEL(f) (the_only_x_display.background_pixel)
@@ -95,10 +80,6 @@ extern Display *x_current_display;
 /* Forward declarations for prototypes.  */
 struct frame;
 struct window;
-#if 0
-extern int face_name_id_number P_ ((struct frame *, Lisp_Object)); /* !!! */
-extern int compute_glyph_face P_ ((struct frame *, int, int)); /* !!! */
-#endif
 
 /* From xterm.c; emulated on msdos.c */
 
@@ -116,12 +97,11 @@ extern int x_pixel_width P_ ((struct frame *));
 extern int x_pixel_height P_ ((struct frame *));
 
 #define XFreeGC (void)
-#define unload_color(p1,p2)
 #define x_destroy_bitmap(p1,p2)
 #define load_pixmap(p1,p2,p3,p4) (0)
 #define XGetGeometry(p1,p2,p3,p4,p5,p6,p7,p8,p9)
-#define DisplayWidth(p1,p2) (selected_frame->width)
-#define DisplayHeight(p1,p2) (selected_frame->height)
+#define DisplayWidth(p1,p2) (SELECTED_FRAME()->width)
+#define DisplayHeight(p1,p2) (SELECTED_FRAME()->height)
 #define XMenuSetAEQ (void)
 #define XMenuSetFreeze (void)
 #define XMenuRecompute (void)
index a3f3e2a..5c8e78c 100644 (file)
@@ -347,8 +347,7 @@ x_window_to_frame (dpyinfo, wdesc)
       if (!GC_FRAMEP (frame))
         continue;
       f = XFRAME (frame);
-      if (f->output_data.nothing == 1 
-         || FRAME_W32_DISPLAY_INFO (f) != dpyinfo)
+      if (!FRAME_W32_P (f) || FRAME_W32_DISPLAY_INFO (f) != dpyinfo)
        continue;
       if (FRAME_W32_WINDOW (f) == wdesc)
         return f;
@@ -6449,9 +6448,8 @@ Lisp_Object w32_find_bdf_fonts_in_dir( Lisp_Object directory )
 }
 
 \f
-DEFUN ("x-color-defined-p", Fx_color_defined_p, Sx_color_defined_p, 1, 2, 0,
-       "Return non-nil if color COLOR is supported on frame FRAME.\n\
-If FRAME is omitted or nil, use the selected frame.")
+DEFUN ("xw-color-defined-p", Fxw_color_defined_p, Sxw_color_defined_p, 1, 2, 0,
+  "Internal function called by `color-defined-p', which see.")
   (color, frame)
      Lisp_Object color, frame;
 {
@@ -6466,12 +6464,8 @@ If FRAME is omitted or nil, use the selected frame.")
     return Qnil;
 }
 
-DEFUN ("x-color-values", Fx_color_values, Sx_color_values, 1, 2, 0,
-  "Return a description of the color named COLOR on frame FRAME.\n\
-The value is a list of integer RGB values--(RED GREEN BLUE).\n\
-These values appear to range from 0 to 65280 or 65535, depending\n\
-on the system; white is (65280 65280 65280) or (65535 65535 65535).\n\
-If FRAME is omitted or nil, use the selected frame.")
+DEFUN ("xw-color-values", Fxw_color_values, Sxw_color_values, 1, 2, 0,
+  "Internal function called by `color-values', which see.")
   (color, frame)
      Lisp_Object color, frame;
 {
@@ -6493,7 +6487,7 @@ If FRAME is omitted or nil, use the selected frame.")
     return Qnil;
 }
 
-DEFUN ("x-display-color-p", Fx_display_color_p, Sx_display_color_p, 0, 1, 0,
+DEFUN ("xw-display-color-p", Fxw_display_color_p, Sxw_display_color_p, 0, 1, 0,
   "Return t if the X display supports color.\n\
 The optional argument DISPLAY specifies which display to ask about.\n\
 DISPLAY should be either a frame or a display name (a string).\n\
@@ -7595,10 +7589,10 @@ only be necessary if the default setting causes problems.");
 
   defsubr (&Sx_get_resource);
   defsubr (&Sx_list_fonts);
-  defsubr (&Sx_display_color_p);
+  defsubr (&Sxw_display_color_p);
   defsubr (&Sx_display_grayscale_p);
-  defsubr (&Sx_color_defined_p);
-  defsubr (&Sx_color_values);
+  defsubr (&Sxw_color_defined_p);
+  defsubr (&Sxw_color_values);
   defsubr (&Sx_server_max_request_size);
   defsubr (&Sx_server_vendor);
   defsubr (&Sx_server_version);
index c93c589..5f0d0eb 100644 (file)
@@ -219,7 +219,7 @@ menubar_id_to_frame (HMENU menu)
       if (!GC_FRAMEP (frame))
         continue;
       f = XFRAME (frame);
-      if (f->output_data.nothing == 1)
+      if (!FRAME_W32_P (f))
        continue;
       if (f->output_data.w32->menubar_widget == menu)
        return f;
index 3ee2199..f762bd3 100644 (file)
@@ -343,6 +343,9 @@ struct w32_output
   volatile char pending_menu_activation;
 };
 
+/* A (mostly empty) structure describing a w32 terminal frame display.  */
+extern struct w32_output w32term_display;
+
 /* Get at the computed faces of an X window frame.  */
 #define FRAME_PARAM_FACES(f) ((f)->output_data.w32->param_faces)
 #define FRAME_N_PARAM_FACES(f) ((f)->output_data.w32->n_param_faces)
index c7b9c1a..05a0d2d 100644 (file)
@@ -255,6 +255,16 @@ Boston, MA 02111-1307, USA.  */
 
 #define FACE_CACHE_BUCKETS_SIZE 1001
 
+/* A definition of XColor for non-X frames.  */
+#ifndef HAVE_X_WINDOWS
+typedef struct {
+  unsigned long pixel;
+  unsigned short red, green, blue;
+  char flags;
+  char pad;
+} XColor;
+#endif
+
 /* Keyword symbols used for face attribute names.  */
 
 Lisp_Object QCfamily, QCheight, QCweight, QCslant, QCunderline;
@@ -368,10 +378,8 @@ static int next_lface_id;
 static Lisp_Object *lface_id_to_name;
 static int lface_id_to_name_size;
 
-/* An alist of elements (COLOR-NAME . INDEX) mapping color names
-   to color indices for tty frames.  */
-
-Lisp_Object Vface_tty_color_alist;
+/* tty color-related functions (defined on lisp/term/tty-colors.el).  */
+Lisp_Object Qtty_color_desc, Qtty_color_by_index;
 
 /* Counter for calls to clear_face_cache.  If this counter reaches
    CLEAR_FONT_TABLE_COUNT, and a frame has more than
@@ -1067,7 +1075,113 @@ load_face_font_or_fontset (f, face, font_name, fontset)
                                X Colors
  ***********************************************************************/
 
+/* A version of defined_color for non-X frames.  */
+int
+tty_defined_color (f, color_name, color_def, alloc)
+     struct frame *f;
+     char *color_name;
+     XColor *color_def;
+     int alloc;
+{
+  Lisp_Object color_desc;
+  int color_idx = FACE_TTY_DEFAULT_COLOR, red = 0, green = 0, blue = 0;
+  int status = 1;
+
+  if (*color_name && !NILP (Ffboundp (Qtty_color_desc)))
+    {
+      status = 0;
+      color_desc = call1 (Qtty_color_desc, build_string (color_name));
+      if (!NILP (color_desc) && CONSP (color_desc))
+       {
+         color_idx = XINT (XCAR (XCDR (color_desc)));
+         if (CONSP (XCDR (XCDR (color_desc))))
+           {
+             red = XINT (XCAR (XCDR (XCDR (color_desc))));
+             green = XINT (XCAR (XCDR (XCDR (XCDR (color_desc)))));
+             blue = XINT (XCAR (XCDR (XCDR (XCDR (XCDR (color_desc))))));
+           }
+         status = 1;
+       }
+      else if (NILP (Fsymbol_value (intern ("tty-color-alist"))))
+       /* We were called early during startup, and the colors are not
+          yet set up in tty-color-alist.  Don't return a failure
+          indication, since this produces the annoying "Unable to
+          load color" messages in the *Messages* buffer.  */
+       status = 1;
+    }
+  color_def->pixel = (unsigned long) color_idx;
+  color_def->red = red;
+  color_def->green = green;
+  color_def->blue = blue;
+
+  return status;
+}
+
+/* Decide if color named COLOR is valid for the display associated
+   with the frame F; if so, return the rgb values in COLOR_DEF.  If
+   ALLOC is nonzero, allocate a new colormap cell.
+
+   This does the right thing for any type of frame.  */
+int
+defined_color (f, color_name, color_def, alloc)
+     struct frame *f;
+     char *color_name;
+     XColor *color_def;
+     int alloc;
+{
+  if (!FRAME_WINDOW_P (f))
+    return tty_defined_color (f, color_name, color_def, alloc);
 #ifdef HAVE_X_WINDOWS
+  else if (FRAME_X_P (f))
+    return x_defined_color (f, color_name, color_def, alloc);
+#endif
+#ifdef WINDOWSNT
+  else if (FRAME_W32_P (f))
+    /* FIXME: w32_defined_color doesn't exist!  w32fns.c defines
+       defined_color which needs to be renamed, and the declaration
+       of color_def therein should be changed.  */
+    return w32_defined_color (f, color_name, color_def, alloc);
+#endif
+#ifdef macintosh
+  else if (FRAME_MAC_P (f))
+    /* FIXME: mac_defined_color doesn't exist!  */
+    return mac_defined_color (f, color_name, color_def, alloc);
+#endif
+  else
+    abort ();
+}
+
+/* Given the index of the tty color, return its name, a Lisp string.  */
+
+Lisp_Object
+tty_color_name (f, idx)
+     struct frame *f;
+     int idx;
+{
+  char *color;
+
+  if (idx >= 0 && !NILP (Ffboundp (Qtty_color_by_index)))
+    {
+      Lisp_Object coldesc = call1 (Qtty_color_by_index, make_number (idx));
+
+      if (!NILP (coldesc))
+       return XCAR (coldesc);
+    }
+#ifdef MSDOS
+  /* We can have an MSDOG 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);
+#endif
+
+#ifdef WINDOWSNT
+  /* FIXME: When/if w32 supports colors in non-window mode, there should
+     be a call here to a w32-specific function that returns the color
+     by index using the default color mapping on a Windows console.  */
+#endif
+
+  return Qunspecified;
+}
 
 /* Return non-zero if COLOR_NAME is a shade of gray (or white or
    black) on frame F.  The algorithm is taken from 20.2 faces.el.  */
@@ -1105,17 +1219,19 @@ face_color_supported_p (f, color_name, background_p)
      int background_p;
 {
   Lisp_Object frame;
+  XColor not_used;
 
   XSETFRAME (frame, f);
-  return (!NILP (Vwindow_system)
-         && (!NILP (Fx_display_color_p (frame))
+  return ((FRAME_WINDOW_P (f)
+         && (!NILP (Fxw_display_color_p (frame))
              || xstricmp (color_name, "black") == 0
              || xstricmp (color_name, "white") == 0
              || (background_p
                  && face_color_gray_p (f, color_name))
              || (!NILP (Fx_display_grayscale_p (frame))
-                 && face_color_gray_p (f, color_name))));
-}  
+                 && face_color_gray_p (f, color_name))))
+         || tty_defined_color (f, color_name, &not_used, 0));
+}
 
 
 DEFUN ("face-color-gray-p", Fface_color_gray_p, Sface_color_gray_p, 1, 2, 0,
@@ -1125,8 +1241,11 @@ If FRAME is nil or omitted, use the selected frame.")
    (color, frame)
      Lisp_Object color, frame;
 {
-  struct frame *f = check_x_frame (frame);
+  struct frame *f;
+
+  CHECK_FRAME (frame, 0);
   CHECK_STRING (color, 0);
+  f = XFRAME (frame);
   return face_color_gray_p (f, XSTRING (color)->data) ? Qt : Qnil;
 }
 
@@ -1140,8 +1259,11 @@ COLOR must be a valid color name.")
    (frame, color, background_p)
      Lisp_Object frame, color, background_p;
 {
-  struct frame *f = check_x_frame (frame);
+  struct frame *f;
+
+  CHECK_FRAME (frame, 0);
   CHECK_STRING (color, 0);
+  f = XFRAME (frame);
   if (face_color_supported_p (f, XSTRING (color)->data, !NILP (background_p)))
     return Qt;
   return Qnil;
@@ -1177,7 +1299,7 @@ load_color (f, face, name, target_index)
      to the values in an existing cell. */
   if (!defined_color (f, XSTRING (name)->data, &color, 1))
     {
-      add_to_log ("Unable to load color %s", name, Qnil);
+      add_to_log ("Unable to load color \"%s\"", name, Qnil);
       
       switch (target_index)
        {
@@ -1223,6 +1345,7 @@ load_color (f, face, name, target_index)
   return color.pixel;
 }
 
+#ifdef HAVE_X_WINDOWS
 
 /* Load colors for face FACE which is used on frame F.  Colors are
    specified by slots LFACE_BACKGROUND_INDEX and LFACE_FOREGROUND_INDEX
@@ -1371,75 +1494,7 @@ free_face_colors (f, face)
       UNBLOCK_INPUT;
     }
 }
-
-#else  /* ! HAVE_X_WINDOWS */
-
-#ifdef MSDOS
-unsigned long
-load_color (f, face, name, target_index)
-     struct frame *f;
-     struct face *face;
-     Lisp_Object name;
-     enum lface_attribute_index target_index;
-{
-  Lisp_Object color;
-  int color_idx = FACE_TTY_DEFAULT_COLOR;
-
-  if (NILP (name))
-    return (unsigned long)FACE_TTY_DEFAULT_COLOR;
-
-  CHECK_STRING (name, 0);
-
-  color = Qnil;
-  if (XSTRING (name)->size && !NILP (Ffboundp (Qmsdos_color_translate)))
-    {
-      color = call1 (Qmsdos_color_translate, name);
-
-      if (INTEGERP (color))
-       return (unsigned long)XINT (color);
-
-      add_to_log ("Unable to load color %s", name, Qnil);
-      
-      switch (target_index)
-       {
-       case LFACE_FOREGROUND_INDEX:
-         face->foreground_defaulted_p = 1;
-         color_idx = FRAME_FOREGROUND_PIXEL (f);
-         break;
-         
-       case LFACE_BACKGROUND_INDEX:
-         face->background_defaulted_p = 1;
-         color_idx = FRAME_BACKGROUND_PIXEL (f);
-         break;
-         
-       case LFACE_UNDERLINE_INDEX:
-         face->underline_defaulted_p = 1;
-         color_idx = FRAME_FOREGROUND_PIXEL (f);
-         break;
-         
-       case LFACE_OVERLINE_INDEX:
-         face->overline_color_defaulted_p = 1;
-         color_idx = FRAME_FOREGROUND_PIXEL (f);
-         break;
-         
-       case LFACE_STRIKE_THROUGH_INDEX:
-         face->strike_through_color_defaulted_p = 1;
-         color_idx = FRAME_FOREGROUND_PIXEL (f);
-         break;
-         
-       case LFACE_BOX_INDEX:
-         face->box_color_defaulted_p = 1;
-         color_idx = FRAME_FOREGROUND_PIXEL (f);
-         break;
-       }
-    }
-  else
-    color_idx = msdos_stdcolor_idx (XSTRING (name)->data);
-
-  return (unsigned long)color_idx;
-}
-#endif /* MSDOS */
-#endif /* ! HAVE_X_WINDOWS */
+#endif /* HAVE_X_WINDOWS */
 
 
 \f
@@ -2714,7 +2769,7 @@ lface_fully_specified_p (attrs)
    for split_font_name, see the comment there.  */
    
 static int
-set_lface_from_font_name (f, lface, font_name, force_p, may_fail_p)
+set_lface_from_font_name (f, lface, font_name, force_p)
      struct frame *f;
      Lisp_Object lface;
      char *font_name;
@@ -2752,10 +2807,8 @@ set_lface_from_font_name (f, lface, font_name, force_p, may_fail_p)
              split_font_name (f, &font, 1);
              have_font_p = 1;
            }
-         
          UNBLOCK_INPUT;
        }
-    }
 
   /* If FONT_NAME is completely bogus try to use something reasonable
      if this function must succeed.  Otherwise, give up.  */
@@ -5628,12 +5681,7 @@ realize_default_face (f)
        LFACE_FOREGROUND (lface) = XCDR (color);
       else if (FRAME_X_P (f))
        return 0;
-      else if (FRAME_TERMCAP_P (f) || FRAME_MSDOS_P (f))
-       /* Frame parameters for terminal frames usually don't contain
-          a color.  Use an empty string to indicate that the face
-          should use the (unknown) default color of the terminal.  */
-       LFACE_FOREGROUND (lface) = build_string ("");
-      else
+      else if (!FRAME_TERMCAP_P (f) && !FRAME_MSDOS_P (f))
        abort ();
     }
   
@@ -5646,12 +5694,7 @@ realize_default_face (f)
        LFACE_BACKGROUND (lface) = XCDR (color);
       else if (FRAME_X_P (f))
        return 0;
-      else if (FRAME_TERMCAP_P (f) || FRAME_MSDOS_P (f))
-       /* Frame parameters for terminal frames usually don't contain
-          a color.  Use an empty string to indicate that the face
-          should use the (unknown) default color of the terminal.  */
-       LFACE_BACKGROUND (lface) = build_string ("");
-      else
+      else if (!FRAME_TERMCAP_P (f) && !FRAME_MSDOS_P (f))
        abort ();
     }
   
@@ -6006,6 +6049,8 @@ realize_tty_face (c, attrs, charset)
   struct face *face;
   int weight, slant;
   Lisp_Object color;
+  Lisp_Object tty_color_alist = Fsymbol_value (intern ("tty-color-alist"));
+  int face_colors_defaulted = 0;
 
   /* Frame must be a termcap frame.  */
   xassert (FRAME_TERMCAP_P (c->f) || FRAME_MSDOS_P (c->f));
@@ -6033,109 +6078,78 @@ realize_tty_face (c, attrs, charset)
   face->foreground = face->background = FACE_TTY_DEFAULT_COLOR;
 
   color = attrs[LFACE_FOREGROUND_INDEX];
-  if (XSTRING (color)->size
-      && (color = Fassoc (color, Vface_tty_color_alist),
+  if (STRINGP (color)
+      && XSTRING (color)->size
+      && !NILP (tty_color_alist)
+      && (color = Fassoc (color, tty_color_alist),
          CONSP (color)))
-    face->foreground = XINT (XCDR (color));
+    /* Associations in tty-color-alist are of the form
+       (NAME INDEX R G B).  We need the INDEX part.  */
+    face->foreground = XINT (XCAR (XCDR (color)));
 
-#ifdef MSDOS
-  if (FRAME_MSDOS_P (c->f) && face->foreground == FACE_TTY_DEFAULT_COLOR)
+  if (face->foreground == FACE_TTY_DEFAULT_COLOR
+      && STRINGP (attrs[LFACE_FOREGROUND_INDEX]))
     {
       face->foreground = load_color (c->f, face,
                                     attrs[LFACE_FOREGROUND_INDEX],
                                     LFACE_FOREGROUND_INDEX);
+#ifdef MSDOS
       /* If the foreground of the default face is the default color,
         use the foreground color defined by the frame.  */
-      if (face->foreground == FACE_TTY_DEFAULT_COLOR)
+      if (FRAME_MSDOS_P (c->f) && face->foreground == FACE_TTY_DEFAULT_COLOR)
        {
          face->foreground = FRAME_FOREGROUND_PIXEL (f);
          attrs[LFACE_FOREGROUND_INDEX] =
-           build_string (msdos_stdcolor_name (face->foreground));
+           msdos_stdcolor_name (face->foreground);
+         face_colors_defaulted = 1;
        }
-    }
 #endif
+    }
 
   color = attrs[LFACE_BACKGROUND_INDEX];
-  if (XSTRING (color)->size
-      && (color = Fassoc (color, Vface_tty_color_alist),
+  if (STRINGP (color)
+      && XSTRING (color)->size
+      && !NILP (tty_color_alist)
+      && (color = Fassoc (color, tty_color_alist),
          CONSP (color)))
-    face->background = XINT (XCDR (color));
+    /* Associations in tty-color-alist are of the form
+       (NAME INDEX R G B).  We need the INDEX part.  */
+    face->background = XINT (XCAR (XCDR (color)));
 
-#ifdef MSDOS
-  if (FRAME_MSDOS_P (c->f) && face->background == FACE_TTY_DEFAULT_COLOR)
+  if (face->background == FACE_TTY_DEFAULT_COLOR
+      && STRINGP (attrs[LFACE_BACKGROUND_INDEX]))
     {
       face->background = load_color (c->f, face,
                                     attrs[LFACE_BACKGROUND_INDEX],
                                     LFACE_BACKGROUND_INDEX);
+#ifdef MSDOS
       /* If the background of the default face is the default color,
         use the background color defined by the frame.  */
-      if (face->background == FACE_TTY_DEFAULT_COLOR)
+      if (FRAME_MSDOS_P (c->f) && face->background == FACE_TTY_DEFAULT_COLOR)
        {
          face->background = FRAME_BACKGROUND_PIXEL (f);
          attrs[LFACE_BACKGROUND_INDEX] =
-           build_string (msdos_stdcolor_name (face->background));
+           msdos_stdcolor_name (face->background);
+         face_colors_defaulted = 1;
        }
+#endif
     }
 
-  /* Swap colors if face is inverse-video.  */
-  if (face->tty_reverse_p)
+  /* Swap colors if face is inverse-video.  If the colors are taken
+     from the frame colors, they are already inverted, since the
+     frame-creation function calls x-handle-reverse-video.  */
+  if (face->tty_reverse_p && !face_colors_defaulted)
     {
       unsigned long tem = face->foreground;
 
       face->foreground = face->background;
       face->background = tem;
     }
-#endif
 
   return face;
 }
 
 
-DEFUN ("face-register-tty-color", Fface_register_tty_color,
-       Sface_register_tty_color, 2, 2, 0,
-  "Say that COLOR is color number NUMBER on the terminal.\n\
-COLOR is a string, the color name.  Value is COLOR.")
-  (color, number)
-     Lisp_Object color, number;
-{
-  Lisp_Object entry;
-  
-  CHECK_STRING (color, 0);
-  CHECK_NUMBER (number, 1);
-  entry = Fassoc (color, Vface_tty_color_alist);
-  if (NILP (entry))
-    Vface_tty_color_alist = Fcons (Fcons (color, number),
-                                  Vface_tty_color_alist);
-  else
-    Fsetcdr (entry, number);
-  return color;
-}
-
-
-DEFUN ("face-clear-tty-colors", Fface_clear_tty_colors,
-       Sface_clear_tty_colors, 0, 0, 0,
-  "Unregister all registered tty colors.")
-  ()
-{
-  return Vface_tty_color_alist = Qnil;
-}
-
-
-DEFUN ("tty-defined-colors", Ftty_defined_colors,
-       Stty_defined_colors, 0, 0, 0,
-  "Return a list of registered tty colors.")
-  ()
-{
-  Lisp_Object list, colors;
-
-  colors = Qnil;
-  for (list = Vface_tty_color_alist; CONSP (list); list = XCDR (list))
-    colors = Fcons (XCAR (XCAR (list)), colors);
-
-  return colors;
-}
-
-
 \f
 /***********************************************************************
                           Computing Faces
@@ -6625,6 +6639,10 @@ syms_of_xfaces ()
   staticpro (&Qborder);
   Qmouse = intern ("mouse");
   staticpro (&Qmouse);
+  Qtty_color_desc = intern ("tty-color-desc");
+  staticpro (&Qtty_color_desc);
+  Qtty_color_by_index = intern ("tty-color-by-index");
+  staticpro (&Qtty_color_by_index);
 
   defsubr (&Sinternal_make_lisp_face);
   defsubr (&Sinternal_lisp_face_p);
@@ -6696,11 +6714,4 @@ scaled if its name matches a regular expression in the list.");
   defsubr (&Sx_family_fonts);
   defsubr (&Sx_font_family_list);
 #endif /* HAVE_X_WINDOWS */
-
-  /* TTY face support.  */
-  defsubr (&Sface_register_tty_color);
-  defsubr (&Sface_clear_tty_colors);
-  defsubr (&Stty_defined_colors);
-  Vface_tty_color_alist = Qnil;
-  staticpro (&Vface_tty_color_alist);
 }
index 813b39a..59fa8e0 100644 (file)
@@ -350,7 +350,7 @@ x_window_to_frame (dpyinfo, wdesc)
       if (!GC_FRAMEP (frame))
         continue;
       f = XFRAME (frame);
-      if (f->output_data.nothing == 1 || FRAME_X_DISPLAY_INFO (f) != dpyinfo)
+      if (!FRAME_X_P (f) || FRAME_X_DISPLAY_INFO (f) != dpyinfo)
        continue;
 #ifdef USE_X_TOOLKIT
       if ((f->output_data.x->edit_widget 
@@ -388,7 +388,7 @@ x_any_window_to_frame (dpyinfo, wdesc)
       if (!GC_FRAMEP (frame))
         continue;
       f = XFRAME (frame);
-      if (f->output_data.nothing == 1 || FRAME_X_DISPLAY_INFO (f) != dpyinfo)
+      if (!FRAME_X_P (f) || FRAME_X_DISPLAY_INFO (f) != dpyinfo)
        continue;
       x = f->output_data.x;
       /* This frame matches if the window is any of its widgets.  */
@@ -426,7 +426,7 @@ x_non_menubar_window_to_frame (dpyinfo, wdesc)
       if (!GC_FRAMEP (frame))
         continue;
       f = XFRAME (frame);
-      if (f->output_data.nothing == 1 || FRAME_X_DISPLAY_INFO (f) != dpyinfo)
+      if (!FRAME_X_P (f) || FRAME_X_DISPLAY_INFO (f) != dpyinfo)
        continue;
       x = f->output_data.x;
       /* This frame matches if the window is any of its widgets.  */
@@ -461,7 +461,7 @@ x_menubar_window_to_frame (dpyinfo, wdesc)
       if (!GC_FRAMEP (frame))
         continue;
       f = XFRAME (frame);
-      if (f->output_data.nothing == 1 || FRAME_X_DISPLAY_INFO (f) != dpyinfo)
+      if (!FRAME_X_P (f) || FRAME_X_DISPLAY_INFO (f) != dpyinfo)
        continue;
       x = f->output_data.x;
       /* Match if the window is this frame's menubar.  */
@@ -490,7 +490,7 @@ x_top_window_to_frame (dpyinfo, wdesc)
       if (!GC_FRAMEP (frame))
         continue;
       f = XFRAME (frame);
-      if (f->output_data.nothing == 1 || FRAME_X_DISPLAY_INFO (f) != dpyinfo)
+      if (!FRAME_X_P (f) || FRAME_X_DISPLAY_INFO (f) != dpyinfo)
        continue;
       x = f->output_data.x;
 
@@ -1230,7 +1230,7 @@ gamma_correct (f, color)
    If ALLOC is nonzero, allocate a new colormap cell.  */
 
 int
-defined_color (f, color, color_def, alloc)
+x_defined_color (f, color, color_def, alloc)
      FRAME_PTR f;
      char *color;
      XColor *color_def;
@@ -1341,9 +1341,9 @@ x_decode_color (f, arg, def)
   if (FRAME_X_DISPLAY_INFO (f)->n_planes == 1)
     return def;
 
-  /* defined_color is responsible for coping with failures
+  /* x_defined_color is responsible for coping with failures
      by looking for a near-miss.  */
-  if (defined_color (f, XSTRING (arg)->data, &cdef, 1))
+  if (x_defined_color (f, XSTRING (arg)->data, &cdef, 1))
     return cdef.pixel;
 
   Fsignal (Qerror, Fcons (build_string ("undefined color"),
@@ -3908,9 +3908,8 @@ x_get_focus_frame (frame)
 }
 
 \f
-DEFUN ("x-color-defined-p", Fx_color_defined_p, Sx_color_defined_p, 1, 2, 0,
-       "Return non-nil if color COLOR is supported on frame FRAME.\n\
-If FRAME is omitted or nil, use the selected frame.")
+DEFUN ("xw-color-defined-p", Fxw_color_defined_p, Sxw_color_defined_p, 1, 2, 0,
+  "Internal function called by `color-defined-p', which see.")
   (color, frame)
      Lisp_Object color, frame;
 {
@@ -3919,18 +3918,14 @@ If FRAME is omitted or nil, use the selected frame.")
 
   CHECK_STRING (color, 1);
 
-  if (defined_color (f, XSTRING (color)->data, &foo, 0))
+  if (x_defined_color (f, XSTRING (color)->data, &foo, 0))
     return Qt;
   else
     return Qnil;
 }
 
-DEFUN ("x-color-values", Fx_color_values, Sx_color_values, 1, 2, 0,
-  "Return a description of the color named COLOR on frame FRAME.\n\
-The value is a list of integer RGB values--(RED GREEN BLUE).\n\
-These values appear to range from 0 to 65280 or 65535, depending\n\
-on the system; white is (65280 65280 65280) or (65535 65535 65535).\n\
-If FRAME is omitted or nil, use the selected frame.")
+DEFUN ("xw-color-values", Fxw_color_values, Sxw_color_values, 1, 2, 0,
+  "Internal function called by `color-values', which see.")
   (color, frame)
      Lisp_Object color, frame;
 {
@@ -3939,7 +3934,7 @@ If FRAME is omitted or nil, use the selected frame.")
 
   CHECK_STRING (color, 1);
 
-  if (defined_color (f, XSTRING (color)->data, &foo, 0))
+  if (x_defined_color (f, XSTRING (color)->data, &foo, 0))
     {
       Lisp_Object rgb[3];
 
@@ -3952,11 +3947,8 @@ If FRAME is omitted or nil, use the selected frame.")
     return Qnil;
 }
 
-DEFUN ("x-display-color-p", Fx_display_color_p, Sx_display_color_p, 0, 1, 0,
-  "Return t if the X display supports color.\n\
-The optional argument DISPLAY specifies which display to ask about.\n\
-DISPLAY should be either a frame or a display name (a string).\n\
-If omitted or nil, that stands for the selected frame's display.")
+DEFUN ("xw-display-color-p", Fxw_display_color_p, Sxw_display_color_p, 0, 1, 0,
+  "Internal function called by `display-color-p', which see.")
   (display)
      Lisp_Object display;
 {
@@ -5878,7 +5870,7 @@ x_alloc_image_color (f, img, color_name, dflt)
 
   xassert (STRINGP (color_name));
 
-  if (defined_color (f, XSTRING (color_name)->data, &color, 1))
+  if (x_defined_color (f, XSTRING (color_name)->data, &color, 1))
     {
       /* This isn't called frequently so we get away with simply
         reallocating the color vector to the needed size, here.  */
@@ -10333,10 +10325,10 @@ Each element of the list is a symbol for a supported image type.");
   defsubr (&Sx_contour_region);
   defsubr (&Sx_uncontour_region);
 #endif
-  defsubr (&Sx_display_color_p);
+  defsubr (&Sxw_display_color_p);
   defsubr (&Sx_display_grayscale_p);
-  defsubr (&Sx_color_defined_p);
-  defsubr (&Sx_color_values);
+  defsubr (&Sxw_color_defined_p);
+  defsubr (&Sxw_color_values);
   defsubr (&Sx_server_max_request_size);
   defsubr (&Sx_server_vendor);
   defsubr (&Sx_server_version);
index a9bda21..fd42d5f 100644 (file)
@@ -215,7 +215,7 @@ menubar_id_to_frame (id)
       if (!GC_FRAMEP (frame))
         continue;
       f = XFRAME (frame);
-      if (f->output_data.nothing == 1)
+      if (!FRAME_WINDOW_P (f))
        continue;
       if (f->output_data.x->id == id)
        return f;