# HG changeset patch # User Eli Zaretskii # Date 1278167778 -10800 # Node ID 254d81c0e7508f33145ca2c6659c7a97f08afe3c # Parent 240177dc47d78bcf21daf1ab459c0ca903cae0e1 Fix setting colors on MS-DOS frames. msdos.c (IT_set_frame_parameters): Fix setting of colors in frames other than the initial one. Fix reversal of colors when `reverse' is specified in the frame parameters. Call update_face_from_frame_parameter instead of internal-set-lisp-face-attribute. Initialize screen colors from initial_screen_colors[] when f->default_face_done_p is zero, instead of depending on being called with default-frame-alist as the alist argument. xfaces.c (update_face_from_frame_parameter): Move out of HAVE_WINDOW_SYSTEM portion. Condition window-system only parts with HAVE_WINDOW_SYSTEM. diff -r 240177dc47d7 -r 254d81c0e750 src/ChangeLog --- a/src/ChangeLog Sat Jul 03 14:54:21 2010 +0300 +++ b/src/ChangeLog Sat Jul 03 17:36:18 2010 +0300 @@ -1,5 +1,18 @@ 2010-07-03 Eli Zaretskii + * msdos.c (IT_set_frame_parameters): Fix setting of colors in + frames other than the initial one. Fix reversal of colors when + `reverse' is specified in the frame parameters. Call + update_face_from_frame_parameter instead of + internal-set-lisp-face-attribute. Initialize screen colors from + initial_screen_colors[] when f->default_face_done_p is zero, + instead of depending on being called with default-frame-alist as + the alist argument. + + * xfaces.c (update_face_from_frame_parameter): Move out of + HAVE_WINDOW_SYSTEM portion. Condition window-system only parts + with HAVE_WINDOW_SYSTEM. + * msdos.c (IT_set_frame_parameters): Set menu-bar-lines according to menu-bar-mode, if not set in the frame parameters or in default-frame-alist. diff -r 240177dc47d7 -r 254d81c0e750 src/msdos.c --- a/src/msdos.c Sat Jul 03 14:54:21 2010 +0300 +++ b/src/msdos.c Sat Jul 03 17:36:18 2010 +0300 @@ -2092,11 +2092,9 @@ = (Lisp_Object *) alloca (length * sizeof (Lisp_Object)); /* Do we have to reverse the foreground and background colors? */ int reverse = EQ (Fcdr (Fassq (Qreverse, f->param_alist)), Qt); - int need_to_reverse, was_reverse = reverse; int redraw = 0, fg_set = 0, bg_set = 0; unsigned long orig_fg, orig_bg; Lisp_Object frame_bg, frame_fg; - extern Lisp_Object Qdefault, QCforeground, QCbackground; struct tty_display_info *tty = FRAME_TTY (f); extern Lisp_Object Qmenu_bar_lines; extern Lisp_Object Vmenu_bar_mode; @@ -2105,24 +2103,16 @@ /* If we are creating a new frame, begin with the original screen colors used for the initial frame. */ - if (EQ (alist, Vdefault_frame_alist) + if (!f->default_face_done_p && 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]; init_frame_faces (f); + f->default_face_done_p = 1; } - orig_fg = FRAME_FOREGROUND_PIXEL (f); - orig_bg = FRAME_BACKGROUND_PIXEL (f); - frame_fg = Fcdr (Fassq (Qforeground_color, f->param_alist)); - frame_bg = Fcdr (Fassq (Qbackground_color, f->param_alist)); - /* frame_fg and frame_bg could be nil if, for example, - f->param_alist is nil, e.g. if we are called from - Fmake_terminal_frame. */ - if (NILP (frame_fg)) - frame_fg = build_string (unspecified_fg); - if (NILP (frame_bg)) - frame_bg = build_string (unspecified_bg); + orig_fg = reverse ? FRAME_BACKGROUND_PIXEL (f) : FRAME_FOREGROUND_PIXEL (f); + orig_bg = reverse ? FRAME_FOREGROUND_PIXEL (f) : FRAME_BACKGROUND_PIXEL (f); /* Extract parm names and values into those vectors. */ i = 0; @@ -2152,58 +2142,75 @@ menu_bar_lines_defined = 1; } - need_to_reverse = reverse && !was_reverse; - if (tty->termscript && need_to_reverse) + if (tty->termscript && reverse) fprintf (tty->termscript, "\n"); /* Now process the alist elements in reverse of specified order. */ for (i--; i >= 0; i--) { - Lisp_Object prop, val, frame; + Lisp_Object prop, val; prop = parms[i]; val = values[i]; if (EQ (prop, Qforeground_color)) { - unsigned long new_color = load_color (f, NULL, val, need_to_reverse + unsigned long new_color = load_color (f, NULL, val, reverse ? LFACE_BACKGROUND_INDEX : LFACE_FOREGROUND_INDEX); if (new_color != FACE_TTY_DEFAULT_COLOR && new_color != FACE_TTY_DEFAULT_FG_COLOR && new_color != FACE_TTY_DEFAULT_BG_COLOR) { - FRAME_FOREGROUND_PIXEL (f) = new_color; - /* Make sure the foreground of the default face for this - frame is changed as well. */ - XSETFRAME (frame, f); - Finternal_set_lisp_face_attribute (Qdefault, QCforeground, - val, frame); - fg_set = 1; + if (!reverse) + { + FRAME_FOREGROUND_PIXEL (f) = new_color; + /* Make sure the foreground of the default face for + this frame is changed as well. */ + update_face_from_frame_parameter (f, Qforeground_color, val); + fg_set = 1; + if (tty->termscript) + fprintf (tty->termscript, "\n", new_color); + } + else + { + FRAME_BACKGROUND_PIXEL (f) = new_color; + update_face_from_frame_parameter (f, Qbackground_color, val); + bg_set = 1; + if (tty->termscript) + fprintf (tty->termscript, "\n", new_color); + } redraw = 1; - if (tty->termscript) - fprintf (tty->termscript, "\n", new_color); } } else if (EQ (prop, Qbackground_color)) { - unsigned long new_color = load_color (f, NULL, val, need_to_reverse + unsigned long new_color = load_color (f, NULL, val, reverse ? LFACE_FOREGROUND_INDEX : LFACE_BACKGROUND_INDEX); if (new_color != FACE_TTY_DEFAULT_COLOR && new_color != FACE_TTY_DEFAULT_FG_COLOR && new_color != FACE_TTY_DEFAULT_BG_COLOR) { - FRAME_BACKGROUND_PIXEL (f) = new_color; - /* Make sure the background of the default face for this - frame is changed as well. */ - XSETFRAME (frame, f); - Finternal_set_lisp_face_attribute (Qdefault, QCbackground, - val, frame); - bg_set = 1; + if (!reverse) + { + FRAME_BACKGROUND_PIXEL (f) = new_color; + /* Make sure the background of the default face for + this frame is changed as well. */ + bg_set = 1; + update_face_from_frame_parameter (f, Qbackground_color, val); + if (tty->termscript) + fprintf (tty->termscript, "\n", new_color); + } + else + { + FRAME_FOREGROUND_PIXEL (f) = new_color; + fg_set = 1; + update_face_from_frame_parameter (f, Qforeground_color, val); + if (tty->termscript) + fprintf (tty->termscript, "\n", new_color); + } redraw = 1; - if (tty->termscript) - fprintf (tty->termscript, "\n", new_color); } } else if (EQ (prop, Qtitle)) @@ -2246,24 +2253,22 @@ /* If they specified "reverse", but not the colors, we need to swap the current frame colors. */ - if (need_to_reverse) + if (reverse) { Lisp_Object frame; if (!fg_set) { - XSETFRAME (frame, f); - Finternal_set_lisp_face_attribute (Qdefault, QCforeground, - tty_color_name (f, orig_bg), - frame); + FRAME_FOREGROUND_PIXEL (f) = orig_bg; + update_face_from_frame_parameter (f, Qforeground_color, + tty_color_name (f, orig_bg)); redraw = 1; } if (!bg_set) { - XSETFRAME (frame, f); - Finternal_set_lisp_face_attribute (Qdefault, QCbackground, - tty_color_name (f, orig_fg), - frame); + FRAME_BACKGROUND_PIXEL (f) = orig_fg; + update_face_from_frame_parameter (f, Qbackground_color, + tty_color_name (f, orig_fg)); redraw = 1; } } diff -r 240177dc47d7 -r 254d81c0e750 src/xfaces.c --- a/src/xfaces.c Sat Jul 03 14:54:21 2010 +0300 +++ b/src/xfaces.c Sat Jul 03 17:36:18 2010 +0300 @@ -3490,37 +3490,6 @@ } -#ifdef HAVE_WINDOW_SYSTEM - -/* Set the `font' frame parameter of FRAME determined from the - font-object set in `default' face attributes LFACE. */ - -static void -set_font_frame_param (frame, lface) - Lisp_Object frame, lface; -{ - struct frame *f = XFRAME (frame); - Lisp_Object font; - - if (FRAME_WINDOW_P (f) - /* Don't do anything if the font is `unspecified'. This can - happen during frame creation. */ - && (font = LFACE_FONT (lface), - ! UNSPECIFIEDP (font))) - { - if (FONT_SPEC_P (font)) - { - font = font_load_for_lface (f, XVECTOR (lface)->contents, font); - if (NILP (font)) - return; - LFACE_FONT (lface) = font; - } - f->default_face_done_p = 0; - Fmodify_frame_parameters (frame, Fcons (Fcons (Qfont, font), Qnil)); - } -} - - /* Update the corresponding face when frame parameter PARAM on frame F has been assigned the value NEW_VALUE. */ @@ -3562,6 +3531,7 @@ ? new_value : Qunspecified); realize_basic_faces (f); } +#ifdef HAVE_WINDOW_SYSTEM else if (EQ (param, Qborder_color)) { face = Qborder; @@ -3583,6 +3553,7 @@ LFACE_BACKGROUND (lface) = (STRINGP (new_value) ? new_value : Qunspecified); } +#endif /* Changing a named face means that all realized faces depending on that face are invalid. Since we cannot tell which realized faces @@ -3598,6 +3569,37 @@ } +#ifdef HAVE_WINDOW_SYSTEM + +/* Set the `font' frame parameter of FRAME determined from the + font-object set in `default' face attributes LFACE. */ + +static void +set_font_frame_param (frame, lface) + Lisp_Object frame, lface; +{ + struct frame *f = XFRAME (frame); + Lisp_Object font; + + if (FRAME_WINDOW_P (f) + /* Don't do anything if the font is `unspecified'. This can + happen during frame creation. */ + && (font = LFACE_FONT (lface), + ! UNSPECIFIEDP (font))) + { + if (FONT_SPEC_P (font)) + { + font = font_load_for_lface (f, XVECTOR (lface)->contents, font); + if (NILP (font)) + return; + LFACE_FONT (lface) = font; + } + f->default_face_done_p = 0; + Fmodify_frame_parameters (frame, Fcons (Fcons (Qfont, font), Qnil)); + } +} + + /* Get the value of X resource RESOURCE, class CLASS for the display of frame FRAME. This is here because ordinary `x-get-resource' doesn't take a frame argument. */