Mercurial > emacs
comparison src/w32fns.c @ 111417:6316c70b291e
Support R2L lines in tool-tip text.
xfns.c (Fx_show_tip): If any of the tool-tip text lines is R2L,
adjust width of tool-tip frame to the width of text, excluding the
stretch glyph at the beginning of R2L glyph rows.
w32fns.c (Fx_show_tip): Likewise.
author | Eli Zaretskii <eliz@gnu.org> |
---|---|
date | Sat, 06 Nov 2010 15:45:37 +0200 |
parents | b9e560ce3ab6 |
children | ad93f2dd2d38 |
comparison
equal
deleted
inserted
replaced
111416:7a88e72dff57 | 111417:6316c70b291e |
---|---|
5655 struct frame *f; | 5655 struct frame *f; |
5656 struct window *w; | 5656 struct window *w; |
5657 int root_x, root_y; | 5657 int root_x, root_y; |
5658 struct buffer *old_buffer; | 5658 struct buffer *old_buffer; |
5659 struct text_pos pos; | 5659 struct text_pos pos; |
5660 int i, width, height; | 5660 int i, width, height, seen_reversed_p; |
5661 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4; | 5661 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4; |
5662 int old_windows_or_buffers_changed = windows_or_buffers_changed; | 5662 int old_windows_or_buffers_changed = windows_or_buffers_changed; |
5663 int count = SPECPDL_INDEX (); | 5663 int count = SPECPDL_INDEX (); |
5664 | 5664 |
5665 specbind (Qinhibit_redisplay, Qt); | 5665 specbind (Qinhibit_redisplay, Qt); |
5785 clear_glyph_matrix (w->current_matrix); | 5785 clear_glyph_matrix (w->current_matrix); |
5786 SET_TEXT_POS (pos, BEGV, BEGV_BYTE); | 5786 SET_TEXT_POS (pos, BEGV, BEGV_BYTE); |
5787 try_window (FRAME_ROOT_WINDOW (f), pos, 0); | 5787 try_window (FRAME_ROOT_WINDOW (f), pos, 0); |
5788 | 5788 |
5789 /* Compute width and height of the tooltip. */ | 5789 /* Compute width and height of the tooltip. */ |
5790 width = height = 0; | 5790 width = height = seen_reversed_p = 0; |
5791 for (i = 0; i < w->desired_matrix->nrows; ++i) | 5791 for (i = 0; i < w->desired_matrix->nrows; ++i) |
5792 { | 5792 { |
5793 struct glyph_row *row = &w->desired_matrix->rows[i]; | 5793 struct glyph_row *row = &w->desired_matrix->rows[i]; |
5794 struct glyph *last; | 5794 struct glyph *last; |
5795 int row_width; | 5795 int row_width; |
5799 break; | 5799 break; |
5800 | 5800 |
5801 /* Let the row go over the full width of the frame. */ | 5801 /* Let the row go over the full width of the frame. */ |
5802 row->full_width_p = 1; | 5802 row->full_width_p = 1; |
5803 | 5803 |
5804 #ifdef TODO /* Investigate why some fonts need more width than is | 5804 row_width = row->pixel_width; |
5805 calculated for some tooltips. */ | |
5806 /* There's a glyph at the end of rows that is use to place | |
5807 the cursor there. Don't include the width of this glyph. */ | |
5808 if (row->used[TEXT_AREA]) | 5805 if (row->used[TEXT_AREA]) |
5809 { | 5806 { |
5810 last = &row->glyphs[TEXT_AREA][row->used[TEXT_AREA] - 1]; | 5807 if (!row->reversed_p) |
5811 row_width = row->pixel_width - last->pixel_width; | 5808 { |
5809 #ifdef TODO /* Investigate why some fonts need more width than is | |
5810 calculated for some tooltips. */ | |
5811 | |
5812 /* There's a glyph at the end of rows that is used to | |
5813 place the cursor there. Don't include the width of | |
5814 this glyph. */ | |
5815 last = &row->glyphs[TEXT_AREA][row->used[TEXT_AREA] - 1]; | |
5816 if (INTEGERP (last->object)) | |
5817 row_width -= last->pixel_width; | |
5818 #endif | |
5819 } | |
5820 else | |
5821 { | |
5822 /* There could be a stretch glyph at the beginning of R2L | |
5823 rows that is produced by extend_face_to_end_of_line. | |
5824 Don't count that glyph. */ | |
5825 struct glyph *g = row->glyphs[TEXT_AREA]; | |
5826 | |
5827 if (g->type == STRETCH_GLYPH && INTEGERP (g->object)) | |
5828 { | |
5829 row_width -= g->pixel_width; | |
5830 seen_reversed_p = 1; | |
5831 } | |
5832 } | |
5812 } | 5833 } |
5813 else | |
5814 #endif | |
5815 row_width = row->pixel_width; | |
5816 | 5834 |
5817 /* TODO: find why tips do not draw along baseline as instructed. */ | 5835 /* TODO: find why tips do not draw along baseline as instructed. */ |
5818 height += row->height; | 5836 height += row->height; |
5819 width = max (width, row_width); | 5837 width = max (width, row_width); |
5838 } | |
5839 | |
5840 /* If we've seen partial-length R2L rows, we need to re-adjust the | |
5841 tool-tip frame width and redisplay it again, to avoid over-wide | |
5842 tips due to the stretch glyph that extends R2L lines to full | |
5843 width of the frame. */ | |
5844 if (seen_reversed_p) | |
5845 { | |
5846 /* w->total_cols and FRAME_TOTAL_COLS want the width in columns, | |
5847 not in pixels. */ | |
5848 width /= WINDOW_FRAME_COLUMN_WIDTH (w); | |
5849 w->total_cols = make_number (width); | |
5850 FRAME_TOTAL_COLS (f) = width; | |
5851 adjust_glyphs (f); | |
5852 clear_glyph_matrix (w->desired_matrix); | |
5853 clear_glyph_matrix (w->current_matrix); | |
5854 try_window (FRAME_ROOT_WINDOW (f), pos, 0); | |
5855 width = height = 0; | |
5856 /* Recompute width and height of the tooltip. */ | |
5857 for (i = 0; i < w->desired_matrix->nrows; ++i) | |
5858 { | |
5859 struct glyph_row *row = &w->desired_matrix->rows[i]; | |
5860 struct glyph *last; | |
5861 int row_width; | |
5862 | |
5863 if (!row->enabled_p || !row->displays_text_p) | |
5864 break; | |
5865 row->full_width_p = 1; | |
5866 row_width = row->pixel_width; | |
5867 #ifdef TODO /* See above. */ | |
5868 if (row->used[TEXT_AREA] && !row->reversed_p) | |
5869 { | |
5870 last = &row->glyphs[TEXT_AREA][row->used[TEXT_AREA] - 1]; | |
5871 if (INTEGERP (last->object)) | |
5872 row_width -= last->pixel_width; | |
5873 } | |
5874 #endif | |
5875 | |
5876 height += row->height; | |
5877 width = max (width, row_width); | |
5878 } | |
5820 } | 5879 } |
5821 | 5880 |
5822 /* Add the frame's internal border to the width and height the X | 5881 /* Add the frame's internal border to the width and height the X |
5823 window should have. */ | 5882 window should have. */ |
5824 height += 2 * FRAME_INTERNAL_BORDER_WIDTH (f); | 5883 height += 2 * FRAME_INTERNAL_BORDER_WIDTH (f); |