diff options
| author | Kim F. Storm | 2003-11-27 21:15:53 +0000 |
|---|---|---|
| committer | Kim F. Storm | 2003-11-27 21:15:53 +0000 |
| commit | 2d4aac37dcdf8d2d842b69ef2c9a6e293c9483e1 (patch) | |
| tree | fb28511e070864c4e0fa5b7e9de5d4c003e00376 /src | |
| parent | 58df72561da95fbfc4f07a6b5d2007424cc744dd (diff) | |
| download | emacs-2d4aac37dcdf8d2d842b69ef2c9a6e293c9483e1.tar.gz emacs-2d4aac37dcdf8d2d842b69ef2c9a6e293c9483e1.zip | |
(buffer_posn_from_coords): Calculate and return pixel
coordinates relative to glyph at posn. If glyph is an image,
return that as object at posn. Callers changed.
(mode_line_string, marginal_area_string): Calculate and return
pixel coordinates relative to glyph. Callers changed.
Diffstat (limited to 'src')
| -rw-r--r-- | src/dispnew.c | 49 |
1 files changed, 40 insertions, 9 deletions
diff --git a/src/dispnew.c b/src/dispnew.c index 35e03eff9c6..c391cd6b615 100644 --- a/src/dispnew.c +++ b/src/dispnew.c | |||
| @@ -5692,9 +5692,10 @@ update_frame_line (f, vpos) | |||
| 5692 | to character positions. */ | 5692 | to character positions. */ |
| 5693 | 5693 | ||
| 5694 | void | 5694 | void |
| 5695 | buffer_posn_from_coords (w, x, y, object, pos) | 5695 | buffer_posn_from_coords (w, x, y, dx, dy, object, pos) |
| 5696 | struct window *w; | 5696 | struct window *w; |
| 5697 | int *x, *y; | 5697 | int *x, *y; |
| 5698 | int *dx, *dy; | ||
| 5698 | Lisp_Object *object; | 5699 | Lisp_Object *object; |
| 5699 | struct display_pos *pos; | 5700 | struct display_pos *pos; |
| 5700 | { | 5701 | { |
| @@ -5702,6 +5703,7 @@ buffer_posn_from_coords (w, x, y, object, pos) | |||
| 5702 | struct buffer *old_current_buffer = current_buffer; | 5703 | struct buffer *old_current_buffer = current_buffer; |
| 5703 | struct text_pos startp; | 5704 | struct text_pos startp; |
| 5704 | struct glyph_row *row; | 5705 | struct glyph_row *row; |
| 5706 | struct image *img; | ||
| 5705 | int x0, x1; | 5707 | int x0, x1; |
| 5706 | 5708 | ||
| 5707 | current_buffer = XBUFFER (w->buffer); | 5709 | current_buffer = XBUFFER (w->buffer); |
| @@ -5721,7 +5723,15 @@ buffer_posn_from_coords (w, x, y, object, pos) | |||
| 5721 | 5723 | ||
| 5722 | current_buffer = old_current_buffer; | 5724 | current_buffer = old_current_buffer; |
| 5723 | 5725 | ||
| 5724 | *object = STRINGP (it.string) ? it.string : w->buffer; | 5726 | *dx = x0 + it.first_visible_x - it.current_x; |
| 5727 | *dy = *y - it.current_y; | ||
| 5728 | |||
| 5729 | if (it.what == IT_IMAGE | ||
| 5730 | && (img = IMAGE_FROM_ID (it.f, it.image_id)) != NULL | ||
| 5731 | && !NILP (img->spec)) | ||
| 5732 | *object = img->spec; | ||
| 5733 | else | ||
| 5734 | *object = STRINGP (it.string) ? it.string : w->buffer; | ||
| 5725 | *pos = it.current; | 5735 | *pos = it.current; |
| 5726 | *x = it.hpos; | 5736 | *x = it.hpos; |
| 5727 | *y = it.vpos; | 5737 | *y = it.vpos; |
| @@ -5734,22 +5744,23 @@ buffer_posn_from_coords (w, x, y, object, pos) | |||
| 5734 | the string returned. */ | 5744 | the string returned. */ |
| 5735 | 5745 | ||
| 5736 | Lisp_Object | 5746 | Lisp_Object |
| 5737 | mode_line_string (w, x, y, part, charpos) | 5747 | mode_line_string (w, x, y, dx, dy, part, charpos) |
| 5738 | struct window *w; | 5748 | struct window *w; |
| 5739 | int *x, *y; | 5749 | int *x, *y; |
| 5750 | int *dx, *dy; | ||
| 5740 | enum window_part part; | 5751 | enum window_part part; |
| 5741 | int *charpos; | 5752 | int *charpos; |
| 5742 | { | 5753 | { |
| 5743 | struct glyph_row *row; | 5754 | struct glyph_row *row; |
| 5744 | struct glyph *glyph, *end; | 5755 | struct glyph *glyph, *end; |
| 5745 | int x0; | 5756 | int x0, y0; |
| 5746 | Lisp_Object string = Qnil; | 5757 | Lisp_Object string = Qnil; |
| 5747 | 5758 | ||
| 5748 | if (part == ON_MODE_LINE) | 5759 | if (part == ON_MODE_LINE) |
| 5749 | row = MATRIX_MODE_LINE_ROW (w->current_matrix); | 5760 | row = MATRIX_MODE_LINE_ROW (w->current_matrix); |
| 5750 | else | 5761 | else |
| 5751 | row = MATRIX_HEADER_LINE_ROW (w->current_matrix); | 5762 | row = MATRIX_HEADER_LINE_ROW (w->current_matrix); |
| 5752 | 5763 | y0 = *y - row->y; | |
| 5753 | *y = row - MATRIX_FIRST_TEXT_ROW (w->current_matrix); | 5764 | *y = row - MATRIX_FIRST_TEXT_ROW (w->current_matrix); |
| 5754 | 5765 | ||
| 5755 | if (row->mode_line_p && row->enabled_p) | 5766 | if (row->mode_line_p && row->enabled_p) |
| @@ -5771,7 +5782,16 @@ mode_line_string (w, x, y, part, charpos) | |||
| 5771 | *x += x0 / WINDOW_FRAME_COLUMN_WIDTH (w); | 5782 | *x += x0 / WINDOW_FRAME_COLUMN_WIDTH (w); |
| 5772 | } | 5783 | } |
| 5773 | else | 5784 | else |
| 5774 | *x = 0; | 5785 | { |
| 5786 | *x = 0; | ||
| 5787 | x0 = 0; | ||
| 5788 | } | ||
| 5789 | |||
| 5790 | if (dx) | ||
| 5791 | { | ||
| 5792 | *dx = x0; | ||
| 5793 | *dy = y0; | ||
| 5794 | } | ||
| 5775 | 5795 | ||
| 5776 | return string; | 5796 | return string; |
| 5777 | } | 5797 | } |
| @@ -5782,15 +5802,16 @@ mode_line_string (w, x, y, part, charpos) | |||
| 5782 | the string returned. */ | 5802 | the string returned. */ |
| 5783 | 5803 | ||
| 5784 | Lisp_Object | 5804 | Lisp_Object |
| 5785 | marginal_area_string (w, x, y, part, charpos) | 5805 | marginal_area_string (w, x, y, dx, dy, part, charpos) |
| 5786 | struct window *w; | 5806 | struct window *w; |
| 5787 | int *x, *y; | 5807 | int *x, *y; |
| 5808 | int *dx, *dy; | ||
| 5788 | enum window_part part; | 5809 | enum window_part part; |
| 5789 | int *charpos; | 5810 | int *charpos; |
| 5790 | { | 5811 | { |
| 5791 | struct glyph_row *row = w->current_matrix->rows; | 5812 | struct glyph_row *row = w->current_matrix->rows; |
| 5792 | struct glyph *glyph, *end; | 5813 | struct glyph *glyph, *end; |
| 5793 | int x0, i, wy = *y; | 5814 | int x0, y0, i, wy = *y; |
| 5794 | int area; | 5815 | int area; |
| 5795 | Lisp_Object string = Qnil; | 5816 | Lisp_Object string = Qnil; |
| 5796 | 5817 | ||
| @@ -5804,6 +5825,7 @@ marginal_area_string (w, x, y, part, charpos) | |||
| 5804 | for (i = 0; row->enabled_p && i < w->current_matrix->nrows; ++i, ++row) | 5825 | for (i = 0; row->enabled_p && i < w->current_matrix->nrows; ++i, ++row) |
| 5805 | if (wy >= row->y && wy < MATRIX_ROW_BOTTOM_Y (row)) | 5826 | if (wy >= row->y && wy < MATRIX_ROW_BOTTOM_Y (row)) |
| 5806 | break; | 5827 | break; |
| 5828 | y0 = *y - row->y; | ||
| 5807 | *y = row - MATRIX_FIRST_TEXT_ROW (w->current_matrix); | 5829 | *y = row - MATRIX_FIRST_TEXT_ROW (w->current_matrix); |
| 5808 | 5830 | ||
| 5809 | if (row->enabled_p) | 5831 | if (row->enabled_p) |
| @@ -5836,7 +5858,16 @@ marginal_area_string (w, x, y, part, charpos) | |||
| 5836 | *x += x0 / WINDOW_FRAME_COLUMN_WIDTH (w); | 5858 | *x += x0 / WINDOW_FRAME_COLUMN_WIDTH (w); |
| 5837 | } | 5859 | } |
| 5838 | else | 5860 | else |
| 5839 | *x = 0; | 5861 | { |
| 5862 | x0 = 0; | ||
| 5863 | *x = 0; | ||
| 5864 | } | ||
| 5865 | |||
| 5866 | if (dx) | ||
| 5867 | { | ||
| 5868 | *dx = x0; | ||
| 5869 | *dy = y0; | ||
| 5870 | } | ||
| 5840 | 5871 | ||
| 5841 | return string; | 5872 | return string; |
| 5842 | } | 5873 | } |