comparison src/w32term.c @ 29321:8e2be36bb1c6

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.
author Jason Rumney <jasonr@gnu.org>
date Tue, 30 May 2000 21:59:27 +0000
parents 3fb90cd81d3b
children ed1979c6dfb9
comparison
equal deleted inserted replaced
29320:33aa00975055 29321:8e2be36bb1c6
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
4 This file is part of GNU Emacs. 5 This file is part of GNU Emacs.
5 6
6 GNU Emacs is free software; you can redistribute it and/or modify 7 GNU Emacs is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by 8 it under the terms of the GNU General Public License as published by
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details. 15 GNU General Public License for more details.
15 16
16 You should have received a copy of the GNU General Public License 17 You should have received a copy of the GNU General Public License
17 along with GNU Emacs; see the file COPYING. If not, write to the 18 along with GNU Emacs; see the file COPYING. If not, write to
18 Free Software Foundation, Inc., 59 Temple Place - Suite 330, 19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. */ 20 Boston, MA 02111-1307, USA. */
20 21
21 #include <config.h> 22 #include <config.h>
22 #include <signal.h> 23 #include <signal.h>
23 #include <stdio.h> 24 #include <stdio.h>
76 CONTINUED_LINE_BITMAP, 77 CONTINUED_LINE_BITMAP,
77 CONTINUATION_LINE_BITMAP, 78 CONTINUATION_LINE_BITMAP,
78 ZV_LINE_BITMAP 79 ZV_LINE_BITMAP
79 }; 80 };
80 81
82 enum 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
84 reflected here. */ 93 reflected here. */
85 94
166 under it. For example, if a block cursor is over a tab, it will be 175 under it. For example, if a block cursor is over a tab, it will be
167 drawn as wide as that tab on the display. */ 176 drawn as wide as that tab on the display. */
168 177
169 int x_stretch_cursor_p; 178 int x_stretch_cursor_p;
170 179
171 #define CP_DEFAULT 1004
172
173 extern unsigned int msh_mousewheel; 180 extern unsigned int msh_mousewheel;
174 181
175 extern void free_frame_menubar (); 182 extern void free_frame_menubar ();
176 183
177 extern void w32_menu_display_help (HMENU menu, UINT menu_item, UINT flags); 184 extern void w32_menu_display_help (HMENU menu, UINT menu_item, UINT flags);
185
186 extern int w32_codepage_for_font (char *fontname);
178 187
179 extern Lisp_Object Vwindow_system; 188 extern 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
182 #define x_top_window_to_frame x_window_to_frame 191 #define x_top_window_to_frame x_window_to_frame
250 int last_scroll_bar_drag_pos; 259 int last_scroll_bar_drag_pos;
251 260
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
255 FRAME_PTR last_mouse_frame; 265 FRAME_PTR last_mouse_frame;
256 static RECT last_mouse_glyph; 266 static RECT last_mouse_glyph;
257 static Lisp_Object last_mouse_press_frame; 267 static Lisp_Object last_mouse_press_frame;
258 268
259 Lisp_Object Vw32_num_mouse_buttons; 269 Lisp_Object Vw32_num_mouse_buttons;
275 so w32_mouse_position can know whether to report a scroll bar motion or 285 so w32_mouse_position can know whether to report a scroll bar motion or
276 an ordinary motion. 286 an ordinary motion.
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. */
280 Lisp_Object last_mouse_scroll_bar; 290 static Lisp_Object last_mouse_scroll_bar;
281 int last_mouse_scroll_bar_pos; 291 static 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. */
289 Time last_mouse_movement_time; 299
290 300 static Time last_mouse_movement_time;
291 /* Associative list linking character set strings to Windows codepages. */ 301
292 Lisp_Object Vw32_charset_info_alist; 302 /* Incremented by w32_read_socket whenever it really tries to read
293 303 events. */
294 /* Incremented by w32_read_socket whenever it really tries to read events. */ 304
295 #ifdef __STDC__ 305 #ifdef __STDC__
296 static int volatile input_signal_count; 306 static int volatile input_signal_count;
297 #else 307 #else
298 static int input_signal_count; 308 static int input_signal_count;
299 #endif 309 #endif
303 extern Lisp_Object Qface, Qmouse_face; 313 extern Lisp_Object Qface, Qmouse_face;
304 314
305 extern int errno; 315 extern 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
308 extern int extra_keyboard_modifiers; 319 extern 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
311 glyphs in x_draw_glyphs. */ 322 glyphs in x_draw_glyphs. */
312 323
367 static void w32_new_focus_frame P_ ((struct w32_display_info *, 378 static void w32_new_focus_frame P_ ((struct w32_display_info *,
368 struct frame *)); 379 struct frame *));
369 static void w32_frame_rehighlight P_ ((struct frame *)); 380 static void w32_frame_rehighlight P_ ((struct frame *));
370 static void x_frame_rehighlight P_ ((struct w32_display_info *)); 381 static void x_frame_rehighlight P_ ((struct w32_display_info *));
371 static void x_draw_hollow_cursor P_ ((struct window *, struct glyph_row *)); 382 static void x_draw_hollow_cursor P_ ((struct window *, struct glyph_row *));
372 static void x_draw_bar_cursor P_ ((struct window *, struct glyph_row *)); 383 static void x_draw_bar_cursor P_ ((struct window *, struct glyph_row *, int));
373 static int w32_intersect_rectangles P_ ((RECT *, RECT *, RECT *)); 384 static int w32_intersect_rectangles P_ ((RECT *, RECT *, RECT *));
374 static void expose_frame P_ ((struct frame *, int, int, int, int)); 385 static void expose_frame P_ ((struct frame *, int, int, int, int));
375 static void expose_window_tree P_ ((struct window *, RECT *)); 386 static void expose_window_tree P_ ((struct window *, RECT *));
376 static void expose_window P_ ((struct window *, RECT *)); 387 static void expose_window P_ ((struct window *, RECT *));
377 static void expose_area P_ ((struct window *, struct glyph_row *, 388 static void expose_area P_ ((struct window *, struct glyph_row *,
392 static void w32_clip_to_row P_ ((struct window *, struct glyph_row *, 403 static void w32_clip_to_row P_ ((struct window *, struct glyph_row *,
393 HDC, int)); 404 HDC, int));
394 405
395 static Lisp_Object Qvendor_specific_keysyms; 406 static Lisp_Object Qvendor_specific_keysyms;
396 407
397 Lisp_Object Qw32_charset_ansi;
398 Lisp_Object Qw32_charset_default;
399 Lisp_Object Qw32_charset_symbol;
400 Lisp_Object Qw32_charset_shiftjis;
401 Lisp_Object Qw32_charset_hangul;
402 Lisp_Object Qw32_charset_gb2312;
403 Lisp_Object Qw32_charset_chinesebig5;
404 Lisp_Object Qw32_charset_oem;
405
406 #ifdef JOHAB_CHARSET
407 Lisp_Object Qw32_charset_easteurope;
408 Lisp_Object Qw32_charset_turkish;
409 Lisp_Object Qw32_charset_baltic;
410 Lisp_Object Qw32_charset_russian;
411 Lisp_Object Qw32_charset_arabic;
412 Lisp_Object Qw32_charset_greek;
413 Lisp_Object Qw32_charset_hebrew;
414 Lisp_Object Qw32_charset_thai;
415 Lisp_Object Qw32_charset_johab;
416 Lisp_Object Qw32_charset_mac;
417 #endif
418
419 #ifdef UNICODE_CHARSET
420 Lisp_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
428 struct record 418 struct record
429 { 419 {
430 char *locus; 420 char *locus;
431 int type; 421 int type;
596 if (f == display_info->mouse_face_mouse_frame) 586 if (f == display_info->mouse_face_mouse_frame)
597 { 587 {
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
606 /* Can we tell that this update does not affect the window 596 /* Can we tell that this update does not affect the window
607 where the mouse highlight is? If so, no need to turn off. 597 where the mouse highlight is? If so, no need to turn off.
680 } 670 }
681 671
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
685 static void 679 static void
686 x_update_end (f) 680 x_update_end (f)
687 struct frame *f; 681 struct frame *f;
688 { 682 {
689 /* Mouse highlight may be displayed again. */ 683 /* Mouse highlight may be displayed again. */
690 FRAME_W32_DISPLAY_INFO (f)->mouse_face_defer = 0; 684 FRAME_W32_DISPLAY_INFO (f)->mouse_face_defer = 0;
691 } 685 }
686
692 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. */
696 691
963 958
964 release_frame_dc (f, hdc); 959 release_frame_dc (f, hdc);
965 } 960 }
966 961
967 962
968
969 /*********************************************************************** 963 /***********************************************************************
970 Line Highlighting 964 Line Highlighting
971 ***********************************************************************/ 965 ***********************************************************************/
972 966
973 /* External interface to control of standout mode. Not used for W32 967 /* External interface to control of standout mode. Not used for W32
989 int new_highlight, vpos, y, first_unused_hpos; 983 int new_highlight, vpos, y, first_unused_hpos;
990 { 984 {
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
998 static void 993 static void
999 w32_set_terminal_modes (void) 994 w32_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
1007 static void 1001 static void
1008 w32_reset_terminal_modes (void) 1002 w32_reset_terminal_modes (void)
1009 { 1003 {
1010 } 1004 }
1005
1011 1006
1012 1007
1013 /*********************************************************************** 1008 /***********************************************************************
1014 Output Cursor 1009 Output Cursor
1015 ***********************************************************************/ 1010 ***********************************************************************/
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
1019 static void 1015 static void
1020 set_output_cursor (cursor) 1016 set_output_cursor (cursor)
1021 struct cursor_pos *cursor; 1017 struct cursor_pos *cursor;
1022 { 1018 {
1023 output_cursor.hpos = cursor->hpos; 1019 output_cursor.hpos = cursor->hpos;
1063 x_display_cursor (w, 1, hpos, vpos, x, y); 1059 x_display_cursor (w, 1, hpos, vpos, x, y);
1064 UNBLOCK_INPUT; 1060 UNBLOCK_INPUT;
1065 } 1061 }
1066 } 1062 }
1067 1063
1064
1068 1065
1069 /*********************************************************************** 1066 /***********************************************************************
1070 Display Iterator 1067 Display Iterator
1071 ***********************************************************************/ 1068 ***********************************************************************/
1072 1069
1077 wchar_t *, 1074 wchar_t *,
1078 int *)); 1075 int *));
1079 static struct face *x_get_char_face_and_encoding P_ ((struct frame *, int, 1076 static struct face *x_get_char_face_and_encoding P_ ((struct frame *, int,
1080 int, wchar_t *, int)); 1077 int, wchar_t *, int));
1081 static XCharStruct *w32_per_char_metric P_ ((HDC hdc, XFontStruct *, 1078 static XCharStruct *w32_per_char_metric P_ ((HDC hdc, XFontStruct *,
1082 wchar_t *, int unicode_p)); 1079 wchar_t *,
1083 static void x_encode_char P_ ((int, wchar_t *, struct font_info *)); 1080 enum w32_char_font_type));
1081 static enum w32_char_font_type
1082 w32_encode_char P_ ((int, wchar_t *, struct font_info *, int *));
1084 static void x_append_glyph P_ ((struct it *)); 1083 static void x_append_glyph P_ ((struct it *));
1085 static void x_append_composite_glyph P_ ((struct it *)); 1084 static void x_append_composite_glyph P_ ((struct it *));
1086 static void x_append_stretch_glyph P_ ((struct it *it, Lisp_Object, 1085 static void x_append_stretch_glyph P_ ((struct it *it, Lisp_Object,
1087 int, int, double)); 1086 int, int, double));
1088 static void x_produce_glyphs P_ ((struct it *)); 1087 static void x_produce_glyphs P_ ((struct it *));
1103 1102
1104 /* NTEMACS_TODO: Add support for bdf fonts back in. */ 1103 /* NTEMACS_TODO: Add support for bdf fonts back in. */
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. */ 1108
1110 1109 static XCharStruct *
1111 static INLINE XCharStruct * 1110 w32_per_char_metric (hdc, font, char2b, font_type)
1112 w32_per_char_metric (hdc, font, char2b, unicode_p)
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;
1120 ABC char_widths; 1118 ABC char_widths;
1121 SIZE sz; 1119 SIZE sz;
1122 BOOL retval; 1120 BOOL retval;
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)
1137 { 1145 {
1138 pcm->width = char_widths.abcA + char_widths.abcB + char_widths.abcC; 1146 pcm->width = char_widths.abcA + char_widths.abcB + char_widths.abcC;
1143 { 1151 {
1144 /* Windows 9x does not implement GetCharABCWidthsW, so if that 1152 /* Windows 9x does not implement GetCharABCWidthsW, so if that
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)
1152 { 1160 {
1153 pcm->width = sz.cx; 1161 pcm->width = sz.cx;
1154 pcm->rbearing = sz.cx; 1162 pcm->rbearing = sz.cx;
1155 pcm->lbearing = 0; 1163 pcm->lbearing = 0;
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
1165 pcm->ascent = FONT_BASE (font); 1172 pcm->ascent = FONT_BASE (font);
1166 pcm->descent = FONT_DESCENT (font); 1173 pcm->descent = FONT_DESCENT (font);
1173 1180
1174 return pcm; 1181 return pcm;
1175 } 1182 }
1176 1183
1177 1184
1185 /* Determine if a font is double byte. */
1186 int 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
1181 static INLINE void 1195 static INLINE enum w32_char_font_type
1182 x_encode_char (c, char2b, font_info) 1196 w32_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;
1207
1208 xassert(two_byte_p);
1209
1210 *two_byte_p = w32_font_is_double_byte (font);
1190 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. */
1194 if (font_info->font_encoder) 1215 if (font_info->font_encoder)
1210 1231
1211 ccl_driver (ccl, NULL, NULL, 0, 0, NULL); 1232 ccl_driver (ccl, NULL, NULL, 0, 0, NULL);
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 {
1228 /* Fixed encoding scheme. See fontset.h for the meaning of the 1243 /* Fixed encoding scheme. See fontset.h for the meaning of the
1229 encoding numbers. */ 1244 encoding numbers. */
1258 temp[2] = '\0'; 1273 temp[2] = '\0';
1259 if (temp[0]) 1274 if (temp[0])
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
1267 /* Get face and two-byte form of character C in face FACE_ID on frame 1292 /* Get face and two-byte form of character C in face FACE_ID on frame
1268 F. The encoding of C is returned in *CHAR2B. MULTIBYTE_P non-zero 1293 F. The encoding of C is returned in *CHAR2B. MULTIBYTE_P non-zero
1307 if (face->font != NULL) 1332 if (face->font != NULL)
1308 { 1333 {
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
1316 /* Make sure X resources of the face are allocated. */ 1341 /* Make sure X resources of the face are allocated. */
1317 xassert (face != NULL); 1342 xassert (face != NULL);
1318 PREPARE_FACE_FOR_DISPLAY (f, face); 1343 PREPARE_FACE_FOR_DISPLAY (f, face);
1319 1344
1320 return face; 1345 return face;
1321 }
1322
1323
1324 /* Determine if a font is double byte. */
1325 int 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 } 1346 }
1331 1347
1332 1348
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
1340 struct glyph *glyph; 1356 struct glyph *glyph;
1341 wchar_t *char2b; 1357 wchar_t *char2b;
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 {
1354 /* Unibyte case. We don't have to encode, but we have to make 1373 /* Unibyte case. We don't have to encode, but we have to make
1355 sure to use a face suitable for unibyte. */ 1374 sure to use a face suitable for unibyte. */
1378 { 1397 {
1379 struct font_info *font_info 1398 struct font_info *font_info
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 }
1389 1407
1390 /* Make sure X resources of the face are allocated. */ 1408 /* Make sure X resources of the face are allocated. */
1509 1527
1510 /* Make sure X resources of the face and image are loaded. */ 1528 /* Make sure X resources of the face and image are loaded. */
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
1518 it->nglyphs = 1; 1536 it->nglyphs = 1;
1519 1537
1843 /* Either unibyte or ASCII. */ 1861 /* Either unibyte or ASCII. */
1844 int stretched_p; 1862 int stretched_p;
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; 1870
1852 it->phys_descent = pcm->descent - boff; 1871 if (pcm)
1853 it->pixel_width = pcm->width; 1872 {
1854 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);
1858 if (stretched_p) 1888 if (stretched_p)
1859 it->pixel_width *= XFLOATINT (it->space_width); 1889 it->pixel_width *= XFLOATINT (it->space_width);
1897 x_append_glyph (it); 1927 x_append_glyph (it);
1898 1928
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')
1909 { 1939 {
1910 /* A newline has no width but we need the height of the line. */ 1940 /* A newline has no width but we need the height of the line. */
1921 } 1951 }
1922 } 1952 }
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;
1932 it->nglyphs = 1; 1960 it->nglyphs = 1;
1933 it->ascent = it->phys_ascent = FONT_BASE (font) + boff; 1961 it->ascent = it->phys_ascent = FONT_BASE (font) + boff;
1946 If we found a font, this font should give us the right 1974 If we found a font, this font should give us the right
1947 metrics. If we didn't find a font, use the frame's 1975 metrics. If we didn't find a font, use the frame's
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 {
1955 int charset = CHAR_CHARSET (it->char_to_display); 1984 int charset = CHAR_CHARSET (it->char_to_display);
1956 1985
1960 it->phys_ascent = FONT_BASE (font) + boff; 1989 it->phys_ascent = FONT_BASE (font) + boff;
1961 it->phys_descent = FONT_DESCENT (font) - boff; 1990 it->phys_descent = FONT_DESCENT (font) - boff;
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
1968 && (pcm->lbearing < 0 1998 && (pcm->lbearing < 0
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;
1976 2005
1977 if (face->box != FACE_NO_BOX) 2006 if (face->box != FACE_NO_BOX)
1994 take_vertical_position_into_account (it); 2023 take_vertical_position_into_account (it);
1995 2024
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 }
2003 else if (it->what == IT_COMPOSITION) 2033 else if (it->what == IT_COMPOSITION)
2004 { 2034 {
2011 2041
2012 /* Accumulate dimensions. */ 2042 /* Accumulate dimensions. */
2013 xassert (it->ascent >= 0 && it->descent > 0); 2043 xassert (it->ascent >= 0 && it->descent > 0);
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;
2046
2047 it->descent += it->extra_line_spacing;
2016 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);
2020 it->max_phys_descent = max (it->max_phys_descent, it->phys_descent); 2052 it->max_phys_descent = max (it->max_phys_descent, it->phys_descent);
2034 /* This function is called so early when Emacs starts that the face 2066 /* This function is called so early when Emacs starts that the face
2035 cache and mode line face are not yet initialized. */ 2067 cache and mode line face are not yet initialized. */
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
2043 return height; 2075 return height;
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. */
2050 int
2051 w32_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
2084 BOOL 2080 BOOL
2085 w32_use_unicode_for_codepage (codepage) 2081 w32_use_unicode_for_codepage (codepage)
2086 int codepage; 2082 int codepage;
2087 { 2083 {
2211 2207
2212 struct glyph_string *next, *prev; 2208 struct glyph_string *next, *prev;
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
2218 void W32_TEXTOUT(s, x, y,chars,nchars) 2214 void W32_TEXTOUT(s, x, y,chars,nchars)
2219 struct glyph_string * s; 2215 struct glyph_string * s;
2220 int x, y; 2216 int x, y;
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
2237 2232
2238 static void 2233 static void
2286 static void x_set_glyph_string_gc P_ ((struct glyph_string *)); 2281 static void x_set_glyph_string_gc P_ ((struct glyph_string *));
2287 static void x_draw_glyph_string_background P_ ((struct glyph_string *, 2282 static void x_draw_glyph_string_background P_ ((struct glyph_string *,
2288 int)); 2283 int));
2289 static void x_draw_glyph_string_foreground P_ ((struct glyph_string *)); 2284 static void x_draw_glyph_string_foreground P_ ((struct glyph_string *));
2290 static void x_draw_composite_glyph_string_foreground P_ ((struct glyph_string *)); 2285 static void x_draw_composite_glyph_string_foreground P_ ((struct glyph_string *));
2291 static void x_draw_glyph_string_underline P_ ((struct glyph_string *));
2292 static void x_draw_glyph_string_underline P_ ((struct glyph_string *));
2293 static void x_draw_glyph_string_box P_ ((struct glyph_string *)); 2286 static void x_draw_glyph_string_box P_ ((struct glyph_string *));
2294 static void x_draw_glyph_string P_ ((struct glyph_string *)); 2287 static void x_draw_glyph_string P_ ((struct glyph_string *));
2295 static void x_compute_glyph_string_overhangs P_ ((struct glyph_string *)); 2288 static void x_compute_glyph_string_overhangs P_ ((struct glyph_string *));
2296 static void x_set_cursor_gc P_ ((struct glyph_string *)); 2289 static void x_set_cursor_gc P_ ((struct glyph_string *));
2297 static void x_set_mode_line_face_gc P_ ((struct glyph_string *)); 2290 static void x_set_mode_line_face_gc P_ ((struct glyph_string *));
2298 static void x_set_mouse_face_gc P_ ((struct glyph_string *)); 2291 static void x_set_mouse_face_gc P_ ((struct glyph_string *));
2299 static void w32_get_glyph_overhangs P_ ((HDC hdc, struct glyph *, 2292 static void w32_get_glyph_overhangs P_ ((HDC hdc, struct glyph *,
2300 struct frame *, 2293 struct frame *,
2301 int *, int *, int)); 2294 int *, int *));
2302 static void x_compute_overhangs_and_x P_ ((struct glyph_string *, int, int)); 2295 static void x_compute_overhangs_and_x P_ ((struct glyph_string *, int, int));
2303 static int w32_alloc_lighter_color (struct frame *, COLORREF *, double, int); 2296 static int w32_alloc_lighter_color (struct frame *, COLORREF *, double, int);
2304 static void w32_setup_relief_color P_ ((struct frame *, struct relief *, 2297 static void w32_setup_relief_color P_ ((struct frame *, struct relief *,
2305 double, int, COLORREF)); 2298 double, int, COLORREF));
2306 static void x_setup_relief_colors P_ ((struct glyph_string *)); 2299 static void x_setup_relief_colors P_ ((struct glyph_string *));
2670 /* Set *LEFT and *RIGHT to the left and right overhang of GLYPH on 2663 /* Set *LEFT and *RIGHT to the left and right overhang of GLYPH on
2671 frame F. Overhangs of glyphs other than type CHAR_GLYPH are 2664 frame F. Overhangs of glyphs other than type CHAR_GLYPH are
2672 assumed to be zero. */ 2665 assumed to be zero. */
2673 2666
2674 static void 2667 static void
2675 w32_get_glyph_overhangs (hdc, glyph, f, left, right, unicode_p) 2668 w32_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
2683 *left = *right = 0; 2676 *left = *right = 0;
2684 2677
2685 if (glyph->type == CHAR_GLYPH) 2678 if (glyph->type == CHAR_GLYPH)
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;
2701 if (pcm->lbearing < 0) 2694 if (pcm->lbearing < 0)
2702 *left = -pcm->lbearing; 2695 *left = -pcm->lbearing;
2711 struct glyph *glyph; 2704 struct glyph *glyph;
2712 struct frame *f; 2705 struct frame *f;
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
2720 2714
2721 /* Return the index of the first glyph preceding glyph string S that 2715 /* Return the index of the first glyph preceding glyph string S that
2761 k = -1; 2755 k = -1;
2762 x = 0; 2756 x = 0;
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;
2771 } 2764 }
2772 2765
2817 k = -1; 2810 k = -1;
2818 x = 0; 2811 x = 0;
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;
2827 } 2819 }
2828 2820
3292 static void 3284 static void
3293 x_draw_image_foreground (s) 3285 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. */
3301 if (s->face->box != FACE_NO_BOX 3293 if (s->face->box != FACE_NO_BOX
3302 && s->first_glyph->left_box_line_p) 3294 && s->first_glyph->left_box_line_p)
3393 struct glyph_string *s; 3385 struct glyph_string *s;
3394 { 3386 {
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
3403 && s->first_glyph->left_box_line_p) 3395 && s->first_glyph->left_box_line_p)
3404 x = s->x + s->face->box_line_width; 3396 x = s->x + s->face->box_line_width;
3444 HBITMAP pixmap; 3436 HBITMAP pixmap;
3445 { 3437 {
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. */
3453 if (s->face->box != FACE_NO_BOX 3445 if (s->face->box != FACE_NO_BOX
3454 && s->first_glyph->left_box_line_p) 3446 && s->first_glyph->left_box_line_p)
3789 } 3781 }
3790 3782
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;
3798 3791
3799 if (s->face->underline_defaulted_p) 3792 if (s->face->underline_defaulted_p)
3824 s->y + dy, s->width, h); 3817 s->y + dy, s->width, h);
3825 } 3818 }
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;
3833 3827
3834 if (s->face->strike_through_color_defaulted_p) 3828 if (s->face->strike_through_color_defaulted_p)
3936 xassert (s->f == XFRAME (s->w->frame)); 3930 xassert (s->f == XFRAME (s->w->frame));
3937 xassert (s->nchars == 0); 3931 xassert (s->nchars == 0);
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;
3945 3938
3946 glyph_not_available_p = glyph->glyph_not_available_p; 3939 glyph_not_available_p = glyph->glyph_not_available_p;
4147 int c, charset, face_id; \ 4140 int c, charset, face_id; \
4148 wchar_t *char2b; \ 4141 wchar_t *char2b; \
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); \
4155 x_append_glyph_string (&HEAD, &TAIL, s); \ 4149 x_append_glyph_string (&HEAD, &TAIL, s); \
4156 s->x = (X); \ 4150 s->x = (X); \
4213 \ 4207 \
4214 ++START; \ 4208 ++START; \
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
4221 DRAW_CURSOR to draw a cursor. X and LAST_X are start and end 4216 DRAW_CURSOR to draw a cursor. X and LAST_X are start and end
4222 x-positions of the drawing area. 4217 x-positions of the drawing area.
4355 BUILD_GLYPH_STRINGS will modify its start parameter. That's 4350 BUILD_GLYPH_STRINGS will modify its start parameter. That's
4356 the reason we use a separate variable `i'. */ 4351 the reason we use a separate variable `i'. */
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
4364 x_reached = x; 4358 x_reached = x;
4365 4359
4405 if (i >= 0) 4399 if (i >= 0)
4406 { 4400 {
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)
4414 *real_start = i; 4407 *real_start = i;
4415 x_compute_overhangs_and_x (t, head->x, 1); 4408 x_compute_overhangs_and_x (t, head->x, 1);
4424 if (i >= 0) 4417 if (i >= 0)
4425 { 4418 {
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)
4433 *real_end = i; 4425 *real_end = i;
4434 } 4426 }
4442 if (i >= 0) 4434 if (i >= 0)
4443 { 4435 {
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);
4451 x_append_glyph_string_lists (&head, &tail, h, t); 4442 x_append_glyph_string_lists (&head, &tail, h, t);
4452 if (real_end) 4443 if (real_end)
4846 BitBlt (hdc, x, to_y, width, height, hdc, x, from_y, SRCCOPY); 4837 BitBlt (hdc, x, to_y, width, height, hdc, x, from_y, SRCCOPY);
4847 4838
4848 UNBLOCK_INPUT; 4839 UNBLOCK_INPUT;
4849 release_frame_dc (f, hdc); 4840 release_frame_dc (f, hdc);
4850 } 4841 }
4842
4851 4843
4852 4844
4853 /*********************************************************************** 4845 /***********************************************************************
4854 Exposure Events 4846 Exposure Events
4855 ***********************************************************************/ 4847 ***********************************************************************/
5171 { 5163 {
5172 RECT *left, *right; 5164 RECT *left, *right;
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
5180 left = r2, right = r1; 5172 left = r2, right = r1;
5181 5173
5209 } 5201 }
5210 5202
5211 return intersection_p; 5203 return intersection_p;
5212 } 5204 }
5213 5205
5206
5207
5208
5214 5209
5215 static void 5210 static void
5216 frame_highlight (f) 5211 frame_highlight (f)
5217 struct frame *f; 5212 struct frame *f;
5218 { 5213 {
5223 frame_unhighlight (f) 5218 frame_unhighlight (f)
5224 struct frame *f; 5219 struct frame *f;
5225 { 5220 {
5226 x_update_cursor (f, 1); 5221 x_update_cursor (f, 1);
5227 } 5222 }
5228
5229 5223
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
5236 void 5230 static void
5237 x_new_focus_frame (dpyinfo, frame) 5231 x_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;
5240 { 5234 {
5241 struct frame *old_focus = dpyinfo->w32_focus_frame; 5235 struct frame *old_focus = dpyinfo->w32_focus_frame;
5267 x_new_focus_frame (dpyinfo, dpyinfo->w32_focus_event_frame); 5261 x_new_focus_frame (dpyinfo, dpyinfo->w32_focus_event_frame);
5268 } 5262 }
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
5277 static void 5272 static void
5278 w32_frame_rehighlight (frame) 5273 w32_frame_rehighlight (frame)
5279 struct frame *frame; 5274 struct frame *frame;
5280 { 5275 {
5281 x_frame_rehighlight (FRAME_W32_DISPLAY_INFO (frame)); 5276 x_frame_rehighlight (FRAME_W32_DISPLAY_INFO (frame));
5326 GetKeyNameText(keysym, value, 100); 5321 GetKeyNameText(keysym, value, 100);
5327 UNBLOCK_INPUT; 5322 UNBLOCK_INPUT;
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
5339 void 5336 void
5340 pixel_to_glyph_coords (f, pix_x, pix_y, x, y, bounds, noclip) 5337 pixel_to_glyph_coords (f, pix_x, pix_y, x, y, bounds, noclip)
5341 FRAME_PTR f; 5338 FRAME_PTR f;
5342 register int pix_x, pix_y; 5339 register int pix_x, pix_y;
5633 note_mouse_highlight (frame, LOWORD (msg->lParam), HIWORD (msg->lParam)); 5630 note_mouse_highlight (frame, LOWORD (msg->lParam), HIWORD (msg->lParam));
5634 } 5631 }
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
5638 int disable_mouse_highlight; 5636 int disable_mouse_highlight;
5639 5637
5640 5638
5641 5639
5642 /************************************************************************ 5640 /************************************************************************
5811 Qlocal_map, glyph->object); 5809 Qlocal_map, glyph->object);
5812 if (!NILP (Fkeymapp (map))) 5810 if (!NILP (Fkeymapp (map)))
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
5826 static void 5826 static void
5827 note_mouse_highlight (f, x, y) 5827 note_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);
5832 int portion; 5832 int portion;
5833 Lisp_Object window; 5833 Lisp_Object window;
5835 5835
5836 /* When a menu is active, don't highlight because this looks odd. */ 5836 /* When a menu is active, don't highlight because this looks odd. */
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;
5844 dpyinfo->mouse_face_mouse_y = y; 5845 dpyinfo->mouse_face_mouse_y = y;
5845 dpyinfo->mouse_face_mouse_frame = f; 5846 dpyinfo->mouse_face_mouse_frame = f;
5888 f->output_data.x->text_cursor); 5889 f->output_data.x->text_cursor);
5889 #endif 5890 #endif
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;
5901 5903
5902 /* Find the glyph under X/Y. */ 5904 /* Find the glyph under X/Y. */
6081 current_buffer = obuf; 6083 current_buffer = obuf;
6082 } 6084 }
6083 } 6085 }
6084 } 6086 }
6085 6087
6086
6087 static void 6088 static void
6088 redo_mouse_highlight () 6089 redo_mouse_highlight ()
6089 { 6090 {
6090 if (!NILP (last_mouse_motion_frame) 6091 if (!NILP (last_mouse_motion_frame)
6091 && FRAME_LIVE_P (XFRAME (last_mouse_motion_frame))) 6092 && FRAME_LIVE_P (XFRAME (last_mouse_motion_frame)))
6153 6154
6154 return 1; 6155 return 1;
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
6162 static void 6163 static void
6163 w32_handle_tool_bar_click (f, button_event) 6164 w32_handle_tool_bar_click (f, button_event)
6214 last_tool_bar_item = -1; 6215 last_tool_bar_item = -1;
6215 } 6216 }
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
6223 static void 6224 static void
6224 note_tool_bar_highlight (f, x, y) 6225 note_tool_bar_highlight (f, x, y)
6308 if (!STRINGP (help_echo)) 6309 if (!STRINGP (help_echo))
6309 help_echo = (XVECTOR (f->current_tool_bar_items) 6310 help_echo = (XVECTOR (f->current_tool_bar_items)
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
6316 current glyphs must be up to date. If POS is above window start 6318 current glyphs must be up to date. If POS is above window start
6317 return (0, 0, 0, 0). If POS is after end of W, return end of 6319 return (0, 0, 0, 0). If POS is after end of W, return end of
6354 { 6356 {
6355 best_row = row; 6357 best_row = row;
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 }
6362 6367
6363 /* Find the right column within BEST_ROW. */ 6368 /* Find the right column within BEST_ROW. */
6499 f->output_data.x->nontext_cursor); 6504 f->output_data.x->nontext_cursor);
6500 #endif 6505 #endif
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
6508 void 6512 void
6509 clear_mouse_face (dpyinfo) 6513 clear_mouse_face (dpyinfo)
6510 struct w32_display_info *dpyinfo; 6514 struct w32_display_info *dpyinfo;
6511 { 6515 {
6537 dpyinfo->mouse_face_end_row = dpyinfo->mouse_face_end_col = -1; 6541 dpyinfo->mouse_face_end_row = dpyinfo->mouse_face_end_col = -1;
6538 dpyinfo->mouse_face_window = Qnil; 6542 dpyinfo->mouse_face_window = Qnil;
6539 } 6543 }
6540 } 6544 }
6541 6545
6542 struct scroll_bar *x_window_to_scroll_bar (); 6546 static struct scroll_bar *x_window_to_scroll_bar ();
6543 static void x_scroll_bar_report_motion (); 6547 static void x_scroll_bar_report_motion ();
6544 6548
6545 /* Return the current position of the mouse. 6549 /* Return the current position of the mouse.
6546 *fp should be a frame which indicates which display to ask about. 6550 *fp should be a frame which indicates which display to ask about.
6547 6551
6552 6556
6553 If the mouse movement started elsewhere, set *fp to the frame the 6557 If the mouse movement started elsewhere, set *fp to the frame the
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
6567 static void 6569 static void
6568 w32_mouse_position (fp, insist, bar_window, part, x, y, time) 6570 w32_mouse_position (fp, insist, bar_window, part, x, y, time)
6569 FRAME_PTR *fp; 6571 FRAME_PTR *fp;
6570 int insist; 6572 int insist;
6576 FRAME_PTR f1; 6578 FRAME_PTR f1;
6577 6579
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 {
6585 POINT pt; 6586 POINT pt;
6586 6587
6682 /* Scroll bar support. */ 6683 /* Scroll bar support. */
6683 6684
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. */
6687 struct scroll_bar * 6688
6689 static struct scroll_bar *
6688 x_window_to_scroll_bar (window_id) 6690 x_window_to_scroll_bar (window_id)
6689 Window window_id; 6691 Window window_id;
6690 { 6692 {
6691 Lisp_Object tail; 6693 Lisp_Object tail;
6692 6694
6944 struct window *w; 6946 struct window *w;
6945 int portion, whole, position; 6947 int 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. */
6953 window_box (w, -1, &window_x, &window_y, &window_width, &window_height); 6955 window_box (w, -1, &window_x, &window_y, &window_width, &window_height);
6954 top = window_y; 6956 top = window_y;
7067 that *all* scroll bars are to be removed, and then save a scroll bar 7069 that *all* scroll bars are to be removed, and then save a scroll bar
7068 from the fiery pit when we actually redisplay its window. */ 7070 from the fiery pit when we actually redisplay its window. */
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
7073 static void 7076 static void
7074 w32_condemn_scroll_bars (frame) 7077 w32_condemn_scroll_bars (frame)
7075 FRAME_PTR frame; 7078 FRAME_PTR frame;
7076 { 7079 {
7077 /* Transfer all the scroll bars to FRAME_CONDEMNED_SCROLL_BARS. */ 7080 /* Transfer all the scroll bars to FRAME_CONDEMNED_SCROLL_BARS. */
7086 XSCROLL_BAR (FRAME_CONDEMNED_SCROLL_BARS (frame))->prev = bar; 7089 XSCROLL_BAR (FRAME_CONDEMNED_SCROLL_BARS (frame))->prev = bar;
7087 FRAME_CONDEMNED_SCROLL_BARS (frame) = bar; 7090 FRAME_CONDEMNED_SCROLL_BARS (frame) = bar;
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. */
7093 static void 7096 static void
7094 w32_redeem_scroll_bar (window) 7097 w32_redeem_scroll_bar (window)
7095 struct window *window; 7098 struct window *window;
7096 { 7099 {
7135 } 7138 }
7136 } 7139 }
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
7140 static void 7144 static void
7141 w32_judge_scroll_bars (f) 7145 w32_judge_scroll_bars (f)
7142 FRAME_PTR f; 7146 FRAME_PTR f;
7143 { 7147 {
7144 Lisp_Object bar, next; 7148 Lisp_Object bar, next;
7203 else 7207 else
7204 y = GetScrollPos ((HWND) msg->msg.lParam, SB_CTL); 7208 y = GetScrollPos ((HWND) msg->msg.lParam, SB_CTL);
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:
7211 emacs_event->part = scroll_bar_down_arrow; 7218 emacs_event->part = scroll_bar_down_arrow;
7212 break; 7219 break;
7285 } 7292 }
7286 } 7293 }
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
7290 static void 7298 static void
7291 x_scroll_bar_report_motion (fp, bar_window, part, x, y, time) 7299 x_scroll_bar_report_motion (fp, bar_window, part, x, y, time)
7292 FRAME_PTR *fp; 7300 FRAME_PTR *fp;
7293 Lisp_Object *bar_window; 7301 Lisp_Object *bar_window;
7294 enum scroll_bar_part *part; 7302 enum scroll_bar_part *part;
7346 *time = last_mouse_movement_time; 7354 *time = last_mouse_movement_time;
7347 7355
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
7355 void 7365 void
7356 x_scroll_bar_clear (f) 7366 x_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)
7367 7377 {
7368 /* Hide scroll bar until ready to repaint. x_scroll_bar_move 7378 HWND window = SCROLL_BAR_W32_WINDOW (XSCROLL_BAR (bar));
7369 arranges to refresh the scroll bar if hidden. */ 7379 HDC hdc = GetDC (window);
7370 my_show_window (f, window, SW_HIDE); 7380 RECT rect;
7371 7381
7372 GetClientRect (window, &rect); 7382 /* Hide scroll bar until ready to repaint. x_scroll_bar_move
7373 select_palette (f, hdc); 7383 arranges to refresh the scroll bar if hidden. */
7374 w32_clear_rect (f, hdc, &rect); 7384 my_show_window (f, window, SW_HIDE);
7375 deselect_palette (f, hdc); 7385
7376 7386 GetClientRect (window, &rect);
7377 ReleaseDC (window, hdc); 7387 select_palette (f, hdc);
7378 } 7388 w32_clear_rect (f, hdc, &rect);
7389 deselect_palette (f, hdc);
7390
7391 ReleaseDC (window, hdc);
7392 }
7379 } 7393 }
7380 7394
7381 show_scroll_bars (f, how) 7395 show_scroll_bars (f, how)
7382 FRAME_PTR f; 7396 FRAME_PTR f;
7383 int how; 7397 int how;
7393 } 7407 }
7394 7408
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
7401 static Time enter_timestamp; 7416 static 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. */
7405 int temp_index; 7420
7406 short temp_buffer[100]; 7421 static int temp_index;
7422 static short temp_buffer[100];
7407 7423
7408 7424
7409 /* Read events coming from the W32 shell. 7425 /* Read events coming from the W32 shell.
7410 This routine is called by the SIGIO handler. 7426 This routine is called by the SIGIO handler.
7411 We return as soon as there are no more events to be read. 7427 We return as soon as there are no more events to be read.
7427 */ 7443 */
7428 7444
7429 int 7445 int
7430 w32_read_socket (sd, bufp, numchars, expected) 7446 w32_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;
7437 int check_visibility = 0; 7453 int check_visibility = 0;
7438 W32Msg msg; 7454 W32Msg msg;
7715 case WM_MENUSELECT: 7731 case WM_MENUSELECT:
7716 { 7732 {
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
7725 case WM_DROPFILES: 7748 case WM_DROPFILES:
7726 f = x_window_to_frame (dpyinfo, msg.msg.hwnd); 7749 f = x_window_to_frame (dpyinfo, msg.msg.hwnd);
7835 XSETFRAME (bufp->frame_or_window, f); 7858 XSETFRAME (bufp->frame_or_window, f);
7836 bufp++; 7859 bufp++;
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. */
7844 record_asynch_buffer_change (); 7868 record_asynch_buffer_change ();
7845 break; 7869 break;
7917 /* If we move outside the frame, then we're 7941 /* If we move outside the frame, then we're
7918 certainly no longer on any text in the frame. */ 7942 certainly no longer on any text in the frame. */
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
7925 the mouse leaves the frame. */ 7950 the mouse leaves the frame. */
7926 if (any_help_event_p) 7951 if (any_help_event_p)
8090 8115
8091 UNBLOCK_INPUT; 8116 UNBLOCK_INPUT;
8092 return count; 8117 return count;
8093 } 8118 }
8094 8119
8120
8121
8095 8122
8096 /*********************************************************************** 8123 /***********************************************************************
8097 Text Cursor 8124 Text Cursor
8098 ***********************************************************************/ 8125 ***********************************************************************/
8099 8126
8143 clip_rect.top = max (clip_rect.top, window_y); 8170 clip_rect.top = max (clip_rect.top, window_y);
8144 clip_rect.right = clip_rect.left + window_width; 8171 clip_rect.right = clip_rect.left + window_width;
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);
8152 clip_rect.right += FRAME_X_FLAGS_AREA_WIDTH (f); 8179 clip_rect.right += FRAME_X_FLAGS_AREA_WIDTH (f);
8153 } 8180 }
8207 angle equal to the one given by the font property XA_ITALIC_ANGLE. 8234 angle equal to the one given by the font property XA_ITALIC_ANGLE.
8208 Unfortunately, I didn't find a font yet that has this property set. 8235 Unfortunately, I didn't find a font yet that has this property set.
8209 --gerd. */ 8236 --gerd. */
8210 8237
8211 static void 8238 static void
8212 x_draw_bar_cursor (w, row) 8239 x_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
8218 glyphs and mini-buffer. */ 8246 glyphs and mini-buffer. */
8219 if (w->phys_cursor.hpos < row->used[TEXT_AREA]) 8247 if (w->phys_cursor.hpos < row->used[TEXT_AREA])
8227 if (cursor_glyph == NULL) 8255 if (cursor_glyph == NULL)
8228 return; 8256 return;
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 }
8241 } 8271 }
8242 8272
8390 struct window *w; 8420 struct window *w;
8391 int on, hpos, vpos, x, y; 8421 int 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;
8398 8429
8399 /* This is pointless on invisible frames, and dangerous on garbaged 8430 /* This is pointless on invisible frames, and dangerous on garbaged
8428 mini-buffer window, we want the cursor only to appear if we are 8459 mini-buffer window, we want the cursor only to appear if we are
8429 reading input from this window. For the selected window, we want 8460 reading input from this window. For the selected window, we want
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))
8436 { 8468 {
8437 if (w == XWINDOW (echo_area_window)) 8469 if (w == XWINDOW (echo_area_window))
8452 new_cursor_type = HOLLOW_BOX_CURSOR; 8484 new_cursor_type = HOLLOW_BOX_CURSOR;
8453 } 8485 }
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
8461 it is in the wrong place, or the cursor type is not what we want, 8501 it is in the wrong place, or the cursor type is not what we want,
8462 erase it. */ 8502 erase it. */
8492 case FILLED_BOX_CURSOR: 8532 case FILLED_BOX_CURSOR:
8493 x_draw_phys_cursor_glyph (w, glyph_row, DRAW_CURSOR); 8533 x_draw_phys_cursor_glyph (w, glyph_row, DRAW_CURSOR);
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:
8501 break; 8541 break;
8502 8542
8564 static void 8604 static void
8565 x_update_window_cursor (w, on) 8605 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 {
8573 } 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 }
8619 }
8620
8574 8621
8575 8622
8576 8623
8577 /* Icons. */ 8624 /* Icons. */
8578 8625
8800 8847
8801 8848
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
8852 void
8805 x_calc_absolute_position (f) 8853 x_calc_absolute_position (f)
8806 struct frame *f; 8854 struct frame *f;
8807 { 8855 {
8808 Window child; 8856 Window child;
8809 POINT pt; 8857 POINT pt;
8858 to really change the position, and 0 when calling from 8906 to really change the position, and 0 when calling from
8859 x_make_frame_visible (in that case, XOFF and YOFF are the current 8907 x_make_frame_visible (in that case, XOFF and YOFF are the current
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
8911 void
8863 x_set_offset (f, xoff, yoff, change_gravity) 8912 x_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;
8866 int change_gravity; 8915 int change_gravity;
8867 { 8916 {
9340 9389
9341 XSetWMHints (FRAME_X_DISPLAY (f), window, &f->display.x->wm_hints); 9390 XSetWMHints (FRAME_X_DISPLAY (f), window, &f->display.x->wm_hints);
9342 #endif 9391 #endif
9343 } 9392 }
9344 9393
9394
9345 9395
9346 /*********************************************************************** 9396 /***********************************************************************
9347 Initialization 9397 Initialization
9348 ***********************************************************************/ 9398 ***********************************************************************/
9349 9399
9712 Far-East Languages on Windows 95/98 from working properly.\n\ 9762 Far-East Languages on Windows 95/98 from working properly.\n\
9713 NT uses Unicode internally anyway, so this flag will probably have no\n\ 9763 NT uses Unicode internally anyway, so this flag will probably have no\n\
9714 affect on NT machines."); 9764 affect 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\
9725 and codepages. Each entry should be of the form:\n\
9726 \n\
9727 (CHARSET_NAME . (WINDOWS_CHARSET . CODEPAGE))\n\
9728 \n\
9729 where CHARSET_NAME is a string used in font names to identify the charset,\n\
9730 WINDOWS_CHARSET is a symbol that can be one of:\n\
9731 w32-charset-ansi, w32-charset-default, w32-charset-symbol,\n\
9732 w32-charset-shiftjis, w32-charset-hangul, w32-charset-gb2312,\n\
9733 w32-charset-chinesebig5, "
9734 #ifdef JOHAB_CHARSET
9735 "w32-charset-johab, w32-charset-hebrew,\n\
9736 w32-charset-arabic, w32-charset-greek, w32-charset-turkish,\n\
9737 w32-charset-vietnamese, w32-charset-thai, w32-charset-easteurope,\n\
9738 w32-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\
9744 CODEPAGE should be an integer specifying the codepage that should be used\n\
9745 to display the character set, t to do no translation and output as Unicode,\n\
9746 or nil to do no translation and output as 8 bit (or multibyte on far-east\n\
9747 versions 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);
9806 previous_help_echo = Qnil; 9770 previous_help_echo = Qnil;
9807 9771