aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorEli Zaretskii2010-07-03 17:36:18 +0300
committerEli Zaretskii2010-07-03 17:36:18 +0300
commit76ea4cc96bbf9db3ed9c0f6785c85f1880c61c08 (patch)
treeb7f8eae2b189a6335f0b0c0b6b307d9d8b65c112 /src
parent1e6255ae888ffbee3a713c7d7fb41b8d6480ddb4 (diff)
downloademacs-76ea4cc96bbf9db3ed9c0f6785c85f1880c61c08.tar.gz
emacs-76ea4cc96bbf9db3ed9c0f6785c85f1880c61c08.zip
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.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog13
-rw-r--r--src/msdos.c97
-rw-r--r--src/xfaces.c64
3 files changed, 97 insertions, 77 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index c79c40e3b09..63bd31f5c83 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,5 +1,18 @@
12010-07-03 Eli Zaretskii <eliz@gnu.org> 12010-07-03 Eli Zaretskii <eliz@gnu.org>
2 2
3 * msdos.c (IT_set_frame_parameters): Fix setting of colors in
4 frames other than the initial one. Fix reversal of colors when
5 `reverse' is specified in the frame parameters. Call
6 update_face_from_frame_parameter instead of
7 internal-set-lisp-face-attribute. Initialize screen colors from
8 initial_screen_colors[] when f->default_face_done_p is zero,
9 instead of depending on being called with default-frame-alist as
10 the alist argument.
11
12 * xfaces.c (update_face_from_frame_parameter): Move out of
13 HAVE_WINDOW_SYSTEM portion. Condition window-system only parts
14 with HAVE_WINDOW_SYSTEM.
15
3 * msdos.c (IT_set_frame_parameters): Set menu-bar-lines according 16 * msdos.c (IT_set_frame_parameters): Set menu-bar-lines according
4 to menu-bar-mode, if not set in the frame parameters or in 17 to menu-bar-mode, if not set in the frame parameters or in
5 default-frame-alist. 18 default-frame-alist.
diff --git a/src/msdos.c b/src/msdos.c
index cca0b2e68b9..3e95978d58e 100644
--- a/src/msdos.c
+++ b/src/msdos.c
@@ -2092,11 +2092,9 @@ IT_set_frame_parameters (f, alist)
2092 = (Lisp_Object *) alloca (length * sizeof (Lisp_Object)); 2092 = (Lisp_Object *) alloca (length * sizeof (Lisp_Object));
2093 /* Do we have to reverse the foreground and background colors? */ 2093 /* Do we have to reverse the foreground and background colors? */
2094 int reverse = EQ (Fcdr (Fassq (Qreverse, f->param_alist)), Qt); 2094 int reverse = EQ (Fcdr (Fassq (Qreverse, f->param_alist)), Qt);
2095 int need_to_reverse, was_reverse = reverse;
2096 int redraw = 0, fg_set = 0, bg_set = 0; 2095 int redraw = 0, fg_set = 0, bg_set = 0;
2097 unsigned long orig_fg, orig_bg; 2096 unsigned long orig_fg, orig_bg;
2098 Lisp_Object frame_bg, frame_fg; 2097 Lisp_Object frame_bg, frame_fg;
2099 extern Lisp_Object Qdefault, QCforeground, QCbackground;
2100 struct tty_display_info *tty = FRAME_TTY (f); 2098 struct tty_display_info *tty = FRAME_TTY (f);
2101 extern Lisp_Object Qmenu_bar_lines; 2099 extern Lisp_Object Qmenu_bar_lines;
2102 extern Lisp_Object Vmenu_bar_mode; 2100 extern Lisp_Object Vmenu_bar_mode;
@@ -2105,24 +2103,16 @@ IT_set_frame_parameters (f, alist)
2105 2103
2106 /* If we are creating a new frame, begin with the original screen colors 2104 /* If we are creating a new frame, begin with the original screen colors
2107 used for the initial frame. */ 2105 used for the initial frame. */
2108 if (EQ (alist, Vdefault_frame_alist) 2106 if (!f->default_face_done_p
2109 && initial_screen_colors[0] != -1 && initial_screen_colors[1] != -1) 2107 && initial_screen_colors[0] != -1 && initial_screen_colors[1] != -1)
2110 { 2108 {
2111 FRAME_FOREGROUND_PIXEL (f) = initial_screen_colors[0]; 2109 FRAME_FOREGROUND_PIXEL (f) = initial_screen_colors[0];
2112 FRAME_BACKGROUND_PIXEL (f) = initial_screen_colors[1]; 2110 FRAME_BACKGROUND_PIXEL (f) = initial_screen_colors[1];
2113 init_frame_faces (f); 2111 init_frame_faces (f);
2112 f->default_face_done_p = 1;
2114 } 2113 }
2115 orig_fg = FRAME_FOREGROUND_PIXEL (f); 2114 orig_fg = reverse ? FRAME_BACKGROUND_PIXEL (f) : FRAME_FOREGROUND_PIXEL (f);
2116 orig_bg = FRAME_BACKGROUND_PIXEL (f); 2115 orig_bg = reverse ? FRAME_FOREGROUND_PIXEL (f) : FRAME_BACKGROUND_PIXEL (f);
2117 frame_fg = Fcdr (Fassq (Qforeground_color, f->param_alist));
2118 frame_bg = Fcdr (Fassq (Qbackground_color, f->param_alist));
2119 /* frame_fg and frame_bg could be nil if, for example,
2120 f->param_alist is nil, e.g. if we are called from
2121 Fmake_terminal_frame. */
2122 if (NILP (frame_fg))
2123 frame_fg = build_string (unspecified_fg);
2124 if (NILP (frame_bg))
2125 frame_bg = build_string (unspecified_bg);
2126 2116
2127 /* Extract parm names and values into those vectors. */ 2117 /* Extract parm names and values into those vectors. */
2128 i = 0; 2118 i = 0;
@@ -2152,58 +2142,75 @@ IT_set_frame_parameters (f, alist)
2152 menu_bar_lines_defined = 1; 2142 menu_bar_lines_defined = 1;
2153 } 2143 }
2154 2144
2155 need_to_reverse = reverse && !was_reverse; 2145 if (tty->termscript && reverse)
2156 if (tty->termscript && need_to_reverse)
2157 fprintf (tty->termscript, "<INVERSE-VIDEO>\n"); 2146 fprintf (tty->termscript, "<INVERSE-VIDEO>\n");
2158 2147
2159 /* Now process the alist elements in reverse of specified order. */ 2148 /* Now process the alist elements in reverse of specified order. */
2160 for (i--; i >= 0; i--) 2149 for (i--; i >= 0; i--)
2161 { 2150 {
2162 Lisp_Object prop, val, frame; 2151 Lisp_Object prop, val;
2163 2152
2164 prop = parms[i]; 2153 prop = parms[i];
2165 val = values[i]; 2154 val = values[i];
2166 2155
2167 if (EQ (prop, Qforeground_color)) 2156 if (EQ (prop, Qforeground_color))
2168 { 2157 {
2169 unsigned long new_color = load_color (f, NULL, val, need_to_reverse 2158 unsigned long new_color = load_color (f, NULL, val, reverse
2170 ? LFACE_BACKGROUND_INDEX 2159 ? LFACE_BACKGROUND_INDEX
2171 : LFACE_FOREGROUND_INDEX); 2160 : LFACE_FOREGROUND_INDEX);
2172 if (new_color != FACE_TTY_DEFAULT_COLOR 2161 if (new_color != FACE_TTY_DEFAULT_COLOR
2173 && new_color != FACE_TTY_DEFAULT_FG_COLOR 2162 && new_color != FACE_TTY_DEFAULT_FG_COLOR
2174 && new_color != FACE_TTY_DEFAULT_BG_COLOR) 2163 && new_color != FACE_TTY_DEFAULT_BG_COLOR)
2175 { 2164 {
2176 FRAME_FOREGROUND_PIXEL (f) = new_color; 2165 if (!reverse)
2177 /* Make sure the foreground of the default face for this 2166 {
2178 frame is changed as well. */ 2167 FRAME_FOREGROUND_PIXEL (f) = new_color;
2179 XSETFRAME (frame, f); 2168 /* Make sure the foreground of the default face for
2180 Finternal_set_lisp_face_attribute (Qdefault, QCforeground, 2169 this frame is changed as well. */
2181 val, frame); 2170 update_face_from_frame_parameter (f, Qforeground_color, val);
2182 fg_set = 1; 2171 fg_set = 1;
2172 if (tty->termscript)
2173 fprintf (tty->termscript, "<FGCOLOR %lu>\n", new_color);
2174 }
2175 else
2176 {
2177 FRAME_BACKGROUND_PIXEL (f) = new_color;
2178 update_face_from_frame_parameter (f, Qbackground_color, val);
2179 bg_set = 1;
2180 if (tty->termscript)
2181 fprintf (tty->termscript, "<BGCOLOR %lu>\n", new_color);
2182 }
2183 redraw = 1; 2183 redraw = 1;
2184 if (tty->termscript)
2185 fprintf (tty->termscript, "<FGCOLOR %lu>\n", new_color);
2186 } 2184 }
2187 } 2185 }
2188 else if (EQ (prop, Qbackground_color)) 2186 else if (EQ (prop, Qbackground_color))
2189 { 2187 {
2190 unsigned long new_color = load_color (f, NULL, val, need_to_reverse 2188 unsigned long new_color = load_color (f, NULL, val, reverse
2191 ? LFACE_FOREGROUND_INDEX 2189 ? LFACE_FOREGROUND_INDEX
2192 : LFACE_BACKGROUND_INDEX); 2190 : LFACE_BACKGROUND_INDEX);
2193 if (new_color != FACE_TTY_DEFAULT_COLOR 2191 if (new_color != FACE_TTY_DEFAULT_COLOR
2194 && new_color != FACE_TTY_DEFAULT_FG_COLOR 2192 && new_color != FACE_TTY_DEFAULT_FG_COLOR
2195 && new_color != FACE_TTY_DEFAULT_BG_COLOR) 2193 && new_color != FACE_TTY_DEFAULT_BG_COLOR)
2196 { 2194 {
2197 FRAME_BACKGROUND_PIXEL (f) = new_color; 2195 if (!reverse)
2198 /* Make sure the background of the default face for this 2196 {
2199 frame is changed as well. */ 2197 FRAME_BACKGROUND_PIXEL (f) = new_color;
2200 XSETFRAME (frame, f); 2198 /* Make sure the background of the default face for
2201 Finternal_set_lisp_face_attribute (Qdefault, QCbackground, 2199 this frame is changed as well. */
2202 val, frame); 2200 bg_set = 1;
2203 bg_set = 1; 2201 update_face_from_frame_parameter (f, Qbackground_color, val);
2202 if (tty->termscript)
2203 fprintf (tty->termscript, "<BGCOLOR %lu>\n", new_color);
2204 }
2205 else
2206 {
2207 FRAME_FOREGROUND_PIXEL (f) = new_color;
2208 fg_set = 1;
2209 update_face_from_frame_parameter (f, Qforeground_color, val);
2210 if (tty->termscript)
2211 fprintf (tty->termscript, "<FGCOLOR %lu>\n", new_color);
2212 }
2204 redraw = 1; 2213 redraw = 1;
2205 if (tty->termscript)
2206 fprintf (tty->termscript, "<BGCOLOR %lu>\n", new_color);
2207 } 2214 }
2208 } 2215 }
2209 else if (EQ (prop, Qtitle)) 2216 else if (EQ (prop, Qtitle))
@@ -2246,24 +2253,22 @@ IT_set_frame_parameters (f, alist)
2246 2253
2247 /* If they specified "reverse", but not the colors, we need to swap 2254 /* If they specified "reverse", but not the colors, we need to swap
2248 the current frame colors. */ 2255 the current frame colors. */
2249 if (need_to_reverse) 2256 if (reverse)
2250 { 2257 {
2251 Lisp_Object frame; 2258 Lisp_Object frame;
2252 2259
2253 if (!fg_set) 2260 if (!fg_set)
2254 { 2261 {
2255 XSETFRAME (frame, f); 2262 FRAME_FOREGROUND_PIXEL (f) = orig_bg;
2256 Finternal_set_lisp_face_attribute (Qdefault, QCforeground, 2263 update_face_from_frame_parameter (f, Qforeground_color,
2257 tty_color_name (f, orig_bg), 2264 tty_color_name (f, orig_bg));
2258 frame);
2259 redraw = 1; 2265 redraw = 1;
2260 } 2266 }
2261 if (!bg_set) 2267 if (!bg_set)
2262 { 2268 {
2263 XSETFRAME (frame, f); 2269 FRAME_BACKGROUND_PIXEL (f) = orig_fg;
2264 Finternal_set_lisp_face_attribute (Qdefault, QCbackground, 2270 update_face_from_frame_parameter (f, Qbackground_color,
2265 tty_color_name (f, orig_fg), 2271 tty_color_name (f, orig_fg));
2266 frame);
2267 redraw = 1; 2272 redraw = 1;
2268 } 2273 }
2269 } 2274 }
diff --git a/src/xfaces.c b/src/xfaces.c
index 714b07c0800..79eb20febc0 100644
--- a/src/xfaces.c
+++ b/src/xfaces.c
@@ -3490,37 +3490,6 @@ FRAME 0 means change the face on all frames, and change the default
3490} 3490}
3491 3491
3492 3492
3493#ifdef HAVE_WINDOW_SYSTEM
3494
3495/* Set the `font' frame parameter of FRAME determined from the
3496 font-object set in `default' face attributes LFACE. */
3497
3498static void
3499set_font_frame_param (frame, lface)
3500 Lisp_Object frame, lface;
3501{
3502 struct frame *f = XFRAME (frame);
3503 Lisp_Object font;
3504
3505 if (FRAME_WINDOW_P (f)
3506 /* Don't do anything if the font is `unspecified'. This can
3507 happen during frame creation. */
3508 && (font = LFACE_FONT (lface),
3509 ! UNSPECIFIEDP (font)))
3510 {
3511 if (FONT_SPEC_P (font))
3512 {
3513 font = font_load_for_lface (f, XVECTOR (lface)->contents, font);
3514 if (NILP (font))
3515 return;
3516 LFACE_FONT (lface) = font;
3517 }
3518 f->default_face_done_p = 0;
3519 Fmodify_frame_parameters (frame, Fcons (Fcons (Qfont, font), Qnil));
3520 }
3521}
3522
3523
3524/* Update the corresponding face when frame parameter PARAM on frame F 3493/* Update the corresponding face when frame parameter PARAM on frame F
3525 has been assigned the value NEW_VALUE. */ 3494 has been assigned the value NEW_VALUE. */
3526 3495
@@ -3562,6 +3531,7 @@ update_face_from_frame_parameter (f, param, new_value)
3562 ? new_value : Qunspecified); 3531 ? new_value : Qunspecified);
3563 realize_basic_faces (f); 3532 realize_basic_faces (f);
3564 } 3533 }
3534#ifdef HAVE_WINDOW_SYSTEM
3565 else if (EQ (param, Qborder_color)) 3535 else if (EQ (param, Qborder_color))
3566 { 3536 {
3567 face = Qborder; 3537 face = Qborder;
@@ -3583,6 +3553,7 @@ update_face_from_frame_parameter (f, param, new_value)
3583 LFACE_BACKGROUND (lface) = (STRINGP (new_value) 3553 LFACE_BACKGROUND (lface) = (STRINGP (new_value)
3584 ? new_value : Qunspecified); 3554 ? new_value : Qunspecified);
3585 } 3555 }
3556#endif
3586 3557
3587 /* Changing a named face means that all realized faces depending on 3558 /* Changing a named face means that all realized faces depending on
3588 that face are invalid. Since we cannot tell which realized faces 3559 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} 3569}
3599 3570
3600 3571
3572#ifdef HAVE_WINDOW_SYSTEM
3573
3574/* Set the `font' frame parameter of FRAME determined from the
3575 font-object set in `default' face attributes LFACE. */
3576
3577static void
3578set_font_frame_param (frame, lface)
3579 Lisp_Object frame, lface;
3580{
3581 struct frame *f = XFRAME (frame);
3582 Lisp_Object font;
3583
3584 if (FRAME_WINDOW_P (f)
3585 /* Don't do anything if the font is `unspecified'. This can
3586 happen during frame creation. */
3587 && (font = LFACE_FONT (lface),
3588 ! UNSPECIFIEDP (font)))
3589 {
3590 if (FONT_SPEC_P (font))
3591 {
3592 font = font_load_for_lface (f, XVECTOR (lface)->contents, font);
3593 if (NILP (font))
3594 return;
3595 LFACE_FONT (lface) = font;
3596 }
3597 f->default_face_done_p = 0;
3598 Fmodify_frame_parameters (frame, Fcons (Fcons (Qfont, font), Qnil));
3599 }
3600}
3601
3602
3601/* Get the value of X resource RESOURCE, class CLASS for the display 3603/* Get the value of X resource RESOURCE, class CLASS for the display
3602 of frame FRAME. This is here because ordinary `x-get-resource' 3604 of frame FRAME. This is here because ordinary `x-get-resource'
3603 doesn't take a frame argument. */ 3605 doesn't take a frame argument. */