X-Git-Url: https://git.hcoop.net/bpt/emacs.git/blobdiff_plain/d235ca2ff8fab139ce797757fcb159d1e28fa7e0..ed4c17bb826f4903fc1ca0a815f5074bf0702f2a:/src/w32term.c diff --git a/src/w32term.c b/src/w32term.c index e04e57cd52..a40fe2edc4 100644 --- a/src/w32term.c +++ b/src/w32term.c @@ -46,7 +46,6 @@ Boston, MA 02110-1301, USA. */ #include "termhooks.h" #include "termopts.h" #include "termchar.h" -#include "gnu.h" #include "disptab.h" #include "buffer.h" #include "window.h" @@ -1764,9 +1763,35 @@ static void w32_compute_glyph_string_overhangs (s) struct glyph_string *s; { + if (s->cmp == NULL + && s->first_glyph->type == CHAR_GLYPH) + { +#ifdef USE_FONT_BACKEND + if (enable_font_backend) + { + unsigned *code = alloca (sizeof (unsigned) * s->nchars); + struct font *font = (struct font *) s->font_info; + struct font_metrics metrics; + int i; + + for (i = 0; i < s->nchars; i++) + code[i] = s->char2b[i]; + font->driver->text_extents (font, code, s->nchars, &metrics); + s->right_overhang = (metrics.rbearing > metrics.width + ? metrics.rbearing - metrics.width : 0); + s->left_overhang = metrics.lbearing < 0 ? -metrics.lbearing : 0; + } +#else /* TODO: Windows does not appear to have a method for getting this info without getting the ABC widths for each individual character and working it out manually. */ +#endif + } + else if (s->cmp) + { + s->right_overhang = s->cmp->rbearing - s->cmp->pixel_width; + s->left_overhang = -s->cmp->lbearing; + } } @@ -1846,6 +1871,7 @@ x_draw_glyph_string_background (s, force_p) || s->font_not_found_p || s->extends_to_end_of_line_p || s->font->bdf + || cleartype_active || force_p) { x_clear_glyph_string_rect (s, s->x, s->y + box_line_width, @@ -1874,7 +1900,8 @@ x_draw_glyph_string_foreground (s) else x = s->x; - if (s->for_overlaps || (s->background_filled_p && s->hl != DRAW_CURSOR)) + if (s->for_overlaps || (s->background_filled_p && s->hl != DRAW_CURSOR) + || cleartype_active) SetBkMode (s->hdc, TRANSPARENT); else SetBkMode (s->hdc, OPAQUE); @@ -4787,19 +4814,64 @@ w32_read_socket (sd, expected, hold_quit) if (temp_index == sizeof temp_buffer / sizeof (short)) temp_index = 0; temp_buffer[temp_index++] = msg.msg.wParam; + + inev.modifiers = msg.dwModifiers; + XSETFRAME (inev.frame_or_window, f); + inev.timestamp = msg.msg.time; + if (msg.msg.message == WM_UNICHAR) { - inev.kind = MULTIBYTE_CHAR_KEYSTROKE_EVENT; inev.code = msg.msg.wParam; } + else if (msg.msg.wParam < 256) + { + wchar_t code; + char dbcs[2]; + dbcs[0] = 0; + dbcs[1] = (char) msg.msg.wParam; + + if (dbcs_lead) + { + dbcs[0] = dbcs_lead; + dbcs_lead = 0; + if (!MultiByteToWideChar (CP_ACP, 0, dbcs, 2, &code, 1)) + { + /* Garbage */ + DebPrint (("Invalid DBCS sequence: %d %d\n", + dbcs[0], dbcs[1])); + inev.kind = NO_EVENT; + break; + } + } + else if (IsDBCSLeadByteEx (CP_ACP, (BYTE) msg.msg.wParam)) + { + dbcs_lead = (char) msg.msg.wParam; + inev.kind = NO_EVENT; + break; + } + else + { + if (!MultiByteToWideChar (CP_ACP, 0, &dbcs[1], 1, + &code, 1)) + { + /* What to do with garbage? */ + DebPrint (("Invalid character: %d\n", dbcs[1])); + inev.kind = NO_EVENT; + break; + } + } + inev.code = code; + } else { - inev.kind = ASCII_KEYSTROKE_EVENT; - inev.code = msg.msg.wParam; + /* Windows shouldn't generate WM_CHAR events above 0xFF + in non-Unicode message handlers. */ + DebPrint (("Non-byte WM_CHAR: %d\n", msg.msg.wParam)); + inev.kind = NO_EVENT; + break; } - inev.modifiers = msg.dwModifiers; - XSETFRAME (inev.frame_or_window, f); - inev.timestamp = msg.msg.time; + inev.kind = inev.code < 128 ? ASCII_KEYSTROKE_EVENT + : MULTIBYTE_CHAR_KEYSTROKE_EVENT; } break; @@ -6846,7 +6918,7 @@ static struct redisplay_interface w32_redisplay_interface = w32_destroy_fringe_bitmap, w32_per_char_metric, w32_encode_char, - NULL, /* w32_compute_glyph_string_overhangs */ + w32_compute_glyph_string_overhangs, x_draw_glyph_string, w32_define_frame_cursor, w32_clear_frame_area, @@ -6988,7 +7060,7 @@ w32_term_init (display_name, xrm_option, resource_name) dpyinfo->resx = GetDeviceCaps (hdc, LOGPIXELSX); dpyinfo->resy = GetDeviceCaps (hdc, LOGPIXELSY); dpyinfo->has_palette = GetDeviceCaps (hdc, RASTERCAPS) & RC_PALETTE; - dpyinfo->image_cache = make_image_cache (); + dpyinfo->terminal->image_cache = make_image_cache (); dpyinfo->height_in = dpyinfo->height / dpyinfo->resx; dpyinfo->width_in = dpyinfo->width / dpyinfo->resy; ReleaseDC (GetDesktopWindow (), hdc); @@ -7012,16 +7084,9 @@ w32_term_init (display_name, xrm_option, resource_name) the bitmaps. */ w32_init_fringe (terminal->rif); -#ifndef F_SETOWN_BUG #ifdef F_SETOWN -#ifdef F_SETOWN_SOCK_NEG - /* stdin is a socket here */ - fcntl (connection, F_SETOWN, -getpid ()); -#else /* ! defined (F_SETOWN_SOCK_NEG) */ fcntl (connection, F_SETOWN, getpid ()); -#endif /* ! defined (F_SETOWN_SOCK_NEG) */ #endif /* ! defined (F_SETOWN) */ -#endif /* F_SETOWN_BUG */ #ifdef SIGIO if (interrupt_input)