aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason Rumney2000-05-30 21:59:27 +0000
committerJason Rumney2000-05-30 21:59:27 +0000
commit9ef2e2cf037d33efa11c9c9157318496a86bb74d (patch)
treec2fd50c36d16754c99e48c582e686753577ffde7
parent6915ded08f4d54122cfa2d8eb0cb2869ea3eb7c3 (diff)
downloademacs-9ef2e2cf037d33efa11c9c9157318496a86bb74d.tar.gz
emacs-9ef2e2cf037d33efa11c9c9157318496a86bb74d.zip
Format and doc changes to bring closer to xterm.c.
(w32_char_font_type): New enum. (Qw32_charset_*, w32_codepage_for_font): Moved to w32fns.c. (w32_per_char_metric): Use w32_char_font_type instead of unicode_p. (w32_encode_char): New function. (x_encode_char): Removed. (x_get_glyph_and_face_encoding): Use w32_encode_char in place of x_encode_char and w32_font_is_double_byte. (x_produce_image_glyph): Use image_ascent. (x_produce_glyphs): Use new version of w32_per_char_metric and handle NULL return value. Allow extra line spacing. (W32_TEXTOUT): Distinguish between Unicode and DBCS text. (w32_get_glyph_overhangs): Remove unicode_p param. Use w32_font_type member of glyph instead. (x_draw_glyph_string): Draw underline and strike-out for BDF fonts. (fast_find_position): Make sure not to consider rows not visible in the window. (w32_read_socket) [WM_MENUSELECT]: Cannot call w32_menu_display_help with input blocked, as it can abort. (x_display_and_set_cursor): Choose cursor depending on buffer-local value of cursor_type. (x_draw_bar_cursor): Add parameter WIDTH.
-rw-r--r--src/w32term.c602
1 files changed, 283 insertions, 319 deletions
diff --git a/src/w32term.c b/src/w32term.c
index e2e4c168c5c..46025c6cd1f 100644
--- a/src/w32term.c
+++ b/src/w32term.c
@@ -1,5 +1,6 @@
1/* Implementation of GUI terminal on the Microsoft W32 API. 1/* Implementation of GUI terminal on the Microsoft W32 API.
2 Copyright (C) 1989, 93, 94, 95, 96, 97, 98 Free Software Foundation, Inc. 2 Copyright (C) 1989, 93, 94, 95, 96, 1997, 1998, 1999, 2000
3 Free Software Foundation, Inc.
3 4
4This file is part of GNU Emacs. 5This file is part of GNU Emacs.
5 6
@@ -14,8 +15,8 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14GNU General Public License for more details. 15GNU General Public License for more details.
15 16
16You should have received a copy of the GNU General Public License 17You should have received a copy of the GNU General Public License
17along with GNU Emacs; see the file COPYING. If not, write to the 18along with GNU Emacs; see the file COPYING. If not, write to
18Free Software Foundation, Inc., 59 Temple Place - Suite 330, 19the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19Boston, MA 02111-1307, USA. */ 20Boston, MA 02111-1307, USA. */
20 21
21#include <config.h> 22#include <config.h>
@@ -78,6 +79,14 @@ enum bitmap_type
78 ZV_LINE_BITMAP 79 ZV_LINE_BITMAP
79}; 80};
80 81
82enum w32_char_font_type
83{
84 UNKNOWN_FONT,
85 ANSI_FONT,
86 UNICODE_FONT,
87 BDF_FONT
88};
89
81/* Bitmaps are all unsigned short, as Windows requires bitmap data to 90/* Bitmaps are all unsigned short, as Windows requires bitmap data to
82 be Word aligned. For some reason they are horizontally reflected 91 be Word aligned. For some reason they are horizontally reflected
83 compared to how they appear on X, so changes in xterm.c should be 92 compared to how they appear on X, so changes in xterm.c should be
@@ -168,14 +177,14 @@ static int any_help_event_p;
168 177
169int x_stretch_cursor_p; 178int x_stretch_cursor_p;
170 179
171#define CP_DEFAULT 1004
172
173extern unsigned int msh_mousewheel; 180extern unsigned int msh_mousewheel;
174 181
175extern void free_frame_menubar (); 182extern void free_frame_menubar ();
176 183
177extern void w32_menu_display_help (HMENU menu, UINT menu_item, UINT flags); 184extern void w32_menu_display_help (HMENU menu, UINT menu_item, UINT flags);
178 185
186extern int w32_codepage_for_font (char *fontname);
187
179extern Lisp_Object Vwindow_system; 188extern Lisp_Object Vwindow_system;
180 189
181#define x_any_window_to_frame x_window_to_frame 190#define x_any_window_to_frame x_window_to_frame
@@ -252,6 +261,7 @@ int last_scroll_bar_drag_pos;
252/* Mouse movement. */ 261/* Mouse movement. */
253 262
254/* Where the mouse was last time we reported a mouse event. */ 263/* Where the mouse was last time we reported a mouse event. */
264
255FRAME_PTR last_mouse_frame; 265FRAME_PTR last_mouse_frame;
256static RECT last_mouse_glyph; 266static RECT last_mouse_glyph;
257static Lisp_Object last_mouse_press_frame; 267static Lisp_Object last_mouse_press_frame;
@@ -277,21 +287,21 @@ Lisp_Object Vw32_recognize_altgr;
277 287
278 If the last motion event didn't occur in a scroll bar, we set this 288 If the last motion event didn't occur in a scroll bar, we set this
279 to Qnil, to tell w32_mouse_position to return an ordinary motion event. */ 289 to Qnil, to tell w32_mouse_position to return an ordinary motion event. */
280Lisp_Object last_mouse_scroll_bar; 290static Lisp_Object last_mouse_scroll_bar;
281int last_mouse_scroll_bar_pos; 291static int last_mouse_scroll_bar_pos;
282 292
283/* This is a hack. We would really prefer that w32_mouse_position would 293/* This is a hack. We would really prefer that w32_mouse_position would
284 return the time associated with the position it returns, but there 294 return the time associated with the position it returns, but there
285 doesn't seem to be any way to wrest the timestamp from the server 295 doesn't seem to be any way to wrest the time-stamp from the server
286 along with the position query. So, we just keep track of the time 296 along with the position query. So, we just keep track of the time
287 of the last movement we received, and return that in hopes that 297 of the last movement we received, and return that in hopes that
288 it's somewhat accurate. */ 298 it's somewhat accurate. */
289Time last_mouse_movement_time;
290 299
291/* Associative list linking character set strings to Windows codepages. */ 300static Time last_mouse_movement_time;
292Lisp_Object Vw32_charset_info_alist; 301
302/* Incremented by w32_read_socket whenever it really tries to read
303 events. */
293 304
294/* Incremented by w32_read_socket whenever it really tries to read events. */
295#ifdef __STDC__ 305#ifdef __STDC__
296static int volatile input_signal_count; 306static int volatile input_signal_count;
297#else 307#else
@@ -305,6 +315,7 @@ extern Lisp_Object Qface, Qmouse_face;
305extern int errno; 315extern int errno;
306 316
307/* A mask of extra modifier bits to put into every keyboard char. */ 317/* A mask of extra modifier bits to put into every keyboard char. */
318
308extern int extra_keyboard_modifiers; 319extern int extra_keyboard_modifiers;
309 320
310/* Enumeration for overriding/changing the face to use for drawing 321/* Enumeration for overriding/changing the face to use for drawing
@@ -369,7 +380,7 @@ static void w32_new_focus_frame P_ ((struct w32_display_info *,
369static void w32_frame_rehighlight P_ ((struct frame *)); 380static void w32_frame_rehighlight P_ ((struct frame *));
370static void x_frame_rehighlight P_ ((struct w32_display_info *)); 381static void x_frame_rehighlight P_ ((struct w32_display_info *));
371static void x_draw_hollow_cursor P_ ((struct window *, struct glyph_row *)); 382static void x_draw_hollow_cursor P_ ((struct window *, struct glyph_row *));
372static void x_draw_bar_cursor P_ ((struct window *, struct glyph_row *)); 383static void x_draw_bar_cursor P_ ((struct window *, struct glyph_row *, int));
373static int w32_intersect_rectangles P_ ((RECT *, RECT *, RECT *)); 384static int w32_intersect_rectangles P_ ((RECT *, RECT *, RECT *));
374static void expose_frame P_ ((struct frame *, int, int, int, int)); 385static void expose_frame P_ ((struct frame *, int, int, int, int));
375static void expose_window_tree P_ ((struct window *, RECT *)); 386static void expose_window_tree P_ ((struct window *, RECT *));
@@ -394,36 +405,15 @@ static void w32_clip_to_row P_ ((struct window *, struct glyph_row *,
394 405
395static Lisp_Object Qvendor_specific_keysyms; 406static Lisp_Object Qvendor_specific_keysyms;
396 407
397Lisp_Object Qw32_charset_ansi;
398Lisp_Object Qw32_charset_default;
399Lisp_Object Qw32_charset_symbol;
400Lisp_Object Qw32_charset_shiftjis;
401Lisp_Object Qw32_charset_hangul;
402Lisp_Object Qw32_charset_gb2312;
403Lisp_Object Qw32_charset_chinesebig5;
404Lisp_Object Qw32_charset_oem;
405
406#ifdef JOHAB_CHARSET
407Lisp_Object Qw32_charset_easteurope;
408Lisp_Object Qw32_charset_turkish;
409Lisp_Object Qw32_charset_baltic;
410Lisp_Object Qw32_charset_russian;
411Lisp_Object Qw32_charset_arabic;
412Lisp_Object Qw32_charset_greek;
413Lisp_Object Qw32_charset_hebrew;
414Lisp_Object Qw32_charset_thai;
415Lisp_Object Qw32_charset_johab;
416Lisp_Object Qw32_charset_mac;
417#endif
418
419#ifdef UNICODE_CHARSET
420Lisp_Object Qw32_charset_unicode;
421#endif
422
423 408
409/***********************************************************************
410 Debugging
411 ***********************************************************************/
412
424#if 0 413#if 0
425/* This is a function useful for recording debugging information 414
426 about the sequence of occurrences in this file. */ 415/* This is a function useful for recording debugging information about
416 the sequence of occurrences in this file. */
427 417
428struct record 418struct record
429{ 419{
@@ -598,8 +588,8 @@ x_update_window_begin (w)
598 /* Don't do highlighting for mouse motion during the update. */ 588 /* Don't do highlighting for mouse motion during the update. */
599 display_info->mouse_face_defer = 1; 589 display_info->mouse_face_defer = 1;
600 590
601 /* If the frame needs to be redrawn, 591 /* If F needs to be redrawn, simply forget about any prior mouse
602 simply forget about any prior mouse highlighting. */ 592 highlighting. */
603 if (FRAME_GARBAGED_P (f)) 593 if (FRAME_GARBAGED_P (f))
604 display_info->mouse_face_window = Qnil; 594 display_info->mouse_face_window = Qnil;
605 595
@@ -682,6 +672,10 @@ x_update_window_end (w, cursor_on_p)
682 updated_window = NULL; 672 updated_window = NULL;
683} 673}
684 674
675
676/* End update of frame F. This function is installed as a hook in
677 update_end. */
678
685static void 679static void
686x_update_end (f) 680x_update_end (f)
687 struct frame *f; 681 struct frame *f;
@@ -690,6 +684,7 @@ x_update_end (f)
690 FRAME_W32_DISPLAY_INFO (f)->mouse_face_defer = 0; 684 FRAME_W32_DISPLAY_INFO (f)->mouse_face_defer = 0;
691} 685}
692 686
687
693/* This function is called from various places in xdisp.c whenever a 688/* This function is called from various places in xdisp.c whenever a
694 complete update has been performed. The global variable 689 complete update has been performed. The global variable
695 updated_window is not available here. */ 690 updated_window is not available here. */
@@ -965,7 +960,6 @@ x_draw_row_bitmaps (w, row)
965} 960}
966 961
967 962
968
969/*********************************************************************** 963/***********************************************************************
970 Line Highlighting 964 Line Highlighting
971 ***********************************************************************/ 965 ***********************************************************************/
@@ -991,24 +985,25 @@ x_change_line_highlight (new_highlight, vpos, y, first_unused_hpos)
991 abort (); 985 abort ();
992} 986}
993 987
994/* This is used when starting Emacs and when restarting after suspend. 988/* This is called when starting Emacs and when restarting after
995 When starting Emacs, no window is mapped. And nothing must be done 989 suspend. When starting Emacs, no window is mapped. And nothing
996 to Emacs's own window if it is suspended (though that rarely happens). */ 990 must be done to Emacs's own window if it is suspended (though that
991 rarely happens). */
997 992
998static void 993static void
999w32_set_terminal_modes (void) 994w32_set_terminal_modes (void)
1000{ 995{
1001} 996}
1002 997
1003/* This is called when exiting or suspending Emacs. 998/* This is called when exiting or suspending Emacs. Exiting will make
1004 Exiting will make the W32 windows go away, and suspending 999 the W32 windows go away, and suspending requires no action. */
1005 requires no action. */
1006 1000
1007static void 1001static void
1008w32_reset_terminal_modes (void) 1002w32_reset_terminal_modes (void)
1009{ 1003{
1010} 1004}
1011 1005
1006
1012 1007
1013/*********************************************************************** 1008/***********************************************************************
1014 Output Cursor 1009 Output Cursor
@@ -1016,6 +1011,7 @@ w32_reset_terminal_modes (void)
1016 1011
1017/* Set the global variable output_cursor to CURSOR. All cursor 1012/* Set the global variable output_cursor to CURSOR. All cursor
1018 positions are relative to updated_window. */ 1013 positions are relative to updated_window. */
1014
1019static void 1015static void
1020set_output_cursor (cursor) 1016set_output_cursor (cursor)
1021 struct cursor_pos *cursor; 1017 struct cursor_pos *cursor;
@@ -1065,6 +1061,7 @@ w32_cursor_to (vpos, hpos, y, x)
1065 } 1061 }
1066} 1062}
1067 1063
1064
1068 1065
1069/*********************************************************************** 1066/***********************************************************************
1070 Display Iterator 1067 Display Iterator
@@ -1079,8 +1076,10 @@ static struct face *x_get_glyph_face_and_encoding P_ ((struct frame *,
1079static struct face *x_get_char_face_and_encoding P_ ((struct frame *, int, 1076static struct face *x_get_char_face_and_encoding P_ ((struct frame *, int,
1080 int, wchar_t *, int)); 1077 int, wchar_t *, int));
1081static XCharStruct *w32_per_char_metric P_ ((HDC hdc, XFontStruct *, 1078static XCharStruct *w32_per_char_metric P_ ((HDC hdc, XFontStruct *,
1082 wchar_t *, int unicode_p)); 1079 wchar_t *,
1083static void x_encode_char P_ ((int, wchar_t *, struct font_info *)); 1080 enum w32_char_font_type));
1081static enum w32_char_font_type
1082 w32_encode_char P_ ((int, wchar_t *, struct font_info *, int *));
1084static void x_append_glyph P_ ((struct it *)); 1083static void x_append_glyph P_ ((struct it *));
1085static void x_append_composite_glyph P_ ((struct it *)); 1084static void x_append_composite_glyph P_ ((struct it *));
1086static void x_append_stretch_glyph P_ ((struct it *it, Lisp_Object, 1085static void x_append_stretch_glyph P_ ((struct it *it, Lisp_Object,
@@ -1105,15 +1104,14 @@ static void x_produce_image_glyph P_ ((struct it *it));
1105 1104
1106/* Get metrics of character CHAR2B in FONT. Value is always non-null. 1105/* Get metrics of character CHAR2B in FONT. Value is always non-null.
1107 If CHAR2B is not contained in FONT, the font's default character 1106 If CHAR2B is not contained in FONT, the font's default character
1108 metric is returned. If unicode_p is non-zero, use unicode functions, 1107 metric is returned. */
1109 otherwise use ANSI functions. */
1110 1108
1111static INLINE XCharStruct * 1109static XCharStruct *
1112w32_per_char_metric (hdc, font, char2b, unicode_p) 1110w32_per_char_metric (hdc, font, char2b, font_type)
1113 HDC hdc; 1111 HDC hdc;
1114 XFontStruct *font; 1112 XFontStruct *font;
1115 wchar_t *char2b; 1113 wchar_t *char2b;
1116 int unicode_p; 1114 enum w32_char_font_type font_type;
1117{ 1115{
1118 /* The result metric information. */ 1116 /* The result metric information. */
1119 XCharStruct *pcm; 1117 XCharStruct *pcm;
@@ -1123,14 +1121,24 @@ w32_per_char_metric (hdc, font, char2b, unicode_p)
1123 1121
1124 xassert (font && char2b); 1122 xassert (font && char2b);
1125 1123
1124 if (font_type == UNKNOWN_FONT)
1125 {
1126 if (font->bdf)
1127 font_type = BDF_FONT;
1128 else if (!w32_enable_unicode_output)
1129 font_type = ANSI_FONT;
1130 else
1131 font_type = UNICODE_FONT; /* NTEMACS_TODO: Need encoding? */
1132 }
1133
1126 pcm = (XCharStruct *) xmalloc (sizeof (XCharStruct)); 1134 pcm = (XCharStruct *) xmalloc (sizeof (XCharStruct));
1127 1135
1128 if (font->hfont) 1136 if (font->hfont)
1129 SelectObject (hdc, font->hfont); 1137 SelectObject (hdc, font->hfont);
1130 1138
1131 if (unicode_p) 1139 if (font_type == UNICODE_FONT)
1132 retval = GetCharABCWidthsW (hdc, *char2b, *char2b, &char_widths); 1140 retval = GetCharABCWidthsW (hdc, *char2b, *char2b, &char_widths);
1133 else 1141 else if (font_type == ANSI_FONT)
1134 retval = GetCharABCWidthsA (hdc, *char2b, *char2b, &char_widths); 1142 retval = GetCharABCWidthsA (hdc, *char2b, *char2b, &char_widths);
1135 1143
1136 if (retval) 1144 if (retval)
@@ -1145,7 +1153,7 @@ w32_per_char_metric (hdc, font, char2b, unicode_p)
1145 failed, try GetTextExtentPoint32W, which is implemented and 1153 failed, try GetTextExtentPoint32W, which is implemented and
1146 at least gives us some of the info we are after (total 1154 at least gives us some of the info we are after (total
1147 character width). */ 1155 character width). */
1148 if (unicode_p) 1156 if (font_type == UNICODE_FONT)
1149 retval = GetTextExtentPoint32W (hdc, char2b, 1, &sz); 1157 retval = GetTextExtentPoint32W (hdc, char2b, 1, &sz);
1150 1158
1151 if (retval) 1159 if (retval)
@@ -1156,9 +1164,8 @@ w32_per_char_metric (hdc, font, char2b, unicode_p)
1156 } 1164 }
1157 else 1165 else
1158 { 1166 {
1159 pcm->width = FONT_MAX_WIDTH (font); 1167 xfree (pcm);
1160 pcm->rbearing = FONT_MAX_WIDTH (font); 1168 return NULL;
1161 pcm->lbearing = 0;
1162 } 1169 }
1163 } 1170 }
1164 1171
@@ -1175,19 +1182,33 @@ w32_per_char_metric (hdc, font, char2b, unicode_p)
1175} 1182}
1176 1183
1177 1184
1185/* Determine if a font is double byte. */
1186int w32_font_is_double_byte (XFontStruct *font)
1187{
1188 return font->double_byte_p;
1189}
1190
1191
1178/* Encode CHAR2B using encoding information from FONT_INFO. CHAR2B is 1192/* Encode CHAR2B using encoding information from FONT_INFO. CHAR2B is
1179 the two-byte form of C. Encoding is returned in *CHAR2B. */ 1193 the two-byte form of C. Encoding is returned in *CHAR2B. */
1180 1194
1181static INLINE void 1195static INLINE enum w32_char_font_type
1182x_encode_char (c, char2b, font_info) 1196w32_encode_char (c, char2b, font_info, two_byte_p)
1183 int c; 1197 int c;
1184 wchar_t *char2b; 1198 wchar_t *char2b;
1185 struct font_info *font_info; 1199 struct font_info *font_info;
1200 int * two_byte_p;
1186{ 1201{
1187 int charset = CHAR_CHARSET (c); 1202 int charset = CHAR_CHARSET (c);
1188 int codepage; 1203 int codepage;
1204 int unicode_p = 0;
1205
1189 XFontStruct *font = font_info->font; 1206 XFontStruct *font = font_info->font;
1190 1207
1208 xassert(two_byte_p);
1209
1210 *two_byte_p = w32_font_is_double_byte (font);
1211
1191 /* FONT_INFO may define a scheme by which to encode byte1 and byte2. 1212 /* FONT_INFO may define a scheme by which to encode byte1 and byte2.
1192 This may be either a program in a special encoder language or a 1213 This may be either a program in a special encoder language or a
1193 fixed encoding. */ 1214 fixed encoding. */
@@ -1212,16 +1233,10 @@ x_encode_char (c, char2b, font_info)
1212 1233
1213 /* We assume that MSBs are appropriately set/reset by CCL 1234 /* We assume that MSBs are appropriately set/reset by CCL
1214 program. */ 1235 program. */
1215 /* NTEMACS_TODO : Use GetFontLanguageInfo to determine if 1236 if (!*two_byte_p) /* 1-byte font */
1216 font is double byte. */
1217#if 0
1218 if (FONT_MAX_BYTE1 (font) == 0) /* 1-byte font */
1219#endif
1220 *char2b = BUILD_WCHAR_T (0, ccl->reg[1]); 1237 *char2b = BUILD_WCHAR_T (0, ccl->reg[1]);
1221#if 0
1222 else 1238 else
1223 *char2b = BUILD_WCHAR_T (ccl->reg[1], ccl->reg[2]); 1239 *char2b = BUILD_WCHAR_T (ccl->reg[1], ccl->reg[2]);
1224#endif
1225 } 1240 }
1226 else if (font_info->encoding[charset]) 1241 else if (font_info->encoding[charset])
1227 { 1242 {
@@ -1260,7 +1275,17 @@ x_encode_char (c, char2b, font_info)
1260 MultiByteToWideChar (codepage, 0, temp, 2, char2b, 1); 1275 MultiByteToWideChar (codepage, 0, temp, 2, char2b, 1);
1261 else 1276 else
1262 MultiByteToWideChar (codepage, 0, temp+1, 1, char2b, 1); 1277 MultiByteToWideChar (codepage, 0, temp+1, 1, char2b, 1);
1263 } 1278 unicode_p = 1;
1279 *two_byte_p = 1;
1280 }
1281 if (!font)
1282 return UNKNOWN_FONT;
1283 else if (font->bdf)
1284 return BDF_FONT;
1285 else if (unicode_p)
1286 return UNICODE_FONT;
1287 else
1288 return ANSI_FONT;
1264} 1289}
1265 1290
1266 1291
@@ -1309,7 +1334,7 @@ x_get_char_face_and_encoding (f, c, face_id, char2b, multibyte_p)
1309 struct font_info *font_info 1334 struct font_info *font_info
1310 = FONT_INFO_FROM_ID (f, face->font_info_id); 1335 = FONT_INFO_FROM_ID (f, face->font_info_id);
1311 if (font_info) 1336 if (font_info)
1312 x_encode_char (c, char2b, font_info); 1337 w32_encode_char (c, char2b, font_info, &multibyte_p);
1313 } 1338 }
1314 } 1339 }
1315 1340
@@ -1321,15 +1346,6 @@ x_get_char_face_and_encoding (f, c, face_id, char2b, multibyte_p)
1321} 1346}
1322 1347
1323 1348
1324/* Determine if a font is double byte. */
1325int w32_font_is_double_byte (XFontStruct *font)
1326{
1327 /* NTEMACS_TODO: Determine this properly using GetFontLanguageInfo
1328 or similar. Returning 1 might work, as we use Unicode anyway. */
1329 return 1;
1330}
1331
1332
1333/* Get face and two-byte form of character glyph GLYPH on frame F. 1349/* Get face and two-byte form of character glyph GLYPH on frame F.
1334 The encoding of GLYPH->u.ch is returned in *CHAR2B. Value is 1350 The encoding of GLYPH->u.ch is returned in *CHAR2B. Value is
1335 a pointer to a realized face that is ready for display. */ 1351 a pointer to a realized face that is ready for display. */
@@ -1342,12 +1358,15 @@ x_get_glyph_face_and_encoding (f, glyph, char2b, two_byte_p)
1342 int *two_byte_p; 1358 int *two_byte_p;
1343{ 1359{
1344 struct face *face; 1360 struct face *face;
1361 int dummy = 0;
1345 1362
1346 xassert (glyph->type == CHAR_GLYPH); 1363 xassert (glyph->type == CHAR_GLYPH);
1347 face = FACE_FROM_ID (f, glyph->face_id); 1364 face = FACE_FROM_ID (f, glyph->face_id);
1348 1365
1349 if (two_byte_p) 1366 if (two_byte_p)
1350 *two_byte_p = 0; 1367 *two_byte_p = 0;
1368 else
1369 two_byte_p = &dummy;
1351 1370
1352 if (!glyph->multibyte_p) 1371 if (!glyph->multibyte_p)
1353 { 1372 {
@@ -1380,9 +1399,8 @@ x_get_glyph_face_and_encoding (f, glyph, char2b, two_byte_p)
1380 = FONT_INFO_FROM_ID (f, face->font_info_id); 1399 = FONT_INFO_FROM_ID (f, face->font_info_id);
1381 if (font_info) 1400 if (font_info)
1382 { 1401 {
1383 x_encode_char (glyph->u.ch, char2b, font_info); 1402 glyph->w32_font_type
1384 if (two_byte_p) 1403 = w32_encode_char (glyph->u.ch, char2b, font_info, two_byte_p);
1385 *two_byte_p = w32_font_is_double_byte (font_info->font);
1386 } 1404 }
1387 } 1405 }
1388 } 1406 }
@@ -1511,7 +1529,7 @@ x_produce_image_glyph (it)
1511 PREPARE_FACE_FOR_DISPLAY (it->f, face); 1529 PREPARE_FACE_FOR_DISPLAY (it->f, face);
1512 prepare_image_for_display (it->f, img); 1530 prepare_image_for_display (it->f, img);
1513 1531
1514 it->ascent = it->phys_ascent = IMAGE_ASCENT (img); 1532 it->ascent = it->phys_ascent = image_ascent (img, face);
1515 it->descent = it->phys_descent = img->height + 2 * img->margin - it->ascent; 1533 it->descent = it->phys_descent = img->height + 2 * img->margin - it->ascent;
1516 it->pixel_width = img->width + 2 * img->margin; 1534 it->pixel_width = img->width + 2 * img->margin;
1517 1535
@@ -1845,13 +1863,25 @@ x_produce_glyphs (it)
1845 1863
1846 it->nglyphs = 1; 1864 it->nglyphs = 1;
1847 1865
1848 pcm = w32_per_char_metric (hdc, font, &char2b, 0); 1866 pcm = w32_per_char_metric (hdc, font, &char2b,
1867 font->bdf ? BDF_FONT : ANSI_FONT);
1849 it->ascent = FONT_BASE (font) + boff; 1868 it->ascent = FONT_BASE (font) + boff;
1850 it->descent = FONT_DESCENT (font) - boff; 1869 it->descent = FONT_DESCENT (font) - boff;
1851 it->phys_ascent = pcm->ascent + boff;
1852 it->phys_descent = pcm->descent - boff;
1853 it->pixel_width = pcm->width;
1854 1870
1871 if (pcm)
1872 {
1873 it->phys_ascent = pcm->ascent + boff;
1874 it->phys_descent = pcm->descent - boff;
1875 it->pixel_width = pcm->width;
1876 }
1877 else
1878 {
1879 it->glyph_not_available_p = 1;
1880 it->phys_ascent = FONT_BASE(font) + boff;
1881 it->phys_descent = FONT_DESCENT(font) - boff;
1882 it->pixel_width = FONT_WIDTH(font);
1883 }
1884
1855 /* If this is a space inside a region of text with 1885 /* If this is a space inside a region of text with
1856 `space-width' property, change its width. */ 1886 `space-width' property, change its width. */
1857 stretched_p = it->char_to_display == ' ' && !NILP (it->space_width); 1887 stretched_p = it->char_to_display == ' ' && !NILP (it->space_width);
@@ -1899,10 +1929,10 @@ x_produce_glyphs (it)
1899 /* If characters with lbearing or rbearing are displayed 1929 /* If characters with lbearing or rbearing are displayed
1900 in this line, record that fact in a flag of the 1930 in this line, record that fact in a flag of the
1901 glyph row. This is used to optimize X output code. */ 1931 glyph row. This is used to optimize X output code. */
1902 if (pcm->lbearing < 0 1932 if (pcm && (pcm->lbearing < 0 || pcm->rbearing > pcm->width))
1903 || pcm->rbearing > pcm->width)
1904 it->glyph_row->contains_overlapping_glyphs_p = 1; 1933 it->glyph_row->contains_overlapping_glyphs_p = 1;
1905 xfree (pcm); 1934 if (pcm)
1935 xfree (pcm);
1906 } 1936 }
1907 } 1937 }
1908 else if (it->char_to_display == '\n') 1938 else if (it->char_to_display == '\n')
@@ -1923,9 +1953,7 @@ x_produce_glyphs (it)
1923 else if (it->char_to_display == '\t') 1953 else if (it->char_to_display == '\t')
1924 { 1954 {
1925 int tab_width = it->tab_width * CANON_X_UNIT (it->f); 1955 int tab_width = it->tab_width * CANON_X_UNIT (it->f);
1926 int x = (it->current_x 1956 int x = it->current_x + it->continuation_lines_width;
1927 - it->prompt_width
1928 + it->continuation_lines_width);
1929 int next_tab_x = ((1 + x + tab_width - 1) / tab_width) * tab_width; 1957 int next_tab_x = ((1 + x + tab_width - 1) / tab_width) * tab_width;
1930 1958
1931 it->pixel_width = next_tab_x - x; 1959 it->pixel_width = next_tab_x - x;
@@ -1948,7 +1976,8 @@ x_produce_glyphs (it)
1948 default font and calculate the width of the character 1976 default font and calculate the width of the character
1949 from the charset width; this is what old redisplay code 1977 from the charset width; this is what old redisplay code
1950 did. */ 1978 did. */
1951 pcm = w32_per_char_metric (hdc, font, &char2b, 1); 1979 pcm = w32_per_char_metric (hdc, font, &char2b,
1980 font->bdf ? BDF_FONT : UNICODE_FONT);
1952 1981
1953 if (font_not_found_p || !pcm) 1982 if (font_not_found_p || !pcm)
1954 { 1983 {
@@ -1962,6 +1991,7 @@ x_produce_glyphs (it)
1962 } 1991 }
1963 else 1992 else
1964 { 1993 {
1994 it->pixel_width = pcm->width;
1965 it->phys_ascent = pcm->ascent + boff; 1995 it->phys_ascent = pcm->ascent + boff;
1966 it->phys_descent = pcm->descent - boff; 1996 it->phys_descent = pcm->descent - boff;
1967 if (it->glyph_row 1997 if (it->glyph_row
@@ -1969,7 +1999,6 @@ x_produce_glyphs (it)
1969 || pcm->rbearing > pcm->width)) 1999 || pcm->rbearing > pcm->width))
1970 it->glyph_row->contains_overlapping_glyphs_p = 1; 2000 it->glyph_row->contains_overlapping_glyphs_p = 1;
1971 } 2001 }
1972
1973 it->nglyphs = 1; 2002 it->nglyphs = 1;
1974 it->ascent = FONT_BASE (font) + boff; 2003 it->ascent = FONT_BASE (font) + boff;
1975 it->descent = FONT_DESCENT (font) - boff; 2004 it->descent = FONT_DESCENT (font) - boff;
@@ -1996,7 +2025,8 @@ x_produce_glyphs (it)
1996 if (it->glyph_row) 2025 if (it->glyph_row)
1997 x_append_glyph (it); 2026 x_append_glyph (it);
1998 2027
1999 xfree (pcm); 2028 if (pcm)
2029 xfree (pcm);
2000 } 2030 }
2001 release_frame_dc (it->f, hdc); 2031 release_frame_dc (it->f, hdc);
2002 } 2032 }
@@ -2014,6 +2044,8 @@ x_produce_glyphs (it)
2014 if (it->area == TEXT_AREA) 2044 if (it->area == TEXT_AREA)
2015 it->current_x += it->pixel_width; 2045 it->current_x += it->pixel_width;
2016 2046
2047 it->descent += it->extra_line_spacing;
2048
2017 it->max_ascent = max (it->max_ascent, it->ascent); 2049 it->max_ascent = max (it->max_ascent, it->ascent);
2018 it->max_descent = max (it->max_descent, it->descent); 2050 it->max_descent = max (it->max_descent, it->descent);
2019 it->max_phys_ascent = max (it->max_phys_ascent, it->phys_ascent); 2051 it->max_phys_ascent = max (it->max_phys_ascent, it->phys_ascent);
@@ -2036,7 +2068,7 @@ x_estimate_mode_line_height (f, face_id)
2036 if (FRAME_FACE_CACHE (f)) 2068 if (FRAME_FACE_CACHE (f))
2037 { 2069 {
2038 struct face *face = FACE_FROM_ID (f, face_id); 2070 struct face *face = FACE_FROM_ID (f, face_id);
2039 if (face && face->font) 2071 if (face)
2040 height = FONT_HEIGHT (face->font) + 2 * face->box_line_width; 2072 height = FONT_HEIGHT (face->font) + 2 * face->box_line_width;
2041 } 2073 }
2042 2074
@@ -2044,42 +2076,6 @@ x_estimate_mode_line_height (f, face_id)
2044} 2076}
2045 2077
2046 2078
2047/* Get the Windows codepage corresponding to the specified font. The
2048 charset info in the font name is used to look up
2049 w32-charset-to-codepage-alist. */
2050int
2051w32_codepage_for_font (char *fontname)
2052{
2053 Lisp_Object codepage;
2054 char charset_str[20], *charset, *end;
2055
2056 /* Extract charset part of font string. */
2057 if (sscanf (fontname,
2058 "-%*[^-]-%*[^-]-%*[^-]-%*[^-]-%*[^-]-%*[^-]-%*[^-]-%*[^-]-%*[^-]-%*[^-]-%*[^-]-%*[^-]-%19s",
2059 charset_str) == EOF)
2060 return CP_DEFAULT;
2061
2062 /* Remove leading "*-". */
2063 if (strncmp ("*-", charset_str, 2) == 0)
2064 charset = charset_str + 2;
2065 else
2066 charset = charset_str;
2067
2068 /* Stop match at wildcard (including preceding '-'). */
2069 if (end = strchr (charset, '*'))
2070 {
2071 if (end > charset && *(end-1) == '-')
2072 end--;
2073 *end = '\0';
2074 }
2075
2076 codepage = Fcdr (Fcdr (Fassoc (build_string(charset),
2077 Vw32_charset_info_alist)));
2078 if (INTEGERP (codepage))
2079 return XINT (codepage);
2080 else
2081 return CP_DEFAULT;
2082}
2083 2079
2084BOOL 2080BOOL
2085w32_use_unicode_for_codepage (codepage) 2081w32_use_unicode_for_codepage (codepage)
@@ -2213,7 +2209,7 @@ struct glyph_string
2213}; 2209};
2214 2210
2215 2211
2216/* Encapsulate the different ways of printing text under W32. */ 2212/* Encapsulate the different ways of displaying text under W32. */
2217 2213
2218void W32_TEXTOUT(s, x, y,chars,nchars) 2214void W32_TEXTOUT(s, x, y,chars,nchars)
2219 struct glyph_string * s; 2215 struct glyph_string * s;
@@ -2221,16 +2217,15 @@ void W32_TEXTOUT(s, x, y,chars,nchars)
2221 wchar_t * chars; 2217 wchar_t * chars;
2222 int nchars; 2218 int nchars;
2223{ 2219{
2224 /* NTEMACS_TODO: Find way to figure out charset_dim. */ 2220 int charset_dim = w32_font_is_double_byte (s->gc->font) ? 2 : 1;
2225 /* int charset_dim = CHARSET_DIMENSION (s->charset); */
2226 if (s->gc->font->bdf) 2221 if (s->gc->font->bdf)
2227 w32_BDF_TextOut (s->gc->font->bdf, s->hdc, 2222 w32_BDF_TextOut (s->gc->font->bdf, s->hdc,
2228 x, y, (char *) chars, 1 /* charset_dim */, nchars, 0); 2223 x, y, (char *) chars, charset_dim, nchars, 0);
2229 else if (s->two_byte_p) 2224 else if (s->first_glyph->w32_font_type == UNICODE_FONT)
2230 ExtTextOutW (s->hdc, x, y, 0, NULL, chars, nchars, NULL); 2225 ExtTextOutW (s->hdc, x, y, 0, NULL, chars, nchars, NULL);
2231 else 2226 else
2232 ExtTextOut (s->hdc, x, y, 0, NULL, (char *) chars, 2227 ExtTextOut (s->hdc, x, y, 0, NULL, (char *) chars,
2233 nchars /* * charset_dim */, NULL); 2228 nchars * charset_dim, NULL);
2234} 2229}
2235 2230
2236#if 0 2231#if 0
@@ -2288,8 +2283,6 @@ static void x_draw_glyph_string_background P_ ((struct glyph_string *,
2288 int)); 2283 int));
2289static void x_draw_glyph_string_foreground P_ ((struct glyph_string *)); 2284static void x_draw_glyph_string_foreground P_ ((struct glyph_string *));
2290static void x_draw_composite_glyph_string_foreground P_ ((struct glyph_string *)); 2285static void x_draw_composite_glyph_string_foreground P_ ((struct glyph_string *));
2291static void x_draw_glyph_string_underline P_ ((struct glyph_string *));
2292static void x_draw_glyph_string_underline P_ ((struct glyph_string *));
2293static void x_draw_glyph_string_box P_ ((struct glyph_string *)); 2286static void x_draw_glyph_string_box P_ ((struct glyph_string *));
2294static void x_draw_glyph_string P_ ((struct glyph_string *)); 2287static void x_draw_glyph_string P_ ((struct glyph_string *));
2295static void x_compute_glyph_string_overhangs P_ ((struct glyph_string *)); 2288static void x_compute_glyph_string_overhangs P_ ((struct glyph_string *));
@@ -2298,7 +2291,7 @@ static void x_set_mode_line_face_gc P_ ((struct glyph_string *));
2298static void x_set_mouse_face_gc P_ ((struct glyph_string *)); 2291static void x_set_mouse_face_gc P_ ((struct glyph_string *));
2299static void w32_get_glyph_overhangs P_ ((HDC hdc, struct glyph *, 2292static void w32_get_glyph_overhangs P_ ((HDC hdc, struct glyph *,
2300 struct frame *, 2293 struct frame *,
2301 int *, int *, int)); 2294 int *, int *));
2302static void x_compute_overhangs_and_x P_ ((struct glyph_string *, int, int)); 2295static void x_compute_overhangs_and_x P_ ((struct glyph_string *, int, int));
2303static int w32_alloc_lighter_color (struct frame *, COLORREF *, double, int); 2296static int w32_alloc_lighter_color (struct frame *, COLORREF *, double, int);
2304static void w32_setup_relief_color P_ ((struct frame *, struct relief *, 2297static void w32_setup_relief_color P_ ((struct frame *, struct relief *,
@@ -2672,11 +2665,11 @@ x_compute_overhangs_and_x (s, x, backward_p)
2672 assumed to be zero. */ 2665 assumed to be zero. */
2673 2666
2674static void 2667static void
2675w32_get_glyph_overhangs (hdc, glyph, f, left, right, unicode_p) 2668w32_get_glyph_overhangs (hdc, glyph, f, left, right)
2676 HDC hdc; 2669 HDC hdc;
2677 struct glyph *glyph; 2670 struct glyph *glyph;
2678 struct frame *f; 2671 struct frame *f;
2679 int *left, *right, unicode_p; 2672 int *left, *right;
2680{ 2673{
2681 int c; 2674 int c;
2682 2675
@@ -2686,15 +2679,15 @@ w32_get_glyph_overhangs (hdc, glyph, f, left, right, unicode_p)
2686 { 2679 {
2687 XFontStruct *font; 2680 XFontStruct *font;
2688 struct face *face; 2681 struct face *face;
2689 struct font_info *font_info;
2690 wchar_t char2b; 2682 wchar_t char2b;
2691 XCharStruct *pcm; 2683 XCharStruct *pcm;
2692 2684
2693 face = x_get_glyph_face_and_encoding (f, glyph, &char2b, NULL); 2685 face = x_get_glyph_face_and_encoding (f, glyph, &char2b, NULL);
2694 font = face->font; 2686 font = face->font;
2695 font_info = FONT_INFO_FROM_ID (f, face->font_info_id); 2687
2696 if (font 2688 if (font
2697 && (pcm = w32_per_char_metric (hdc, font, &char2b, unicode_p))) 2689 && (pcm = w32_per_char_metric (hdc, font, &char2b,
2690 glyph->w32_font_type)))
2698 { 2691 {
2699 if (pcm->rbearing > pcm->width) 2692 if (pcm->rbearing > pcm->width)
2700 *right = pcm->rbearing - pcm->width; 2693 *right = pcm->rbearing - pcm->width;
@@ -2713,7 +2706,8 @@ x_get_glyph_overhangs (glyph, f, left, right)
2713 int *left, *right; 2706 int *left, *right;
2714{ 2707{
2715 HDC hdc = get_frame_dc (f); 2708 HDC hdc = get_frame_dc (f);
2716 w32_get_glyph_overhangs (hdc, glyph, f, left, right, glyph->multibyte_p); 2709 /* Convert to unicode! */
2710 w32_get_glyph_overhangs (hdc, glyph, f, left, right);
2717 release_frame_dc (f, hdc); 2711 release_frame_dc (f, hdc);
2718} 2712}
2719 2713
@@ -2763,8 +2757,7 @@ x_left_overwriting (s)
2763 for (i = first - 1; i >= 0; --i) 2757 for (i = first - 1; i >= 0; --i)
2764 { 2758 {
2765 int left, right; 2759 int left, right;
2766 w32_get_glyph_overhangs (s->hdc, glyphs + i, s->f, &left, 2760 w32_get_glyph_overhangs (s->hdc, glyphs + i, s->f, &left, &right);
2767 &right, s->two_byte_p);
2768 if (x + right > 0) 2761 if (x + right > 0)
2769 k = i; 2762 k = i;
2770 x -= glyphs[i].pixel_width; 2763 x -= glyphs[i].pixel_width;
@@ -2819,8 +2812,7 @@ x_right_overwriting (s)
2819 for (i = first; i < end; ++i) 2812 for (i = first; i < end; ++i)
2820 { 2813 {
2821 int left, right; 2814 int left, right;
2822 w32_get_glyph_overhangs (s->hdc, glyphs + i, s->f, &left, 2815 w32_get_glyph_overhangs (s->hdc, glyphs + i, s->f, &left, &right);
2823 &right, s->two_byte_p);
2824 if (x - left < 0) 2816 if (x - left < 0)
2825 k = i; 2817 k = i;
2826 x += glyphs[i].pixel_width; 2818 x += glyphs[i].pixel_width;
@@ -3294,7 +3286,7 @@ x_draw_image_foreground (s)
3294 struct glyph_string *s; 3286 struct glyph_string *s;
3295{ 3287{
3296 int x; 3288 int x;
3297 int y = s->ybase - IMAGE_ASCENT (s->img); 3289 int y = s->ybase - image_ascent (s->img, s->face);
3298 3290
3299 /* If first glyph of S has a left box line, start drawing it to the 3291 /* If first glyph of S has a left box line, start drawing it to the
3300 right of that line. */ 3292 right of that line. */
@@ -3395,8 +3387,8 @@ x_draw_image_relief (s)
3395 int x0, y0, x1, y1, thick, raised_p; 3387 int x0, y0, x1, y1, thick, raised_p;
3396 RECT r; 3388 RECT r;
3397 int x; 3389 int x;
3398 int y = s->ybase - IMAGE_ASCENT (s->img); 3390 int y = s->ybase - image_ascent (s->img, s->face);
3399 3391
3400 /* If first glyph of S has a left box line, start drawing it to the 3392 /* If first glyph of S has a left box line, start drawing it to the
3401 right of that line. */ 3393 right of that line. */
3402 if (s->face->box != FACE_NO_BOX 3394 if (s->face->box != FACE_NO_BOX
@@ -3446,7 +3438,7 @@ w32_draw_image_foreground_1 (s, pixmap)
3446 HDC hdc = CreateCompatibleDC (s->hdc); 3438 HDC hdc = CreateCompatibleDC (s->hdc);
3447 HGDIOBJ orig_hdc_obj = SelectObject (hdc, pixmap); 3439 HGDIOBJ orig_hdc_obj = SelectObject (hdc, pixmap);
3448 int x; 3440 int x;
3449 int y = s->ybase - s->y - IMAGE_ASCENT (s->img); 3441 int y = s->ybase - s->y - image_ascent (s->img, s->face);
3450 3442
3451 /* If first glyph of S has a left box line, start drawing it to the 3443 /* If first glyph of S has a left box line, start drawing it to the
3452 right of that line. */ 3444 right of that line. */
@@ -3791,7 +3783,8 @@ x_draw_glyph_string (s)
3791 if (!s->for_overlaps_p) 3783 if (!s->for_overlaps_p)
3792 { 3784 {
3793 /* Draw underline. */ 3785 /* Draw underline. */
3794 if (s->face->underline_p && (!s->font->bdf && !s->font->tm.tmUnderlined)) 3786 if (s->face->underline_p
3787 && (s->font->bdf || !s->font->tm.tmUnderlined))
3795 { 3788 {
3796 unsigned long h = 1; 3789 unsigned long h = 1;
3797 unsigned long dy = s->height - h; 3790 unsigned long dy = s->height - h;
@@ -3826,7 +3819,8 @@ x_draw_glyph_string (s)
3826 } 3819 }
3827 3820
3828 /* Draw strike-through. */ 3821 /* Draw strike-through. */
3829 if (s->face->strike_through_p && (!s->font->bdf &&!s->font->tm.tmStruckOut)) 3822 if (s->face->strike_through_p
3823 && (s->font->bdf || !s->font->tm.tmStruckOut))
3830 { 3824 {
3831 unsigned long h = 1; 3825 unsigned long h = 1;
3832 unsigned long dy = (s->height - h) / 2; 3826 unsigned long dy = (s->height - h) / 2;
@@ -3938,7 +3932,6 @@ x_fill_glyph_string (s, face_id, start, end, overlaps_p)
3938 xassert (start >= 0 && end > start); 3932 xassert (start >= 0 && end > start);
3939 3933
3940 s->for_overlaps_p = overlaps_p; 3934 s->for_overlaps_p = overlaps_p;
3941
3942 glyph = s->row->glyphs[s->area] + start; 3935 glyph = s->row->glyphs[s->area] + start;
3943 last = s->row->glyphs[s->area] + end; 3936 last = s->row->glyphs[s->area] + end;
3944 voffset = glyph->voffset; 3937 voffset = glyph->voffset;
@@ -4149,6 +4142,7 @@ x_set_glyph_string_background_width (s, start, last_x)
4149 \ 4142 \
4150 c = (ROW)->glyphs[AREA][START].u.ch; \ 4143 c = (ROW)->glyphs[AREA][START].u.ch; \
4151 face_id = (ROW)->glyphs[AREA][START].face_id; \ 4144 face_id = (ROW)->glyphs[AREA][START].face_id; \
4145 \
4152 s = (struct glyph_string *) alloca (sizeof *s); \ 4146 s = (struct glyph_string *) alloca (sizeof *s); \
4153 char2b = (wchar_t *) alloca ((END - START) * sizeof *char2b); \ 4147 char2b = (wchar_t *) alloca ((END - START) * sizeof *char2b); \
4154 w32_init_glyph_string (s, hdc, char2b, W, ROW, AREA, START, HL); \ 4148 w32_init_glyph_string (s, hdc, char2b, W, ROW, AREA, START, HL); \
@@ -4215,6 +4209,7 @@ x_set_glyph_string_background_width (s, start, last_x)
4215 s = first_s; \ 4209 s = first_s; \
4216 } while (0) 4210 } while (0)
4217 4211
4212
4218/* Build a list of glyph strings between HEAD and TAIL for the glyphs 4213/* Build a list of glyph strings between HEAD and TAIL for the glyphs
4219 of AREA of glyph row ROW on window W between indices START and END. 4214 of AREA of glyph row ROW on window W between indices START and END.
4220 HL overrides the face for drawing glyph strings, e.g. it is 4215 HL overrides the face for drawing glyph strings, e.g. it is
@@ -4357,7 +4352,6 @@ x_draw_glyphs (w, x, row, area, start, end, hl, real_start, real_end,
4357 i = start; 4352 i = start;
4358 BUILD_GLYPH_STRINGS (hdc, w, row, area, i, end, head, tail, hl, x, last_x, 4353 BUILD_GLYPH_STRINGS (hdc, w, row, area, i, end, head, tail, hl, x, last_x,
4359 overlaps_p); 4354 overlaps_p);
4360
4361 if (tail) 4355 if (tail)
4362 x_reached = tail->x + tail->background_width; 4356 x_reached = tail->x + tail->background_width;
4363 else 4357 else
@@ -4407,7 +4401,6 @@ x_draw_glyphs (w, x, row, area, start, end, hl, real_start, real_end,
4407 BUILD_GLYPH_STRINGS (hdc, w, row, area, i, start, h, t, 4401 BUILD_GLYPH_STRINGS (hdc, w, row, area, i, start, h, t,
4408 DRAW_NORMAL_TEXT, dummy_x, last_x, 4402 DRAW_NORMAL_TEXT, dummy_x, last_x,
4409 overlaps_p); 4403 overlaps_p);
4410
4411 for (s = h; s; s = s->next) 4404 for (s = h; s; s = s->next)
4412 s->background_filled_p = 1; 4405 s->background_filled_p = 1;
4413 if (real_start) 4406 if (real_start)
@@ -4426,7 +4419,6 @@ x_draw_glyphs (w, x, row, area, start, end, hl, real_start, real_end,
4426 BUILD_GLYPH_STRINGS (hdc, w, row, area, end, i, h, t, 4419 BUILD_GLYPH_STRINGS (hdc, w, row, area, end, i, h, t,
4427 DRAW_NORMAL_TEXT, x, last_x, 4420 DRAW_NORMAL_TEXT, x, last_x,
4428 overlaps_p); 4421 overlaps_p);
4429
4430 x_compute_overhangs_and_x (h, tail->x + tail->width, 0); 4422 x_compute_overhangs_and_x (h, tail->x + tail->width, 0);
4431 x_append_glyph_string_lists (&head, &tail, h, t); 4423 x_append_glyph_string_lists (&head, &tail, h, t);
4432 if (real_end) 4424 if (real_end)
@@ -4444,7 +4436,6 @@ x_draw_glyphs (w, x, row, area, start, end, hl, real_start, real_end,
4444 BUILD_GLYPH_STRINGS (hdc, w, row, area, end, i, h, t, 4436 BUILD_GLYPH_STRINGS (hdc, w, row, area, end, i, h, t,
4445 DRAW_NORMAL_TEXT, x, last_x, 4437 DRAW_NORMAL_TEXT, x, last_x,
4446 overlaps_p); 4438 overlaps_p);
4447
4448 for (s = h; s; s = s->next) 4439 for (s = h; s; s = s->next)
4449 s->background_filled_p = 1; 4440 s->background_filled_p = 1;
4450 x_compute_overhangs_and_x (h, tail->x + tail->width, 0); 4441 x_compute_overhangs_and_x (h, tail->x + tail->width, 0);
@@ -4849,6 +4840,7 @@ x_scroll_run (w, run)
4849 release_frame_dc (f, hdc); 4840 release_frame_dc (f, hdc);
4850} 4841}
4851 4842
4843
4852 4844
4853/*********************************************************************** 4845/***********************************************************************
4854 Exposure Events 4846 Exposure Events
@@ -5173,7 +5165,7 @@ w32_intersect_rectangles (r1, r2, result)
5173 RECT *upper, *lower; 5165 RECT *upper, *lower;
5174 int intersection_p = 0; 5166 int intersection_p = 0;
5175 5167
5176 /* Arrange so that left is the left-most rectangle. */ 5168 /* Rerrange so that R1 is the left-most rectangle. */
5177 if (r1->left < r2->left) 5169 if (r1->left < r2->left)
5178 left = r1, right = r2; 5170 left = r1, right = r2;
5179 else 5171 else
@@ -5211,6 +5203,9 @@ w32_intersect_rectangles (r1, r2, result)
5211 return intersection_p; 5203 return intersection_p;
5212} 5204}
5213 5205
5206
5207
5208
5214 5209
5215static void 5210static void
5216frame_highlight (f) 5211frame_highlight (f)
@@ -5226,14 +5221,13 @@ frame_unhighlight (f)
5226 x_update_cursor (f, 1); 5221 x_update_cursor (f, 1);
5227} 5222}
5228 5223
5229
5230/* The focus has changed. Update the frames as necessary to reflect 5224/* The focus has changed. Update the frames as necessary to reflect
5231 the new situation. Note that we can't change the selected frame 5225 the new situation. Note that we can't change the selected frame
5232 here, because the Lisp code we are interrupting might become confused. 5226 here, because the Lisp code we are interrupting might become confused.
5233 Each event gets marked with the frame in which it occurred, so the 5227 Each event gets marked with the frame in which it occurred, so the
5234 Lisp code can tell when the switch took place by examining the events. */ 5228 Lisp code can tell when the switch took place by examining the events. */
5235 5229
5236void 5230static void
5237x_new_focus_frame (dpyinfo, frame) 5231x_new_focus_frame (dpyinfo, frame)
5238 struct w32_display_info *dpyinfo; 5232 struct w32_display_info *dpyinfo;
5239 struct frame *frame; 5233 struct frame *frame;
@@ -5269,11 +5263,12 @@ x_mouse_leave (dpyinfo)
5269 5263
5270/* The focus has changed, or we have redirected a frame's focus to 5264/* The focus has changed, or we have redirected a frame's focus to
5271 another frame (this happens when a frame uses a surrogate 5265 another frame (this happens when a frame uses a surrogate
5272 minibuffer frame). Shift the highlight as appropriate. 5266 mini-buffer frame). Shift the highlight as appropriate.
5273 5267
5274 The FRAME argument doesn't necessarily have anything to do with which 5268 The FRAME argument doesn't necessarily have anything to do with which
5275 frame is being highlighted or unhighlighted; we only use it to find 5269 frame is being highlighted or un-highlighted; we only use it to find
5276 the appropriate display info. */ 5270 the appropriate X display info. */
5271
5277static void 5272static void
5278w32_frame_rehighlight (frame) 5273w32_frame_rehighlight (frame)
5279 struct frame *frame; 5274 struct frame *frame;
@@ -5328,13 +5323,15 @@ x_get_keysym_name (keysym)
5328 5323
5329 return value; 5324 return value;
5330} 5325}
5326
5327
5331 5328
5332/* Mouse clicks and mouse movement. Rah. */ 5329/* Mouse clicks and mouse movement. Rah. */
5333 5330
5334/* Given a pixel position (PIX_X, PIX_Y) on the frame F, return 5331/* Given a pixel position (PIX_X, PIX_Y) on frame F, return glyph
5335 glyph co-ordinates in (*X, *Y). Set *BOUNDS to the rectangle 5332 co-ordinates in (*X, *Y). Set *BOUNDS to the rectangle that the
5336 that the glyph at X, Y occupies, if BOUNDS != 0. 5333 glyph at X, Y occupies, if BOUNDS != 0. If NOCLIP is non-zero, do
5337 If NOCLIP is nonzero, do not force the value into range. */ 5334 not force the value into range. */
5338 5335
5339void 5336void
5340pixel_to_glyph_coords (f, pix_x, pix_y, x, y, bounds, noclip) 5337pixel_to_glyph_coords (f, pix_x, pix_y, x, y, bounds, noclip)
@@ -5635,6 +5632,7 @@ note_mouse_movement (frame, msg)
5635} 5632}
5636 5633
5637/* This is used for debugging, to turn off note_mouse_highlight. */ 5634/* This is used for debugging, to turn off note_mouse_highlight. */
5635
5638int disable_mouse_highlight; 5636int disable_mouse_highlight;
5639 5637
5640 5638
@@ -5813,19 +5811,21 @@ note_mode_line_highlight (w, x, mode_line_p)
5813 cursor = f->output_data.w32->nontext_cursor; 5811 cursor = f->output_data.w32->nontext_cursor;
5814 } 5812 }
5815 } 5813 }
5814
5816#if 0 /* NTEMACS_TODO: mouse cursor */ 5815#if 0 /* NTEMACS_TODO: mouse cursor */
5817 XDefineCursor (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), cursor); 5816 XDefineCursor (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), cursor);
5818#endif 5817#endif
5819} 5818}
5820 5819
5821/* Take proper action when the mouse has moved to position X, Y on frame F 5820
5822 as regards highlighting characters that have mouse-face properties. 5821/* Take proper action when the mouse has moved to position X, Y on
5823 Also dehighlighting chars where the mouse was before. 5822 frame F as regards highlighting characters that have mouse-face
5823 properties. Also de-highlighting chars where the mouse was before.
5824 X and Y can be negative or out of range. */ 5824 X and Y can be negative or out of range. */
5825 5825
5826static void 5826static void
5827note_mouse_highlight (f, x, y) 5827note_mouse_highlight (f, x, y)
5828 FRAME_PTR f; 5828 struct frame *f;
5829 int x, y; 5829 int x, y;
5830{ 5830{
5831 struct w32_display_info *dpyinfo = FRAME_W32_DISPLAY_INFO (f); 5831 struct w32_display_info *dpyinfo = FRAME_W32_DISPLAY_INFO (f);
@@ -5837,7 +5837,8 @@ note_mouse_highlight (f, x, y)
5837 if (popup_activated ()) 5837 if (popup_activated ())
5838 return; 5838 return;
5839 5839
5840 if (disable_mouse_highlight || !f->glyphs_initialized_p) 5840 if (disable_mouse_highlight
5841 || !f->glyphs_initialized_p)
5841 return; 5842 return;
5842 5843
5843 dpyinfo->mouse_face_mouse_x = x; 5844 dpyinfo->mouse_face_mouse_x = x;
@@ -5890,11 +5891,12 @@ note_mouse_highlight (f, x, y)
5890 5891
5891 /* Are we in a window whose display is up to date? 5892 /* Are we in a window whose display is up to date?
5892 And verify the buffer's text has not changed. */ 5893 And verify the buffer's text has not changed. */
5893 if (/* Within the text portion of the window. */ 5894 if (/* Within text portion of the window. */
5894 portion == 0 5895 portion == 0
5895 && EQ (w->window_end_valid, w->buffer) 5896 && EQ (w->window_end_valid, w->buffer)
5896 && w->last_modified == BUF_MODIFF (XBUFFER (w->buffer)) 5897 && XFASTINT (w->last_modified) == BUF_MODIFF (XBUFFER (w->buffer))
5897 && w->last_overlay_modified == BUF_OVERLAY_MODIFF (XBUFFER (w->buffer))) 5898 && (XFASTINT (w->last_overlay_modified)
5899 == BUF_OVERLAY_MODIFF (XBUFFER (w->buffer))))
5898 { 5900 {
5899 int hpos, vpos, pos, i, area; 5901 int hpos, vpos, pos, i, area;
5900 struct glyph *glyph; 5902 struct glyph *glyph;
@@ -6083,7 +6085,6 @@ note_mouse_highlight (f, x, y)
6083 } 6085 }
6084} 6086}
6085 6087
6086
6087static void 6088static void
6088redo_mouse_highlight () 6089redo_mouse_highlight ()
6089{ 6090{
@@ -6155,7 +6156,7 @@ x_tool_bar_item (f, x, y, glyph, hpos, vpos, prop_idx)
6155} 6156}
6156 6157
6157 6158
6158/* Handle mouse button event on the tool_bar of frame F, at 6159/* Handle mouse button event on the tool-bar of frame F, at
6159 frame-relative coordinates X/Y. EVENT_TYPE is either ButtionPress 6160 frame-relative coordinates X/Y. EVENT_TYPE is either ButtionPress
6160 or ButtonRelase. */ 6161 or ButtonRelase. */
6161 6162
@@ -6216,7 +6217,7 @@ w32_handle_tool_bar_click (f, button_event)
6216} 6217}
6217 6218
6218 6219
6219/* Possibly highlight a tool_bar item on frame F when mouse moves to 6220/* Possibly highlight a tool-bar item on frame F when mouse moves to
6220 tool-bar window-relative coordinates X/Y. Called from 6221 tool-bar window-relative coordinates X/Y. Called from
6221 note_mouse_highlight. */ 6222 note_mouse_highlight. */
6222 6223
@@ -6310,6 +6311,7 @@ note_tool_bar_highlight (f, x, y)
6310 ->contents[prop_idx + TOOL_BAR_ITEM_CAPTION]); 6311 ->contents[prop_idx + TOOL_BAR_ITEM_CAPTION]);
6311} 6312}
6312 6313
6314
6313 6315
6314/* Find the glyph matrix position of buffer position POS in window W. 6316/* Find the glyph matrix position of buffer position POS in window W.
6315 *HPOS, *VPOS, *X, and *Y are set to the positions found. W's 6317 *HPOS, *VPOS, *X, and *Y are set to the positions found. W's
@@ -6356,6 +6358,9 @@ fast_find_position (w, pos, hpos, vpos, x, y)
6356 best_row_vpos = row_vpos; 6358 best_row_vpos = row_vpos;
6357 } 6359 }
6358 6360
6361 if (row->y + row->height >= yb)
6362 break;
6363
6359 ++row; 6364 ++row;
6360 ++row_vpos; 6365 ++row_vpos;
6361 } 6366 }
@@ -6501,9 +6506,8 @@ show_mouse_face (dpyinfo, draw)
6501 ; 6506 ;
6502} 6507}
6503 6508
6504
6505/* Clear out the mouse-highlighted active region. 6509/* Clear out the mouse-highlighted active region.
6506 Redraw it unhighlighted first. */ 6510 Redraw it un-highlighted first. */
6507 6511
6508void 6512void
6509clear_mouse_face (dpyinfo) 6513clear_mouse_face (dpyinfo)
@@ -6539,7 +6543,7 @@ cancel_mouse_face (f)
6539 } 6543 }
6540} 6544}
6541 6545
6542struct scroll_bar *x_window_to_scroll_bar (); 6546static struct scroll_bar *x_window_to_scroll_bar ();
6543static void x_scroll_bar_report_motion (); 6547static void x_scroll_bar_report_motion ();
6544 6548
6545/* Return the current position of the mouse. 6549/* Return the current position of the mouse.
@@ -6554,15 +6558,13 @@ static void x_scroll_bar_report_motion ();
6554 mouse is on, *bar_window to nil, and *x and *y to the character cell 6558 mouse is on, *bar_window to nil, and *x and *y to the character cell
6555 the mouse is over. 6559 the mouse is over.
6556 6560
6557 Set *time to the server timestamp for the time at which the mouse 6561 Set *time to the server time-stamp for the time at which the mouse
6558 was at this position. 6562 was at this position.
6559 6563
6560 Don't store anything if we don't have a valid set of values to report. 6564 Don't store anything if we don't have a valid set of values to report.
6561 6565
6562 This clears the mouse_moved flag, so we can wait for the next mouse 6566 This clears the mouse_moved flag, so we can wait for the next mouse
6563 movement. This also calls XQueryPointer, which will cause the 6567 movement. */
6564 server to give us another MotionNotify when the mouse moves
6565 again. */
6566 6568
6567static void 6569static void
6568w32_mouse_position (fp, insist, bar_window, part, x, y, time) 6570w32_mouse_position (fp, insist, bar_window, part, x, y, time)
@@ -6578,7 +6580,6 @@ w32_mouse_position (fp, insist, bar_window, part, x, y, time)
6578 BLOCK_INPUT; 6580 BLOCK_INPUT;
6579 6581
6580 if (! NILP (last_mouse_scroll_bar) && insist == 0) 6582 if (! NILP (last_mouse_scroll_bar) && insist == 0)
6581 /* This is never called at the moment. */
6582 x_scroll_bar_report_motion (fp, bar_window, part, x, y, time); 6583 x_scroll_bar_report_motion (fp, bar_window, part, x, y, time);
6583 else 6584 else
6584 { 6585 {
@@ -6684,7 +6685,8 @@ w32_mouse_position (fp, insist, bar_window, part, x, y, time)
6684/* Given an window ID, find the struct scroll_bar which manages it. 6685/* Given an window ID, find the struct scroll_bar which manages it.
6685 This can be called in GC, so we have to make sure to strip off mark 6686 This can be called in GC, so we have to make sure to strip off mark
6686 bits. */ 6687 bits. */
6687struct scroll_bar * 6688
6689static struct scroll_bar *
6688x_window_to_scroll_bar (window_id) 6690x_window_to_scroll_bar (window_id)
6689 Window window_id; 6691 Window window_id;
6690{ 6692{
@@ -6946,7 +6948,7 @@ w32_set_vertical_scroll_bar (w, portion, whole, position)
6946{ 6948{
6947 struct frame *f = XFRAME (w->frame); 6949 struct frame *f = XFRAME (w->frame);
6948 struct scroll_bar *bar; 6950 struct scroll_bar *bar;
6949 int top, left, sb_left, width, sb_width, height; 6951 int top, height, left, sb_left, width, sb_width;
6950 int window_x, window_y, window_width, window_height; 6952 int window_x, window_y, window_width, window_height;
6951 6953
6952 /* Get window dimensions. */ 6954 /* Get window dimensions. */
@@ -7069,7 +7071,8 @@ w32_set_vertical_scroll_bar (w, portion, whole, position)
7069 7071
7070/* Arrange for all scroll bars on FRAME to be removed at the next call 7072/* Arrange for all scroll bars on FRAME to be removed at the next call
7071 to `*judge_scroll_bars_hook'. A scroll bar may be spared if 7073 to `*judge_scroll_bars_hook'. A scroll bar may be spared if
7072 `*redeem_scroll_bar_hook' is applied to its window before the judgement. */ 7074 `*redeem_scroll_bar_hook' is applied to its window before the judgment. */
7075
7073static void 7076static void
7074w32_condemn_scroll_bars (frame) 7077w32_condemn_scroll_bars (frame)
7075 FRAME_PTR frame; 7078 FRAME_PTR frame;
@@ -7088,7 +7091,7 @@ w32_condemn_scroll_bars (frame)
7088 } 7091 }
7089} 7092}
7090 7093
7091/* Unmark WINDOW's scroll bar for deletion in this judgement cycle. 7094/* Un-mark WINDOW's scroll bar for deletion in this judgment cycle.
7092 Note that WINDOW isn't necessarily condemned at all. */ 7095 Note that WINDOW isn't necessarily condemned at all. */
7093static void 7096static void
7094w32_redeem_scroll_bar (window) 7097w32_redeem_scroll_bar (window)
@@ -7137,6 +7140,7 @@ w32_redeem_scroll_bar (window)
7137 7140
7138/* Remove all scroll bars on FRAME that haven't been saved since the 7141/* Remove all scroll bars on FRAME that haven't been saved since the
7139 last call to `*condemn_scroll_bars_hook'. */ 7142 last call to `*condemn_scroll_bars_hook'. */
7143
7140static void 7144static void
7141w32_judge_scroll_bars (f) 7145w32_judge_scroll_bars (f)
7142 FRAME_PTR f; 7146 FRAME_PTR f;
@@ -7205,6 +7209,9 @@ x_scroll_bar_handle_click (bar, msg, emacs_event)
7205 7209
7206 bar->dragging = Qnil; 7210 bar->dragging = Qnil;
7207 7211
7212
7213 last_mouse_scroll_bar_pos = msg->msg.wParam;
7214
7208 switch (LOWORD (msg->msg.wParam)) 7215 switch (LOWORD (msg->msg.wParam))
7209 { 7216 {
7210 case SB_LINEDOWN: 7217 case SB_LINEDOWN:
@@ -7287,6 +7294,7 @@ x_scroll_bar_handle_click (bar, msg, emacs_event)
7287 7294
7288/* Return information to the user about the current position of the mouse 7295/* Return information to the user about the current position of the mouse
7289 on the scroll bar. */ 7296 on the scroll bar. */
7297
7290static void 7298static void
7291x_scroll_bar_report_motion (fp, bar_window, part, x, y, time) 7299x_scroll_bar_report_motion (fp, bar_window, part, x, y, time)
7292 FRAME_PTR *fp; 7300 FRAME_PTR *fp;
@@ -7348,34 +7356,40 @@ x_scroll_bar_report_motion (fp, bar_window, part, x, y, time)
7348 UNBLOCK_INPUT; 7356 UNBLOCK_INPUT;
7349} 7357}
7350 7358
7359
7351/* The screen has been cleared so we may have changed foreground or 7360/* The screen has been cleared so we may have changed foreground or
7352 background colors, and the scroll bars may need to be redrawn. 7361 background colors, and the scroll bars may need to be redrawn.
7353 Clear out the scroll bars, and ask for expose events, so we can 7362 Clear out the scroll bars, and ask for expose events, so we can
7354 redraw them. */ 7363 redraw them. */
7364
7355void 7365void
7356x_scroll_bar_clear (f) 7366x_scroll_bar_clear (f)
7357 struct frame *f; 7367 FRAME_PTR f;
7358{ 7368{
7359 Lisp_Object bar; 7369 Lisp_Object bar;
7360 7370
7361 for (bar = FRAME_SCROLL_BARS (f); VECTORP (bar); 7371 /* We can have scroll bars even if this is 0,
7362 bar = XSCROLL_BAR (bar)->next) 7372 if we just turned off scroll bar mode.
7363 { 7373 But in that case we should not clear them. */
7364 HWND window = SCROLL_BAR_W32_WINDOW (XSCROLL_BAR (bar)); 7374 if (FRAME_HAS_VERTICAL_SCROLL_BARS (f))
7365 HDC hdc = GetDC (window); 7375 for (bar = FRAME_SCROLL_BARS (f); VECTORP (bar);
7366 RECT rect; 7376 bar = XSCROLL_BAR (bar)->next)
7377 {
7378 HWND window = SCROLL_BAR_W32_WINDOW (XSCROLL_BAR (bar));
7379 HDC hdc = GetDC (window);
7380 RECT rect;
7367 7381
7368 /* Hide scroll bar until ready to repaint. x_scroll_bar_move 7382 /* Hide scroll bar until ready to repaint. x_scroll_bar_move
7369 arranges to refresh the scroll bar if hidden. */ 7383 arranges to refresh the scroll bar if hidden. */
7370 my_show_window (f, window, SW_HIDE); 7384 my_show_window (f, window, SW_HIDE);
7371 7385
7372 GetClientRect (window, &rect); 7386 GetClientRect (window, &rect);
7373 select_palette (f, hdc); 7387 select_palette (f, hdc);
7374 w32_clear_rect (f, hdc, &rect); 7388 w32_clear_rect (f, hdc, &rect);
7375 deselect_palette (f, hdc); 7389 deselect_palette (f, hdc);
7376 7390
7377 ReleaseDC (window, hdc); 7391 ReleaseDC (window, hdc);
7378 } 7392 }
7379} 7393}
7380 7394
7381show_scroll_bars (f, how) 7395show_scroll_bars (f, how)
@@ -7395,15 +7409,17 @@ show_scroll_bars (f, how)
7395 7409
7396/* The main W32 event-reading loop - w32_read_socket. */ 7410/* The main W32 event-reading loop - w32_read_socket. */
7397 7411
7398/* Timestamp of enter window event. This is only used by w32_read_socket, 7412/* Time stamp of enter window event. This is only used by w32_read_socket,
7399 but we have to put it out here, since static variables within functions 7413 but we have to put it out here, since static variables within functions
7400 sometimes don't work. */ 7414 sometimes don't work. */
7415
7401static Time enter_timestamp; 7416static Time enter_timestamp;
7402 7417
7403/* Record the last 100 characters stored 7418/* Record the last 100 characters stored
7404 to help debug the loss-of-chars-during-GC problem. */ 7419 to help debug the loss-of-chars-during-GC problem. */
7405int temp_index; 7420
7406short temp_buffer[100]; 7421static int temp_index;
7422static short temp_buffer[100];
7407 7423
7408 7424
7409/* Read events coming from the W32 shell. 7425/* Read events coming from the W32 shell.
@@ -7429,8 +7445,8 @@ short temp_buffer[100];
7429int 7445int
7430w32_read_socket (sd, bufp, numchars, expected) 7446w32_read_socket (sd, bufp, numchars, expected)
7431 register int sd; 7447 register int sd;
7432 register struct input_event *bufp; 7448 /* register */ struct input_event *bufp;
7433 register int numchars; 7449 /* register */ int numchars;
7434 int expected; 7450 int expected;
7435{ 7451{
7436 int count = 0; 7452 int count = 0;
@@ -7717,8 +7733,15 @@ w32_read_socket (sd, bufp, numchars, expected)
7717 HMENU menu = (HMENU) msg.msg.lParam; 7733 HMENU menu = (HMENU) msg.msg.lParam;
7718 UINT menu_item = (UINT) LOWORD (msg.msg.wParam); 7734 UINT menu_item = (UINT) LOWORD (msg.msg.wParam);
7719 UINT flags = (UINT) HIWORD (msg.msg.wParam); 7735 UINT flags = (UINT) HIWORD (msg.msg.wParam);
7720 7736
7737 /* NTEMACS_TODO: Can't call the below with input blocked,
7738 as it may result in hooks being called if the window
7739 layout needs to change to display the message, and
7740 Feval will abort if input is blocked. But unblocking
7741 temporarily is not the best solution. */
7742 UNBLOCK_INPUT;
7721 w32_menu_display_help (menu, menu_item, flags); 7743 w32_menu_display_help (menu, menu_item, flags);
7744 BLOCK_INPUT;
7722 } 7745 }
7723 break; 7746 break;
7724 7747
@@ -7837,7 +7860,8 @@ w32_read_socket (sd, bufp, numchars, expected)
7837 count++; 7860 count++;
7838 numchars--; 7861 numchars--;
7839 } 7862 }
7840 else 7863 else if (! NILP (Vframe_list)
7864 && ! NILP (XCDR (Vframe_list)))
7841 /* Force a redisplay sooner or later 7865 /* Force a redisplay sooner or later
7842 to update the frame titles 7866 to update the frame titles
7843 in case this is the second frame. */ 7867 in case this is the second frame. */
@@ -7919,6 +7943,7 @@ w32_read_socket (sd, bufp, numchars, expected)
7919 clear_mouse_face (dpyinfo); 7943 clear_mouse_face (dpyinfo);
7920 dpyinfo->mouse_face_mouse_frame = 0; 7944 dpyinfo->mouse_face_mouse_frame = 0;
7921 } 7945 }
7946
7922 /* Generate a nil HELP_EVENT to cancel a help-echo. 7947 /* Generate a nil HELP_EVENT to cancel a help-echo.
7923 Do it only if there's something to cancel. 7948 Do it only if there's something to cancel.
7924 Otherwise, the startup message is cleared when 7949 Otherwise, the startup message is cleared when
@@ -8092,6 +8117,8 @@ w32_read_socket (sd, bufp, numchars, expected)
8092 return count; 8117 return count;
8093} 8118}
8094 8119
8120
8121
8095 8122
8096/*********************************************************************** 8123/***********************************************************************
8097 Text Cursor 8124 Text Cursor
@@ -8145,7 +8172,7 @@ w32_clip_to_row (w, row, hdc, whole_line_p)
8145 clip_rect.bottom = clip_rect.top + row->visible_height; 8172 clip_rect.bottom = clip_rect.top + row->visible_height;
8146 8173
8147 /* If clipping to the whole line, including trunc marks, extend 8174 /* If clipping to the whole line, including trunc marks, extend
8148 the rectangle to the left and right. */ 8175 the rectangle to the left and increase its width. */
8149 if (whole_line_p) 8176 if (whole_line_p)
8150 { 8177 {
8151 clip_rect.left -= FRAME_X_LEFT_FLAGS_AREA_WIDTH (f); 8178 clip_rect.left -= FRAME_X_LEFT_FLAGS_AREA_WIDTH (f);
@@ -8209,9 +8236,10 @@ x_draw_hollow_cursor (w, row)
8209 --gerd. */ 8236 --gerd. */
8210 8237
8211static void 8238static void
8212x_draw_bar_cursor (w, row) 8239x_draw_bar_cursor (w, row, width)
8213 struct window *w; 8240 struct window *w;
8214 struct glyph_row *row; 8241 struct glyph_row *row;
8242 int width;
8215{ 8243{
8216 /* If cursor hpos is out of bounds, don't draw garbage. This can 8244 /* If cursor hpos is out of bounds, don't draw garbage. This can
8217 happen in mini-buffer windows when switching between echo area 8245 happen in mini-buffer windows when switching between echo area
@@ -8229,12 +8257,14 @@ x_draw_bar_cursor (w, row)
8229 8257
8230 x = WINDOW_TEXT_TO_FRAME_PIXEL_X (w, w->phys_cursor.x); 8258 x = WINDOW_TEXT_TO_FRAME_PIXEL_X (w, w->phys_cursor.x);
8231 8259
8260 if (width < 0)
8261 width = f->output_data.w32->cursor_width;
8262
8232 hdc = get_frame_dc (f); 8263 hdc = get_frame_dc (f);
8233 w32_fill_area (f, hdc, f->output_data.w32->cursor_pixel, 8264 w32_fill_area (f, hdc, f->output_data.w32->cursor_pixel,
8234 x, 8265 x,
8235 WINDOW_TO_FRAME_PIXEL_Y (w, w->phys_cursor.y), 8266 WINDOW_TO_FRAME_PIXEL_Y (w, w->phys_cursor.y),
8236 min (cursor_glyph->pixel_width, 8267 min (cursor_glyph->pixel_width, width),
8237 f->output_data.w32->cursor_width),
8238 row->height); 8268 row->height);
8239 release_frame_dc (f, hdc); 8269 release_frame_dc (f, hdc);
8240 } 8270 }
@@ -8392,6 +8422,7 @@ x_display_and_set_cursor (w, on, hpos, vpos, x, y)
8392{ 8422{
8393 struct frame *f = XFRAME (w->frame); 8423 struct frame *f = XFRAME (w->frame);
8394 int new_cursor_type; 8424 int new_cursor_type;
8425 int new_cursor_width;
8395 struct glyph_matrix *current_glyphs; 8426 struct glyph_matrix *current_glyphs;
8396 struct glyph_row *glyph_row; 8427 struct glyph_row *glyph_row;
8397 struct glyph *glyph; 8428 struct glyph *glyph;
@@ -8430,6 +8461,7 @@ x_display_and_set_cursor (w, on, hpos, vpos, x, y)
8430 the cursor type given by the frame parameter. If explicitly 8461 the cursor type given by the frame parameter. If explicitly
8431 marked off, draw no cursor. In all other cases, we want a hollow 8462 marked off, draw no cursor. In all other cases, we want a hollow
8432 box cursor. */ 8463 box cursor. */
8464 new_cursor_width = -1;
8433 if (cursor_in_echo_area 8465 if (cursor_in_echo_area
8434 && FRAME_HAS_MINIBUF_P (f) 8466 && FRAME_HAS_MINIBUF_P (f)
8435 && EQ (FRAME_MINIBUF_WINDOW (f), echo_area_window)) 8467 && EQ (FRAME_MINIBUF_WINDOW (f), echo_area_window))
@@ -8454,7 +8486,15 @@ x_display_and_set_cursor (w, on, hpos, vpos, x, y)
8454 else if (w->cursor_off_p) 8486 else if (w->cursor_off_p)
8455 new_cursor_type = NO_CURSOR; 8487 new_cursor_type = NO_CURSOR;
8456 else 8488 else
8457 new_cursor_type = FRAME_DESIRED_CURSOR (f); 8489 {
8490 struct buffer *b = XBUFFER (w->buffer);
8491
8492 if (EQ (b->cursor_type, Qt))
8493 new_cursor_type = FRAME_DESIRED_CURSOR (f);
8494 else
8495 new_cursor_type = x_specified_cursor_type (b->cursor_type,
8496 &new_cursor_width);
8497 }
8458 } 8498 }
8459 8499
8460 /* If cursor is currently being shown and we don't want it to be or 8500 /* If cursor is currently being shown and we don't want it to be or
@@ -8494,7 +8534,7 @@ x_display_and_set_cursor (w, on, hpos, vpos, x, y)
8494 break; 8534 break;
8495 8535
8496 case BAR_CURSOR: 8536 case BAR_CURSOR:
8497 x_draw_bar_cursor (w, glyph_row); 8537 x_draw_bar_cursor (w, glyph_row, new_cursor_width);
8498 break; 8538 break;
8499 8539
8500 case NO_CURSOR: 8540 case NO_CURSOR:
@@ -8566,13 +8606,20 @@ x_update_window_cursor (w, on)
8566 struct window *w; 8606 struct window *w;
8567 int on; 8607 int on;
8568{ 8608{
8569 BLOCK_INPUT; 8609 /* Don't update cursor in windows whose frame is in the process
8570 x_display_and_set_cursor (w, on, w->phys_cursor.hpos, w->phys_cursor.vpos, 8610 of being deleted. */
8571 w->phys_cursor.x, w->phys_cursor.y); 8611 if (w->current_matrix)
8572 UNBLOCK_INPUT; 8612 {
8613 BLOCK_INPUT;
8614 x_display_and_set_cursor (w, on, w->phys_cursor.hpos,
8615 w->phys_cursor.vpos, w->phys_cursor.x,
8616 w->phys_cursor.y);
8617 UNBLOCK_INPUT;
8618 }
8573} 8619}
8574 8620
8575 8621
8622
8576 8623
8577/* Icons. */ 8624/* Icons. */
8578 8625
@@ -8802,6 +8849,7 @@ x_compute_min_glyph_bounds (f)
8802/* Calculate the absolute position in frame F 8849/* Calculate the absolute position in frame F
8803 from its current recorded position values and gravity. */ 8850 from its current recorded position values and gravity. */
8804 8851
8852void
8805x_calc_absolute_position (f) 8853x_calc_absolute_position (f)
8806 struct frame *f; 8854 struct frame *f;
8807{ 8855{
@@ -8860,6 +8908,7 @@ x_calc_absolute_position (f)
8860 position values). It is -1 when calling from x_set_frame_parameters, 8908 position values). It is -1 when calling from x_set_frame_parameters,
8861 which means, do adjust for borders but don't change the gravity. */ 8909 which means, do adjust for borders but don't change the gravity. */
8862 8910
8911void
8863x_set_offset (f, xoff, yoff, change_gravity) 8912x_set_offset (f, xoff, yoff, change_gravity)
8864 struct frame *f; 8913 struct frame *f;
8865 register int xoff, yoff; 8914 register int xoff, yoff;
@@ -9342,6 +9391,7 @@ x_wm_set_icon_position (f, icon_x, icon_y)
9342#endif 9391#endif
9343} 9392}
9344 9393
9394
9345 9395
9346/*********************************************************************** 9396/***********************************************************************
9347 Initialization 9397 Initialization
@@ -9714,92 +9764,6 @@ NT uses Unicode internally anyway, so this flag will probably have no\n\
9714affect on NT machines."); 9764affect on NT machines.");
9715 w32_enable_unicode_output = 1; 9765 w32_enable_unicode_output = 1;
9716 9766
9717/* VIETNAMESE_CHARSET is not defined in some versions of MSVC. */
9718#ifndef VIETNAMESE_CHARSET
9719#define VIETNAMESE_CHARSET 163
9720#endif
9721
9722 DEFVAR_LISP ("w32-charset-info-alist",
9723 &Vw32_charset_info_alist,
9724 "Alist linking Emacs character sets to Windows fonts\n\
9725and codepages. Each entry should be of the form:\n\
9726\n\
9727 (CHARSET_NAME . (WINDOWS_CHARSET . CODEPAGE))\n\
9728\n\
9729where CHARSET_NAME is a string used in font names to identify the charset,\n\
9730WINDOWS_CHARSET is a symbol that can be one of:\n\
9731w32-charset-ansi, w32-charset-default, w32-charset-symbol,\n\
9732w32-charset-shiftjis, w32-charset-hangul, w32-charset-gb2312,\n\
9733w32-charset-chinesebig5, "
9734#ifdef JOHAB_CHARSET
9735"w32-charset-johab, w32-charset-hebrew,\n\
9736w32-charset-arabic, w32-charset-greek, w32-charset-turkish,\n\
9737w32-charset-vietnamese, w32-charset-thai, w32-charset-easteurope,\n\
9738w32-charset-russian, w32-charset-mac, w32-charset-baltic,\n"
9739#endif
9740#ifdef UNICODE_CHARSET
9741"w32-charset-unicode, "
9742#endif
9743"or w32-charset-oem.\n\
9744CODEPAGE should be an integer specifying the codepage that should be used\n\
9745to display the character set, t to do no translation and output as Unicode,\n\
9746or nil to do no translation and output as 8 bit (or multibyte on far-east\n\
9747versions of Windows) characters.");
9748 Vw32_charset_info_alist = Qnil;
9749
9750 staticpro (&Qw32_charset_ansi);
9751 Qw32_charset_ansi = intern ("w32-charset-ansi");
9752 staticpro (&Qw32_charset_symbol);
9753 Qw32_charset_symbol = intern ("w32-charset-symbol");
9754 staticpro (&Qw32_charset_shiftjis);
9755 Qw32_charset_shiftjis = intern ("w32-charset-shiftjis");
9756 staticpro (&Qw32_charset_hangul);
9757 Qw32_charset_hangul = intern ("w32-charset-hangul");
9758 staticpro (&Qw32_charset_chinesebig5);
9759 Qw32_charset_chinesebig5 = intern ("w32-charset-chinesebig5");
9760 staticpro (&Qw32_charset_gb2312);
9761 Qw32_charset_gb2312 = intern ("w32-charset-gb2312");
9762 staticpro (&Qw32_charset_oem);
9763 Qw32_charset_oem = intern ("w32-charset-oem");
9764
9765#ifdef JOHAB_CHARSET
9766 {
9767 static int w32_extra_charsets_defined = 1;
9768 DEFVAR_BOOL ("w32-extra-charsets-defined", w32_extra_charsets_defined, "");
9769
9770 staticpro (&Qw32_charset_johab);
9771 Qw32_charset_johab = intern ("w32-charset-johab");
9772 staticpro (&Qw32_charset_easteurope);
9773 Qw32_charset_easteurope = intern ("w32-charset-easteurope");
9774 staticpro (&Qw32_charset_turkish);
9775 Qw32_charset_turkish = intern ("w32-charset-turkish");
9776 staticpro (&Qw32_charset_baltic);
9777 Qw32_charset_baltic = intern ("w32-charset-baltic");
9778 staticpro (&Qw32_charset_russian);
9779 Qw32_charset_russian = intern ("w32-charset-russian");
9780 staticpro (&Qw32_charset_arabic);
9781 Qw32_charset_arabic = intern ("w32-charset-arabic");
9782 staticpro (&Qw32_charset_greek);
9783 Qw32_charset_greek = intern ("w32-charset-greek");
9784 staticpro (&Qw32_charset_hebrew);
9785 Qw32_charset_hebrew = intern ("w32-charset-hebrew");
9786 staticpro (&Qw32_charset_thai);
9787 Qw32_charset_thai = intern ("w32-charset-thai");
9788 staticpro (&Qw32_charset_mac);
9789 Qw32_charset_mac = intern ("w32-charset-mac");
9790 }
9791#endif
9792
9793#ifdef UNICODE_CHARSET
9794 {
9795 static int w32_unicode_charset_defined = 1;
9796 DEFVAR_BOOL ("w32-unicode-charset-defined",
9797 w32_unicode_charset_defined, "");
9798
9799 staticpro (&Qw32_charset_unicode);
9800 Qw32_charset_unicode = intern ("w32-charset-unicode");
9801#endif
9802
9803 staticpro (&help_echo); 9767 staticpro (&help_echo);
9804 help_echo = Qnil; 9768 help_echo = Qnil;
9805 staticpro (&previous_help_echo); 9769 staticpro (&previous_help_echo);