/[emacs]/emacs/src/w32term.c
ViewVC logotype

Diff of /emacs/src/w32term.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.169 by kfstorm, Sat Oct 26 23:52:52 2002 UTC revision 1.170 by lektu, Fri Nov 8 08:42:03 2002 UTC
# Line 155  Lisp_Object Vx_toolkit_scroll_bars; Line 155  Lisp_Object Vx_toolkit_scroll_bars;
155    
156  /* If a string, w32_read_socket generates an event to display that string.  /* If a string, w32_read_socket generates an event to display that string.
157     (The display is done in read_char.)  */     (The display is done in read_char.)  */
158      
159  static Lisp_Object help_echo;  static Lisp_Object help_echo;
160  static Lisp_Object help_echo_window;  static Lisp_Object help_echo_window;
161  static Lisp_Object help_echo_object;  static Lisp_Object help_echo_object;
# Line 415  static void x_erase_phys_cursor P_ ((str Line 415  static void x_erase_phys_cursor P_ ((str
415  void x_display_cursor P_ ((struct window *w, int, int, int, int, int));  void x_display_cursor P_ ((struct window *w, int, int, int, int, int));
416  void x_display_and_set_cursor P_ ((struct window *, int, int, int, int, int));  void x_display_and_set_cursor P_ ((struct window *, int, int, int, int, int));
417  static void w32_draw_fringe_bitmap P_ ((struct window *, HDC hdc,  static void w32_draw_fringe_bitmap P_ ((struct window *, HDC hdc,
418                                          struct glyph_row *,                                          struct glyph_row *,
419                                          enum fringe_bitmap_type, int left_p));                                          enum fringe_bitmap_type, int left_p));
420  static void w32_clip_to_row P_ ((struct window *, struct glyph_row *,  static void w32_clip_to_row P_ ((struct window *, struct glyph_row *,
421                                   HDC, int));                                   HDC, int));
# Line 438  static Lisp_Object Qvendor_specific_keys Line 438  static Lisp_Object Qvendor_specific_keys
438  /* This is a function useful for recording debugging information about  /* This is a function useful for recording debugging information about
439     the sequence of occurrences in this file.  */     the sequence of occurrences in this file.  */
440    
441  struct record  struct record
442  {  {
443    char *locus;    char *locus;
444    int type;    int type;
# Line 527  w32_draw_rectangle (HDC hdc, XGCValues * Line 527  w32_draw_rectangle (HDC hdc, XGCValues *
527  }  }
528    
529  /* Draw a filled rectangle at the specified position. */  /* Draw a filled rectangle at the specified position. */
530  void  void
531  w32_fill_rect (f, hdc, pix, lprect)  w32_fill_rect (f, hdc, pix, lprect)
532       FRAME_PTR f;       FRAME_PTR f;
533       HDC hdc;       HDC hdc;
# Line 541  w32_fill_rect (f, hdc, pix, lprect) Line 541  w32_fill_rect (f, hdc, pix, lprect)
541    DeleteObject (hb);    DeleteObject (hb);
542  }  }
543    
544  void  void
545  w32_clear_window (f)  w32_clear_window (f)
546       FRAME_PTR f;       FRAME_PTR f;
547  {  {
# Line 564  w32_clear_window (f) Line 564  w32_clear_window (f)
564  /***********************************************************************  /***********************************************************************
565                      Starting and ending an update                      Starting and ending an update
566   ***********************************************************************/   ***********************************************************************/
567                                                                            
568  /* Start an update of frame F.  This function is installed as a hook  /* Start an update of frame F.  This function is installed as a hook
569     for update_begin, i.e. it is called when update_begin is called.     for update_begin, i.e. it is called when update_begin is called.
570     This function is called prior to calls to x_update_window_begin for     This function is called prior to calls to x_update_window_begin for
# Line 625  x_update_window_begin (w) Line 625  x_update_window_begin (w)
625           flag set.  So, rows containing mouse-face glyphs are never           flag set.  So, rows containing mouse-face glyphs are never
626           scrolled, and we don't have to switch the mouse highlight off           scrolled, and we don't have to switch the mouse highlight off
627           here to prevent it from being scrolled.  */           here to prevent it from being scrolled.  */
628          
629        /* Can we tell that this update does not affect the window        /* Can we tell that this update does not affect the window
630           where the mouse highlight is?  If so, no need to turn off.           where the mouse highlight is?  If so, no need to turn off.
631           Likewise, don't do anything if the frame is garbaged;           Likewise, don't do anything if the frame is garbaged;
# Line 658  x_draw_vertical_border (w) Line 658  x_draw_vertical_border (w)
658       struct window *w;       struct window *w;
659  {  {
660    struct frame *f = XFRAME (WINDOW_FRAME (w));    struct frame *f = XFRAME (WINDOW_FRAME (w));
661      
662    /* Redraw borders between horizontally adjacent windows.  Don't    /* Redraw borders between horizontally adjacent windows.  Don't
663       do it for frames with vertical scroll bars because either the       do it for frames with vertical scroll bars because either the
664       right scroll bar of a window, or the left scroll bar of its       right scroll bar of a window, or the left scroll bar of its
# Line 681  x_draw_vertical_border (w) Line 681  x_draw_vertical_border (w)
681      }      }
682  }  }
683    
684      
685  /* End update of window W (which is equal to updated_window).  /* End update of window W (which is equal to updated_window).
686    
687     Draw vertical borders between horizontally adjacent windows, and     Draw vertical borders between horizontally adjacent windows, and
# Line 711  x_update_window_end (w, cursor_on_p, mou Line 711  x_update_window_end (w, cursor_on_p, mou
711          x_display_and_set_cursor (w, 1, output_cursor.hpos,          x_display_and_set_cursor (w, 1, output_cursor.hpos,
712                                    output_cursor.vpos,                                    output_cursor.vpos,
713                                    output_cursor.x, output_cursor.y);                                    output_cursor.x, output_cursor.y);
714          
715        x_draw_vertical_border (w);        x_draw_vertical_border (w);
716        UNBLOCK_INPUT;        UNBLOCK_INPUT;
717      }      }
# Line 792  x_after_update_window_line (desired_row) Line 792  x_after_update_window_line (desired_row)
792    int width, height;    int width, height;
793    
794    xassert (w);    xassert (w);
795      
796    if (!desired_row->mode_line_p && !w->pseudo_window_p)    if (!desired_row->mode_line_p && !w->pseudo_window_p)
797      {      {
798        BLOCK_INPUT;        BLOCK_INPUT;
# Line 847  w32_draw_fringe_bitmap (w, hdc, row, whi Line 847  w32_draw_fringe_bitmap (w, hdc, row, whi
847       int left_p;       int left_p;
848  {  {
849    struct frame *f = XFRAME (WINDOW_FRAME (w));    struct frame *f = XFRAME (WINDOW_FRAME (w));
   Window window = FRAME_W32_WINDOW (f);  
850    HDC compat_hdc;    HDC compat_hdc;
851    int x, y, wd, h, dy;    int x, y, wd, h, dy;
852    int b1, b2;    int b1, b2;
# Line 873  w32_draw_fringe_bitmap (w, hdc, row, whi Line 872  w32_draw_fringe_bitmap (w, hdc, row, whi
872        h = left_height;        h = left_height;
873        pixmap = left_bmp;        pixmap = left_bmp;
874        break;        break;
875          
876      case OVERLAY_ARROW_BITMAP:      case OVERLAY_ARROW_BITMAP:
877        wd = ov_width;        wd = ov_width;
878        h = ov_height;        h = ov_height;
879        pixmap = ov_bmp;        pixmap = ov_bmp;
880        break;        break;
881          
882      case RIGHT_TRUNCATION_BITMAP:      case RIGHT_TRUNCATION_BITMAP:
883        wd = right_width;        wd = right_width;
884        h = right_height;        h = right_height;
# Line 891  w32_draw_fringe_bitmap (w, hdc, row, whi Line 890  w32_draw_fringe_bitmap (w, hdc, row, whi
890        h = continued_height;        h = continued_height;
891        pixmap = continued_bmp;        pixmap = continued_bmp;
892        break;        break;
893          
894      case CONTINUATION_LINE_BITMAP:      case CONTINUATION_LINE_BITMAP:
895        wd = continuation_width;        wd = continuation_width;
896        h = continuation_height;        h = continuation_height;
# Line 959  w32_draw_fringe_bitmap (w, hdc, row, whi Line 958  w32_draw_fringe_bitmap (w, hdc, row, whi
958    if (b1 >= 0)    if (b1 >= 0)
959      {      {
960        int header_line_height = WINDOW_DISPLAY_HEADER_LINE_HEIGHT (w);        int header_line_height = WINDOW_DISPLAY_HEADER_LINE_HEIGHT (w);
961          
962        w32_fill_area (f, hdc, face->background,        w32_fill_area (f, hdc, face->background,
963                       b1,                       b1,
964                       WINDOW_TO_FRAME_PIXEL_Y (w, max (header_line_height,                       WINDOW_TO_FRAME_PIXEL_Y (w, max (header_line_height,
# Line 1087  set_output_cursor (cursor) Line 1086  set_output_cursor (cursor)
1086    
1087     HPOS and VPOS are column/row positions in a window glyph matrix.  X     HPOS and VPOS are column/row positions in a window glyph matrix.  X
1088     and Y are window text area relative pixel positions.     and Y are window text area relative pixel positions.
1089      
1090     If this is done during an update, updated_window will contain the     If this is done during an update, updated_window will contain the
1091     window that is being updated and the position is the future output     window that is being updated and the position is the future output
1092     cursor position for that window.  If updated_window is null, use     cursor position for that window.  If updated_window is null, use
# Line 1385  int w32_font_is_double_byte (XFontStruct Line 1384  int w32_font_is_double_byte (XFontStruct
1384  }  }
1385    
1386    
1387  static BOOL  static BOOL
1388  w32_use_unicode_for_codepage (codepage)  w32_use_unicode_for_codepage (codepage)
1389       int codepage;       int codepage;
1390  {  {
# Line 1449  w32_encode_char (c, char2b, font_info, t Line 1448  w32_encode_char (c, char2b, font_info, t
1448        /* Fixed encoding scheme.  See fontset.h for the meaning of the        /* Fixed encoding scheme.  See fontset.h for the meaning of the
1449           encoding numbers.  */           encoding numbers.  */
1450        int enc = font_info->encoding[charset];        int enc = font_info->encoding[charset];
1451          
1452        if ((enc == 1 || enc == 2)        if ((enc == 1 || enc == 2)
1453            && CHARSET_DIMENSION (charset) == 2)            && CHARSET_DIMENSION (charset) == 2)
1454          *char2b = BUILD_WCHAR_T (BYTE1 (*char2b) | 0x80, BYTE2 (*char2b));          *char2b = BUILD_WCHAR_T (BYTE1 (*char2b) | 0x80, BYTE2 (*char2b));
1455          
1456        if (enc == 1 || enc == 3        if (enc == 1 || enc == 3
1457            || (enc == 4 && CHARSET_DIMENSION (charset) == 1))            || (enc == 4 && CHARSET_DIMENSION (charset) == 1))
1458          *char2b = BUILD_WCHAR_T (BYTE1 (*char2b), BYTE2 (*char2b) | 0x80);          *char2b = BUILD_WCHAR_T (BYTE1 (*char2b), BYTE2 (*char2b) | 0x80);
# Line 1531  x_get_char_face_and_encoding (f, c, face Line 1530  x_get_char_face_and_encoding (f, c, face
1530    else    else
1531      {      {
1532        int c1, c2, charset;        int c1, c2, charset;
1533          
1534        /* Split characters into bytes.  If c2 is -1 afterwards, C is        /* Split characters into bytes.  If c2 is -1 afterwards, C is
1535           really a one-byte character so that byte1 is zero.  */           really a one-byte character so that byte1 is zero.  */
1536        SPLIT_CHAR (c, charset, c1, c2);        SPLIT_CHAR (c, charset, c1, c2);
# Line 1539  x_get_char_face_and_encoding (f, c, face Line 1538  x_get_char_face_and_encoding (f, c, face
1538          *char2b = BUILD_WCHAR_T (c1, c2);          *char2b = BUILD_WCHAR_T (c1, c2);
1539        else        else
1540          *char2b = BUILD_WCHAR_T (0, c1);          *char2b = BUILD_WCHAR_T (0, c1);
1541      
1542        /* Maybe encode the character in *CHAR2B.  */        /* Maybe encode the character in *CHAR2B.  */
1543        if (face->font != NULL)        if (face->font != NULL)
1544          {          {
# Line 1553  x_get_char_face_and_encoding (f, c, face Line 1552  x_get_char_face_and_encoding (f, c, face
1552    /* Make sure X resources of the face are allocated.  */    /* Make sure X resources of the face are allocated.  */
1553    xassert (face != NULL);    xassert (face != NULL);
1554    PREPARE_FACE_FOR_DISPLAY (f, face);    PREPARE_FACE_FOR_DISPLAY (f, face);
1555      
1556    return face;    return face;
1557  }  }
1558    
# Line 1595  x_get_glyph_face_and_encoding (f, glyph, Line 1594  x_get_glyph_face_and_encoding (f, glyph,
1594    else    else
1595      {      {
1596        int c1, c2, charset;        int c1, c2, charset;
1597          
1598        /* Split characters into bytes.  If c2 is -1 afterwards, C is        /* Split characters into bytes.  If c2 is -1 afterwards, C is
1599           really a one-byte character so that byte1 is zero.  */           really a one-byte character so that byte1 is zero.  */
1600        SPLIT_CHAR (glyph->u.ch, charset, c1, c2);        SPLIT_CHAR (glyph->u.ch, charset, c1, c2);
# Line 1624  x_get_glyph_face_and_encoding (f, glyph, Line 1623  x_get_glyph_face_and_encoding (f, glyph,
1623  }  }
1624    
1625    
1626  /* Store one glyph for IT->char_to_display in IT->glyph_row.    /* Store one glyph for IT->char_to_display in IT->glyph_row.
1627     Called from x_produce_glyphs when IT->glyph_row is non-null.  */     Called from x_produce_glyphs when IT->glyph_row is non-null.  */
1628    
1629  static INLINE void  static INLINE void
# Line 1633  x_append_glyph (it) Line 1632  x_append_glyph (it)
1632  {  {
1633    struct glyph *glyph;    struct glyph *glyph;
1634    enum glyph_row_area area = it->area;    enum glyph_row_area area = it->area;
1635      
1636    xassert (it->glyph_row);    xassert (it->glyph_row);
1637    xassert (it->char_to_display != '\n' && it->char_to_display != '\t');    xassert (it->char_to_display != '\n' && it->char_to_display != '\t');
1638      
1639    glyph = it->glyph_row->glyphs[area] + it->glyph_row->used[area];    glyph = it->glyph_row->glyphs[area] + it->glyph_row->used[area];
1640    if (glyph < it->glyph_row->glyphs[area + 1])    if (glyph < it->glyph_row->glyphs[area + 1])
1641      {      {
# Line 1659  x_append_glyph (it) Line 1658  x_append_glyph (it)
1658      }      }
1659  }  }
1660    
1661  /* Store one glyph for the composition IT->cmp_id in IT->glyph_row.    /* Store one glyph for the composition IT->cmp_id in IT->glyph_row.
1662     Called from x_produce_glyphs when IT->glyph_row is non-null.  */     Called from x_produce_glyphs when IT->glyph_row is non-null.  */
1663    
1664  static INLINE void  static INLINE void
# Line 1668  x_append_composite_glyph (it) Line 1667  x_append_composite_glyph (it)
1667  {  {
1668    struct glyph *glyph;    struct glyph *glyph;
1669    enum glyph_row_area area = it->area;    enum glyph_row_area area = it->area;
1670      
1671    xassert (it->glyph_row);    xassert (it->glyph_row);
1672      
1673    glyph = it->glyph_row->glyphs[area] + it->glyph_row->used[area];    glyph = it->glyph_row->glyphs[area] + it->glyph_row->used[area];
1674    if (glyph < it->glyph_row->glyphs[area + 1])    if (glyph < it->glyph_row->glyphs[area + 1])
1675      {      {
# Line 1741  x_produce_image_glyph (it) Line 1740  x_produce_image_glyph (it)
1740    it->pixel_width = img->width + 2 * img->hmargin;    it->pixel_width = img->width + 2 * img->hmargin;
1741    
1742    it->nglyphs = 1;    it->nglyphs = 1;
1743      
1744    if (face->box != FACE_NO_BOX)    if (face->box != FACE_NO_BOX)
1745      {      {
1746        if (face->box_line_width > 0)        if (face->box_line_width > 0)
# Line 1749  x_produce_image_glyph (it) Line 1748  x_produce_image_glyph (it)
1748            it->ascent += face->box_line_width;            it->ascent += face->box_line_width;
1749            it->descent += face->box_line_width;            it->descent += face->box_line_width;
1750          }          }
1751          
1752        if (it->start_of_box_run_p)        if (it->start_of_box_run_p)
1753          it->pixel_width += abs (face->box_line_width);          it->pixel_width += abs (face->box_line_width);
1754        if (it->end_of_box_run_p)        if (it->end_of_box_run_p)
# Line 1757  x_produce_image_glyph (it) Line 1756  x_produce_image_glyph (it)
1756      }      }
1757    
1758    take_vertical_position_into_account (it);    take_vertical_position_into_account (it);
1759      
1760    if (it->glyph_row)    if (it->glyph_row)
1761      {      {
1762        struct glyph *glyph;        struct glyph *glyph;
1763        enum glyph_row_area area = it->area;        enum glyph_row_area area = it->area;
1764          
1765        glyph = it->glyph_row->glyphs[area] + it->glyph_row->used[area];        glyph = it->glyph_row->glyphs[area] + it->glyph_row->used[area];
1766        if (glyph < it->glyph_row->glyphs[area + 1])        if (glyph < it->glyph_row->glyphs[area + 1])
1767          {          {
# Line 1787  x_produce_image_glyph (it) Line 1786  x_produce_image_glyph (it)
1786    
1787    
1788  /* Append a stretch glyph to IT->glyph_row.  OBJECT is the source  /* Append a stretch glyph to IT->glyph_row.  OBJECT is the source
1789     of the glyph, WIDTH and HEIGHT are the width and height of the     of the glyph, WIDTH and HEIGHT are the width and height of the
1790     stretch.  ASCENT is the percentage/100 of HEIGHT to use for the     stretch.  ASCENT is the percentage/100 of HEIGHT to use for the
1791     ascent of the glyph (0 <= ASCENT <= 1).  */     ascent of the glyph (0 <= ASCENT <= 1).  */
1792      
1793  static void  static void
1794  x_append_stretch_glyph (it, object, width, height, ascent)  x_append_stretch_glyph (it, object, width, height, ascent)
1795       struct it *it;       struct it *it;
# Line 1802  x_append_stretch_glyph (it, object, widt Line 1801  x_append_stretch_glyph (it, object, widt
1801    enum glyph_row_area area = it->area;    enum glyph_row_area area = it->area;
1802    
1803    xassert (ascent >= 0 && ascent <= 1);    xassert (ascent >= 0 && ascent <= 1);
1804      
1805    glyph = it->glyph_row->glyphs[area] + it->glyph_row->used[area];    glyph = it->glyph_row->glyphs[area] + it->glyph_row->used[area];
1806    if (glyph < it->glyph_row->glyphs[area + 1])    if (glyph < it->glyph_row->glyphs[area + 1])
1807      {      {
# Line 1832  x_append_stretch_glyph (it, object, widt Line 1831  x_append_stretch_glyph (it, object, widt
1831     being recognized:     being recognized:
1832    
1833     1. `:width WIDTH' specifies that the space should be WIDTH *     1. `:width WIDTH' specifies that the space should be WIDTH *
1834     canonical char width wide.  WIDTH may be an integer or floating     canonical char width wide.  WIDTH may be an integer or floating
1835     point number.     point number.
1836    
1837     2. `:relative-width FACTOR' specifies that the width of the stretch     2. `:relative-width FACTOR' specifies that the width of the stretch
# Line 1842  x_append_stretch_glyph (it, object, widt Line 1841  x_append_stretch_glyph (it, object, widt
1841     3. `:align-to HPOS' specifies that the space should be wide enough     3. `:align-to HPOS' specifies that the space should be wide enough
1842     to reach HPOS, a value in canonical character units.     to reach HPOS, a value in canonical character units.
1843    
1844     Exactly one of the above pairs must be present.       Exactly one of the above pairs must be present.
1845    
1846     4. `:height HEIGHT' specifies that the height of the stretch produced     4. `:height HEIGHT' specifies that the height of the stretch produced
1847     should be HEIGHT, measured in canonical character units.     should be HEIGHT, measured in canonical character units.
# Line 1880  x_produce_stretch_glyph (it) Line 1879  x_produce_stretch_glyph (it)
1879    XFontStruct *font = face->font ? face->font : FRAME_FONT (it->f);    XFontStruct *font = face->font ? face->font : FRAME_FONT (it->f);
1880    
1881    PREPARE_FACE_FOR_DISPLAY (it->f, face);    PREPARE_FACE_FOR_DISPLAY (it->f, face);
1882      
1883    /* List should start with `space'.  */    /* List should start with `space'.  */
1884    xassert (CONSP (it->object) && EQ (XCAR (it->object), Qspace));    xassert (CONSP (it->object) && EQ (XCAR (it->object), Qspace));
1885    plist = XCDR (it->object);    plist = XCDR (it->object);
# Line 1898  x_produce_stretch_glyph (it) Line 1897  x_produce_stretch_glyph (it)
1897           property.  */           property.  */
1898        struct it it2;        struct it it2;
1899        unsigned char *p = BYTE_POS_ADDR (IT_BYTEPOS (*it));        unsigned char *p = BYTE_POS_ADDR (IT_BYTEPOS (*it));
1900          
1901        it2 = *it;        it2 = *it;
1902        if (it->multibyte_p)        if (it->multibyte_p)
1903          {          {
# Line 1920  x_produce_stretch_glyph (it) Line 1919  x_produce_stretch_glyph (it)
1919    else    else
1920      /* Nothing specified -> width defaults to canonical char width.  */      /* Nothing specified -> width defaults to canonical char width.  */
1921      width = CANON_X_UNIT (it->f);      width = CANON_X_UNIT (it->f);
1922      
1923    /* Compute height.  */    /* Compute height.  */
1924    if (prop = Fplist_get (plist, QCheight),    if (prop = Fplist_get (plist, QCheight),
1925        NUMVAL (prop) > 0)        NUMVAL (prop) > 0)
# Line 1931  x_produce_stretch_glyph (it) Line 1930  x_produce_stretch_glyph (it)
1930    else    else
1931      height = FONT_HEIGHT (font);      height = FONT_HEIGHT (font);
1932    
1933    /* Compute percentage of height used for ascent.  If    /* Compute percentage of height used for ascent.  If
1934       `:ascent ASCENT' is present and valid, use that.  Otherwise,       `:ascent ASCENT' is present and valid, use that.  Otherwise,
1935       derive the ascent from the font in use.  */       derive the ascent from the font in use.  */
1936    if (prop = Fplist_get (plist, QCascent),    if (prop = Fplist_get (plist, QCascent),
# Line 1965  x_produce_stretch_glyph (it) Line 1964  x_produce_stretch_glyph (it)
1964            it->ascent += face->box_line_width;            it->ascent += face->box_line_width;
1965            it->descent += face->box_line_width;            it->descent += face->box_line_width;
1966          }          }
1967          
1968        if (it->start_of_box_run_p)        if (it->start_of_box_run_p)
1969          it->pixel_width += abs (face->box_line_width);          it->pixel_width += abs (face->box_line_width);
1970        if (it->end_of_box_run_p)        if (it->end_of_box_run_p)
1971          it->pixel_width += abs (face->box_line_width);          it->pixel_width += abs (face->box_line_width);
1972      }      }
1973      
1974    take_vertical_position_into_account (it);    take_vertical_position_into_account (it);
1975  }  }
1976    
# Line 2063  x_produce_glyphs (it) Line 2062  x_produce_glyphs (it)
2062                face = FACE_FROM_ID (it->f, it->face_id);                face = FACE_FROM_ID (it->f, it->face_id);
2063              }              }
2064          }          }
2065          
2066        /* Get font to use.  Encode IT->char_to_display.  */        /* Get font to use.  Encode IT->char_to_display.  */
2067        x_get_char_face_and_encoding (it->f, it->char_to_display,        x_get_char_face_and_encoding (it->f, it->char_to_display,
2068                                      it->face_id, &char2b,                                      it->face_id, &char2b,
# Line 2112  x_produce_glyphs (it) Line 2111  x_produce_glyphs (it)
2111                it->phys_descent = FONT_DESCENT (font) - boff;                it->phys_descent = FONT_DESCENT (font) - boff;
2112                it->pixel_width = FONT_WIDTH (font);                it->pixel_width = FONT_WIDTH (font);
2113              }              }
2114              
2115            /* If this is a space inside a region of text with            /* If this is a space inside a region of text with
2116               `space-width' property, change its width.  */               `space-width' property, change its width.  */
2117            stretched_p = it->char_to_display == ' ' && !NILP (it->space_width);            stretched_p = it->char_to_display == ' ' && !NILP (it->space_width);
# Line 2125  x_produce_glyphs (it) Line 2124  x_produce_glyphs (it)
2124            if (face->box != FACE_NO_BOX)            if (face->box != FACE_NO_BOX)
2125              {              {
2126                int thick = face->box_line_width;                int thick = face->box_line_width;
2127                  
2128                if (thick > 0)                if (thick > 0)
2129                  {                  {
2130                    it->ascent += thick;                    it->ascent += thick;
# Line 2133  x_produce_glyphs (it) Line 2132  x_produce_glyphs (it)
2132                  }                  }
2133                else                else
2134                  thick = -thick;                  thick = -thick;
2135                  
2136                if (it->start_of_box_run_p)                if (it->start_of_box_run_p)
2137                  it->pixel_width += thick;                  it->pixel_width += thick;
2138                if (it->end_of_box_run_p)                if (it->end_of_box_run_p)
# Line 2146  x_produce_glyphs (it) Line 2145  x_produce_glyphs (it)
2145              it->ascent += 2;              it->ascent += 2;
2146    
2147            take_vertical_position_into_account (it);            take_vertical_position_into_account (it);
2148      
2149            /* If we have to actually produce glyphs, do it.  */            /* If we have to actually produce glyphs, do it.  */
2150            if (it->glyph_row)            if (it->glyph_row)
2151              {              {
# Line 2156  x_produce_glyphs (it) Line 2155  x_produce_glyphs (it)
2155                       into a stretch glyph.  */                       into a stretch glyph.  */
2156                    double ascent = (double) FONT_BASE (font)                    double ascent = (double) FONT_BASE (font)
2157                                  / FONT_HEIGHT (font);                                  / FONT_HEIGHT (font);
2158                    x_append_stretch_glyph (it, it->object, it->pixel_width,                    x_append_stretch_glyph (it, it->object, it->pixel_width,
2159                                            it->ascent + it->descent, ascent);                                            it->ascent + it->descent, ascent);
2160                  }                  }
2161                else                else
# Line 2176  x_produce_glyphs (it) Line 2175  x_produce_glyphs (it)
2175            it->nglyphs = 0;            it->nglyphs = 0;
2176            it->ascent = it->phys_ascent = FONT_BASE (font) + boff;            it->ascent = it->phys_ascent = FONT_BASE (font) + boff;
2177            it->descent = it->phys_descent = FONT_DESCENT (font) - boff;            it->descent = it->phys_descent = FONT_DESCENT (font) - boff;
2178          
2179            if (face->box != FACE_NO_BOX            if (face->box != FACE_NO_BOX
2180                && face->box_line_width > 0)                && face->box_line_width > 0)
2181              {              {
# Line 2189  x_produce_glyphs (it) Line 2188  x_produce_glyphs (it)
2188            int tab_width = it->tab_width * CANON_X_UNIT (it->f);            int tab_width = it->tab_width * CANON_X_UNIT (it->f);
2189            int x = it->current_x + it->continuation_lines_width;            int x = it->current_x + it->continuation_lines_width;
2190            int next_tab_x = ((1 + x + tab_width - 1) / tab_width) * tab_width;            int next_tab_x = ((1 + x + tab_width - 1) / tab_width) * tab_width;
2191          
2192            /* If the distance from the current position to the next tab            /* If the distance from the current position to the next tab
2193               stop is less than a canonical character width, use the               stop is less than a canonical character width, use the
2194               tab stop after that.  */               tab stop after that.  */
# Line 2200  x_produce_glyphs (it) Line 2199  x_produce_glyphs (it)
2199            it->nglyphs = 1;            it->nglyphs = 1;
2200            it->ascent = it->phys_ascent = FONT_BASE (font) + boff;            it->ascent = it->phys_ascent = FONT_BASE (font) + boff;
2201            it->descent = it->phys_descent = FONT_DESCENT (font) - boff;            it->descent = it->phys_descent = FONT_DESCENT (font) - boff;
2202              
2203            if (it->glyph_row)            if (it->glyph_row)
2204              {              {
2205                double ascent = (double) it->ascent / (it->ascent + it->descent);                double ascent = (double) it->ascent / (it->ascent + it->descent);
2206                x_append_stretch_glyph (it, it->object, it->pixel_width,                x_append_stretch_glyph (it, it->object, it->pixel_width,
2207                                        it->ascent + it->descent, ascent);                                        it->ascent + it->descent, ascent);
2208              }              }
2209          }          }
2210        else        else
2211          {          {
2212            /* A multi-byte character.            /* A multi-byte character.
2213               If we found a font, this font should give us the right               If we found a font, this font should give us the right
# Line 2261  x_produce_glyphs (it) Line 2260  x_produce_glyphs (it)
2260                  }                  }
2261                else                else
2262                  thick = - thick;                  thick = - thick;
2263              
2264                if (it->start_of_box_run_p)                if (it->start_of_box_run_p)
2265                  it->pixel_width += thick;                  it->pixel_width += thick;
2266                if (it->end_of_box_run_p)                if (it->end_of_box_run_p)
2267                  it->pixel_width += thick;                  it->pixel_width += thick;
2268              }              }
2269      
2270            /* If face has an overline, add the height of the overline            /* If face has an overline, add the height of the overline
2271               (1 pixel) and a 1 pixel margin to the character height.  */               (1 pixel) and a 1 pixel margin to the character height.  */
2272            if (face->overline_p)            if (face->overline_p)
2273              it->ascent += 2;              it->ascent += 2;
2274    
2275            take_vertical_position_into_account (it);            take_vertical_position_into_account (it);
2276      
2277            if (it->glyph_row)            if (it->glyph_row)
2278              x_append_glyph (it);              x_append_glyph (it);
2279          }          }
# Line 2376  x_produce_glyphs (it) Line 2375  x_produce_glyphs (it)
2375                ascent = FONT_BASE (font);                ascent = FONT_BASE (font);
2376                descent = FONT_DESCENT (font);                descent = FONT_DESCENT (font);
2377              }              }
2378              
2379            rightmost = width;            rightmost = width;
2380            lowest = - descent + boff;            lowest = - descent + boff;
2381            highest = ascent + boff;            highest = ascent + boff;
2382            leftmost = 0;            leftmost = 0;
2383              
2384            if (font_info            if (font_info
2385                && font_info->default_ascent                && font_info->default_ascent
2386                && CHAR_TABLE_P (Vuse_default_ascent)                && CHAR_TABLE_P (Vuse_default_ascent)
# Line 2549  x_produce_glyphs (it) Line 2548  x_produce_glyphs (it)
2548              }              }
2549            else            else
2550              thick = - thick;              thick = - thick;
2551              
2552            if (it->start_of_box_run_p)            if (it->start_of_box_run_p)
2553              it->pixel_width += thick;              it->pixel_width += thick;
2554            if (it->end_of_box_run_p)            if (it->end_of_box_run_p)
2555              it->pixel_width += thick;              it->pixel_width += thick;
2556          }          }
2557      
2558        /* If face has an overline, add the height of the overline        /* If face has an overline, add the height of the overline
2559           (1 pixel) and a 1 pixel margin to the character height.  */           (1 pixel) and a 1 pixel margin to the character height.  */
2560        if (face->overline_p)        if (face->overline_p)
2561          it->ascent += 2;          it->ascent += 2;
2562    
2563        take_vertical_position_into_account (it);        take_vertical_position_into_account (it);
2564      
2565        if (it->glyph_row)        if (it->glyph_row)
2566          x_append_composite_glyph (it);          x_append_composite_glyph (it);
2567      }      }
# Line 2609  x_estimate_mode_line_height (f, face_id) Line 2608  x_estimate_mode_line_height (f, face_id)
2608                height += 2 * face->box_line_width;                height += 2 * face->box_line_width;
2609            }            }
2610        }        }
2611      
2612    return height;    return height;
2613  }  }
2614    
# Line 2801  static int x_fill_glyph_string P_ ((stru Line 2800  static int x_fill_glyph_string P_ ((stru
2800  static void w32_init_glyph_string P_ ((struct glyph_string *, HDC hdc,  static void w32_init_glyph_string P_ ((struct glyph_string *, HDC hdc,
2801                                         wchar_t *, struct window *,                                         wchar_t *, struct window *,
2802                                         struct glyph_row *,                                         struct glyph_row *,
2803                                         enum glyph_row_area, int,                                         enum glyph_row_area, int,
2804                                         enum draw_glyphs_face));                                         enum draw_glyphs_face));
2805  static int x_draw_glyphs P_ ((struct window *, int , struct glyph_row *,  static int x_draw_glyphs P_ ((struct window *, int , struct glyph_row *,
2806                                enum glyph_row_area, int, int,                                enum glyph_row_area, int, int,
# Line 2847  static int x_fill_stretch_glyph_string P Line 2846  static int x_fill_stretch_glyph_string P
2846  static void x_check_font P_ ((struct frame *, XFontStruct *));  static void x_check_font P_ ((struct frame *, XFontStruct *));
2847  #endif  #endif
2848    
2849        
2850  /* Append the list of glyph strings with head H and tail T to the list  /* Append the list of glyph strings with head H and tail T to the list
2851     with head *HEAD and tail *TAIL.  Set *HEAD and *TAIL to the result.  */     with head *HEAD and tail *TAIL.  Set *HEAD and *TAIL to the result.  */
2852    
# Line 2956  x_set_cursor_gc (s) Line 2955  x_set_cursor_gc (s)
2955    
2956    
2957  /* Set up S->gc of glyph string S for drawing text in mouse face.  */  /* Set up S->gc of glyph string S for drawing text in mouse face.  */
2958      
2959  static void  static void
2960  x_set_mouse_face_gc (s)  x_set_mouse_face_gc (s)
2961       struct glyph_string *s;       struct glyph_string *s;
2962  {      {
2963    int face_id;    int face_id;
2964    struct face *face;    struct face *face;
2965    
# Line 2969  x_set_mouse_face_gc (s) Line 2968  x_set_mouse_face_gc (s)
2968    face = FACE_FROM_ID (s->f, face_id);    face = FACE_FROM_ID (s->f, face_id);
2969    if (face == NULL)    if (face == NULL)
2970      face = FACE_FROM_ID (s->f, MOUSE_FACE_ID);      face = FACE_FROM_ID (s->f, MOUSE_FACE_ID);
2971      
2972    if (s->first_glyph->type == CHAR_GLYPH)    if (s->first_glyph->type == CHAR_GLYPH)
2973      face_id = FACE_FOR_CHAR (s->f, face, s->first_glyph->u.ch);      face_id = FACE_FOR_CHAR (s->f, face, s->first_glyph->u.ch);
2974    else    else
# Line 2986  x_set_mouse_face_gc (s) Line 2985  x_set_mouse_face_gc (s)
2985           but font FONT.  */           but font FONT.  */
2986        XGCValues xgcv;        XGCValues xgcv;
2987        unsigned long mask;        unsigned long mask;
2988          
2989        xgcv.background = s->face->background;        xgcv.background = s->face->background;
2990        xgcv.foreground = s->face->foreground;        xgcv.foreground = s->face->foreground;
2991        IF_DEBUG (x_check_font (s->f, s->font));        IF_DEBUG (x_check_font (s->f, s->font));
2992        xgcv.font = s->font;        xgcv.font = s->font;
2993        mask = GCForeground | GCBackground | GCFont;        mask = GCForeground | GCBackground | GCFont;
2994          
2995        if (FRAME_W32_DISPLAY_INFO (s->f)->scratch_cursor_gc)        if (FRAME_W32_DISPLAY_INFO (s->f)->scratch_cursor_gc)
2996          XChangeGC (NULL, FRAME_W32_DISPLAY_INFO (s->f)->scratch_cursor_gc,          XChangeGC (NULL, FRAME_W32_DISPLAY_INFO (s->f)->scratch_cursor_gc,
2997                     mask, &xgcv);                     mask, &xgcv);
2998        else        else
2999          FRAME_W32_DISPLAY_INFO (s->f)->scratch_cursor_gc          FRAME_W32_DISPLAY_INFO (s->f)->scratch_cursor_gc
3000            = XCreateGC (NULL, s->window, mask, &xgcv);            = XCreateGC (NULL, s->window, mask, &xgcv);
3001          
3002        s->gc = FRAME_W32_DISPLAY_INFO (s->f)->scratch_cursor_gc;        s->gc = FRAME_W32_DISPLAY_INFO (s->f)->scratch_cursor_gc;
3003      }      }
3004    
# Line 3014  x_set_mouse_face_gc (s) Line 3013  x_set_mouse_face_gc (s)
3013  static INLINE void  static INLINE void
3014  x_set_mode_line_face_gc (s)  x_set_mode_line_face_gc (s)
3015       struct glyph_string *s;       struct glyph_string *s;
3016  {      {
3017    s->gc = s->face->gc;    s->gc = s->face->gc;
3018  }  }
3019    
# Line 3028  x_set_glyph_string_gc (s) Line 3027  x_set_glyph_string_gc (s)
3027       struct glyph_string *s;       struct glyph_string *s;
3028  {  {
3029    PREPARE_FACE_FOR_DISPLAY (s->f, s->face);    PREPARE_FACE_FOR_DISPLAY (s->f, s->face);
3030      
3031    if (s->hl == DRAW_NORMAL_TEXT)    if (s->hl == DRAW_NORMAL_TEXT)
3032      {      {
3033        s->gc = s->face->gc;        s->gc = s->face->gc;
# Line 3079  w32_get_glyph_string_clip_rect (s, r) Line 3078  w32_get_glyph_string_clip_rect (s, r)
3078      {      {
3079        /* Draw full-width.  X coordinates are relative to S->w->left.  */        /* Draw full-width.  X coordinates are relative to S->w->left.  */
3080        int canon_x = CANON_X_UNIT (s->f);        int canon_x = CANON_X_UNIT (s->f);
3081          
3082        r->left = WINDOW_LEFT_MARGIN (s->w) * canon_x;        r->left = WINDOW_LEFT_MARGIN (s->w) * canon_x;
3083        r_width = XFASTINT (s->w->width) * canon_x;        r_width = XFASTINT (s->w->width) * canon_x;
3084    
# Line 3089  w32_get_glyph_string_clip_rect (s, r) Line 3088  w32_get_glyph_string_clip_rect (s, r)
3088            if (FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT (s->f))            if (FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT (s->f))
3089              r->left -= width;              r->left -= width;
3090          }          }
3091          
3092        r->left += FRAME_INTERNAL_BORDER_WIDTH (s->f);        r->left += FRAME_INTERNAL_BORDER_WIDTH (s->f);
3093    
3094        /* Unless displaying a mode or menu bar line, which are always        /* Unless displaying a mode or menu bar line, which are always
# Line 3168  x_compute_glyph_string_overhangs (s) Line 3167  x_compute_glyph_string_overhangs (s)
3167  /* Compute overhangs and x-positions for glyph string S and its  /* Compute overhangs and x-positions for glyph string S and its
3168     predecessors, or successors.  X is the starting x-position for S.     predecessors, or successors.  X is the starting x-position for S.
3169     BACKWARD_P non-zero means process predecessors.  */     BACKWARD_P non-zero means process predecessors.  */
3170      
3171  static void  static void
3172  x_compute_overhangs_and_x (s, x, backward_p)  x_compute_overhangs_and_x (s, x, backward_p)
3173       struct glyph_string *s;       struct glyph_string *s;
# Line 3210  w32_get_glyph_overhangs (hdc, glyph, f, Line 3209  w32_get_glyph_overhangs (hdc, glyph, f,
3209       int *left, *right;       int *left, *right;
3210  {  {
3211    *left = *right = 0;    *left = *right = 0;
3212      
3213    if (glyph->type == CHAR_GLYPH)    if (glyph->type == CHAR_GLYPH)
3214      {      {
3215        XFontStruct *font;        XFontStruct *font;
# Line 3256  x_left_overwritten (s) Line 3255  x_left_overwritten (s)
3255       struct glyph_string *s;       struct glyph_string *s;
3256  {  {
3257    int k;    int k;
3258        
3259    if (s->left_overhang)    if (s->left_overhang)
3260      {      {
3261        int x = 0, i;        int x = 0, i;
# Line 3318  x_right_overwritten (s) Line 3317  x_right_overwritten (s)
3317        struct glyph *glyphs = s->row->glyphs[s->area];        struct glyph *glyphs = s->row->glyphs[s->area];
3318        int first = (s->first_glyph - glyphs) + (s->cmp ? 1 : s->nchars);        int first = (s->first_glyph - glyphs) + (s->cmp ? 1 : s->nchars);
3319        int end = s->row->used[s->area];        int end = s->row->used[s->area];
3320          
3321        for (i = first; i < end && s->right_overhang > x; ++i)        for (i = first; i < end && s->right_overhang > x; ++i)
3322          x += glyphs[i].pixel_width;          x += glyphs[i].pixel_width;
3323    
# Line 3597  w32_alloc_lighter_color (f, color, facto Line 3596  w32_alloc_lighter_color (f, color, facto
3596        double dimness = 1 - (double)bright / HIGHLIGHT_COLOR_DARK_BOOST_LIMIT;        double dimness = 1 - (double)bright / HIGHLIGHT_COLOR_DARK_BOOST_LIMIT;
3597        /* The additive adjustment.  */        /* The additive adjustment.  */
3598        int min_delta = delta * dimness * factor / 2;        int min_delta = delta * dimness * factor / 2;
3599          
3600        if (factor < 1)        if (factor < 1)
3601          new = PALETTERGB (max (0, min (0xff, min_delta - GetRValue (*color))),          new = PALETTERGB (max (0, min (0xff, min_delta - GetRValue (*color))),
3602                            max (0, min (0xff, min_delta - GetGValue (*color))),                            max (0, min (0xff, min_delta - GetGValue (*color))),
# Line 3607  w32_alloc_lighter_color (f, color, facto Line 3606  w32_alloc_lighter_color (f, color, facto
3606                            max (0, min (0xff, min_delta + GetGValue (*color))),                            max (0, min (0xff, min_delta + GetGValue (*color))),
3607                            max (0, min (0xff, min_delta + GetBValue (*color))));                            max (0, min (0xff, min_delta + GetBValue (*color))));
3608      }      }
3609      
3610    if (new == *color)    if (new == *color)
3611      new = PALETTERGB (max (0, min (0xff, delta + GetRValue (*color))),      new = PALETTERGB (max (0, min (0xff, delta + GetRValue (*color))),
3612                        max (0, min (0xff, delta + GetGValue (*color))),                        max (0, min (0xff, delta + GetGValue (*color))),
# Line 3631  w32_alloc_lighter_color (f, color, facto Line 3630  w32_alloc_lighter_color (f, color, facto
3630     DELTA lighter or darker than the relief's background which is found     DELTA lighter or darker than the relief's background which is found
3631     in S->f->output_data.x->relief_background.  If such a color cannot     in S->f->output_data.x->relief_background.  If such a color cannot
3632     be allocated, use DEFAULT_PIXEL, instead.  */     be allocated, use DEFAULT_PIXEL, instead.  */
3633      
3634  static void  static void
3635  w32_setup_relief_color (f, relief, factor, delta, default_pixel)  w32_setup_relief_color (f, relief, factor, delta, default_pixel)
3636       struct frame *f;       struct frame *f;
# Line 3657  w32_setup_relief_color (f, relief, facto Line 3656  w32_setup_relief_color (f, relief, facto
3656        relief->allocated_p = 1;        relief->allocated_p = 1;
3657        xgcv.foreground = relief->pixel = pixel;        xgcv.foreground = relief->pixel = pixel;
3658      }      }
3659      
3660    if (relief->gc == 0)    if (relief->gc == 0)
3661      {      {
3662  #if 0 /* TODO: stipple */  #if 0 /* TODO: stipple */
# Line 3744  w32_draw_relief_rect (f, left_x, top_y, Line 3743  w32_draw_relief_rect (f, left_x, top_y,
3743      gc.foreground = f->output_data.w32->black_relief.gc->foreground;      gc.foreground = f->output_data.w32->black_relief.gc->foreground;
3744    else    else
3745      gc.foreground = f->output_data.w32->white_relief.gc->foreground;      gc.foreground = f->output_data.w32->white_relief.gc->foreground;
3746      
3747    /* Bottom.  */    /* Bottom.  */
3748    for (i = 0; i < width; ++i)    for (i = 0; i < width; ++i)
3749      w32_fill_area (f, hdc, gc.foreground,      w32_fill_area (f, hdc, gc.foreground,
3750                     left_x + i * left_p, bottom_y - i,                     left_x + i * left_p, bottom_y - i,
3751                     right_x - left_x - i * (left_p + right_p) + 1, 1);                     right_x - left_x - i * (left_p + right_p) + 1, 1);
3752    
# Line 3759  w32_draw_relief_rect (f, left_x, top_y, Line 3758  w32_draw_relief_rect (f, left_x, top_y,
3758                       bottom_y - top_y - 2 * i - 1);                       bottom_y - top_y - 2 * i - 1);
3759    
3760    w32_set_clip_rectangle (hdc, NULL);    w32_set_clip_rectangle (hdc, NULL);
3761      
3762    release_frame_dc (f, hdc);    release_frame_dc (f, hdc);
3763  }  }
3764    
# Line 3779  w32_draw_box_rect (s, left_x, top_y, rig Line 3778  w32_draw_box_rect (s, left_x, top_y, rig
3778       RECT *clip_rect;       RECT *clip_rect;
3779  {  {
3780    w32_set_clip_rectangle (s->hdc, clip_rect);    w32_set_clip_rectangle (s->hdc, clip_rect);
3781      
3782    /* Top.  */    /* Top.  */
3783    w32_fill_area (s->f, s->hdc, s->face->box_color,    w32_fill_area (s->f, s->hdc, s->face->box_color,
3784                    left_x, top_y, right_x - left_x + 1, width);                    left_x, top_y, right_x - left_x + 1, width);
# Line 3790  w32_draw_box_rect (s, left_x, top_y, rig Line 3789  w32_draw_box_rect (s, left_x, top_y, rig
3789        w32_fill_area (s->f, s->hdc, s->face->box_color,        w32_fill_area (s->f, s->hdc, s->face->box_color,
3790                       left_x, top_y, width, bottom_y - top_y + 1);                       left_x, top_y, width, bottom_y - top_y + 1);
3791      }      }
3792      
3793    /* Bottom.  */    /* Bottom.  */
3794    w32_fill_area (s->f, s->hdc, s->face->box_color,    w32_fill_area (s->f, s->hdc, s->face->box_color,
3795                   left_x, bottom_y - width + 1, right_x - left_x + 1, width);                   left_x, bottom_y - width + 1, right_x - left_x + 1, width);
3796      
3797    /* Right.  */    /* Right.  */
3798    if (right_p)    if (right_p)
3799      {      {
# Line 3825  x_draw_glyph_string_box (s) Line 3824  x_draw_glyph_string_box (s)
3824        if (FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT (s->f))        if (FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT (s->f))
3825          last_x += FRAME_SCROLL_BAR_WIDTH (s->f) * CANON_X_UNIT (s->f);          last_x += FRAME_SCROLL_BAR_WIDTH (s->f) * CANON_X_UNIT (s->f);
3826      }      }
3827      
3828    /* The glyph that may have a right box line.  */    /* The glyph that may have a right box line.  */
3829    last_glyph = (s->cmp || s->img    last_glyph = (s->cmp || s->img
3830                  ? s->first_glyph                  ? s->first_glyph
# Line 3848  x_draw_glyph_string_box (s) Line 3847  x_draw_glyph_string_box (s)
3847               || (s->hl == DRAW_MOUSE_FACE               || (s->hl == DRAW_MOUSE_FACE
3848                   && (s->next == NULL                   && (s->next == NULL
3849                       || s->next->hl != s->hl)));                       || s->next->hl != s->hl)));
3850      
3851    w32_get_glyph_string_clip_rect (s, &clip_rect);    w32_get_glyph_string_clip_rect (s, &clip_rect);
3852    
3853    if (s->face->box == FACE_SIMPLE_BOX)    if (s->face->box == FACE_SIMPLE_BOX)
# Line 3907  x_draw_image_foreground (s) Line 3906  x_draw_image_foreground (s)
3906            xgcv.clip_y_origin = y;            xgcv.clip_y_origin = y;
3907            xgcv.function = GXcopy;            xgcv.function = GXcopy;
3908            XChangeGC (s->display, s->gc, mask, &xgcv);            XChangeGC (s->display, s->gc, mask, &xgcv);
3909              
3910            w32_get_glyph_string_clip_rect (s, &clip_rect);            w32_get_glyph_string_clip_rect (s, &clip_rect);
3911            image_rect.x = x;            image_rect.x = x;
3912            image_rect.y = y;            image_rect.y = y;
# Line 3977  x_draw_image_relief (s) Line 3976  x_draw_image_relief (s)
3976    RECT r;    RECT r;
3977    int x;    int x;
3978    int y = s->ybase - image_ascent (s->img, s->face);    int y = s->ybase - image_ascent (s->img, s->face);
3979    
3980    /* If first glyph of S has a left box line, start drawing it to the    /* If first glyph of S has a left box line, start drawing it to the
3981       right of that line.  */       right of that line.  */
3982    if (s->face->box != FACE_NO_BOX    if (s->face->box != FACE_NO_BOX
# Line 3985  x_draw_image_relief (s) Line 3984  x_draw_image_relief (s)
3984      x = s->x + abs (s->face->box_line_width);      x = s->x + abs (s->face->box_line_width);
3985    else    else
3986      x = s->x;      x = s->x;
3987      
3988    /* If there is a margin around the image, adjust x- and y-position    /* If there is a margin around the image, adjust x- and y-position
3989       by that margin.  */       by that margin.  */
3990    x += s->img->hmargin;    x += s->img->hmargin;
3991    y += s->img->vmargin;    y += s->img->vmargin;
3992      
3993    if (s->hl == DRAW_IMAGE_SUNKEN    if (s->hl == DRAW_IMAGE_SUNKEN
3994        || s->hl == DRAW_IMAGE_RAISED)        || s->hl == DRAW_IMAGE_RAISED)
3995      {      {
# Line 4002  x_draw_image_relief (s) Line 4001  x_draw_image_relief (s)
4001        thick = abs (s->img->relief);        thick = abs (s->img->relief);
4002        raised_p = s->img->relief > 0;        raised_p = s->img->relief > 0;
4003      }      }
4004      
4005    x0 = x - thick;    x0 = x - thick;
4006    y0 = y - thick;    y0 = y - thick;
4007    x1 = x + s->img->width + thick - 1;    x1 = x + s->img->width + thick - 1;
4008    y1 = y + s->img->height + thick - 1;    y1 = y + s->img->height + thick - 1;
4009      
4010    x_setup_relief_colors (s);    x_setup_relief_colors (s);
4011    w32_get_glyph_string_clip_rect (s, &r);    w32_get_glyph_string_clip_rect (s, &r);
4012    w32_draw_relief_rect (s->f, x0, y0, x1, y1, thick, raised_p, 1, 1, &r);    w32_draw_relief_rect (s->f, x0, y0, x1, y1, thick, raised_p, 1, 1, &r);
# Line 4133  x_draw_glyph_string_bg_rect (s, x, y, w, Line 4132  x_draw_glyph_string_bg_rect (s, x, y, w,
4132  }  }
4133    
4134    
4135  /* Draw image glyph string S.    /* Draw image glyph string S.
4136    
4137              s->y              s->y
4138     s->x      +-------------------------     s->x      +-------------------------
# Line 4176  x_draw_image_glyph_string (s) Line 4175  x_draw_image_glyph_string (s)
4175          x = s->x + box_line_hwidth;          x = s->x + box_line_hwidth;
4176        else        else
4177          x = s->x;          x = s->x;
4178          
4179        y = s->y + box_line_vwidth;        y = s->y + box_line_vwidth;
4180  #if 0 /* TODO: image mask */  #if 0 /* TODO: image mask */
4181        if (s->img->mask)        if (s->img->mask)
# Line 4191  x_draw_image_glyph_string (s) Line 4190  x_draw_image_glyph_string (s)
4190            pixmap = XCreatePixmap (s->display, s->window,            pixmap = XCreatePixmap (s->display, s->window,
4191                                    s->background_width,                                    s->background_width,
4192                                    s->height, depth);                                    s->height, depth);
4193              
4194            /* Don't clip in the following because we're working on the            /* Don't clip in the following because we're working on the
4195               pixmap.  */               pixmap.  */
4196            XSetClipMask (s->display, s->gc, None);            XSetClipMask (s->display, s->gc, None);
# Line 4219  x_draw_image_glyph_string (s) Line 4218  x_draw_image_glyph_string (s)
4218        else        else
4219  #endif  #endif
4220          x_draw_glyph_string_bg_rect (s, x, y, s->background_width, height);          x_draw_glyph_string_bg_rect (s, x, y, s->background_width, height);
4221          
4222        s->background_filled_p = 1;        s->background_filled_p = 1;
4223      }      }
4224    
# Line 4300  x_draw_stretch_glyph_string (s) Line 4299  x_draw_stretch_glyph_string (s)
4299              }              }
4300            else            else
4301              gc = s->face->gc;              gc = s->face->gc;
4302      
4303            w32_get_glyph_string_clip_rect (s, &r);            w32_get_glyph_string_clip_rect (s, &r);
4304            w32_set_clip_rectangle (hdc, &r);            w32_set_clip_rectangle (hdc, &r);
4305    
# Line 4322  x_draw_stretch_glyph_string (s) Line 4321  x_draw_stretch_glyph_string (s)
4321    else if (!s->background_filled_p)    else if (!s->background_filled_p)
4322      x_draw_glyph_string_bg_rect (s, s->x, s->y, s->background_width,      x_draw_glyph_string_bg_rect (s, s->x, s->y, s->background_width,
4323                                   s->height);                                   s->height);
4324      
4325    s->background_filled_p = 1;    s->background_filled_p = 1;
4326  }  }
4327    
# Line 4470  static int x_fill_composite_glyph_string Line 4469  static int x_fill_composite_glyph_string
4469    
4470    
4471  /* Fill glyph string S with composition components specified by S->cmp.  /* Fill glyph string S with composition components specified by S->cmp.
4472      
4473     FACES is an array of faces for all components of this composition.     FACES is an array of faces for all components of this composition.
4474     S->gidx is the index of the first component for S.     S->gidx is the index of the first component for S.
4475     OVERLAPS_P non-zero means S should draw the foreground only, and     OVERLAPS_P non-zero means S should draw the foreground only, and
# Line 4518  x_fill_composite_glyph_string (s, faces, Line 4517  x_fill_composite_glyph_string (s, faces,
4517    
4518    /* Adjust base line for subscript/superscript text.  */    /* Adjust base line for subscript/superscript text.  */
4519    s->ybase += s->first_glyph->voffset;    s->ybase += s->first_glyph->voffset;
4520      
4521    xassert (s->face && s->face->gc);    xassert (s->face && s->face->gc);
4522    
4523    /* This glyph string must always be drawn with 16-bit functions.  */    /* This glyph string must always be drawn with 16-bit functions.  */
# Line 4529  x_fill_composite_glyph_string (s, faces, Line 4528  x_fill_composite_glyph_string (s, faces,
4528    
4529    
4530  /* Fill glyph string S from a sequence of character glyphs.  /* Fill glyph string S from a sequence of character glyphs.
4531      
4532     FACE_ID is the face id of the string.  START is the index of the     FACE_ID is the face id of the string.  START is the index of the
4533     first glyph to consider, END is the index of the last + 1.     first glyph to consider, END is the index of the last + 1.
4534     OVERLAPS_P non-zero means S should draw the foreground only, and     OVERLAPS_P non-zero means S should draw the foreground only, and
# Line 4579  x_fill_glyph_string (s, face_id, start, Line 4578  x_fill_glyph_string (s, face_id, start,
4578    
4579    s->font = s->face->font;    s->font = s->face->font;
4580    s->font_info = FONT_INFO_FROM_ID (s->f, s->face->font_info_id);    s->font_info = FONT_INFO_FROM_ID (s->f, s->face->font_info_id);
4581      
4582    /* If the specified font could not be loaded, use the frame's font,    /* If the specified font could not be loaded, use the frame's font,
4583       but record the fact that we couldn't load it in       but record the fact that we couldn't load it in
4584       S->font_not_found_p so that we can draw rectangles for the       S->font_not_found_p so that we can draw rectangles for the
# Line 4592  x_fill_glyph_string (s, face_id, start, Line 4591  x_fill_glyph_string (s, face_id, start,
4591    
4592    /* Adjust base line for subscript/superscript text.  */    /* Adjust base line for subscript/superscript text.  */
4593    s->ybase += voffset;    s->ybase += voffset;
4594      
4595    xassert (s->face && s->face->gc);    xassert (s->face && s->face->gc);
4596    return glyph - s->row->glyphs[s->area];    return glyph - s->row->glyphs[s->area];
4597  }  }
# Line 4610  x_fill_image_glyph_string (s) Line 4609  x_fill_image_glyph_string (s)
4609    s->face = FACE_FROM_ID (s->f, s->first_glyph->face_id);    s->face = FACE_FROM_ID (s->f, s->first_glyph->face_id);
4610    s->font = s->face->font;    s->font = s->face->font;
4611    s->width = s->first_glyph->pixel_width;    s->width = s->first_glyph->pixel_width;
4612      
4613    /* Adjust base line for subscript/superscript text.  */    /* Adjust base line for subscript/superscript text.  */
4614    s->ybase += s->first_glyph->voffset;    s->ybase += s->first_glyph->voffset;
4615  }  }
# Line 4633  x_fill_stretch_glyph_string (s, row, are Line 4632  x_fill_stretch_glyph_string (s, row, are
4632  {  {
4633    struct glyph *glyph, *last;    struct glyph *glyph, *last;
4634    int voffset, face_id;    int voffset, face_id;
4635      
4636    xassert (s->first_glyph->type == STRETCH_GLYPH);    xassert (s->first_glyph->type == STRETCH_GLYPH);
4637      
4638    glyph = s->row->glyphs[s->area] + start;    glyph = s->row->glyphs[s->area] + start;
4639    last = s->row->glyphs[s->area] + end;    last = s->row->glyphs[s->area] + end;
4640    face_id = glyph->face_id;    face_id = glyph->face_id;
# Line 4652  x_fill_stretch_glyph_string (s, row, are Line 4651  x_fill_stretch_glyph_string (s, row, are
4651          && glyph->face_id == face_id);          && glyph->face_id == face_id);
4652         ++glyph)         ++glyph)
4653      s->width += glyph->pixel_width;      s->width += glyph->pixel_width;
4654      
4655    /* Adjust base line for subscript/superscript text.  */    /* Adjust base line for subscript/superscript text.  */
4656    s->ybase += voffset;    s->ybase += voffset;
4657    
# Line 4668  x_fill_stretch_glyph_string (s, row, are Line 4667  x_fill_stretch_glyph_string (s, row, are
4667     and area within the row from which S is constructed.  START is the     and area within the row from which S is constructed.  START is the
4668     index of the first glyph structure covered by S.  HL is a     index of the first glyph structure covered by S.  HL is a
4669     face-override for drawing S.  */     face-override for drawing S.  */
4670      
4671  static void  static void
4672  w32_init_glyph_string (s, hdc, char2b, w, row, area, start, hl)  w32_init_glyph_string (s, hdc, char2b, w, row, area, start, hl)
4673       struct glyph_string *s;       struct glyph_string *s;
# Line 4696  w32_init_glyph_string (s, hdc, char2b, w Line 4695  w32_init_glyph_string (s, hdc, char2b, w
4695    /* Display the internal border below the tool-bar window.  */    /* Display the internal border below the tool-bar window.  */
4696    if (s->w == XWINDOW (s->f->tool_bar_window))    if (s->w == XWINDOW (s->f->tool_bar_window))
4697      s->y -= s->f->output_data.w32->internal_border_width;      s->y -= s->f->output_data.w32->internal_border_width;
4698      
4699    s->ybase = s->y + row->ascent;    s->ybase = s->y + row->ascent;
4700  }  }
4701    
# Line 4714  x_set_glyph_string_background_width (s, Line 4713  x_set_glyph_string_background_width (s,
4713    /* If the face of this glyph string has to be drawn to the end of    /* If the face of this glyph string has to be drawn to the end of
4714       the drawing area, set S->extends_to_end_of_line_p.  */       the drawing area, set S->extends_to_end_of_line_p.  */
4715    struct face *default_face = FACE_FROM_ID (s->f, DEFAULT_FACE_ID);    struct face *default_face = FACE_FROM_ID (s->f, DEFAULT_FACE_ID);
4716      
4717    if (start == s->row->used[s->area]    if (start == s->row->used[s->area]
4718        && s->area == TEXT_AREA        && s->area == TEXT_AREA
4719        && ((s->hl == DRAW_NORMAL_TEXT        && ((s->hl == DRAW_NORMAL_TEXT
# Line 4726  x_set_glyph_string_background_width (s, Line 4725  x_set_glyph_string_background_width (s,
4725            || ((s->hl == DRAW_IMAGE_RAISED || s->hl == DRAW_IMAGE_SUNKEN)            || ((s->hl == DRAW_IMAGE_RAISED || s->hl == DRAW_IMAGE_SUNKEN)
4726                && s->row->fill_line_p)))                && s->row->fill_line_p)))
4727      s->extends_to_end_of_line_p = 1;      s->extends_to_end_of_line_p = 1;
4728      
4729    /* If S extends its face to the end of the line, set its    /* If S extends its face to the end of the line, set its
4730       background_width to the distance to the right edge of the drawing       background_width to the distance to the right edge of the drawing
4731       area.  */       area.  */
# Line 4805  x_set_glyph_string_background_width (s, Line 4804  x_set_glyph_string_background_width (s,
4804                                            OVERLAPS_P);                     \                                            OVERLAPS_P);                     \
4805         }                                                                   \         }                                                                   \
4806       while (0)       while (0)
4807        
4808    
4809  /* Add a glyph string for a composite sequence to the list of strings  /* Add a glyph string for a composite sequence to the list of strings
4810     between HEAD and TAIL.  START is the index of the first glyph in     between HEAD and TAIL.  START is the index of the first glyph in
# Line 4930  x_set_glyph_string_background_width (s, Line 4929  x_set_glyph_string_background_width (s,
4929     and clip to the physical height of ROW.     and clip to the physical height of ROW.
4930    
4931     Value is the x-position reached, relative to AREA of W.  */     Value is the x-position reached, relative to AREA of W.  */
4932        
4933  static int  static int
4934  x_draw_glyphs (w, x, row, area, start, end, hl, overlaps_p)  x_draw_glyphs (w, x, row, area, start, end, hl, overlaps_p)
4935       struct window *w;       struct window *w;
# Line 5012  x_draw_glyphs (w, x, row, area, start, e Line 5011  x_draw_glyphs (w, x, row, area, start, e
5011        /* Prepend glyph strings for glyphs in front of the first glyph        /* Prepend glyph strings for glyphs in front of the first glyph
5012           string that are overwritten because of the first glyph           string that are overwritten because of the first glyph
5013           string's left overhang.  The background of all strings           string's left overhang.  The background of all strings
5014           prepended must be drawn because the first glyph string           prepended must be drawn because the first glyph string
5015           draws over it.  */           draws over it.  */
5016        i = x_left_overwritten (head);        i = x_left_overwritten (head);
5017        if (i >= 0)        if (i >= 0)
# Line 5090  x_draw_glyphs (w, x, row, area, start, e Line 5089  x_draw_glyphs (w, x, row, area, start, e
5089      {      {
5090        int x0 = head ? head->x : x;        int x0 = head ? head->x : x;
5091        int x1 = tail ? tail->x + tail->background_width : x;        int x1 = tail ? tail->x + tail->background_width : x;
5092          
5093        x0 = FRAME_TO_WINDOW_PIXEL_X (w, x0);        x0 = FRAME_TO_WINDOW_PIXEL_X (w, x0);
5094        x1 = FRAME_TO_WINDOW_PIXEL_X (w, x1);        x1 = FRAME_TO_WINDOW_PIXEL_X (w, x1);
5095          
5096        if (!row->full_width_p && XFASTINT (w->left_margin_width) != 0)        if (!row->full_width_p && XFASTINT (w->left_margin_width) != 0)
5097          {          {
5098            int left_area_width = window_box_width (w, LEFT_MARGIN_AREA);            int left_area_width = window_box_width (w, LEFT_MARGIN_AREA);
# Line 5131  x_fix_overlapping_area (w, row, area) Line 5130  x_fix_overlapping_area (w, row, area)
5130       enum glyph_row_area area;       enum glyph_row_area area;
5131  {  {
5132    int i, x;    int i, x;
5133      
5134    BLOCK_INPUT;    BLOCK_INPUT;
5135      
5136    if (area == LEFT_MARGIN_AREA)    if (area == LEFT_MARGIN_AREA)
5137      x = 0;      x = 0;
5138    else if (area == TEXT_AREA)    else if (area == TEXT_AREA)
# Line 5165  x_fix_overlapping_area (w, row, area) Line 5164  x_fix_overlapping_area (w, row, area)
5164            ++i;            ++i;
5165          }          }
5166      }      }
5167      
5168    UNBLOCK_INPUT;    UNBLOCK_INPUT;
5169  }  }
5170    
# Line 5185  x_write_glyphs (start, len) Line 5184  x_write_glyphs (start, len)
5184    
5185    xassert (updated_window && updated_row);    xassert (updated_window && updated_row);
5186    BLOCK_INPUT;    BLOCK_INPUT;
5187      
5188    /* Write glyphs.  */    /* Write glyphs.  */
5189    
5190    hpos = start - updated_row->glyphs[updated_area];    hpos = start - updated_row->glyphs[updated_area];
# Line 5195  x_write_glyphs (start, len) Line 5194  x_write_glyphs (start, len)
5194                       DRAW_NORMAL_TEXT, 0);                       DRAW_NORMAL_TEXT, 0);
5195    
5196    UNBLOCK_INPUT;    UNBLOCK_INPUT;
5197      
5198    /* Advance the output cursor.  */    /* Advance the output cursor.  */
5199    output_cursor.hpos += len;    output_cursor.hpos += len;
5200    output_cursor.x = x;    output_cursor.x = x;
# Line 5294  x_clear_end_of_line (to_x) Line 5293  x_clear_end_of_line (to_x)
5293    struct window *w = updated_window;    struct window *w = updated_window;
5294    int max_x, min_y, max_y;    int max_x, min_y, max_y;
5295    int from_x, from_y, to_y;    int from_x, from_y, to_y;
5296      
5297    xassert (updated_window && updated_row);    xassert (updated_window && updated_row);
5298    f = XFRAME (w->frame);    f = XFRAME (w->frame);
5299      
5300    if (updated_row->full_width_p)    if (updated_row->full_width_p)
5301      {      {
5302        max_x = XFASTINT (w->width) * CANON_X_UNIT (f);        max_x = XFASTINT (w->width) * CANON_X_UNIT (f);
# Line 5319  x_clear_end_of_line (to_x) Line 5318  x_clear_end_of_line (to_x)
5318      to_x = min (to_x, max_x);      to_x = min (to_x, max_x);
5319    
5320    to_y = min (max_y, output_cursor.y + updated_row->height);    to_y = min (max_y, output_cursor.y + updated_row->height);
5321      
5322    /* Notice if the cursor will be cleared by this operation.  */    /* Notice if the cursor will be cleared by this operation.  */
5323    if (!updated_row->full_width_p)    if (!updated_row->full_width_p)
5324      notice_overwritten_cursor (w, updated_area,      notice_overwritten_cursor (w, updated_area,
# Line 5340  x_clear_end_of_line (to_x) Line 5339  x_clear_end_of_line (to_x)
5339        from_x = WINDOW_AREA_TO_FRAME_PIXEL_X (w, updated_area, from_x);        from_x = WINDOW_AREA_TO_FRAME_PIXEL_X (w, updated_area, from_x);
5340        to_x = WINDOW_AREA_TO_FRAME_PIXEL_X (w, updated_area, to_x);        to_x = WINDOW_AREA_TO_FRAME_PIXEL_X (w, updated_area, to_x);
5341      }      }
5342      
5343    min_y = WINDOW_DISPLAY_HEADER_LINE_HEIGHT (w);    min_y = WINDOW_DISPLAY_HEADER_LINE_HEIGHT (w);
5344    from_y = WINDOW_TO_FRAME_PIXEL_Y (w, max (min_y, output_cursor.y));    from_y = WINDOW_TO_FRAME_PIXEL_Y (w, max (min_y, output_cursor.y));
5345    to_y = WINDOW_TO_FRAME_PIXEL_Y (w, to_y);    to_y = WINDOW_TO_FRAME_PIXEL_Y (w, to_y);
5346      
5347    /* Prevent inadvertently clearing to end of the X window.  */    /* Prevent inadvertently clearing to end of the X window.  */
5348    if (to_x > from_x && to_y > from_y)    if (to_x > from_x && to_y > from_y)
5349      {      {
# Line 5411  w32_ring_bell (void) Line 5410  w32_ring_bell (void)
5410        int i;        int i;
5411        HWND hwnd = FRAME_W32_WINDOW (SELECTED_FRAME ());        HWND hwnd = FRAME_W32_WINDOW (SELECTED_FRAME ());
5412    
5413        for (i = 0; i < 5; i++)        for (i = 0; i < 5; i++)
5414          {          {
5415            FlashWindow (hwnd, TRUE);            FlashWindow (hwnd, TRUE);
5416            Sleep (10);            Sleep (10);
# Line 5509  x_scroll_run (w, run) Line 5508  x_scroll_run (w, run)
5508      }      }
5509    
5510    BLOCK_INPUT;    BLOCK_INPUT;
5511      
5512    /* Cursor off.  Will be switched on again in x_update_window_end.  */    /* Cursor off.  Will be switched on again in x_update_window_end.  */
5513    updated_window = w;    updated_window = w;
5514    x_clear_cursor (w);    x_clear_cursor (w);
# Line 5547  x_scroll_run (w, run) Line 5546  x_scroll_run (w, run)
5546  /***********************************************************************  /***********************************************************************
5547                             Exposure Events                             Exposure Events
5548   ***********************************************************************/   ***********************************************************************/
5549                                                                            
5550  /* Redisplay an exposed area of frame F.  X and Y are the upper-left  /* Redisplay an exposed area of frame F.  X and Y are the upper-left
5551     corner of the exposed rectangle.  W and H are width and height of     corner of the exposed rectangle.  W and H are width and height of
5552     the exposed area.  All are pixel values.  W or H zero means redraw     the exposed area.  All are pixel values.  W or H zero means redraw
# Line 5698  expose_area (w, row, r, area) Line 5697  expose_area (w, row, r, area)
5697            x += first->pixel_width;            x += first->pixel_width;
5698            ++first;            ++first;
5699          }          }
5700      
5701        /* Find the last one.  */        /* Find the last one.  */
5702        last = first;        last = first;
5703        first_x = x;        first_x = x;
# Line 5730  expose_line (w, row, r) Line 5729  expose_line (w, row, r)
5729       RECT *r;       RECT *r;
5730  {  {
5731    xassert (row->enabled_p);    xassert (row->enabled_p);
5732      
5733    if (row->mode_line_p || w->pseudo_window_p)    if (row->mode_line_p || w->pseudo_window_p)
5734      x_draw_glyphs (w, 0, row, TEXT_AREA, 0, row->used[TEXT_AREA],      x_draw_glyphs (w, 0, row, TEXT_AREA, 0, row->used[TEXT_AREA],
5735                     DRAW_NORMAL_TEXT, 0);                     DRAW_NORMAL_TEXT, 0);
# Line 5788  expose_overlaps (w, first_overlapping_ro Line 5787  expose_overlaps (w, first_overlapping_ro
5787       struct glyph_row *last_overlapping_row;       struct glyph_row *last_overlapping_row;
5788  {  {
5789    struct glyph_row *row;    struct glyph_row *row;
5790      
5791    for (row = first_overlapping_row; row <= last_overlapping_row; ++row)    for (row = first_overlapping_row; row <= last_overlapping_row; ++row)
5792      if (row->overlapping_p)      if (row->overlapping_p)
5793        {        {
5794          xassert (row->enabled_p && !row->mode_line_p);          xassert (row->enabled_p && !row->mode_line_p);
5795              
5796          if (row->used[LEFT_MARGIN_AREA])          if (row->used[LEFT_MARGIN_AREA])
5797            x_fix_overlapping_area (w, row, LEFT_MARGIN_AREA);            x_fix_overlapping_area (w, row, LEFT_MARGIN_AREA);
5798      
5799          if (row->used[TEXT_AREA])          if (row->used[TEXT_AREA])
5800            x_fix_overlapping_area (w, row, TEXT_AREA);            x_fix_overlapping_area (w, row, TEXT_AREA);
5801      
5802          if (row->used[RIGHT_MARGIN_AREA])          if (row->used[RIGHT_MARGIN_AREA])
5803            x_fix_overlapping_area (w, row, RIGHT_MARGIN_AREA);            x_fix_overlapping_area (w, row, RIGHT_MARGIN_AREA);
5804        }        }
# Line 5888  expose_window (w, fr) Line 5887  expose_window (w, fr)
5887                      first_overlapping_row = row;                      first_overlapping_row = row;
5888                    last_overlapping_row = row;                    last_overlapping_row = row;
5889                  }                  }
5890                  
5891                if (expose_line (w, row, &r))                if (expose_line (w, row, &r))
5892                  mouse_face_overwritten_p = 1;                  mouse_face_overwritten_p = 1;
5893              }              }
# Line 5912  expose_window (w, fr) Line 5911  expose_window (w, fr)
5911            /* Fix the display of overlapping rows.  */            /* Fix the display of overlapping rows.  */
5912            if (first_overlapping_row)            if (first_overlapping_row)
5913              expose_overlaps (w, first_overlapping_row, last_overlapping_row);              expose_overlaps (w, first_overlapping_row, last_overlapping_row);
5914              
5915            /* Draw border between windows.  */            /* Draw border between windows.  */
5916            x_draw_vertical_border (w);            x_draw_vertical_border (w);
5917    
# Line 6152  glyph_to_pixel_coords (w, hpos, vpos, fr Line 6151  glyph_to_pixel_coords (w, hpos, vpos, fr
6151  /* Parse a button MESSAGE. The button index is returned in PBUTTON, and  /* Parse a button MESSAGE. The button index is returned in PBUTTON, and
6152     the state in PUP. XBUTTON provides extra information for extended mouse     the state in PUP. XBUTTON provides extra information for extended mouse
6153     button messages. Returns FALSE if unable to parse the message.  */     button messages. Returns FALSE if unable to parse the message.  */
6154  BOOL  BOOL
6155  parse_button (message, xbutton, pbutton, pup)  parse_button (message, xbutton, pbutton, pup)
6156       int message;       int message;
6157       int xbutton;       int xbutton;
# Line 6161  parse_button (message, xbutton, pbutton, Line 6160  parse_button (message, xbutton, pbutton,
6160  {  {
6161    int button = 0;    int button = 0;
6162    int up = 0;    int up = 0;
6163      
6164    switch (message)    switch (message)
6165      {      {
6166      case WM_LBUTTONDOWN:      case WM_LBUTTONDOWN:
# Line 6211  parse_button (message, xbutton, pbutton, Line 6210  parse_button (message, xbutton, pbutton,
6210      default:      default:
6211        return (FALSE);        return (FALSE);
6212      }      }
6213      
6214    if (pup) *pup = up;    if (pup) *pup = up;
6215    if (pbutton) *pbutton = button;    if (pbutton) *pbutton = button;
6216      
6217    return (TRUE);    return (TRUE);
6218  }  }
6219    
# Line 6477  x_y_to_hpos_vpos (w, x, y, hpos, vpos, a Line 6476  x_y_to_hpos_vpos (w, x, y, hpos, vpos, a
6476            else if (!buffer_only_p || BUFFERP (glyph->object))            else if (!buffer_only_p || BUFFERP (glyph->object))
6477              break;              break;
6478          }          }
6479          
6480        x0 += glyph->pixel_width;        x0 += glyph->pixel_width;
6481        ++glyph;        ++glyph;
6482      }      }
# Line 6540  note_mode_line_highlight (w, x, mode_lin Line 6539  note_mode_line_highlight (w, x, mode_lin
6539        struct glyph *glyph, *end;        struct glyph *glyph, *end;
6540        Lisp_Object help, map;        Lisp_Object help, map;
6541        int x0;        int x0;
6542          
6543        /* Find the glyph under X.  */        /* Find the glyph under X.  */
6544        glyph = row->glyphs[TEXT_AREA];        glyph = row->glyphs[TEXT_AREA];
6545        end = glyph + row->used[TEXT_AREA];        end = glyph + row->used[TEXT_AREA];
6546        x0 = - (FRAME_LEFT_SCROLL_BAR_WIDTH (f) * CANON_X_UNIT (f)        x0 = - (FRAME_LEFT_SCROLL_BAR_WIDTH (f) * CANON_X_UNIT (f)
6547                + FRAME_X_LEFT_FRINGE_WIDTH (f));                + FRAME_X_LEFT_FRINGE_WIDTH (f));
6548          
6549        while (glyph < end        while (glyph < end
6550               && x >= x0 + glyph->pixel_width)               && x >= x0 + glyph->pixel_width)
6551          {          {
# Line 6904  note_mouse_highlight (f, x, y) Line 6903  note_mouse_highlight (f, x, y)
6903                   the text ``under'' it might have.  */                   the text ``under'' it might have.  */
6904                struct glyph_row *r = MATRIX_ROW (w->current_matrix, vpos);                struct glyph_row *r = MATRIX_ROW (w->current_matrix, vpos);
6905                int start = MATRIX_ROW_START_CHARPOS (r);                int start = MATRIX_ROW_START_CHARPOS (r);
6906                  
6907                pos = string_buffer_position (w, object, start);                pos = string_buffer_position (w, object, start);
6908                if (pos > 0)                if (pos > 0)
6909                  mouse_face = get_char_property_and_overlay (make_number (pos),                  mouse_face = get_char_property_and_overlay (make_number (pos),
# Line 6928  note_mouse_highlight (f, x, y) Line 6927  note_mouse_highlight (f, x, y)
6927                                        &dpyinfo->mouse_face_beg_x,                                        &dpyinfo->mouse_face_beg_x,
6928                                        &dpyinfo->mouse_face_beg_y,                                        &dpyinfo->mouse_face_beg_y,
6929                                        object);                                        object);
6930                          
6931                    dpyinfo->mouse_face_past_end                    dpyinfo->mouse_face_past_end
6932                      = !fast_find_position (w, XFASTINT (after),                      = !fast_find_position (w, XFASTINT (after),
6933                                             &dpyinfo->mouse_face_end_col,                                             &dpyinfo->mouse_face_end_col,
# Line 6960  note_mouse_highlight (f, x, y) Line 6959  note_mouse_highlight (f, x, y)
6959          for (i = noverlays - 1; i >= 0 && NILP (help); --i)          for (i = noverlays - 1; i >= 0 && NILP (help); --i)
6960            {            {
6961              overlay = overlay_vec[i];              overlay = overlay_vec[i];
6962              help = Foverlay_get (overlay, Qhelp_echo);              help = Foverlay_get (overlay, Qhelp_echo);
6963            }            }
6964    
6965          if (!NILP (help))          if (!NILP (help))
# Line 7007  note_mouse_highlight (f, x, y) Line 7006  note_mouse_highlight (f, x, y)
7006                       && charpos < ZV)                       && charpos < ZV)
7007                help = Fget_text_property (make_number (charpos), Qhelp_echo,                help = Fget_text_property (make_number (charpos), Qhelp_echo,
7008                                           object);                                           object);
7009                
7010              if (!NILP (help))              if (!NILP (help))
7011                {                {
7012                  help_echo = help;                  help_echo = help;
# Line 7094  x_tool_bar_item (f, x, y, glyph, hpos, v Line 7093  x_tool_bar_item (f, x, y, glyph, hpos, v
7093            || *hpos < dpyinfo->mouse_face_end_col            || *hpos < dpyinfo->mouse_face_end_col
7094            || dpyinfo->mouse_face_past_end))            || dpyinfo->mouse_face_past_end))
7095      return 0;      return 0;
7096      
7097    return 1;    return 1;
7098  }  }
7099    
# Line 7115  w32_handle_tool_bar_click (f, button_eve Line 7114  w32_handle_tool_bar_click (f, button_eve
7114    Lisp_Object enabled_p;    Lisp_Object enabled_p;
7115    int x = XFASTINT (button_event->x);    int x = XFASTINT (button_event->x);
7116    int y = XFASTINT (button_event->y);    int y = XFASTINT (button_event->y);
7117      
7118    /* If not on the highlighted tool-bar item, return.  */    /* If not on the highlighted tool-bar item, return.  */
7119    frame_to_window_pixel_xy (w, &x, &y);    frame_to_window_pixel_xy (w, &x, &y);
7120    if (x_tool_bar_item (f, x, y, &glyph, &hpos, &vpos, &prop_idx) != 0)    if (x_tool_bar_item (f, x, y, &glyph, &hpos, &vpos, &prop_idx) != 0)
# Line 7125  w32_handle_tool_bar_click (f, button_eve Line 7124  w32_handle_tool_bar_click (f, button_eve
7124    enabled_p = AREF (f->tool_bar_items, prop_idx + TOOL_BAR_ITEM_ENABLED_P);    enabled_p = AREF (f->tool_bar_items, prop_idx + TOOL_BAR_ITEM_ENABLED_P);
7125    if (NILP (enabled_p))    if (NILP (enabled_p))
7126      return;      return;
7127      
7128    if (button_event->modifiers & down_modifier)    if (button_event->modifiers & down_modifier)
7129      {      {
7130        /* Show item in pressed state.  */        /* Show item in pressed state.  */
# Line 7202  note_tool_bar_highlight (f, x, y) Line 7201  note_tool_bar_highlight (f, x, y)
7201      goto set_help_echo;      goto set_help_echo;
7202    
7203    clear_mouse_face (dpyinfo);    clear_mouse_face (dpyinfo);
7204      
7205    /* Mouse is down, but on different tool-bar item?  */    /* Mouse is down, but on different tool-bar item?  */
7206    mouse_down_p = (dpyinfo->grabbed    mouse_down_p = (dpyinfo->grabbed
7207                    && f == last_mouse_frame                    && f == last_mouse_frame
# Line 7213  note_tool_bar_highlight (f, x, y) Line 7212  note_tool_bar_highlight (f, x, y)
7212    
7213    dpyinfo->mouse_face_image_state = DRAW_NORMAL_TEXT;    dpyinfo->mouse_face_image_state = DRAW_NORMAL_TEXT;
7214    draw = mouse_down_p ? DRAW_IMAGE_SUNKEN : DRAW_IMAGE_RAISED;    draw = mouse_down_p ? DRAW_IMAGE_SUNKEN : DRAW_IMAGE_RAISED;
7215      
7216    /* If tool-bar item is not enabled, don't highlight it.  */    /* If tool-bar item is not enabled, don't highlight it.  */
7217    enabled_p = AREF (f->tool_bar_items, prop_idx + TOOL_BAR_ITEM_ENABLED_P);    enabled_p = AREF (f->tool_bar_items, prop_idx + TOOL_BAR_ITEM_ENABLED_P);
7218    if (!NILP (enabled_p))    if (!NILP (enabled_p))
# Line 7223  note_tool_bar_highlight (f, x, y) Line 7222  note_tool_bar_highlight (f, x, y)
7222        row = MATRIX_ROW (w->current_matrix, vpos);        row = MATRIX_ROW (w->current_matrix, vpos);
7223        for (i = x = 0; i < hpos; ++i)        for (i = x = 0; i < hpos; ++i)
7224          x += row->glyphs[TEXT_AREA][i].pixel_width;          x += row->glyphs[TEXT_AREA][i].pixel_width;
7225          
7226        /* Record this as the current active region.  */        /* Record this as the current active region.  */
7227        dpyinfo->mouse_face_beg_col = hpos;        dpyinfo->mouse_face_beg_col = hpos;
7228        dpyinfo->mouse_face_beg_row = vpos;        dpyinfo->mouse_face_beg_row = vpos;
7229        dpyinfo->mouse_face_beg_x = x;        dpyinfo->mouse_face_beg_x = x;
7230        dpyinfo->mouse_face_beg_y = row->y;        dpyinfo->mouse_face_beg_y = row->y;
7231        dpyinfo->mouse_face_past_end = 0;        dpyinfo->mouse_face_past_end = 0;
7232          
7233        dpyinfo->mouse_face_end_col = hpos + 1;        dpyinfo->mouse_face_end_col = hpos + 1;
7234        dpyinfo->mouse_face_end_row = vpos;        dpyinfo->mouse_face_end_row = vpos;
7235        dpyinfo->mouse_face_end_x = x + glyph->pixel_width;        dpyinfo->mouse_face_end_x = x + glyph->pixel_width;
7236        dpyinfo->mouse_face_end_y = row->y;        dpyinfo->mouse_face_end_y = row->y;
7237        dpyinfo->mouse_face_window = window;        dpyinfo->mouse_face_window = window;
7238        dpyinfo->mouse_face_face_id = TOOL_BAR_FACE_ID;        dpyinfo->mouse_face_face_id = TOOL_BAR_FACE_ID;
7239          
7240        /* Display it as active.  */        /* Display it as active.  */
7241        show_mouse_face (dpyinfo, draw);        show_mouse_face (dpyinfo, draw);
7242        dpyinfo->mouse_face_image_state = draw;        dpyinfo->mouse_face_image_state = draw;
7243      }      }
7244          
7245   set_help_echo:   set_help_echo:
7246      
7247    /* Set help_echo to a help string.to display for this tool-bar item.    /* Set help_echo to a help string.to display for this tool-bar item.
7248       w32_read_socket does the rest.  */       w32_read_socket does the rest.  */
7249    help_echo_object = help_echo_window = Qnil;    help_echo_object = help_echo_window = Qnil;
# Line 7266  note_tool_bar_highlight (f, x, y) Line 7265  note_tool_bar_highlight (f, x, y)
7265  #if 0 /* This is a version of fast_find_position that's more correct  #if 0 /* This is a version of fast_find_position that's more correct
7266           in the presence of hscrolling, for example.  I didn't install           in the presence of hscrolling, for example.  I didn't install
7267           it right away because the problem fixed is minor, it failed           it right away because the problem fixed is minor, it failed
7268           in 20.x as well, and I think it's too risky to install           in 20.x as well, and I think it's too risky to install
7269           so near the release of 21.1.  2001-09-25 gerd.  */           so near the release of 21.1.  2001-09-25 gerd.  */
7270    
7271  static int  static int
# Line 7299  fast_find_position (w, charpos, hpos, vp Line 7298  fast_find_position (w, charpos, hpos, vp
7298    *x = row->x;    *x = row->x;
7299    *y = row->y;    *y = row->y;
7300    *vpos = MATRIX_ROW_VPOS (row, w->current_matrix);    *vpos = MATRIX_ROW_VPOS (row, w->current_matrix);
7301      
7302    glyph = row->glyphs[TEXT_AREA];    glyph = row->glyphs[TEXT_AREA];
7303    end = glyph + row->used[TEXT_AREA];    end = glyph + row->used[TEXT_AREA];
7304      
7305    /* Skip over glyphs not having an object at the start of the row.    /* Skip over glyphs not having an object at the start of the row.
7306       These are special glyphs like truncation marks on terminal       These are special glyphs like truncation marks on terminal
7307       frames.  */       frames.  */
# Line 7504  fast_find_string_pos (w, pos, object, hp Line 7503  fast_find_string_pos (w, pos, object, hp
7503            *x += best_glyph->pixel_width;            *x += best_glyph->pixel_width;
7504            ++*hpos;            ++*hpos;
7505          }          }
7506          
7507        *y = best_row->y;        *y = best_row->y;
7508        *vpos = best_row - w->current_matrix->rows;        *vpos = best_row - w->current_matrix->rows;
7509      }      }
# Line 7523  show_mouse_face (dpyinfo, draw) Line 7522  show_mouse_face (dpyinfo, draw)
7522  {  {
7523    struct window *w = XWINDOW (dpyinfo->mouse_face_window);    struct window *w = XWINDOW (dpyinfo->mouse_face_window);
7524    struct frame *f = XFRAME (WINDOW_FRAME (w));    struct frame *f = XFRAME (WINDOW_FRAME (w));
7525      
7526    if (/* If window is in the process of being destroyed, don't bother    if (/* If window is in the process of being destroyed, don't bother
7527           to do anything.  */           to do anything.  */
7528        w->current_matrix != NULL        w->current_matrix != NULL
# Line 7538  show_mouse_face (dpyinfo, draw) Line 7537  show_mouse_face (dpyinfo, draw)
7537    
7538        first = MATRIX_ROW (w->current_matrix, dpyinfo->mouse_face_beg_row);        first = MATRIX_ROW (w->current_matrix, dpyinfo->mouse_face_beg_row);
7539        last = MATRIX_ROW (w->current_matrix, dpyinfo->mouse_face_end_row);        last = MATRIX_ROW (w->current_matrix, dpyinfo->mouse_face_end_row);
7540          
7541        for (row = first; row <= last && row->enabled_p; ++row)        for (row = first; row <= last && row->enabled_p; ++row)
7542          {          {
7543            int start_hpos, end_hpos, start_x;            int start_hpos, end_hpos, start_x;
# Line 7562  show_mouse_face (dpyinfo, draw) Line 7561  show_mouse_face (dpyinfo, draw)
7561    
7562            if (end_hpos > start_hpos)            if (end_hpos > start_hpos)
7563              {              {
7564                x_draw_glyphs (w, start_x, row, TEXT_AREA,                x_draw_glyphs (w, start_x, row, TEXT_AREA,
7565                               start_hpos, end_hpos, draw, 0);                               start_hpos, end_hpos, draw, 0);
7566    
7567                row->mouse_face_p                row->mouse_face_p
# Line 7804  w32_mouse_position (fp, insist, bar_wind Line 7803  w32_mouse_position (fp, insist, bar_wind
7803          XFRAME (frame)->mouse_moved = 0;          XFRAME (frame)->mouse_moved = 0;
7804    
7805        last_mouse_scroll_bar = Qnil;        last_mouse_scroll_bar = Qnil;
7806          
7807        GetCursorPos (&pt);        GetCursorPos (&pt);
7808    
7809        /* Now we have a position on the root; find the innermost window        /* Now we have a position on the root; find the innermost window
# Line 7981  w32_set_scroll_bar_thumb (bar, portion, Line 7980  w32_set_scroll_bar_thumb (bar, portion,
7980  /************************************************************************  /************************************************************************
7981                           Scroll bars, general                           Scroll bars, general
7982   ************************************************************************/   ************************************************************************/
7983                                                                            
7984  HWND  HWND
7985  my_create_scrollbar (f, bar)  my_create_scrollbar (f, bar)
7986       struct frame * f;       struct frame * f;
7987       struct scroll_bar * bar;       struct scroll_bar * bar;
7988  {  {
7989    return (HWND) SendMessage (FRAME_W32_WINDOW (f),    return (HWND) SendMessage (FRAME_W32_WINDOW (f),
7990                               WM_EMACS_CREATESCROLLBAR, (WPARAM) f,                               WM_EMACS_CREATESCROLLBAR, (WPARAM) f,
7991                               (LPARAM) bar);                               (LPARAM) bar);
7992  }  }
7993    
# Line 8028  my_set_focus (f, hwnd) Line 8027  my_set_focus (f, hwnd)
8027       struct frame * f;       struct frame * f;
8028       HWND hwnd;       HWND hwnd;
8029  {  {
8030    SendMessage (FRAME_W32_WINDOW (f), WM_EMACS_SETFOCUS,    SendMessage (FRAME_W32_WINDOW (f), WM_EMACS_SETFOCUS,
8031                 (WPARAM) hwnd, 0);                 (WPARAM) hwnd, 0);
8032  }  }
8033    
# Line 8044  my_destroy_window (f, hwnd) Line 8043  my_destroy_window (f, hwnd)
8043       struct frame * f;       struct frame * f;
8044       HWND hwnd;       HWND hwnd;
8045  {  {
8046    SendMessage (FRAME_W32_WINDOW (f), WM_EMACS_DESTROYWINDOW,    SendMessage (FRAME_W32_WINDOW (f), WM_EMACS_DESTROYWINDOW,
8047                 (WPARAM) hwnd, 0);                 (WPARAM) hwnd, 0);
8048  }  }
8049    
# Line 8171  w32_set_vertical_scroll_bar (w, portion, Line 8170  w32_set_vertical_scroll_bar (w, portion,
8170    
8171    /* Compute the left edge of the scroll bar.  */    /* Compute the left edge of the scroll bar.  */
8172    if (FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT (f))    if (FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT (f))
8173      sb_left = left + width - sb_width - (width - sb_width) / 2;      sb_left = left + width - sb_width - (width - sb_width) / 2;
8174    else    else
8175      sb_left = left + (width - sb_width) / 2;      sb_left = left + (width - sb_width) / 2;
8176    
# Line 8192  w32_set_vertical_scroll_bar (w, portion, Line 8191  w32_set_vertical_scroll_bar (w, portion,
8191      }      }
8192    else    else
8193      {      {
8194        /* It may just need to be moved and resized.  */              /* It may just need to be moved and resized.  */
8195        HWND hwnd;        HWND hwnd;
8196    
8197        bar = XSCROLL_BAR (w->vertical_scroll_bar);        bar = XSCROLL_BAR (w->vertical_scroll_bar);
# Line 8414  w32_scroll_bar_handle_click (bar, msg, e Line 8413  w32_scroll_bar_handle_click (bar, msg, e
8413    
8414    
8415      last_mouse_scroll_bar_pos = msg->msg.wParam;      last_mouse_scroll_bar_pos = msg->msg.wParam;
8416    
8417      switch (LOWORD (msg->msg.wParam))      switch (LOWORD (msg->msg.wParam))
8418        {        {
8419        case SB_LINEDOWN:        case SB_LINEDOWN:
# Line 8614  static short temp_buffer[100]; Line 8613  static short temp_buffer[100];
8613     We return the number of characters stored into the buffer,     We return the number of characters stored into the buffer,
8614     thus pretending to be `read'.     thus pretending to be `read'.
8615    
8616     EXPECTED is nonzero if the caller knows input is available.       EXPECTED is nonzero if the caller knows input is available.
8617    
8618     Some of these messages are reposted back to the message queue since the     Some of these messages are reposted back to the message queue since the
8619     system calls the windows proc directly in a context where we cannot return     system calls the windows proc directly in a context where we cannot return
8620     the data nor can we guarantee the state we are in.  So if we dispatch  them     the data nor can we guarantee the state we are in.  So if we dispatch  them
8621     we will get into an infinite loop.  To prevent this from ever happening we     we will get into an infinite loop.  To prevent this from ever happening we
8622     will set a variable to indicate we are in the read_socket call and indicate     will set a variable to indicate we are in the read_socket call and indicate
8623     which message we are processing since the windows proc gets called     which message we are processing since the windows proc gets called
8624     recursively with different messages by the system.     recursively with different messages by the system.
8625  */  */
8626    
# Line 8662  w32_read_socket (sd, bufp, numchars, exp Line 8661  w32_read_socket (sd, bufp, numchars, exp
8661          case WM_PAINT:          case WM_PAINT:
8662            f = x_window_to_frame (dpyinfo, msg.msg.hwnd);            f = x_window_to_frame (dpyinfo, msg.msg.hwnd);
8663    
8664            if (f)            if (f)
8665              {              {
8666                if (msg.rect.right == msg.rect.left ||                if (msg.rect.right == msg.rect.left ||
8667                    msg.rect.bottom == msg.rect.top)                    msg.rect.bottom == msg.rect.top)
# Line 8722  w32_read_socket (sd, bufp, numchars, exp Line 8721  w32_read_socket (sd, bufp, numchars, exp
8721              {              {
8722                if (numchars == 0)                if (numchars == 0)
8723                  abort ();                  abort ();
8724              
8725                bufp->kind = LANGUAGE_CHANGE_EVENT;                bufp->kind = LANGUAGE_CHANGE_EVENT;
8726                XSETFRAME (bufp->frame_or_window, f);                XSETFRAME (bufp->frame_or_window, f);
8727                bufp->arg = Qnil;                bufp->arg = Qnil;
# Line 8737  w32_read_socket (sd, bufp, numchars, exp Line 8736  w32_read_socket (sd, bufp, numchars, exp
8736          case WM_KEYDOWN:          case WM_KEYDOWN:
8737          case WM_SYSKEYDOWN:          case WM_SYSKEYDOWN:
8738            f = x_window_to_frame (dpyinfo, msg.msg.hwnd);            f = x_window_to_frame (dpyinfo, msg.msg.hwnd);
8739              
8740            if (f && !f->iconified)            if (f && !f->iconified)
8741              {              {
8742                if (!dpyinfo->mouse_face_hidden && INTEGERP (Vmouse_highlight))                if (!dpyinfo->mouse_face_hidden && INTEGERP (Vmouse_highlight))
# Line 8764  w32_read_socket (sd, bufp, numchars, exp Line 8763  w32_read_socket (sd, bufp, numchars, exp
8763          case WM_SYSCHAR:          case WM_SYSCHAR:
8764          case WM_CHAR:          case WM_CHAR:
8765            f = x_window_to_frame (dpyinfo, msg.msg.hwnd);            f = x_window_to_frame (dpyinfo, msg.msg.hwnd);
8766              
8767            if (f && !f->iconified)            if (f && !f->iconified)
8768              {              {
8769                if (!dpyinfo->mouse_face_hidden && INTEGERP (Vmouse_highlight))                if (!dpyinfo->mouse_face_hidden && INTEGERP (Vmouse_highlight))
# Line 8798  w32_read_socket (sd, bufp, numchars, exp Line 8797  w32_read_socket (sd, bufp, numchars, exp
8797              f = last_mouse_frame;              f = last_mouse_frame;
8798            else            else
8799              f = x_window_to_frame (dpyinfo, msg.msg.hwnd);              f = x_window_to_frame (dpyinfo, msg.msg.hwnd);
8800              
8801            if (dpyinfo->mouse_face_hidden)            if (dpyinfo->mouse_face_hidden)
8802              {              {
8803                dpyinfo->mouse_face_hidden = 0;                dpyinfo->mouse_face_hidden = 0;
# Line 8851  w32_read_socket (sd, bufp, numchars, exp Line 8850  w32_read_socket (sd, bufp, numchars, exp
8850              int up;              int up;
8851    
8852              emacs_event.kind = NO_EVENT;              emacs_event.kind = NO_EVENT;
8853                
8854              if (dpyinfo->grabbed && last_mouse_frame              if (dpyinfo->grabbed && last_mouse_frame
8855                  && FRAME_LIVE_P (last_mouse_frame))                  && FRAME_LIVE_P (last_mouse_frame))
8856                f = last_mouse_frame;                f = last_mouse_frame;
8857              else              else
8858                f = x_window_to_frame (dpyinfo, msg.msg.hwnd);                f = x_window_to_frame (dpyinfo, msg.msg.hwnd);
8859                
8860              if (f)              if (f)
8861                {                {
8862                  construct_mouse_click (&emacs_event, &msg, f);                  construct_mouse_click (&emacs_event, &msg, f);
8863                    
8864                  /* Is this in the tool-bar?  */                  /* Is this in the tool-bar?  */
8865                  if (WINDOWP (f->tool_bar_window)                  if (WINDOWP (f->tool_bar_window)
8866                      && XFASTINT (XWINDOW (f->tool_bar_window)->height))                      && XFASTINT (XWINDOW (f->tool_bar_window)->height))
# Line 8893  w32_read_socket (sd, bufp, numchars, exp Line 8892  w32_read_socket (sd, bufp, numchars, exp
8892                        numchars--;                        numchars--;
8893                      }                      }
8894                }                }
8895                
8896              parse_button (msg.msg.message, HIWORD (msg.msg.wParam),              parse_button (msg.msg.message, HIWORD (msg.msg.wParam),
8897                            &button, &up);                            &button, &up);
8898    
# Line 8917  w32_read_socket (sd, bufp, numchars, exp Line 8916  w32_read_socket (sd, bufp, numchars, exp
8916                }                }
8917              break;              break;
8918            }            }
8919              
8920        case WM_MOUSEWHEEL:        case WM_MOUSEWHEEL:
8921            if (dpyinfo->grabbed && last_mouse_frame            if (dpyinfo->grabbed && last_mouse_frame
8922                && FRAME_LIVE_P (last_mouse_frame))                && FRAME_LIVE_P (last_mouse_frame))
# Line 8927  w32_read_socket (sd, bufp, numchars, exp Line 8926  w32_read_socket (sd, bufp, numchars, exp
8926    
8927            if (f)            if (f)
8928              {              {
8929                if ((!dpyinfo->w32_focus_frame                if ((!dpyinfo->w32_focus_frame
8930                     || f == dpyinfo->w32_focus_frame)                     || f == dpyinfo->w32_focus_frame)
8931                    && (numchars >= 1))                    && (numchars >= 1))
8932                  {                  {
# Line 8955  w32_read_socket (sd, bufp, numchars, exp Line 8954  w32_read_socket (sd, bufp, numchars, exp
8954            {            {
8955              struct scroll_bar *bar =              struct scroll_bar *bar =
8956                x_window_to_scroll_bar ((HWND)msg.msg.lParam);                x_window_to_scroll_bar ((HWND)msg.msg.lParam);
8957                  
8958              if (bar && numchars >= 1)              if (bar && numchars >= 1)
8959                {                {
8960                  if (w32_scroll_bar_handle_click (bar, &msg, bufp))                  if (w32_scroll_bar_handle_click (bar, &msg, bufp))
# Line 8967  w32_read_socket (sd, bufp, numchars, exp Line 8966  w32_read_socket (sd, bufp, numchars, exp
8966                }                }
8967              break;              break;
8968            }            }
8969              
8970          case WM_WINDOWPOSCHANGED:          case WM_WINDOWPOSCHANGED:
8971            f = x_window_to_frame (dpyinfo, msg.msg.hwnd);            f = x_window_to_frame (dpyinfo, msg.msg.hwnd);
8972            if (f)            if (f)
# Line 8990  w32_read_socket (sd, bufp, numchars, exp Line 8989  w32_read_socket (sd, bufp, numchars, exp
8989    
8990          case WM_MOVE:          case WM_MOVE:
8991            f = x_window_to_frame (dpyinfo, msg.msg.hwnd);            f = x_window_to_frame (dpyinfo, msg.msg.hwnd);
8992              
8993            if (f && !f->async_iconified)            if (f && !f->async_iconified)
8994              {              {
8995                int x, y;                int x, y;
# Line 9032  w32_read_socket (sd, bufp, numchars, exp Line 9031  w32_read_socket (sd, bufp, numchars, exp
9031    
9032          case WM_SIZE:          case WM_SIZE:
9033            f = x_window_to_frame (dpyinfo, msg.msg.hwnd);            f = x_window_to_frame (dpyinfo, msg.msg.hwnd);
9034              
9035            /* Inform lisp of whether frame has been iconified etc. */            /* Inform lisp of whether frame has been iconified etc. */
9036            if (f)            if (f)
9037              {              {
# Line 9041  w32_read_socket (sd, bufp, numchars, exp Line 9040  w32_read_socket (sd, bufp, numchars, exp
9040                  case SIZE_MINIMIZED:                  case SIZE_MINIMIZED:
9041                    f->async_visible = 0;                    f->async_visible = 0;
9042                    f->async_iconified = 1;                    f->async_iconified = 1;
9043                      
9044                    bufp->kind = ICONIFY_EVENT;                    bufp->kind = ICONIFY_EVENT;
9045                    XSETFRAME (bufp->frame_or_window, f);                    XSETFRAME (bufp->frame_or_window, f);
9046                    bufp->arg = Qnil;                    bufp->arg = Qnil;
# Line 9054  w32_read_socket (sd, bufp, numchars, exp Line 9053  w32_read_socket (sd, bufp, numchars, exp
9053                  case SIZE_RESTORED:                  case SIZE_RESTORED:
9054                    f->async_visible = 1;                    f->async_visible = 1;
9055                    f->async_iconified = 0;                    f->async_iconified = 0;
9056                      
9057                    /* wait_reading_process_input will notice this and update                    /* wait_reading_process_input will notice this and update
9058                       the frame's display structures.  */                       the frame's display structures.  */
9059                    SET_FRAME_GARBAGED (f);                    SET_FRAME_GARBAGED (f);
9060                      
9061                    if (f->iconified)                    if (f->iconified)
9062                      {                      {
9063                        int x, y;                        int x, y;
# Line 9096  w32_read_socket (sd, bufp, numchars, exp Line 9095  w32_read_socket (sd, bufp, numchars, exp
9095                int columns;                int columns;
9096                int width;                int width;
9097                int height;                int height;
9098                  
9099                GetClientRect (msg.msg.hwnd, &rect);                GetClientRect (msg.msg.hwnd, &rect);
9100                  
9101                height = rect.bottom - rect.top;                height = rect.bottom - rect.top;
9102                width = rect.right - rect.left;                width = rect.right - rect.left;
9103                  
9104                rows = PIXEL_TO_CHAR_HEIGHT (f, height);                rows = PIXEL_TO_CHAR_HEIGHT (f, height);
9105                columns = PIXEL_TO_CHAR_WIDTH (f, width);                columns = PIXEL_TO_CHAR_WIDTH (f, width);
9106                  
9107                /* TODO: Clip size to the screen dimensions.  */                /* TODO: Clip size to the screen dimensions.  */
9108                  
9109                /* Even if the number of character rows and columns has                /* Even if the number of character rows and columns has
9110                   not changed, the font size may have changed, so we need                   not changed, the font size may have changed, so we need
9111                   to check the pixel dimensions as well.  */                   to check the pixel dimensions as well.  */
9112                  
9113                if (columns != f->width                if (columns != f->width
9114                    || rows != f->height                    || rows != f->height
9115                    || width != f->output_data.w32->pixel_width                    || width != f->output_data.w32->pixel_width
# Line 9157  w32_read_socket (sd, bufp, numchars, exp Line 9156  w32_read_socket (sd, bufp, numchars, exp
9156                  }                  }
9157              }              }
9158            break;            break;
9159                  
9160          case WM_SETFOCUS:          case WM_SETFOCUS:
9161            f = x_any_window_to_frame (dpyinfo, msg.msg.hwnd);            f = x_any_window_to_frame (dpyinfo, msg.msg.hwnd);
9162    
9163            dpyinfo->w32_focus_event_frame = f;            dpyinfo->w32_focus_event_frame = f;
9164              
9165            if (f)            if (f)
9166              x_new_focus_frame (dpyinfo, f);              x_new_focus_frame (dpyinfo, f);
9167    
# Line 9214  w32_read_socket (sd, bufp, numchars, exp Line 9213  w32_read_socket (sd, bufp, numchars, exp
9213    
9214          case WM_CLOSE:          case WM_CLOSE:
9215            f = x_window_to_frame (dpyinfo, msg.msg.hwnd);            f = x_window_to_frame (dpyinfo, msg.msg.hwnd);
9216              
9217            if (f)            if (f)
9218              {              {
9219                if (numchars == 0)                if (numchars == 0)
9220                  abort ();                  abort ();
9221                  
9222                bufp->kind = DELETE_WINDOW_EVENT;                bufp->kind = DELETE_WINDOW_EVENT;
9223                XSETFRAME (bufp->frame_or_window, f);                XSETFRAME (bufp->frame_or_window, f);
9224                bufp->arg = Qnil;                bufp->arg = Qnil;
# Line 9231  w32_read_socket (sd, bufp, numchars, exp Line 9230  w32_read_socket (sd, bufp, numchars, exp
9230    
9231          case WM_INITMENU:          case WM_INITMENU:
9232            f = x_window_to_frame (dpyinfo, msg.msg.hwnd);            f = x_window_to_frame (dpyinfo, msg.msg.hwnd);
9233              
9234            if (f)            if (f)
9235              {              {
9236                if (numchars == 0)                if (numchars == 0)
9237                  abort ();                  abort ();
9238              
9239                bufp->kind = MENU_BAR_ACTIVATE_EVENT;                bufp->kind = MENU_BAR_ACTIVATE_EVENT;
9240                XSETFRAME (bufp->frame_or_window, f);                XSETFRAME (bufp->frame_or_window, f);
9241                bufp->arg = Qnil;                bufp->arg = Qnil;
# Line 9262  w32_read_socket (sd, bufp, numchars, exp Line 9261  w32_read_socket (sd, bufp, numchars, exp
9261          case WM_DISPLAYCHANGE:          case WM_DISPLAYCHANGE:
9262            f = x_window_to_frame (dpyinfo, msg.msg.hwnd);            f = x_window_to_frame (dpyinfo, msg.msg.hwnd);
9263    
9264            if (f)            if (f)
9265              {              {
9266                dpyinfo->width = (short) LOWORD (msg.msg.lParam);                dpyinfo->width = (short) LOWORD (msg.msg.lParam);
9267                dpyinfo->height = (short) HIWORD (msg.msg.lParam);                dpyinfo->height = (short) HIWORD (msg.msg.lParam);
# Line 9270  w32_read_socket (sd, bufp, numchars, exp Line 9269  w32_read_socket (sd, bufp, numchars, exp
9269                DebPrint (("display change: %d %d\n", dpyinfo->width,                DebPrint (("display change: %d %d\n", dpyinfo->width,
9270                           dpyinfo->height));                           dpyinfo->height));
9271              }              }
9272              
9273            check_visibility = 1;            check_visibility = 1;
9274            break;            break;
9275    
# Line 9278  w32_read_socket (sd, bufp, numchars, exp Line 9277  w32_read_socket (sd, bufp, numchars, exp
9277            /* Check for messages registered at runtime. */            /* Check for messages registered at runtime. */
9278            if (msg.msg.message == msh_mousewheel)            if (msg.msg.message == msh_mousewheel)
9279              {              {
9280                if (dpyinfo->grabbed && last_mouse_frame                if (dpyinfo->grabbed && last_mouse_frame
9281                    && FRAME_LIVE_P (last_mouse_frame))                    && FRAME_LIVE_P (last_mouse_frame))
9282                  f = last_mouse_frame;                  f = last_mouse_frame;
9283                else                else
9284                  f = x_window_to_frame (dpyinfo, msg.msg.hwnd);                  f = x_window_to_frame (dpyinfo, msg.msg.hwnd);
9285              
9286                if (f)                if (f)
9287                  {                  {
9288                    if ((!dpyinfo->w32_focus_frame                    if ((!dpyinfo->w32_focus_frame
9289                         || f == dpyinfo->w32_focus_frame)                         || f == dpyinfo->w32_focus_frame)
9290                        && (numchars >= 1))                        && (numchars >= 1))
9291                      {                      {
# Line 9643  x_erase_phys_cursor (w) Line 9642  x_erase_phys_cursor (w)
9642       screen.  */       screen.  */
9643    if (w->phys_cursor_type == NO_CURSOR)    if (w->phys_cursor_type == NO_CURSOR)
9644      goto mark_cursor_off;      goto mark_cursor_off;
9645              
9646    /* VPOS >= active_glyphs->nrows means that window has been resized.    /* VPOS >= active_glyphs->nrows means that window has been resized.
9647       Don't bother to erase the cursor.  */       Don't bother to erase the cursor.  */
9648    if (vpos >= active_glyphs->nrows)    if (vpos >= active_glyphs->nrows)
# Line 9654  x_erase_phys_cursor (w) Line 9653  x_erase_phys_cursor (w)
9653    cursor_row = MATRIX_ROW (active_glyphs, vpos);    cursor_row = MATRIX_ROW (active_glyphs, vpos);
9654    if (!cursor_row->enabled_p)    if (!cursor_row->enabled_p)
9655      goto mark_cursor_off;      goto mark_cursor_off;
9656      
9657    /* If row is completely invisible, don't attempt to delete a cursor which    /* If row is completely invisible, don't attempt to delete a cursor which
9658       isn't there.  This may happen if cursor is at top of window, and       isn't there.  This may happen if cursor is at top of window, and
9659       we switch to a buffer with a header line in that window.  */       we switch to a buffer with a header line in that window.  */
9660    if (cursor_row->visible_height <= 0)    if (cursor_row->visible_height <= 0)
9661      goto mark_cursor_off;      goto mark_cursor_off;
9662      
9663    /* This can happen when the new row is shorter than the old one.    /* This can happen when the new row is shorter than the old one.
9664       In this case, either x_draw_glyphs or clear_end_of_line       In this case, either x_draw_glyphs or clear_end_of_line
9665       should have cleared the cursor.  Note that we wouldn't be       should have cleared the cursor.  Note that we wouldn't be
# Line 9706  x_erase_phys_cursor (w) Line 9705  x_erase_phys_cursor (w)
9705                        cursor_row->visible_height);                        cursor_row->visible_height);
9706        release_frame_dc (f, hdc);        release_frame_dc (f, hdc);
9707      }      }
9708      
9709    /* Erase the cursor by redrawing the character underneath it.  */    /* Erase the cursor by redrawing the character underneath it.  */
9710    if (mouse_face_here_p)    if (mouse_face_here_p)
9711      hl = DRAW_MOUSE_FACE;      hl = DRAW_MOUSE_FACE;
# Line 9729  cursor_in_mouse_face_p (w) Line 9728  cursor_in_mouse_face_p (w)
9728    struct w32_display_info *dpyinfo    struct w32_display_info *dpyinfo
9729      = FRAME_W32_DISPLAY_INFO (XFRAME (w->frame));      = FRAME_W32_DISPLAY_INFO (XFRAME (w->frame));
9730    int in_mouse_face = 0;    int in_mouse_face = 0;
9731      
9732    if (WINDOWP (dpyinfo->mouse_face_window)    if (WINDOWP (dpyinfo->mouse_face_window)
9733        && XWINDOW (dpyinfo->mouse_face_window) == w)        && XWINDOW (dpyinfo->mouse_face_window) == w)
9734      {      {
# Line 9784  x_display_and_set_cursor (w, on, hpos, v Line 9783  x_display_and_set_cursor (w, on, hpos, v
9783    current_glyphs = w->current_matrix;    current_glyphs = w->current_matrix;
9784    glyph_row = MATRIX_ROW (current_glyphs, vpos);    glyph_row = MATRIX_ROW (current_glyphs, vpos);
9785    glyph = glyph_row->glyphs[TEXT_AREA] + hpos;    glyph = glyph_row->glyphs[TEXT_AREA] + hpos;
9786      
9787    /* If cursor row is not enabled, we don't really know where to    /* If cursor row is not enabled, we don't really know where to
9788       display the cursor.  */       display the cursor.  */
9789    if (!glyph_row->enabled_p)    if (!glyph_row->enabled_p)
9790      {      {
# Line 9819  x_display_and_set_cursor (w, on, hpos, v Line 9818  x_display_and_set_cursor (w, on, hpos, v
9818      {      {
9819        w->phys_cursor_ascent = glyph_row->ascent;        w->phys_cursor_ascent = glyph_row->ascent;
9820        w->phys_cursor_height = glyph_row->height;        w->phys_cursor_height = glyph_row->height;
9821          
9822        /* Set phys_cursor_.* before x_draw_.* is called because some        /* Set phys_cursor_.* before x_draw_.* is called because some
9823           of them may need the information.  */           of them may need the information.  */
9824        w->phys_cursor.x = x;        w->phys_cursor.x = x;
# Line 10256  x_calc_absolute_position (f) Line 10255  x_calc_absolute_position (f)
10255    {    {
10256        RECT rt;        RECT rt;
10257        rt.left = rt.right = rt.top = rt.bottom = 0;        rt.left = rt.right = rt.top = rt.bottom = 0;
10258          
10259        BLOCK_INPUT;        BLOCK_INPUT;
10260        AdjustWindowRect(&rt, f->output_data.w32->dwStyle,        AdjustWindowRect(&rt, f->output_data.w32->dwStyle,
10261                         FRAME_EXTERNAL_MENU_BAR (f));                         FRAME_EXTERNAL_MENU_BAR (f));
# Line 10336  x_check_fullscreen (f) Line 10335  x_check_fullscreen (f)
10335    if (f->output_data.w32->want_fullscreen & FULLSCREEN_BOTH)    if (f->output_data.w32->want_fullscreen & FULLSCREEN_BOTH)
10336      {      {
10337        int width, height, ign;        int width, height, ign;
10338                          
10339        x_real_positions (f, &f->output_data.w32->left_pos,        x_real_positions (f, &f->output_data.w32->left_pos,
10340                          &f->output_data.w32->top_pos);                          &f->output_data.w32->top_pos);
10341    
10342        x_fullscreen_adjust (f, &width, &height, &ign, &ign);        x_fullscreen_adjust (f, &width, &height, &ign, &ign);
10343                      
10344        /* We do not need to move the window, it shall be taken care of        /* We do not need to move the window, it shall be taken care of
10345           when setting WM manager hints.           when setting WM manager hints.
10346           If the frame is visible already, the position is checked by           If the frame is visible already, the position is checked by
# Line 10377  x_check_fullscreen_move (f) Line 10376  x_check_fullscreen_move (f)
10376        expect_top = 0;        expect_top = 0;
10377      if (f->output_data.w32->want_fullscreen & FULLSCREEN_WIDTH)      if (f->output_data.w32->want_fullscreen & FULLSCREEN_WIDTH)
10378        expect_left = 0;        expect_left = 0;
10379        
10380      if (expect_top != f->output_data.w32->top_pos      if (expect_top != f->output_data.w32->top_pos
10381          || expect_left != f->output_data.w32->left_pos)          || expect_left != f->output_data.w32->left_pos)
10382        x_set_offset (f, expect_left, expect_top, 1);        x_set_offset (f, expect_left, expect_top, 1);
# Line 10405  x_fullscreen_adjust (f, width, height, t Line 10404  x_fullscreen_adjust (f, width, height, t
10404    
10405    *top_pos = f->output_data.w32->top_pos;    *top_pos = f->output_data.w32->top_pos;
10406    *left_pos = f->output_data.w32->left_pos;    *left_pos = f->output_data.w32->left_pos;
10407      
10408    if (f->output_data.w32->want_fullscreen & FULLSCREEN_HEIGHT)    if (f->output_data.w32->want_fullscreen & FULLSCREEN_HEIGHT)
10409      {      {
10410        int ph;        int ph;
10411          
10412        ph = FRAME_X_DISPLAY_INFO (f)->height;        ph = FRAME_X_DISPLAY_INFO (f)->height;
10413        newheight = PIXEL_TO_CHAR_HEIGHT (f, ph);        newheight = PIXEL_TO_CHAR_HEIGHT (f, ph);
10414        ph = CHAR_TO_PIXEL_HEIGHT (f, newheight)        ph = CHAR_TO_PIXEL_HEIGHT (f, newheight)
# Line 10421  x_fullscreen_adjust (f, width, height, t Line 10420  x_fullscreen_adjust (f, width, height, t
10420    if (f->output_data.w32->want_fullscreen & FULLSCREEN_WIDTH)    if (f->output_data.w32->want_fullscreen & FULLSCREEN_WIDTH)
10421      {      {
10422        int pw;        int pw;
10423          
10424        pw = FRAME_X_DISPLAY_INFO (f)->width;        pw = FRAME_X_DISPLAY_INFO (f)->width;
10425        newwidth = PIXEL_TO_CHAR_WIDTH (f, pw);        newwidth = PIXEL_TO_CHAR_WIDTH (f, pw);
10426        pw = CHAR_TO_PIXEL_WIDTH (f, newwidth)        pw = CHAR_TO_PIXEL_WIDTH (f, newwidth)
# Line 10447  x_set_window_size (f, change_gravity, co Line 10446  x_set_window_size (f, change_gravity, co
10446       int cols, rows;       int cols, rows;
10447  {  {
10448    int pixelwidth, pixelheight;    int pixelwidth, pixelheight;
10449      
10450    BLOCK_INPUT;    BLOCK_INPUT;
10451      
10452    check_frame_size (f, &rows, &cols);    check_frame_size (f, &rows, &cols);
10453    f->output_data.w32->vertical_scroll_bar_extra    f->output_data.w32->vertical_scroll_bar_extra
10454      = (!FRAME_HAS_VERTICAL_SCROLL_BARS (f)      = (!FRAME_HAS_VERTICAL_SCROLL_BARS (f)
# Line 10460  x_set_window_size (f, change_gravity, co Line 10459  x_set_window_size (f, change_gravity, co
10459    
10460    pixelwidth = CHAR_TO_PIXEL_WIDTH (f, cols);    pixelwidth = CHAR_TO_PIXEL_WIDTH (f, cols);
10461    pixelheight = CHAR_TO_PIXEL_HEIGHT (f, rows);    pixelheight = CHAR_TO_PIXEL_HEIGHT (f, rows);
10462      
10463    f->output_data.w32->win_gravity = NorthWestGravity;    f->output_data.w32->win_gravity = NorthWestGravity;
10464    x_wm_set_size_hint (f, (long) 0, 0);    x_wm_set_size_hint (f, (long) 0, 0);
10465      
10466    {    {
10467      RECT rect;      RECT rect;
10468    
10469      rect.left = rect.top = 0;      rect.left = rect.top = 0;
10470      rect.right = pixelwidth;      rect.right = pixelwidth;
10471      rect.bottom = pixelheight;      rect.bottom = pixelheight;
10472          
10473      AdjustWindowRect(&rect, f->output_data.w32->dwStyle,      AdjustWindowRect(&rect, f->output_data.w32->dwStyle,
10474                       FRAME_EXTERNAL_MENU_BAR (f));                       FRAME_EXTERNAL_MENU_BAR (f));
10475          
10476      my_set_window_pos (FRAME_W32_WINDOW (f),      my_set_window_pos (FRAME_W32_WINDOW (f),
10477                         NULL,                         NULL,
10478                         0, 0,                         0, 0,
10479                         rect.right - rect.left,                         rect.right - rect.left,
10480                         rect.bottom - rect.top,                         rect.bottom - rect.top,
10481                         SWP_NOZORDER | SWP_NOMOVE | SWP_NOACTIVATE);                         SWP_NOZORDER | SWP_NOMOVE | SWP_NOACTIVATE);
10482    }    }
10483      
10484    /* Now, strictly speaking, we can't be sure that this is accurate,    /* Now, strictly speaking, we can't be sure that this is accurate,
10485       but the window manager will get around to dealing with the size       but the window manager will get around to dealing with the size
10486       change request eventually, and we'll hear how it went when the       change request eventually, and we'll hear how it went when the
10487       ConfigureNotify event gets here.       ConfigureNotify event gets here.
10488        
10489       We could just not bother storing any of this information here,       We could just not bother storing any of this information here,
10490       and let the ConfigureNotify event set everything up, but that       and let the ConfigureNotify event set everything up, but that
10491       might be kind of confusing to the Lisp code, since size changes       might be kind of confusing to the Lisp code, since size changes
# Line 10509  x_set_window_size (f, change_gravity, co Line 10508  x_set_window_size (f, change_gravity, co
10508    mark_window_cursors_off (XWINDOW (f->root_window));    mark_window_cursors_off (XWINDOW (f->root_window));
10509    
10510    /* Clear out any recollection of where the mouse highlighting was,    /* Clear out any recollection of where the mouse highlighting was,
10511       since it might be in a place that's outside the new frame size.       since it might be in a place that's outside the new frame size.
10512       Actually checking whether it is outside is a pain in the neck,       Actually checking whether it is outside is a pain in the neck,
10513       so don't try--just let the highlighting be done afresh with new size.  */       so don't try--just let the highlighting be done afresh with new size.  */
10514    cancel_mouse_face (f);    cancel_mouse_face (f);
# Line 10761  x_make_frame_invisible (f) Line 10760  x_make_frame_invisible (f)
10760    /* Don't keep the highlight on an invisible frame.  */    /* Don't keep the highlight on an invisible frame.  */
10761    if (FRAME_W32_DISPLAY_INFO (f)->x_highlight_frame == f)    if (FRAME_W32_DISPLAY_INFO (f)->x_highlight_frame == f)
10762      FRAME_W32_DISPLAY_INFO (f)->x_highlight_frame = 0;      FRAME_W32_DISPLAY_INFO (f)->x_highlight_frame = 0;
10763      
10764    BLOCK_INPUT;    BLOCK_INPUT;
10765      
10766    my_show_window (f, FRAME_W32_WINDOW (f), SW_HIDE);    my_show_window (f, FRAME_W32_WINDOW (f), SW_HIDE);
10767      
10768    /* We can't distinguish this from iconification    /* We can't distinguish this from iconification
10769       just by the event that we get from the server.       just by the event that we get from the server.
10770       So we can't win using the usual strategy of letting       So we can't win using the usual strategy of letting
# Line 10775  x_make_frame_invisible (f) Line 10774  x_make_frame_invisible (f)
10774    FRAME_ICONIFIED_P (f) = 0;    FRAME_ICONIFIED_P (f) = 0;
10775    f->async_visible = 0;    f->async_visible = 0;
10776    f->async_iconified = 0;    f->async_iconified = 0;
10777      
10778    UNBLOCK_INPUT;    UNBLOCK_INPUT;
10779  }  }
10780    
# Line 10819  x_free_frame_resources (f) Line 10818  x_free_frame_resources (f)
10818    
10819    if (FRAME_W32_WINDOW (f))    if (FRAME_W32_WINDOW (f))
10820      my_destroy_window (f, FRAME_W32_WINDOW (f));      my_destroy_window (f, FRAME_W32_WINDOW (f));
10821          
10822    free_frame_menubar (f);    free_frame_menubar (f);
10823    
10824    unload_color (f, f->output_data.x->foreground_pixel);    unload_color (f, f->output_data.x->foreground_pixel);
# Line 10835  x_free_frame_resources (f) Line 10834  x_free_frame_resources (f)
10834    
10835    if (FRAME_FACE_CACHE (f))    if (FRAME_FACE_CACHE (f))
10836      free_frame_faces (f);      free_frame_faces (f);
10837          
10838    xfree (f->output_data.w32);    xfree (f->output_data.w32);
10839    f->output_data.w32 = NULL;    f->output_data.w32 = NULL;
10840      
10841    if (f == dpyinfo->w32_focus_frame)    if (f == dpyinfo->w32_focus_frame)
10842      dpyinfo->w32_focus_frame = 0;      dpyinfo->w32_focus_frame = 0;
10843    if (f == dpyinfo->w32_focus_event_frame)    if (f == dpyinfo->w32_focus_event_frame)
# Line 10944  x_check_font (f, font) Line 10943  x_check_font (f, font)
10943    xassert (font != NULL);    xassert (font != NULL);
10944    
10945    for (i = 0; i < dpyinfo->n_fonts; i++)    for (i = 0; i < dpyinfo->n_fonts; i++)
10946      if (dpyinfo->font_table[i].name      if (dpyinfo->font_table[i].name
10947          && font == dpyinfo->font_table[i].font)          && font == dpyinfo->font_table[i].font)
10948        break;        break;
10949    
# Line 10988  x_compute_min_glyph_bounds (f) Line 10987  x_compute_min_glyph_bounds (f)
10987    XFontStruct *font;    XFontStruct *font;
10988    int old_width = dpyinfo->smallest_char_width;    int old_width = dpyinfo->smallest_char_width;
10989    int old_height = dpyinfo->smallest_font_height;    int old_height = dpyinfo->smallest_font_height;
10990      
10991    dpyinfo->smallest_font_height = 100000;    dpyinfo->smallest_font_height = 100000;
10992    dpyinfo->smallest_char_width = 100000;    dpyinfo->smallest_char_width = 100000;
10993      
10994    for (i = 0; i < dpyinfo->n_fonts; ++i)    for (i = 0; i < dpyinfo->n_fonts; ++i)
10995      if (dpyinfo->font_table[i].name)      if (dpyinfo->font_table[i].name)
10996        {        {
10997          struct font_info *fontp = dpyinfo->font_table + i;          struct font_info *fontp = dpyinfo->font_table + i;
10998          int w, h;          int w, h;
10999            
11000          font = (XFontStruct *) fontp->font;          font = (XFontStruct *) fontp->font;
11001          xassert (font != (XFontStruct *) ~0);          xassert (font != (XFontStruct *) ~0);
11002          x_font_min_bounds (font, &w, &h);          x_font_min_bounds (font, &w, &h);
11003            
11004          dpyinfo->smallest_font_height = min (dpyinfo->smallest_font_height, h);          dpyinfo->smallest_font_height = min (dpyinfo->smallest_font_height, h);
11005          dpyinfo->smallest_char_width = min (dpyinfo->smallest_char_width, w);          dpyinfo->smallest_char_width = min (dpyinfo->smallest_char_width, w);
11006        }        }
# Line 11041  w32_initialize_display_info (display_nam Line 11040  w32_initialize_display_info (display_nam
11040    w32_display_name_list = Fcons (Fcons (display_name, Qnil),    w32_display_name_list = Fcons (Fcons (display_name, Qnil),
11041                                   w32_display_name_list);                                   w32_display_name_list);
11042    dpyinfo->name_list_element = XCAR (w32_display_name_list);    dpyinfo->name_list_element = XCAR (w32_display_name_list);
11043      
11044    dpyinfo->w32_id_name    dpyinfo->w32_id_name
11045      = (char *) xmalloc (SCHARS (Vinvocation_name)      = (char *) xmalloc (SCHARS (Vinvocation_name)
11046                          + SCHARS (Vsystem_name)                          + SCHARS (Vsystem_name)
# Line 11079  w32_term_init (display_name, xrm_option, Line 11078  w32_term_init (display_name, xrm_option,
11078  {  {
11079    struct w32_display_info *dpyinfo;    struct w32_display_info *dpyinfo;
11080    HDC hdc;    HDC hdc;
11081      
11082    BLOCK_INPUT;    BLOCK_INPUT;
11083      
11084    if (!w32_initialized)    if (!w32_initialized)
11085      {      {
11086        w32_initialize ();        w32_initialize ();
11087        w32_initialized = 1;        w32_initialized = 1;
11088      }      }
11089      
11090    {    {
11091      int argc = 0;      int argc = 0;
11092      char *argv[3];      char *argv[3];
# Line 11100  w32_term_init (display_name, xrm_option, Line 11099  w32_term_init (display_name, xrm_option,
11099          argv[argc++] = xrm_option;          argv[argc++] = xrm_option;
11100        }        }
11101    }    }
11102      
11103    w32_initialize_display_info (display_name);    w32_initialize_display_info (display_name);
11104    
11105    dpyinfo = &one_w32_display_info;    dpyinfo = &one_w32_display_info;
# Line 11108  w32_term_init (display_name, xrm_option, Line 11107  w32_term_init (display_name, xrm_option,
11107    /* Put this display on the chain.  */    /* Put this display on the chain.  */
11108    dpyinfo->next = x_display_list;    dpyinfo->next = x_display_list;
11109    x_display_list = dpyinfo;    x_display_list = dpyinfo;
11110      
11111    hdc = GetDC (GetDesktopWindow ());    hdc = GetDC (GetDesktopWindow ());
11112    
11113    dpyinfo->height = GetDeviceCaps (hdc, VERTRES);    dpyinfo->height = GetDeviceCaps (hdc, VERTRES);
# Line 11291  w32_initialize () Line 11290  w32_initialize ()
11290    init_crit ();    init_crit ();
11291    
11292    dwMainThreadId = GetCurrentThreadId ();    dwMainThreadId = GetCurrentThreadId ();
11293    DuplicateHandle (GetCurrentProcess (), GetCurrentThread (),    DuplicateHandle (GetCurrentProcess (), GetCurrentThread (),
11294                     GetCurrentProcess (), &hMainThread, 0, TRUE, DUPLICATE_SAME_ACCESS);                     GetCurrentProcess (), &hMainThread, 0, TRUE, DUPLICATE_SAME_ACCESS);
11295    
11296    /* Wait for thread to start */    /* Wait for thread to start */
# Line 11301  w32_initialize () Line 11300  w32_initialize ()
11300    
11301      PeekMessage (&msg, NULL, 0, 0, PM_NOREMOVE);      PeekMessage (&msg, NULL, 0, 0, PM_NOREMOVE);
11302    
11303      hWindowsThread = CreateThread (NULL, 0,      hWindowsThread = CreateThread (NULL, 0,
11304                                 (LPTHREAD_START_ROUTINE) w32_msg_worker,                                 (LPTHREAD_START_ROUTINE) w32_msg_worker,
11305                                 0, 0, &dwWindowsThreadId);                                 0, 0, &dwWindowsThreadId);
11306    
11307      GetMessage (&msg, NULL, WM_EMACS_DONE, WM_EMACS_DONE);      GetMessage (&msg, NULL, WM_EMACS_DONE, WM_EMACS_DONE);
11308    }    }
11309      
11310    /* It is desirable that mainThread should have the same notion of    /* It is desirable that mainThread should have the same notion of
11311       focus window and active window as windowsThread.  Unfortunately, the       focus window and active window as windowsThread.  Unfortunately, the
11312       following call to AttachThreadInput, which should do precisely what       following call to AttachThreadInput, which should do precisely what
# Line 11387  When nil, CapsLock only affects normal c Line 11386  When nil, CapsLock only affects normal c
11386                 &Vw32_recognize_altgr,                 &Vw32_recognize_altgr,
11387                 doc: /* Recognize right-alt and left-ctrl as AltGr.                 doc: /* Recognize right-alt and left-ctrl as AltGr.
11388  When nil, the right-alt and left-ctrl key combination is  When nil, the right-alt and left-ctrl key combination is
11389  interpreted normally.  */);  interpreted normally.  */);
11390    Vw32_recognize_altgr = Qt;    Vw32_recognize_altgr = Qt;
11391    
11392    DEFVAR_BOOL ("w32-enable-unicode-output",    DEFVAR_BOOL ("w32-enable-unicode-output",
# Line 11420  When this is non-nil, Emacs will indicat Line 11419  When this is non-nil, Emacs will indicat
11419  using the system caret instead of drawing its own cursor.  Some screen  using the system caret instead of drawing its own cursor.  Some screen
11420  reader software does not track the system cursor properly when it is  reader software does not track the system cursor properly when it is
11421  invisible, and gets confused by Emacs drawing its own cursor, so this  invisible, and gets confused by Emacs drawing its own cursor, so this
11422  variable is initialized to t when Emacs detects that screen reader  variable is initialized to t when Emacs detects that screen reader
11423  software is running as it starts up.  software is running as it starts up.
11424    
11425  When this variable is set, other variables affecting the appearance of  When this variable is set, other variables affecting the appearance of

Legend:
Removed from v.1.169  
changed lines
  Added in v.1.170

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26