aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJason Rumney2000-09-29 21:20:59 +0000
committerJason Rumney2000-09-29 21:20:59 +0000
commit9127e20e661969ff6ab5977825a43dbf85f8802a (patch)
tree75f62e93c25e524137cd861c2b93b13693f81ff9 /src
parentc70c6b58c075dd455a85025396e7cd1e1b5a188a (diff)
downloademacs-9127e20e661969ff6ab5977825a43dbf85f8802a.tar.gz
emacs-9127e20e661969ff6ab5977825a43dbf85f8802a.zip
(w32_char_font_type, w32_encode_char, x_produce_glyphs): Distinguish
single and multibyte BDF fonts. (w32_bdf_per_char_metric): New function. (w32_per_char_metric): Use it. (x_draw_glyph_string_background): Always draw background for BDF glyphs. (x_produce_glyphs): If the distance from the current position to the next tab stop is less than a canonical character width, use the tab stop after that. (x_draw_glyphs): Handle case START and END are out of bounds more carefully. (x_clear_mouse_face): Block/unblock input. (x_display_and_set_cursor): Don't show a hollow box cursor for buffers whose cursor_type is nil.
Diffstat (limited to 'src')
-rw-r--r--src/w32term.c143
1 files changed, 100 insertions, 43 deletions
diff --git a/src/w32term.c b/src/w32term.c
index cba210ebab5..b336fc9fbe5 100644
--- a/src/w32term.c
+++ b/src/w32term.c
@@ -84,7 +84,8 @@ enum w32_char_font_type
84 UNKNOWN_FONT, 84 UNKNOWN_FONT,
85 ANSI_FONT, 85 ANSI_FONT,
86 UNICODE_FONT, 86 UNICODE_FONT,
87 BDF_FONT 87 BDF_1D_FONT,
88 BDF_2D_FONT
88}; 89};
89 90
90/* Bitmaps are all unsigned short, as Windows requires bitmap data to 91/* Bitmaps are all unsigned short, as Windows requires bitmap data to
@@ -1125,34 +1126,69 @@ static void x_produce_image_glyph P_ ((struct it *it));
1125 ((ch) & 0x00ff) 1126 ((ch) & 0x00ff)
1126 1127
1127 1128
1128/* NTEMACS_TODO: Add support for bdf fonts back in. */
1129
1130/* Get metrics of character CHAR2B in FONT. Value is always non-null. 1129/* Get metrics of character CHAR2B in FONT. Value is always non-null.
1131 If CHAR2B is not contained in FONT, the font's default character 1130 If CHAR2B is not contained in FONT, the font's default character
1132 metric is returned. */ 1131 metric is returned. */
1133 1132
1134static XCharStruct * 1133static XCharStruct *
1134w32_bdf_per_char_metric (font, char2b, dim)
1135 XFontStruct *font;
1136 wchar_t *char2b;
1137 int dim;
1138{
1139 glyph_metric * bdf_metric;
1140 char buf[2];
1141 XCharStruct * pcm = (XCharStruct *) xmalloc (sizeof (XCharStruct));
1142
1143 if (dim == 1)
1144 buf[0] = (char)char2b;
1145 else
1146 {
1147 buf[0] = BYTE1 (*char2b);
1148 buf[1] = BYTE2 (*char2b);
1149 }
1150
1151 bdf_metric = w32_BDF_TextMetric (font->bdf, buf, dim);
1152
1153 if (bdf_metric)
1154 {
1155 pcm->width = bdf_metric->dwidth;
1156 pcm->lbearing = bdf_metric->bbox;
1157 pcm->rbearing = bdf_metric->dwidth
1158 - (bdf_metric->bbox + bdf_metric->bbw);
1159 pcm->ascent = bdf_metric->bboy + bdf_metric->bbh;
1160 pcm->descent = bdf_metric->bboy;
1161 }
1162 else
1163 {
1164 xfree (pcm);
1165 return NULL;
1166 }
1167 return pcm;
1168}
1169
1170
1171static XCharStruct *
1135w32_per_char_metric (hdc, font, char2b, font_type) 1172w32_per_char_metric (hdc, font, char2b, font_type)
1136 HDC hdc; 1173 HDC hdc;
1137 XFontStruct *font; 1174 XFontStruct *font;
1138 wchar_t *char2b; 1175 wchar_t *char2b;
1139 enum w32_char_font_type font_type; 1176 enum w32_char_font_type font_type;
1140{ 1177{
1178 /* NTEMACS_TODO: Use GetGlyphOutline where possible (no Unicode
1179 version on W9x) */
1180
1141 /* The result metric information. */ 1181 /* The result metric information. */
1142 XCharStruct *pcm; 1182 XCharStruct *pcm;
1143 BOOL retval; 1183 BOOL retval;
1144 1184
1145 xassert (font && char2b); 1185 xassert (font && char2b);
1186 xassert (font_type != UNKNOWN_FONT);
1146 1187
1147 if (font_type == UNKNOWN_FONT) 1188 if (font_type == BDF_1D_FONT)
1148 { 1189 return w32_bdf_per_char_metric (font, char2b, 1);
1149 if (font->bdf) 1190 else if (font_type == BDF_2D_FONT)
1150 font_type = BDF_FONT; 1191 return w32_bdf_per_char_metric (font, char2b, 2);
1151 else if (!w32_enable_unicode_output)
1152 font_type = ANSI_FONT;
1153 else
1154 font_type = UNICODE_FONT;
1155 }
1156 1192
1157 pcm = (XCharStruct *) xmalloc (sizeof (XCharStruct)); 1193 pcm = (XCharStruct *) xmalloc (sizeof (XCharStruct));
1158 1194
@@ -1224,7 +1260,7 @@ w32_per_char_metric (hdc, font, char2b, font_type)
1224 if (pcm->width == 0 && (pcm->rbearing - pcm->lbearing) == 0) 1260 if (pcm->width == 0 && (pcm->rbearing - pcm->lbearing) == 0)
1225 { 1261 {
1226 xfree (pcm); 1262 xfree (pcm);
1227 pcm = NULL; 1263 return NULL;
1228 } 1264 }
1229 1265
1230 return pcm; 1266 return pcm;
@@ -1254,7 +1290,7 @@ w32_encode_char (c, char2b, font_info, two_byte_p)
1254 1290
1255 XFontStruct *font = font_info->font; 1291 XFontStruct *font = font_info->font;
1256 1292
1257 xassert(two_byte_p); 1293 xassert (two_byte_p);
1258 1294
1259 *two_byte_p = w32_font_is_double_byte (font); 1295 *two_byte_p = w32_font_is_double_byte (font);
1260 1296
@@ -1329,8 +1365,10 @@ w32_encode_char (c, char2b, font_info, two_byte_p)
1329 } 1365 }
1330 if (!font) 1366 if (!font)
1331 return UNKNOWN_FONT; 1367 return UNKNOWN_FONT;
1368 else if (font->bdf && CHARSET_DIMENSION (charset) == 1)
1369 return BDF_1D_FONT;
1332 else if (font->bdf) 1370 else if (font->bdf)
1333 return BDF_FONT; 1371 return BDF_2D_FONT;
1334 else if (unicode_p) 1372 else if (unicode_p)
1335 return UNICODE_FONT; 1373 return UNICODE_FONT;
1336 else 1374 else
@@ -1916,7 +1954,7 @@ x_produce_glyphs (it)
1916 it->nglyphs = 1; 1954 it->nglyphs = 1;
1917 1955
1918 pcm = w32_per_char_metric (hdc, font, &char2b, 1956 pcm = w32_per_char_metric (hdc, font, &char2b,
1919 font->bdf ? BDF_FONT : ANSI_FONT); 1957 font->bdf ? BDF_1D_FONT : ANSI_FONT);
1920 it->ascent = FONT_BASE (font) + boff; 1958 it->ascent = FONT_BASE (font) + boff;
1921 it->descent = FONT_DESCENT (font) - boff; 1959 it->descent = FONT_DESCENT (font) - boff;
1922 1960
@@ -1929,9 +1967,9 @@ x_produce_glyphs (it)
1929 else 1967 else
1930 { 1968 {
1931 it->glyph_not_available_p = 1; 1969 it->glyph_not_available_p = 1;
1932 it->phys_ascent = FONT_BASE(font) + boff; 1970 it->phys_ascent = FONT_BASE (font) + boff;
1933 it->phys_descent = FONT_DESCENT(font) - boff; 1971 it->phys_descent = FONT_DESCENT (font) - boff;
1934 it->pixel_width = FONT_WIDTH(font); 1972 it->pixel_width = FONT_WIDTH (font);
1935 } 1973 }
1936 1974
1937 /* If this is a space inside a region of text with 1975 /* If this is a space inside a region of text with
@@ -2008,6 +2046,12 @@ x_produce_glyphs (it)
2008 int x = it->current_x + it->continuation_lines_width; 2046 int x = it->current_x + it->continuation_lines_width;
2009 int next_tab_x = ((1 + x + tab_width - 1) / tab_width) * tab_width; 2047 int next_tab_x = ((1 + x + tab_width - 1) / tab_width) * tab_width;
2010 2048
2049 /* If the distance from the current position to the next tab
2050 stop is less than a canonical character width, use the
2051 tab stop after that. */
2052 if (next_tab_x - x < CANON_X_UNIT (it->f))
2053 next_tab_x += tab_width;
2054
2011 it->pixel_width = next_tab_x - x; 2055 it->pixel_width = next_tab_x - x;
2012 it->nglyphs = 1; 2056 it->nglyphs = 1;
2013 it->ascent = it->phys_ascent = FONT_BASE (font) + boff; 2057 it->ascent = it->phys_ascent = FONT_BASE (font) + boff;
@@ -2028,8 +2072,16 @@ x_produce_glyphs (it)
2028 default font and calculate the width of the character 2072 default font and calculate the width of the character
2029 from the charset width; this is what old redisplay code 2073 from the charset width; this is what old redisplay code
2030 did. */ 2074 did. */
2031 pcm = w32_per_char_metric (hdc, font, &char2b, 2075 enum w32_char_font_type type;
2032 font->bdf ? BDF_FONT : UNICODE_FONT); 2076
2077 if (font->bdf && CHARSET_DIMENSION (CHAR_CHARSET (it->c)) == 1)
2078 type = BDF_1D_FONT;
2079 else if (font->bdf)
2080 type = BDF_2D_FONT;
2081 else
2082 type = UNICODE_FONT;
2083
2084 pcm = w32_per_char_metric (hdc, font, &char2b, type);
2033 2085
2034 if (font_not_found_p || !pcm) 2086 if (font_not_found_p || !pcm)
2035 { 2087 {
@@ -2263,7 +2315,7 @@ struct glyph_string
2263 2315
2264/* Encapsulate the different ways of displaying text under W32. */ 2316/* Encapsulate the different ways of displaying text under W32. */
2265 2317
2266void W32_TEXTOUT(s, x, y,chars,nchars) 2318void W32_TEXTOUT (s, x, y,chars,nchars)
2267 struct glyph_string * s; 2319 struct glyph_string * s;
2268 int x, y; 2320 int x, y;
2269 wchar_t * chars; 2321 wchar_t * chars;
@@ -2928,6 +2980,7 @@ x_draw_glyph_string_background (s, force_p)
2928 if (FONT_HEIGHT (s->font) < s->height - 2 * s->face->box_line_width 2980 if (FONT_HEIGHT (s->font) < s->height - 2 * s->face->box_line_width
2929 || s->font_not_found_p 2981 || s->font_not_found_p
2930 || s->extends_to_end_of_line_p 2982 || s->extends_to_end_of_line_p
2983 || s->font->bdf
2931 || force_p) 2984 || force_p)
2932 { 2985 {
2933 x_clear_glyph_string_rect (s, s->x, s->y + s->face->box_line_width, 2986 x_clear_glyph_string_rect (s, s->x, s->y + s->face->box_line_width,
@@ -3414,7 +3467,7 @@ x_draw_image_foreground (s)
3414 if (s->hl == DRAW_CURSOR) 3467 if (s->hl == DRAW_CURSOR)
3415 w32_draw_rectangle (s->hdc, s->gc, x, y, s->img->width - 1, 3468 w32_draw_rectangle (s->hdc, s->gc, x, y, s->img->width - 1,
3416 s->img->height - 1); 3469 s->img->height - 1);
3417 w32_set_clip_rectangle(s->hdc, NULL); 3470 w32_set_clip_rectangle (s->hdc, NULL);
3418 } 3471 }
3419 } 3472 }
3420 else 3473 else
@@ -3676,10 +3729,6 @@ x_draw_image_glyph_string (s)
3676 } 3729 }
3677 else 3730 else
3678#endif 3731#endif
3679 /* Implementation idea: Is it possible to construct a mask?
3680 We could look at the color at the margins of the image, and
3681 say that this color is probably the background color of the
3682 image. */
3683 x_draw_glyph_string_bg_rect (s, x, y, s->background_width, height); 3732 x_draw_glyph_string_bg_rect (s, x, y, s->background_width, height);
3684 3733
3685 s->background_filled_p = 1; 3734 s->background_filled_p = 1;
@@ -4380,8 +4429,10 @@ x_draw_glyphs (w, x, row, area, start, end, hl, real_start, real_end,
4380 HDC hdc = get_frame_dc (XFRAME (WINDOW_FRAME (w))); 4429 HDC hdc = get_frame_dc (XFRAME (WINDOW_FRAME (w)));
4381 4430
4382 /* Let's rather be paranoid than getting a SEGV. */ 4431 /* Let's rather be paranoid than getting a SEGV. */
4383 start = max (0, start);
4384 end = min (end, row->used[area]); 4432 end = min (end, row->used[area]);
4433 start = max (0, start);
4434 start = min (end, start);
4435
4385 if (real_start) 4436 if (real_start)
4386 *real_start = start; 4437 *real_start = start;
4387 if (real_end) 4438 if (real_end)
@@ -4435,7 +4486,7 @@ x_draw_glyphs (w, x, row, area, start, end, hl, real_start, real_end,
4435 /* If there are any glyphs with lbearing < 0 or rbearing > width in 4486 /* If there are any glyphs with lbearing < 0 or rbearing > width in
4436 the row, redraw some glyphs in front or following the glyph 4487 the row, redraw some glyphs in front or following the glyph
4437 strings built above. */ 4488 strings built above. */
4438 if (!overlaps_p && row->contains_overlapping_glyphs_p) 4489 if (head && !overlaps_p && row->contains_overlapping_glyphs_p)
4439 { 4490 {
4440 int dummy_x = 0; 4491 int dummy_x = 0;
4441 struct glyph_string *h, *t; 4492 struct glyph_string *h, *t;
@@ -5339,7 +5390,7 @@ x_get_keysym_name (keysym)
5339 static char value[100]; 5390 static char value[100];
5340 5391
5341 BLOCK_INPUT; 5392 BLOCK_INPUT;
5342 GetKeyNameText(keysym, value, 100); 5393 GetKeyNameText (keysym, value, 100);
5343 UNBLOCK_INPUT; 5394 UNBLOCK_INPUT;
5344 5395
5345 return value; 5396 return value;
@@ -5373,7 +5424,7 @@ pixel_to_glyph_coords (f, pix_x, pix_y, x, y, bounds, noclip)
5373 /* Arrange for the division in PIXEL_TO_CHAR_COL etc. to round down 5424 /* Arrange for the division in PIXEL_TO_CHAR_COL etc. to round down
5374 even for negative values. */ 5425 even for negative values. */
5375 if (pix_x < 0) 5426 if (pix_x < 0)
5376 pix_x -= FONT_WIDTH (FRAME_FONT(f)) - 1; 5427 pix_x -= FONT_WIDTH (FRAME_FONT (f)) - 1;
5377 if (pix_y < 0) 5428 if (pix_y < 0)
5378 pix_y -= (f)->output_data.w32->line_height - 1; 5429 pix_y -= (f)->output_data.w32->line_height - 1;
5379 5430
@@ -5384,7 +5435,7 @@ pixel_to_glyph_coords (f, pix_x, pix_y, x, y, bounds, noclip)
5384 { 5435 {
5385 bounds->left = CHAR_TO_PIXEL_COL (f, pix_x); 5436 bounds->left = CHAR_TO_PIXEL_COL (f, pix_x);
5386 bounds->top = CHAR_TO_PIXEL_ROW (f, pix_y); 5437 bounds->top = CHAR_TO_PIXEL_ROW (f, pix_y);
5387 bounds->right = bounds->left + FONT_WIDTH (FRAME_FONT(f)) - 1; 5438 bounds->right = bounds->left + FONT_WIDTH (FRAME_FONT (f)) - 1;
5388 bounds->bottom = bounds->top + f->output_data.w32->line_height - 1; 5439 bounds->bottom = bounds->top + f->output_data.w32->line_height - 1;
5389 } 5440 }
5390 5441
@@ -5553,7 +5604,7 @@ construct_mouse_wheel (result, msg, f)
5553 result->modifiers = msg->dwModifiers; 5604 result->modifiers = msg->dwModifiers;
5554 p.x = LOWORD (msg->msg.lParam); 5605 p.x = LOWORD (msg->msg.lParam);
5555 p.y = HIWORD (msg->msg.lParam); 5606 p.y = HIWORD (msg->msg.lParam);
5556 ScreenToClient(msg->msg.hwnd, &p); 5607 ScreenToClient (msg->msg.hwnd, &p);
5557 XSETINT (result->x, p.x); 5608 XSETINT (result->x, p.x);
5558 XSETINT (result->y, p.y); 5609 XSETINT (result->y, p.y);
5559 XSETFRAME (result->frame_or_window, f); 5610 XSETFRAME (result->frame_or_window, f);
@@ -6590,9 +6641,11 @@ x_clear_mouse_face (w)
6590 = FRAME_W32_DISPLAY_INFO (XFRAME (w->frame)); 6641 = FRAME_W32_DISPLAY_INFO (XFRAME (w->frame));
6591 Lisp_Object window; 6642 Lisp_Object window;
6592 6643
6644 BLOCK_INPUT;
6593 XSETWINDOW (window, w); 6645 XSETWINDOW (window, w);
6594 if (EQ (window, dpyinfo->mouse_face_window)) 6646 if (EQ (window, dpyinfo->mouse_face_window))
6595 clear_mouse_face (dpyinfo); 6647 clear_mouse_face (dpyinfo);
6648 UNBLOCK_INPUT;
6596} 6649}
6597 6650
6598 6651
@@ -6680,13 +6733,15 @@ w32_mouse_position (fp, insist, bar_window, part, x, y, time)
6680 else 6733 else
6681 { 6734 {
6682 /* Is window under mouse one of our frames? */ 6735 /* Is window under mouse one of our frames? */
6683 f1 = x_window_to_frame (FRAME_W32_DISPLAY_INFO (*fp), WindowFromPoint(pt)); 6736 f1 = x_window_to_frame (FRAME_W32_DISPLAY_INFO (*fp),
6737 WindowFromPoint (pt));
6684 } 6738 }
6685 6739
6686 /* If not, is it one of our scroll bars? */ 6740 /* If not, is it one of our scroll bars? */
6687 if (! f1) 6741 if (! f1)
6688 { 6742 {
6689 struct scroll_bar *bar = x_window_to_scroll_bar (WindowFromPoint(pt)); 6743 struct scroll_bar *bar
6744 = x_window_to_scroll_bar (WindowFromPoint (pt));
6690 6745
6691 if (bar) 6746 if (bar)
6692 { 6747 {
@@ -7418,8 +7473,8 @@ x_scroll_bar_report_motion (fp, bar_window, part, x, y, time)
7418 break; 7473 break;
7419 } 7474 }
7420 7475
7421 XSETINT(*x, pos); 7476 XSETINT (*x, pos);
7422 XSETINT(*y, top_range); 7477 XSETINT (*y, top_range);
7423 7478
7424 f->mouse_moved = 0; 7479 f->mouse_moved = 0;
7425 last_mouse_scroll_bar = Qnil; 7480 last_mouse_scroll_bar = Qnil;
@@ -7582,7 +7637,7 @@ w32_read_socket (sd, bufp, numchars, expected)
7582 count++; 7637 count++;
7583 numchars--; 7638 numchars--;
7584 } 7639 }
7585 else if (! NILP(Vframe_list) 7640 else if (! NILP (Vframe_list)
7586 && ! NILP (XCDR (Vframe_list))) 7641 && ! NILP (XCDR (Vframe_list)))
7587 /* Force a redisplay sooner or later to update the 7642 /* Force a redisplay sooner or later to update the
7588 frame titles in case this is the second frame. */ 7643 frame titles in case this is the second frame. */
@@ -7953,7 +8008,7 @@ w32_read_socket (sd, bufp, numchars, expected)
7953 int width; 8008 int width;
7954 int height; 8009 int height;
7955 8010
7956 GetClientRect(msg.msg.hwnd, &rect); 8011 GetClientRect (msg.msg.hwnd, &rect);
7957 8012
7958 height = rect.bottom - rect.top; 8013 height = rect.bottom - rect.top;
7959 width = rect.right - rect.left; 8014 width = rect.right - rect.left;
@@ -8570,7 +8625,9 @@ x_display_and_set_cursor (w, on, hpos, vpos, x, y)
8570 { 8625 {
8571 extern int cursor_in_non_selected_windows; 8626 extern int cursor_in_non_selected_windows;
8572 8627
8573 if (MINI_WINDOW_P (w) || !cursor_in_non_selected_windows) 8628 if (MINI_WINDOW_P (w)
8629 || !cursor_in_non_selected_windows
8630 || NILP (XBUFFER (w->buffer)->cursor_type))
8574 new_cursor_type = NO_CURSOR; 8631 new_cursor_type = NO_CURSOR;
8575 else 8632 else
8576 new_cursor_type = HOLLOW_BOX_CURSOR; 8633 new_cursor_type = HOLLOW_BOX_CURSOR;
@@ -9649,7 +9706,7 @@ x_delete_display (dpyinfo)
9649 { 9706 {
9650 struct w32_palette_entry * pentry = plist; 9707 struct w32_palette_entry * pentry = plist;
9651 plist = plist->next; 9708 plist = plist->next;
9652 xfree(pentry); 9709 xfree (pentry);
9653 } 9710 }
9654 dpyinfo->color_list = NULL; 9711 dpyinfo->color_list = NULL;
9655 if (dpyinfo->palette) 9712 if (dpyinfo->palette)
@@ -9777,8 +9834,8 @@ w32_initialize ()
9777#define LOAD_PROC(fn) pfn##fn = (void *) GetProcAddress (user_lib, #fn) 9834#define LOAD_PROC(fn) pfn##fn = (void *) GetProcAddress (user_lib, #fn)
9778 9835
9779 /* New proportional scroll bar functions. */ 9836 /* New proportional scroll bar functions. */
9780 LOAD_PROC( SetScrollInfo ); 9837 LOAD_PROC (SetScrollInfo);
9781 LOAD_PROC( GetScrollInfo ); 9838 LOAD_PROC (GetScrollInfo);
9782 9839
9783#undef LOAD_PROC 9840#undef LOAD_PROC
9784 9841