X-Git-Url: https://code.delx.au/gnu-emacs/blobdiff_plain/6e6c82a4e687708d5a7a3887f92db45bd74da276..21238f117336d2a3f1e7970832ba05da14d44a03:/src/w32term.c diff --git a/src/w32term.c b/src/w32term.c index 8a0e9efc94..fc4522d56f 100644 --- a/src/w32term.c +++ b/src/w32term.c @@ -1,4 +1,4 @@ -/* Implementation of GUI terminal on the Microsoft W32 API. +/* Implementation of GUI terminal on the Microsoft Windows API. Copyright (C) 1989, 1993-2012 Free Software Foundation, Inc. @@ -155,6 +155,9 @@ int vertical_scroll_bar_bottom_border; int last_scroll_bar_drag_pos; +/* Keyboard code page - may be changed by language-change events. */ +int w32_keyboard_codepage; + /* Mouse movement. */ /* Where the mouse was last time we reported a mouse event. */ @@ -188,9 +191,6 @@ static int volatile input_signal_count; static int input_signal_count; #endif -/* Keyboard code page - may be changed by language-change events. */ -static int keyboard_codepage; - static void x_update_window_end (struct window *, int, int); static void w32_handle_tool_bar_click (struct frame *, struct input_event *); @@ -231,6 +231,10 @@ static void my_set_focus (struct frame *, HWND); static void my_set_foreground_window (HWND); static void my_destroy_window (struct frame *, HWND); +#ifdef GLYPH_DEBUG +static void x_check_font (struct frame *, struct font *); +#endif + static Lisp_Object Qvendor_specific_keysyms; @@ -281,8 +285,7 @@ XChangeGC (void *ignore, XGCValues *gc, unsigned long mask, XGCValues * XCreateGC (void *ignore, Window window, unsigned long mask, XGCValues *xgcv) { - XGCValues *gc = (XGCValues *) xmalloc (sizeof (XGCValues)); - memset (gc, 0, sizeof (XGCValues)); + XGCValues *gc = xzalloc (sizeof (XGCValues)); XChangeGC (ignore, gc, mask, xgcv); @@ -309,6 +312,94 @@ w32_set_clip_rectangle (HDC hdc, RECT *rect) SelectClipRgn (hdc, NULL); } +/* Restore clipping rectangle in S */ +static void +w32_restore_glyph_string_clip (struct glyph_string *s) +{ + RECT *r = s->clip; + int n = s->num_clips; + + if (n == 1) + w32_set_clip_rectangle (s->hdc, r); + else if (n > 1) + { + HRGN clip1 = CreateRectRgnIndirect (r); + HRGN clip2 = CreateRectRgnIndirect (r + 1); + if (CombineRgn (clip1, clip1, clip2, RGN_OR) != ERROR) + SelectClipRgn (s->hdc, clip1); + DeleteObject (clip1); + DeleteObject (clip2); + } +} + +/* + Draw a wavy line under S. The wave fills wave_height pixels from y0. + + x0 wave_length = 2 + -- + y0 * * * * * + |* * * * * * * * * + wave_height = 3 | * * * * + +*/ + +void +w32_draw_underwave (struct glyph_string *s, COLORREF color) +{ + int wave_height = 2, wave_length = 3; + int dx, dy, x0, y0, width, x1, y1, x2, y2, odd, xmax; + XRectangle wave_clip, string_clip, final_clip; + RECT w32_final_clip, w32_string_clip; + HPEN hp, oldhp; + + dx = wave_length; + dy = wave_height - 1; + x0 = s->x; + y0 = s->ybase + 1; + width = s->width; + xmax = x0 + width; + + /* Find and set clipping rectangle */ + + wave_clip = (XRectangle){ x0, y0, width, wave_height }; + get_glyph_string_clip_rect (s, &w32_string_clip); + CONVERT_TO_XRECT (string_clip, w32_string_clip); + + if (!x_intersect_rectangles (&wave_clip, &string_clip, &final_clip)) + return; + + hp = CreatePen (PS_SOLID, 0, color); + oldhp = SelectObject (s->hdc, hp); + CONVERT_FROM_XRECT (final_clip, w32_final_clip); + w32_set_clip_rectangle (s->hdc, &w32_final_clip); + + /* Draw the waves */ + + x1 = x0 - (x0 % dx); + x2 = x1 + dx; + odd = (x1/dx) % 2; + y1 = y2 = y0; + + if (odd) + y1 += dy; + else + y2 += dy; + + MoveToEx (s->hdc, x1, y1, NULL); + + while (x1 <= xmax) + { + LineTo (s->hdc, x2, y2); + x1 = x2, y1 = y2; + x2 += dx, y2 = y0 + odd*dy; + odd = !odd; + } + + /* Restore previous pen and clipping rectangle(s) */ + w32_restore_glyph_string_clip (s); + SelectObject (s->hdc, oldhp); + DeleteObject (hp); +} /* Draw a hollow rectangle at the specified position. */ void @@ -558,7 +649,7 @@ static void x_update_window_end (struct window *w, int cursor_on_p, int mouse_face_overwritten_p) { - Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (XFRAME (w->frame)); + Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (XFRAME (WGET (w, frame))); if (!w->pseudo_window_p) { @@ -650,7 +741,7 @@ x_after_update_window_line (struct glyph_row *desired_row) struct frame *f; int width, height; - xassert (w); + eassert (w); if (!desired_row->mode_line_p && !w->pseudo_window_p) desired_row->redraw_fringe_bitmaps_p = 1; @@ -663,7 +754,7 @@ x_after_update_window_line (struct glyph_row *desired_row) overhead is very small. */ if (windows_or_buffers_changed && desired_row->full_width_p - && (f = XFRAME (w->frame), + && (f = XFRAME (WGET (w, frame)), width = FRAME_INTERNAL_BORDER_WIDTH (f), width != 0) && (height = desired_row->visible_height, @@ -994,7 +1085,7 @@ x_set_mouse_face_gc (struct glyph_string *s) s->gc = FRAME_W32_DISPLAY_INFO (s->f)->scratch_cursor_gc; } - xassert (s->gc != 0); + eassert (s->gc != 0); } @@ -1051,7 +1142,7 @@ x_set_glyph_string_gc (struct glyph_string *s) } /* GC must have been set. */ - xassert (s->gc != 0); + eassert (s->gc != 0); } @@ -1468,7 +1559,7 @@ w32_alloc_lighter_color (struct frame *f, COLORREF *color, delta /= 256; /* Change RGB values by specified FACTOR. Avoid overflow! */ - xassert (factor >= 0); + eassert (factor >= 0); new = PALETTERGB (min (0xff, factor * GetRValue (*color)), min (0xff, factor * GetGValue (*color)), min (0xff, factor * GetBValue (*color))); @@ -2145,7 +2236,7 @@ x_draw_image_glyph_string (struct glyph_string *s) static void x_draw_stretch_glyph_string (struct glyph_string *s) { - xassert (s->first_glyph->type == STRETCH_GLYPH); + eassert (s->first_glyph->type == STRETCH_GLYPH); if (s->hl == DRAW_CURSOR && !x_stretch_cursor_p) @@ -2343,60 +2434,74 @@ x_draw_glyph_string (struct glyph_string *s) /* Draw underline. */ if (s->face->underline_p) { - unsigned long thickness, position; - int y; - - if (s->prev && s->prev->face->underline_p) + if (s->face->underline_type == FACE_UNDER_WAVE) { - /* We use the same underline style as the previous one. */ - thickness = s->prev->underline_thickness; - position = s->prev->underline_position; + COLORREF color; + + if (s->face->underline_defaulted_p) + color = s->gc->foreground; + else + color = s->face->underline_color; + + w32_draw_underwave (s, color); } - else + else if (s->face->underline_type == FACE_UNDER_LINE) { - /* Get the underline thickness. Default is 1 pixel. */ - if (s->font && s->font->underline_thickness > 0) - thickness = s->font->underline_thickness; + unsigned long thickness, position; + int y; + + if (s->prev && s->prev->face->underline_p) + { + /* We use the same underline style as the previous one. */ + thickness = s->prev->underline_thickness; + position = s->prev->underline_position; + } else - thickness = 1; - if (x_underline_at_descent_line) - position = (s->height - thickness) - (s->ybase - s->y); + { + /* Get the underline thickness. Default is 1 pixel. */ + if (s->font && s->font->underline_thickness > 0) + thickness = s->font->underline_thickness; + else + thickness = 1; + if (x_underline_at_descent_line) + position = (s->height - thickness) - (s->ybase - s->y); + else + { + /* Get the underline position. This is the recommended + vertical offset in pixels from the baseline to the top of + the underline. This is a signed value according to the + specs, and its default is + + ROUND ((maximum_descent) / 2), with + ROUND (x) = floor (x + 0.5) */ + + if (x_use_underline_position_properties + && s->font && s->font->underline_position >= 0) + position = s->font->underline_position; + else if (s->font) + position = (s->font->descent + 1) / 2; + } + position = max (position, underline_minimum_offset); + } + /* Check the sanity of thickness and position. We should + avoid drawing underline out of the current line area. */ + if (s->y + s->height <= s->ybase + position) + position = (s->height - 1) - (s->ybase - s->y); + if (s->y + s->height < s->ybase + position + thickness) + thickness = (s->y + s->height) - (s->ybase + position); + s->underline_thickness = thickness; + s->underline_position =position; + y = s->ybase + position; + if (s->face->underline_defaulted_p) + { + w32_fill_area (s->f, s->hdc, s->gc->foreground, s->x, + y, s->width, 1); + } else { - /* Get the underline position. This is the recommended - vertical offset in pixels from the baseline to the top of - the underline. This is a signed value according to the - specs, and its default is - - ROUND ((maximum_descent) / 2), with - ROUND (x) = floor (x + 0.5) */ - - if (x_use_underline_position_properties - && s->font && s->font->underline_position >= 0) - position = s->font->underline_position; - else if (s->font) - position = (s->font->descent + 1) / 2; + w32_fill_area (s->f, s->hdc, s->face->underline_color, s->x, + y, s->width, 1); } - position = max (position, underline_minimum_offset); - } - /* Check the sanity of thickness and position. We should - avoid drawing underline out of the current line area. */ - if (s->y + s->height <= s->ybase + position) - position = (s->height - 1) - (s->ybase - s->y); - if (s->y + s->height < s->ybase + position + thickness) - thickness = (s->y + s->height) - (s->ybase + position); - s->underline_thickness = thickness; - s->underline_position =position; - y = s->ybase + position; - if (s->face->underline_defaulted_p) - { - w32_fill_area (s->f, s->hdc, s->gc->foreground, s->x, - y, s->width, 1); - } - else - { - w32_fill_area (s->f, s->hdc, s->face->underline_color, s->x, - y, s->width, 1); } } /* Draw overline. */ @@ -2613,7 +2718,7 @@ x_ins_del_lines (struct frame *f, int vpos, int n) static void x_scroll_run (struct window *w, struct run *run) { - struct frame *f = XFRAME (w->frame); + struct frame *f = XFRAME (WGET (w, frame)); int x, y, width, height, from_y, to_y, bottom_y; HWND hwnd = FRAME_W32_WINDOW (f); HRGN expect_dirty; @@ -2867,7 +2972,7 @@ x_frame_rehighlight (struct w32_display_info *dpyinfo) : dpyinfo->w32_focus_frame); if (! FRAME_LIVE_P (dpyinfo->x_highlight_frame)) { - FRAME_FOCUS_FRAME (dpyinfo->w32_focus_frame) = Qnil; + FSET (dpyinfo->w32_focus_frame, focus_frame, Qnil); dpyinfo->x_highlight_frame = dpyinfo->w32_focus_frame; } } @@ -3488,6 +3593,12 @@ my_destroy_window (struct frame * f, HWND hwnd) (WPARAM) hwnd, 0); } +static void +my_bring_window_to_top (HWND hwnd) +{ + SendMessage (hwnd, WM_EMACS_BRINGTOTOP, (WPARAM) hwnd, 0); +} + /* Create a scroll bar and return the scroll bar vector for it. W is the Emacs window on which to create the scroll bar. TOP, LEFT, WIDTH and HEIGHT are the pixel coordinates and dimensions of the @@ -3501,6 +3612,7 @@ x_scroll_bar_create (struct window *w, int top, int left, int width, int height) SCROLLINFO si; struct scroll_bar *bar = XSCROLL_BAR (Fmake_vector (make_number (SCROLL_BAR_VEC_SIZE), Qnil)); + Lisp_Object barobj; BLOCK_INPUT; @@ -3533,7 +3645,8 @@ x_scroll_bar_create (struct window *w, int top, int left, int width, int height) /* Add bar to its frame's list of scroll bars. */ bar->next = FRAME_SCROLL_BARS (f); bar->prev = Qnil; - XSETVECTOR (FRAME_SCROLL_BARS (f), bar); + XSETVECTOR (barobj, bar); + FSET (f, scroll_bars, barobj); if (! NILP (bar->next)) XSETVECTOR (XSCROLL_BAR (bar->next)->prev, bar); @@ -3557,7 +3670,7 @@ x_scroll_bar_remove (struct scroll_bar *bar) my_destroy_window (f, SCROLL_BAR_W32_WINDOW (bar)); /* Dissociate this scroll bar from its window. */ - XWINDOW (bar->window)->vertical_scroll_bar = Qnil; + WSET (XWINDOW (bar->window), vertical_scroll_bar, Qnil); UNBLOCK_INPUT; } @@ -3570,7 +3683,7 @@ static void w32_set_vertical_scroll_bar (struct window *w, int portion, int whole, int position) { - struct frame *f = XFRAME (w->frame); + struct frame *f = XFRAME (WGET (w, frame)); struct scroll_bar *bar; int top, height, left, sb_left, width, sb_width; int window_y, window_height; @@ -3610,7 +3723,7 @@ w32_set_vertical_scroll_bar (struct window *w, || WINDOW_RIGHT_MARGIN_COLS (w) == 0)); /* Does the scroll bar exist yet? */ - if (NILP (w->vertical_scroll_bar)) + if (NILP (WGET (w, vertical_scroll_bar))) { HDC hdc; BLOCK_INPUT; @@ -3632,7 +3745,7 @@ w32_set_vertical_scroll_bar (struct window *w, /* It may just need to be moved and resized. */ HWND hwnd; - bar = XSCROLL_BAR (w->vertical_scroll_bar); + bar = XSCROLL_BAR (WGET (w, vertical_scroll_bar)); hwnd = SCROLL_BAR_W32_WINDOW (bar); /* If already correctly positioned, do nothing. */ @@ -3694,7 +3807,7 @@ w32_set_vertical_scroll_bar (struct window *w, w32_set_scroll_bar_thumb (bar, portion, position, whole); - XSETVECTOR (w->vertical_scroll_bar, bar); + XSETVECTOR (WGET (w, vertical_scroll_bar), bar); } @@ -3718,12 +3831,12 @@ w32_condemn_scroll_bars (FRAME_PTR frame) { Lisp_Object bar; bar = FRAME_SCROLL_BARS (frame); - FRAME_SCROLL_BARS (frame) = XSCROLL_BAR (bar)->next; + FSET (frame, scroll_bars, XSCROLL_BAR (bar)->next); XSCROLL_BAR (bar)->next = FRAME_CONDEMNED_SCROLL_BARS (frame); XSCROLL_BAR (bar)->prev = Qnil; if (! NILP (FRAME_CONDEMNED_SCROLL_BARS (frame))) XSCROLL_BAR (FRAME_CONDEMNED_SCROLL_BARS (frame))->prev = bar; - FRAME_CONDEMNED_SCROLL_BARS (frame) = bar; + FSET (frame, condemned_scroll_bars, bar); } } @@ -3735,13 +3848,14 @@ static void w32_redeem_scroll_bar (struct window *window) { struct scroll_bar *bar; + Lisp_Object barobj; struct frame *f; /* We can't redeem this window's scroll bar if it doesn't have one. */ - if (NILP (window->vertical_scroll_bar)) + if (NILP (WGET (window, vertical_scroll_bar))) abort (); - bar = XSCROLL_BAR (window->vertical_scroll_bar); + bar = XSCROLL_BAR (WGET (window, vertical_scroll_bar)); /* Unlink it from the condemned list. */ f = XFRAME (WINDOW_FRAME (window)); @@ -3749,12 +3863,12 @@ w32_redeem_scroll_bar (struct window *window) { /* If the prev pointer is nil, it must be the first in one of the lists. */ - if (EQ (FRAME_SCROLL_BARS (f), window->vertical_scroll_bar)) + if (EQ (FRAME_SCROLL_BARS (f), WGET (window, vertical_scroll_bar))) /* It's not condemned. Everything's fine. */ return; else if (EQ (FRAME_CONDEMNED_SCROLL_BARS (f), - window->vertical_scroll_bar)) - FRAME_CONDEMNED_SCROLL_BARS (f) = bar->next; + WGET (window, vertical_scroll_bar))) + FSET (f, condemned_scroll_bars, bar->next); else /* If its prev pointer is nil, it must be at the front of one or the other! */ @@ -3768,7 +3882,8 @@ w32_redeem_scroll_bar (struct window *window) bar->next = FRAME_SCROLL_BARS (f); bar->prev = Qnil; - XSETVECTOR (FRAME_SCROLL_BARS (f), bar); + XSETVECTOR (barobj, bar); + FSET (f, scroll_bars, barobj); if (! NILP (bar->next)) XSETVECTOR (XSCROLL_BAR (bar->next)->prev, bar); } @@ -3785,7 +3900,7 @@ w32_judge_scroll_bars (FRAME_PTR f) /* Clear out the condemned list now so we won't try to process any more events on the hapless scroll bars. */ - FRAME_CONDEMNED_SCROLL_BARS (f) = Qnil; + FSET (f, condemned_scroll_bars, Qnil); for (; ! NILP (bar); bar = next) { @@ -4078,7 +4193,7 @@ w32_read_socket (struct terminal *terminal, int expected, /* We may get paint messages even though the client area is clipped - these are not expose events. */ DebPrint (("clipped frame %p (%s) got WM_PAINT - ignored\n", f, - SDATA (f->name))); + SDATA (FGET (f, name)))); } else if (f->async_visible != 1) { @@ -4087,7 +4202,7 @@ w32_read_socket (struct terminal *terminal, int expected, f->async_iconified = 0; SET_FRAME_GARBAGED (f); DebPrint (("frame %p (%s) reexposed by WM_PAINT\n", f, - SDATA (f->name))); + SDATA (FGET (f, name)))); /* WM_PAINT serves as MapNotify as well, so report visibility changes properly. */ @@ -4122,16 +4237,16 @@ w32_read_socket (struct terminal *terminal, int expected, /* Generate a language change event. */ f = x_window_to_frame (dpyinfo, msg.msg.hwnd); - /* lParam contains the input lang ID. Use it to update our - record of the keyboard codepage. */ - keyboard_codepage = codepage_for_locale ((LCID)(msg.msg.lParam - & 0xffff)); + /* lParam contains the input language ID in its low 16 bits. + Use it to update our record of the keyboard codepage. */ + w32_keyboard_codepage = codepage_for_locale ((LCID)(msg.msg.lParam + & 0xffff)); if (f) { inev.kind = LANGUAGE_CHANGE_EVENT; XSETFRAME (inev.frame_or_window, f); - inev.code = msg.msg.wParam; + inev.code = w32_keyboard_codepage; inev.modifiers = msg.msg.lParam & 0xffff; } break; @@ -4143,7 +4258,7 @@ w32_read_socket (struct terminal *terminal, int expected, if (f && !f->iconified) { if (!hlinfo->mouse_face_hidden && INTEGERP (Vmouse_highlight) - && !EQ (f->tool_bar_window, hlinfo->mouse_face_window)) + && !EQ (FGET (f, tool_bar_window), hlinfo->mouse_face_window)) { clear_mouse_face (hlinfo); hlinfo->mouse_face_hidden = 1; @@ -4168,7 +4283,7 @@ w32_read_socket (struct terminal *terminal, int expected, if (f && !f->iconified) { if (!hlinfo->mouse_face_hidden && INTEGERP (Vmouse_highlight) - && !EQ (f->tool_bar_window, hlinfo->mouse_face_window)) + && !EQ (FGET (f, tool_bar_window), hlinfo->mouse_face_window)) { clear_mouse_face (hlinfo); hlinfo->mouse_face_hidden = 1; @@ -4197,7 +4312,7 @@ w32_read_socket (struct terminal *terminal, int expected, { dbcs[0] = dbcs_lead; dbcs_lead = 0; - if (!MultiByteToWideChar (keyboard_codepage, 0, + if (!MultiByteToWideChar (w32_keyboard_codepage, 0, dbcs, 2, &code, 1)) { /* Garbage */ @@ -4207,7 +4322,7 @@ w32_read_socket (struct terminal *terminal, int expected, break; } } - else if (IsDBCSLeadByteEx (keyboard_codepage, + else if (IsDBCSLeadByteEx (w32_keyboard_codepage, (BYTE) msg.msg.wParam)) { dbcs_lead = (char) msg.msg.wParam; @@ -4216,7 +4331,7 @@ w32_read_socket (struct terminal *terminal, int expected, } else { - if (!MultiByteToWideChar (keyboard_codepage, 0, + if (!MultiByteToWideChar (w32_keyboard_codepage, 0, &dbcs[1], 1, &code, 1)) { /* What to do with garbage? */ @@ -4246,7 +4361,7 @@ w32_read_socket (struct terminal *terminal, int expected, if (f && !f->iconified) { if (!hlinfo->mouse_face_hidden && INTEGERP (Vmouse_highlight) - && !EQ (f->tool_bar_window, hlinfo->mouse_face_window)) + && !EQ (FGET (f, tool_bar_window), hlinfo->mouse_face_window)) { clear_mouse_face (hlinfo); hlinfo->mouse_face_hidden = 1; @@ -4311,8 +4426,8 @@ w32_read_socket (struct terminal *terminal, int expected, create event iff we don't leave the selected frame. */ && (focus_follows_mouse - || (EQ (XWINDOW (window)->frame, - XWINDOW (selected_window)->frame)))) + || (EQ (WGET (XWINDOW (window), frame), + WGET (XWINDOW (selected_window), frame))))) { inev.kind = SELECT_WINDOW_EVENT; inev.frame_or_window = window; @@ -4332,7 +4447,7 @@ w32_read_socket (struct terminal *terminal, int expected, /* If the contents of the global variable help_echo_string has changed, generate a HELP_EVENT. */ -#if 0 /* The below is an invalid comparison when USE_LISP_UNION_TYPE. +#if 0 /* The below is an invalid comparison when CHECK_LISP_OBJECT_TYPE. But it was originally changed to this to fix a bug, so I have not removed it completely in case the bug is still there. */ if (help_echo_string != previous_help_echo_string || @@ -4370,8 +4485,8 @@ w32_read_socket (struct terminal *terminal, int expected, construct_mouse_click (&inev, &msg, f); /* Is this in the tool-bar? */ - if (WINDOWP (f->tool_bar_window) - && WINDOW_TOTAL_LINES (XWINDOW (f->tool_bar_window))) + if (WINDOWP (FGET (f, tool_bar_window)) + && WINDOW_TOTAL_LINES (XWINDOW (FGET (f, tool_bar_window)))) { Lisp_Object window; int x = XFASTINT (inev.x); @@ -4379,7 +4494,7 @@ w32_read_socket (struct terminal *terminal, int expected, window = window_from_coordinates (f, x, y, 0, 1); - if (EQ (window, f->tool_bar_window)) + if (EQ (window, FGET (f, tool_bar_window))) { w32_handle_tool_bar_click (f, &inev); tool_bar_p = 1; @@ -4824,7 +4939,7 @@ w32_read_socket (struct terminal *terminal, int expected, if (!FRAME_OBSCURED_P (f)) { DebPrint (("frame %p (%s) obscured\n", f, - SDATA (f->name))); + SDATA (FGET (f, name)))); } } else @@ -4836,7 +4951,7 @@ w32_read_socket (struct terminal *terminal, int expected, { SET_FRAME_GARBAGED (f); DebPrint (("obscured frame %p (%s) found to be visible\n", f, - SDATA (f->name))); + SDATA (FGET (f, name)))); /* Force a redisplay sooner or later. */ record_asynch_buffer_change (); @@ -4927,7 +5042,7 @@ static void x_draw_bar_cursor (struct window *w, struct glyph_row *row, int width, enum text_cursor_kinds kind) { - struct frame *f = XFRAME (w->frame); + struct frame *f = XFRAME (WGET (w, frame)); struct glyph *cursor_glyph; /* If cursor is out of bounds, don't draw garbage. This can happen @@ -5484,7 +5599,7 @@ x_set_window_size (struct frame *f, int change_gravity, int cols, int rows) SET_FRAME_GARBAGED (f); /* If cursor was outside the new size, mark it as off. */ - mark_window_cursors_off (XWINDOW (f->root_window)); + mark_window_cursors_off (XWINDOW (FGET (f, root_window))); /* Clear out any recollection of where the mouse highlighting was, since it might be in a place that's outside the new frame size. @@ -5596,24 +5711,27 @@ x_raise_frame (struct frame *f) HDWP handle = BeginDeferWindowPos (2); if (handle) { - DeferWindowPos (handle, - FRAME_W32_WINDOW (f), - HWND_TOP, - 0, 0, 0, 0, - SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE); - - DeferWindowPos (handle, - GetForegroundWindow (), - FRAME_W32_WINDOW (f), - 0, 0, 0, 0, - SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE); - - EndDeferWindowPos (handle); + handle = DeferWindowPos (handle, + FRAME_W32_WINDOW (f), + HWND_TOP, + 0, 0, 0, 0, + SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE); + if (handle) + { + handle = DeferWindowPos (handle, + GetForegroundWindow (), + FRAME_W32_WINDOW (f), + 0, 0, 0, 0, + SWP_NOSIZE | SWP_NOMOVE | + SWP_NOACTIVATE); + if (handle) + EndDeferWindowPos (handle); + } } } else { - my_set_foreground_window (FRAME_W32_WINDOW (f)); + my_bring_window_to_top (FRAME_W32_WINDOW (f)); } UNBLOCK_INPUT; @@ -5904,6 +6022,27 @@ x_wm_set_icon_position (struct frame *f, int icon_x, int icon_y) #endif } + +/*********************************************************************** + Fonts + ***********************************************************************/ + +#ifdef GLYPH_DEBUG + +/* Check that FONT is valid on frame F. It is if it can be found in F's + font table. */ + +static void +x_check_font (struct frame *f, struct font *font) +{ + eassert (font != NULL && ! NILP (font->props[FONT_TYPE_INDEX])); + if (font->driver->check) + eassert (font->driver->check (f, font) == 0); +} + +#endif /* GLYPH_DEBUG */ + + /*********************************************************************** Initialization @@ -5924,10 +6063,8 @@ w32_initialize_display_info (Lisp_Object display_name) w32_display_name_list); dpyinfo->name_list_element = XCAR (w32_display_name_list); - dpyinfo->w32_id_name - = (char *) xmalloc (SCHARS (Vinvocation_name) - + SCHARS (Vsystem_name) - + 2); + dpyinfo->w32_id_name = xmalloc (SCHARS (Vinvocation_name) + + SCHARS (Vsystem_name) + 2); sprintf (dpyinfo->w32_id_name, "%s@%s", SDATA (Vinvocation_name), SDATA (Vsystem_name)); @@ -6092,7 +6229,7 @@ w32_create_terminal (struct w32_display_info *dpyinfo) /* We don't yet support separate terminals on W32, so don't try to share keyboards between virtual terminals that are on the same physical terminal like X does. */ - terminal->kboard = (KBOARD *) xmalloc (sizeof (KBOARD)); + terminal->kboard = xmalloc (sizeof (KBOARD)); init_kboard (terminal->kboard); KVAR (terminal->kboard, Vwindow_system) = intern ("w32"); terminal->kboard->next_kboard = all_kboards; @@ -6144,7 +6281,7 @@ w32_term_init (Lisp_Object display_name, char *xrm_option, char *resource_name) terminal = w32_create_terminal (dpyinfo); /* Set the name of the terminal. */ - terminal->name = (char *) xmalloc (SBYTES (display_name) + 1); + terminal->name = xmalloc (SBYTES (display_name) + 1); strncpy (terminal->name, SDATA (display_name), SBYTES (display_name)); terminal->name[SBYTES (display_name)] = 0; @@ -6293,7 +6430,8 @@ w32_initialize (void) { DWORD input_locale_id = (DWORD) GetKeyboardLayout (0); - keyboard_codepage = codepage_for_locale ((LCID) (input_locale_id & 0xffff)); + w32_keyboard_codepage = + codepage_for_locale ((LCID) (input_locale_id & 0xffff)); } /* Create the window thread - it will terminate itself when the app @@ -6411,7 +6549,7 @@ the cursor have no effect. */); from cus-start.el and other places, like "M-x set-variable". */ DEFVAR_BOOL ("x-use-underline-position-properties", x_use_underline_position_properties, - doc: /* *Non-nil means make use of UNDERLINE_POSITION font properties. + doc: /* Non-nil means make use of UNDERLINE_POSITION font properties. A value of nil means ignore them. If you encounter fonts with bogus UNDERLINE_POSITION font properties, for example 7x13 on XFree prior to 4.1, set this to nil. You can also use `underline-minimum-offset' @@ -6421,7 +6559,7 @@ sizes. */); DEFVAR_BOOL ("x-underline-at-descent-line", x_underline_at_descent_line, - doc: /* *Non-nil means to draw the underline at the same place as the descent line. + doc: /* Non-nil means to draw the underline at the same place as the descent line. A value of nil means to draw the underline according to the value of the variable `x-use-underline-position-properties', which is usually at the baseline level. The default value is nil. */);