diff options
| author | Eli Zaretskii | 2010-07-03 17:42:02 +0300 |
|---|---|---|
| committer | Eli Zaretskii | 2010-07-03 17:42:02 +0300 |
| commit | f4e8a59cc198809f258d46c4af161dbf452c56c3 (patch) | |
| tree | fefd449863aa84c249d4097a29fd3bd37a6e7db6 /src | |
| parent | a52a00a3d745844419d93209ddec1c4236aed22a (diff) | |
| parent | 76ea4cc96bbf9db3ed9c0f6785c85f1880c61c08 (diff) | |
| download | emacs-f4e8a59cc198809f258d46c4af161dbf452c56c3.tar.gz emacs-f4e8a59cc198809f258d46c4af161dbf452c56c3.zip | |
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.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 17 | ||||
| -rw-r--r-- | src/msdos.c | 115 | ||||
| -rw-r--r-- | src/xfaces.c | 64 |
3 files changed, 119 insertions, 77 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 68e3d7aae4e..63bd31f5c83 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,5 +1,22 @@ | |||
| 1 | 2010-07-03 Eli Zaretskii <eliz@gnu.org> | 1 | 2010-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 | |||
| 16 | * msdos.c (IT_set_frame_parameters): Set menu-bar-lines according | ||
| 17 | to menu-bar-mode, if not set in the frame parameters or in | ||
| 18 | default-frame-alist. | ||
| 19 | |||
| 3 | * w32console.c (sys_tputs): Adjust argument list to prototype in | 20 | * w32console.c (sys_tputs): Adjust argument list to prototype in |
| 4 | term.c. | 21 | term.c. |
| 5 | 22 | ||
diff --git a/src/msdos.c b/src/msdos.c index ea604d29992..3e95978d58e 100644 --- a/src/msdos.c +++ b/src/msdos.c | |||
| @@ -2092,33 +2092,27 @@ 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); |
| 2099 | extern Lisp_Object Qmenu_bar_lines; | ||
| 2100 | extern Lisp_Object Vmenu_bar_mode; | ||
| 2101 | int menu_bar_lines_defined = | ||
| 2102 | !NILP (Fassq (Qmenu_bar_lines, Vdefault_frame_alist)); | ||
| 2101 | 2103 | ||
| 2102 | /* 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 |
| 2103 | used for the initial frame. */ | 2105 | used for the initial frame. */ |
| 2104 | if (EQ (alist, Vdefault_frame_alist) | 2106 | if (!f->default_face_done_p |
| 2105 | && initial_screen_colors[0] != -1 && initial_screen_colors[1] != -1) | 2107 | && initial_screen_colors[0] != -1 && initial_screen_colors[1] != -1) |
| 2106 | { | 2108 | { |
| 2107 | FRAME_FOREGROUND_PIXEL (f) = initial_screen_colors[0]; | 2109 | FRAME_FOREGROUND_PIXEL (f) = initial_screen_colors[0]; |
| 2108 | FRAME_BACKGROUND_PIXEL (f) = initial_screen_colors[1]; | 2110 | FRAME_BACKGROUND_PIXEL (f) = initial_screen_colors[1]; |
| 2109 | init_frame_faces (f); | 2111 | init_frame_faces (f); |
| 2112 | f->default_face_done_p = 1; | ||
| 2110 | } | 2113 | } |
| 2111 | orig_fg = FRAME_FOREGROUND_PIXEL (f); | 2114 | orig_fg = reverse ? FRAME_BACKGROUND_PIXEL (f) : FRAME_FOREGROUND_PIXEL (f); |
| 2112 | orig_bg = FRAME_BACKGROUND_PIXEL (f); | 2115 | orig_bg = reverse ? FRAME_FOREGROUND_PIXEL (f) : FRAME_BACKGROUND_PIXEL (f); |
| 2113 | frame_fg = Fcdr (Fassq (Qforeground_color, f->param_alist)); | ||
| 2114 | frame_bg = Fcdr (Fassq (Qbackground_color, f->param_alist)); | ||
| 2115 | /* frame_fg and frame_bg could be nil if, for example, | ||
| 2116 | f->param_alist is nil, e.g. if we are called from | ||
| 2117 | Fmake_terminal_frame. */ | ||
| 2118 | if (NILP (frame_fg)) | ||
| 2119 | frame_fg = build_string (unspecified_fg); | ||
| 2120 | if (NILP (frame_bg)) | ||
| 2121 | frame_bg = build_string (unspecified_bg); | ||
| 2122 | 2116 | ||
| 2123 | /* Extract parm names and values into those vectors. */ | 2117 | /* Extract parm names and values into those vectors. */ |
| 2124 | i = 0; | 2118 | i = 0; |
| @@ -2144,60 +2138,79 @@ IT_set_frame_parameters (f, alist) | |||
| 2144 | 2138 | ||
| 2145 | if (EQ (prop, Qreverse)) | 2139 | if (EQ (prop, Qreverse)) |
| 2146 | reverse = EQ (val, Qt); | 2140 | reverse = EQ (val, Qt); |
| 2141 | else if (!menu_bar_lines_defined && EQ (prop, Qmenu_bar_lines)) | ||
| 2142 | menu_bar_lines_defined = 1; | ||
| 2147 | } | 2143 | } |
| 2148 | 2144 | ||
| 2149 | need_to_reverse = reverse && !was_reverse; | 2145 | if (tty->termscript && reverse) |
| 2150 | if (tty->termscript && need_to_reverse) | ||
| 2151 | fprintf (tty->termscript, "<INVERSE-VIDEO>\n"); | 2146 | fprintf (tty->termscript, "<INVERSE-VIDEO>\n"); |
| 2152 | 2147 | ||
| 2153 | /* Now process the alist elements in reverse of specified order. */ | 2148 | /* Now process the alist elements in reverse of specified order. */ |
| 2154 | for (i--; i >= 0; i--) | 2149 | for (i--; i >= 0; i--) |
| 2155 | { | 2150 | { |
| 2156 | Lisp_Object prop, val, frame; | 2151 | Lisp_Object prop, val; |
| 2157 | 2152 | ||
| 2158 | prop = parms[i]; | 2153 | prop = parms[i]; |
| 2159 | val = values[i]; | 2154 | val = values[i]; |
| 2160 | 2155 | ||
| 2161 | if (EQ (prop, Qforeground_color)) | 2156 | if (EQ (prop, Qforeground_color)) |
| 2162 | { | 2157 | { |
| 2163 | unsigned long new_color = load_color (f, NULL, val, need_to_reverse | 2158 | unsigned long new_color = load_color (f, NULL, val, reverse |
| 2164 | ? LFACE_BACKGROUND_INDEX | 2159 | ? LFACE_BACKGROUND_INDEX |
| 2165 | : LFACE_FOREGROUND_INDEX); | 2160 | : LFACE_FOREGROUND_INDEX); |
| 2166 | if (new_color != FACE_TTY_DEFAULT_COLOR | 2161 | if (new_color != FACE_TTY_DEFAULT_COLOR |
| 2167 | && new_color != FACE_TTY_DEFAULT_FG_COLOR | 2162 | && new_color != FACE_TTY_DEFAULT_FG_COLOR |
| 2168 | && new_color != FACE_TTY_DEFAULT_BG_COLOR) | 2163 | && new_color != FACE_TTY_DEFAULT_BG_COLOR) |
| 2169 | { | 2164 | { |
| 2170 | FRAME_FOREGROUND_PIXEL (f) = new_color; | 2165 | if (!reverse) |
| 2171 | /* Make sure the foreground of the default face for this | 2166 | { |
| 2172 | frame is changed as well. */ | 2167 | FRAME_FOREGROUND_PIXEL (f) = new_color; |
| 2173 | XSETFRAME (frame, f); | 2168 | /* Make sure the foreground of the default face for |
| 2174 | Finternal_set_lisp_face_attribute (Qdefault, QCforeground, | 2169 | this frame is changed as well. */ |
| 2175 | val, frame); | 2170 | update_face_from_frame_parameter (f, Qforeground_color, val); |
| 2176 | 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 | } | ||
| 2177 | redraw = 1; | 2183 | redraw = 1; |
| 2178 | if (tty->termscript) | ||
| 2179 | fprintf (tty->termscript, "<FGCOLOR %lu>\n", new_color); | ||
| 2180 | } | 2184 | } |
| 2181 | } | 2185 | } |
| 2182 | else if (EQ (prop, Qbackground_color)) | 2186 | else if (EQ (prop, Qbackground_color)) |
| 2183 | { | 2187 | { |
| 2184 | unsigned long new_color = load_color (f, NULL, val, need_to_reverse | 2188 | unsigned long new_color = load_color (f, NULL, val, reverse |
| 2185 | ? LFACE_FOREGROUND_INDEX | 2189 | ? LFACE_FOREGROUND_INDEX |
| 2186 | : LFACE_BACKGROUND_INDEX); | 2190 | : LFACE_BACKGROUND_INDEX); |
| 2187 | if (new_color != FACE_TTY_DEFAULT_COLOR | 2191 | if (new_color != FACE_TTY_DEFAULT_COLOR |
| 2188 | && new_color != FACE_TTY_DEFAULT_FG_COLOR | 2192 | && new_color != FACE_TTY_DEFAULT_FG_COLOR |
| 2189 | && new_color != FACE_TTY_DEFAULT_BG_COLOR) | 2193 | && new_color != FACE_TTY_DEFAULT_BG_COLOR) |
| 2190 | { | 2194 | { |
| 2191 | FRAME_BACKGROUND_PIXEL (f) = new_color; | 2195 | if (!reverse) |
| 2192 | /* Make sure the background of the default face for this | 2196 | { |
| 2193 | frame is changed as well. */ | 2197 | FRAME_BACKGROUND_PIXEL (f) = new_color; |
| 2194 | XSETFRAME (frame, f); | 2198 | /* Make sure the background of the default face for |
| 2195 | Finternal_set_lisp_face_attribute (Qdefault, QCbackground, | 2199 | this frame is changed as well. */ |
| 2196 | val, frame); | 2200 | bg_set = 1; |
| 2197 | 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 | } | ||
| 2198 | redraw = 1; | 2213 | redraw = 1; |
| 2199 | if (tty->termscript) | ||
| 2200 | fprintf (tty->termscript, "<BGCOLOR %lu>\n", new_color); | ||
| 2201 | } | 2214 | } |
| 2202 | } | 2215 | } |
| 2203 | else if (EQ (prop, Qtitle)) | 2216 | else if (EQ (prop, Qtitle)) |
| @@ -2226,26 +2239,36 @@ IT_set_frame_parameters (f, alist) | |||
| 2226 | store_frame_param (f, prop, val); | 2239 | store_frame_param (f, prop, val); |
| 2227 | } | 2240 | } |
| 2228 | 2241 | ||
| 2242 | /* If menu-bar-lines is neither in the frame parameters nor in | ||
| 2243 | default-frame-alist, set it according to menu-bar-mode. */ | ||
| 2244 | if (!menu_bar_lines_defined) | ||
| 2245 | { | ||
| 2246 | store_frame_param (f, Qmenu_bar_lines, | ||
| 2247 | NILP (Vmenu_bar_mode) | ||
| 2248 | ? make_number (0) : make_number (1)); | ||
| 2249 | if (tty->termscript) | ||
| 2250 | fprintf (tty->termscript, "<MENU BAR LINES DEFAULTED: %d\n", | ||
| 2251 | !NILP (Vmenu_bar_mode)); | ||
| 2252 | } | ||
| 2253 | |||
| 2229 | /* 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 |
| 2230 | the current frame colors. */ | 2255 | the current frame colors. */ |
| 2231 | if (need_to_reverse) | 2256 | if (reverse) |
| 2232 | { | 2257 | { |
| 2233 | Lisp_Object frame; | 2258 | Lisp_Object frame; |
| 2234 | 2259 | ||
| 2235 | if (!fg_set) | 2260 | if (!fg_set) |
| 2236 | { | 2261 | { |
| 2237 | XSETFRAME (frame, f); | 2262 | FRAME_FOREGROUND_PIXEL (f) = orig_bg; |
| 2238 | Finternal_set_lisp_face_attribute (Qdefault, QCforeground, | 2263 | update_face_from_frame_parameter (f, Qforeground_color, |
| 2239 | tty_color_name (f, orig_bg), | 2264 | tty_color_name (f, orig_bg)); |
| 2240 | frame); | ||
| 2241 | redraw = 1; | 2265 | redraw = 1; |
| 2242 | } | 2266 | } |
| 2243 | if (!bg_set) | 2267 | if (!bg_set) |
| 2244 | { | 2268 | { |
| 2245 | XSETFRAME (frame, f); | 2269 | FRAME_BACKGROUND_PIXEL (f) = orig_fg; |
| 2246 | Finternal_set_lisp_face_attribute (Qdefault, QCbackground, | 2270 | update_face_from_frame_parameter (f, Qbackground_color, |
| 2247 | tty_color_name (f, orig_fg), | 2271 | tty_color_name (f, orig_fg)); |
| 2248 | frame); | ||
| 2249 | redraw = 1; | 2272 | redraw = 1; |
| 2250 | } | 2273 | } |
| 2251 | } | 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 | |||
| 3498 | static void | ||
| 3499 | set_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 | |||
| 3577 | static void | ||
| 3578 | set_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. */ |