Commit f4e8a59c authored by Eli Zaretskii's avatar Eli Zaretskii
Browse files

Fix menu bar and colors on MS-DOS.

 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.  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.
parents a52a00a3 76ea4cc9
2010-07-03 Eli Zaretskii <eliz@gnu.org> 2010-07-03 Eli Zaretskii <eliz@gnu.org>
   
* 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.
* w32console.c (sys_tputs): Adjust argument list to prototype in * w32console.c (sys_tputs): Adjust argument list to prototype in
term.c. term.c.
   
......
...@@ -2092,33 +2092,27 @@ IT_set_frame_parameters (f, alist) ...@@ -2092,33 +2092,27 @@ IT_set_frame_parameters (f, alist)
= (Lisp_Object *) alloca (length * sizeof (Lisp_Object)); = (Lisp_Object *) alloca (length * sizeof (Lisp_Object));
/* Do we have to reverse the foreground and background colors? */ /* Do we have to reverse the foreground and background colors? */
int reverse = EQ (Fcdr (Fassq (Qreverse, f->param_alist)), Qt); 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; int redraw = 0, fg_set = 0, bg_set = 0;
unsigned long orig_fg, orig_bg; unsigned long orig_fg, orig_bg;
Lisp_Object frame_bg, frame_fg; Lisp_Object frame_bg, frame_fg;
extern Lisp_Object Qdefault, QCforeground, QCbackground;
struct tty_display_info *tty = FRAME_TTY (f); struct tty_display_info *tty = FRAME_TTY (f);
extern Lisp_Object Qmenu_bar_lines;
extern Lisp_Object Vmenu_bar_mode;
int menu_bar_lines_defined =
!NILP (Fassq (Qmenu_bar_lines, Vdefault_frame_alist));
/* If we are creating a new frame, begin with the original screen colors /* If we are creating a new frame, begin with the original screen colors
used for the initial frame. */ 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) && initial_screen_colors[0] != -1 && initial_screen_colors[1] != -1)
{ {
FRAME_FOREGROUND_PIXEL (f) = initial_screen_colors[0]; FRAME_FOREGROUND_PIXEL (f) = initial_screen_colors[0];
FRAME_BACKGROUND_PIXEL (f) = initial_screen_colors[1]; FRAME_BACKGROUND_PIXEL (f) = initial_screen_colors[1];
init_frame_faces (f); init_frame_faces (f);
f->default_face_done_p = 1;
} }
orig_fg = FRAME_FOREGROUND_PIXEL (f); orig_fg = reverse ? FRAME_BACKGROUND_PIXEL (f) : FRAME_FOREGROUND_PIXEL (f);
orig_bg = FRAME_BACKGROUND_PIXEL (f); orig_bg = reverse ? FRAME_FOREGROUND_PIXEL (f) : 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);
/* Extract parm names and values into those vectors. */ /* Extract parm names and values into those vectors. */
i = 0; i = 0;
...@@ -2144,60 +2138,79 @@ IT_set_frame_parameters (f, alist) ...@@ -2144,60 +2138,79 @@ IT_set_frame_parameters (f, alist)
if (EQ (prop, Qreverse)) if (EQ (prop, Qreverse))
reverse = EQ (val, Qt); reverse = EQ (val, Qt);
else if (!menu_bar_lines_defined && EQ (prop, Qmenu_bar_lines))
menu_bar_lines_defined = 1;
} }
need_to_reverse = reverse && !was_reverse; if (tty->termscript && reverse)
if (tty->termscript && need_to_reverse)
fprintf (tty->termscript, "<INVERSE-VIDEO>\n"); fprintf (tty->termscript, "<INVERSE-VIDEO>\n");
/* Now process the alist elements in reverse of specified order. */ /* Now process the alist elements in reverse of specified order. */
for (i--; i >= 0; i--) for (i--; i >= 0; i--)
{ {
Lisp_Object prop, val, frame; Lisp_Object prop, val;
prop = parms[i]; prop = parms[i];
val = values[i]; val = values[i];
if (EQ (prop, Qforeground_color)) 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_BACKGROUND_INDEX
: LFACE_FOREGROUND_INDEX); : LFACE_FOREGROUND_INDEX);
if (new_color != FACE_TTY_DEFAULT_COLOR if (new_color != FACE_TTY_DEFAULT_COLOR
&& new_color != FACE_TTY_DEFAULT_FG_COLOR && new_color != FACE_TTY_DEFAULT_FG_COLOR
&& new_color != FACE_TTY_DEFAULT_BG_COLOR) && new_color != FACE_TTY_DEFAULT_BG_COLOR)
{ {
FRAME_FOREGROUND_PIXEL (f) = new_color; if (!reverse)
/* Make sure the foreground of the default face for this {
frame is changed as well. */ FRAME_FOREGROUND_PIXEL (f) = new_color;
XSETFRAME (frame, f); /* Make sure the foreground of the default face for
Finternal_set_lisp_face_attribute (Qdefault, QCforeground, this frame is changed as well. */
val, frame); update_face_from_frame_parameter (f, Qforeground_color, val);
fg_set = 1; fg_set = 1;
if (tty->termscript)
fprintf (tty->termscript, "<FGCOLOR %lu>\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, "<BGCOLOR %lu>\n", new_color);
}
redraw = 1; redraw = 1;
if (tty->termscript)
fprintf (tty->termscript, "<FGCOLOR %lu>\n", new_color);
} }
} }
else if (EQ (prop, Qbackground_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_FOREGROUND_INDEX
: LFACE_BACKGROUND_INDEX); : LFACE_BACKGROUND_INDEX);
if (new_color != FACE_TTY_DEFAULT_COLOR if (new_color != FACE_TTY_DEFAULT_COLOR
&& new_color != FACE_TTY_DEFAULT_FG_COLOR && new_color != FACE_TTY_DEFAULT_FG_COLOR
&& new_color != FACE_TTY_DEFAULT_BG_COLOR) && new_color != FACE_TTY_DEFAULT_BG_COLOR)
{ {
FRAME_BACKGROUND_PIXEL (f) = new_color; if (!reverse)
/* Make sure the background of the default face for this {
frame is changed as well. */ FRAME_BACKGROUND_PIXEL (f) = new_color;
XSETFRAME (frame, f); /* Make sure the background of the default face for
Finternal_set_lisp_face_attribute (Qdefault, QCbackground, this frame is changed as well. */
val, frame); bg_set = 1;
bg_set = 1; update_face_from_frame_parameter (f, Qbackground_color, val);
if (tty->termscript)
fprintf (tty->termscript, "<BGCOLOR %lu>\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, "<FGCOLOR %lu>\n", new_color);
}
redraw = 1; redraw = 1;
if (tty->termscript)
fprintf (tty->termscript, "<BGCOLOR %lu>\n", new_color);
} }
} }
else if (EQ (prop, Qtitle)) else if (EQ (prop, Qtitle))
...@@ -2226,26 +2239,36 @@ IT_set_frame_parameters (f, alist) ...@@ -2226,26 +2239,36 @@ IT_set_frame_parameters (f, alist)
store_frame_param (f, prop, val); store_frame_param (f, prop, val);
} }
/* If menu-bar-lines is neither in the frame parameters nor in
default-frame-alist, set it according to menu-bar-mode. */
if (!menu_bar_lines_defined)
{
store_frame_param (f, Qmenu_bar_lines,
NILP (Vmenu_bar_mode)
? make_number (0) : make_number (1));
if (tty->termscript)
fprintf (tty->termscript, "<MENU BAR LINES DEFAULTED: %d\n",
!NILP (Vmenu_bar_mode));
}
/* If they specified "reverse", but not the colors, we need to swap /* If they specified "reverse", but not the colors, we need to swap
the current frame colors. */ the current frame colors. */
if (need_to_reverse) if (reverse)
{ {
Lisp_Object frame; Lisp_Object frame;
if (!fg_set) if (!fg_set)
{ {
XSETFRAME (frame, f); FRAME_FOREGROUND_PIXEL (f) = orig_bg;
Finternal_set_lisp_face_attribute (Qdefault, QCforeground, update_face_from_frame_parameter (f, Qforeground_color,
tty_color_name (f, orig_bg), tty_color_name (f, orig_bg));
frame);
redraw = 1; redraw = 1;
} }
if (!bg_set) if (!bg_set)
{ {
XSETFRAME (frame, f); FRAME_BACKGROUND_PIXEL (f) = orig_fg;
Finternal_set_lisp_face_attribute (Qdefault, QCbackground, update_face_from_frame_parameter (f, Qbackground_color,
tty_color_name (f, orig_fg), tty_color_name (f, orig_fg));
frame);
redraw = 1; redraw = 1;
} }
} }
......
...@@ -3490,37 +3490,6 @@ FRAME 0 means change the face on all frames, and change the default ...@@ -3490,37 +3490,6 @@ FRAME 0 means change the face on all frames, and change the default
} }
#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 /* Update the corresponding face when frame parameter PARAM on frame F
has been assigned the value NEW_VALUE. */ has been assigned the value NEW_VALUE. */
...@@ -3562,6 +3531,7 @@ update_face_from_frame_parameter (f, param, new_value) ...@@ -3562,6 +3531,7 @@ update_face_from_frame_parameter (f, param, new_value)
? new_value : Qunspecified); ? new_value : Qunspecified);
realize_basic_faces (f); realize_basic_faces (f);
} }
#ifdef HAVE_WINDOW_SYSTEM
else if (EQ (param, Qborder_color)) else if (EQ (param, Qborder_color))
{ {
face = Qborder; face = Qborder;
...@@ -3583,6 +3553,7 @@ update_face_from_frame_parameter (f, param, new_value) ...@@ -3583,6 +3553,7 @@ update_face_from_frame_parameter (f, param, new_value)
LFACE_BACKGROUND (lface) = (STRINGP (new_value) LFACE_BACKGROUND (lface) = (STRINGP (new_value)
? new_value : Qunspecified); ? new_value : Qunspecified);
} }
#endif
/* Changing a named face means that all realized faces depending on /* Changing a named face means that all realized faces depending on
that face are invalid. Since we cannot tell which realized faces that face are invalid. Since we cannot tell which realized faces
...@@ -3598,6 +3569,37 @@ update_face_from_frame_parameter (f, param, new_value) ...@@ -3598,6 +3569,37 @@ update_face_from_frame_parameter (f, param, new_value)
} }
#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 /* Get the value of X resource RESOURCE, class CLASS for the display
of frame FRAME. This is here because ordinary `x-get-resource' of frame FRAME. This is here because ordinary `x-get-resource'
doesn't take a frame argument. */ doesn't take a frame argument. */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment