diff options
| author | Eli Zaretskii | 2017-10-28 16:51:46 +0300 |
|---|---|---|
| committer | Eli Zaretskii | 2017-10-28 16:51:46 +0300 |
| commit | a8e67410662e653e60e8dcc7aaf27042492afee8 (patch) | |
| tree | 96648b688548081b339bba5fc588d4c252c80265 /src | |
| parent | d43b486f6c334ba88c4ecfc485b8d1102b8d20a3 (diff) | |
| download | emacs-a8e67410662e653e60e8dcc7aaf27042492afee8.tar.gz emacs-a8e67410662e653e60e8dcc7aaf27042492afee8.zip | |
Fix conversion of pixel coordinates to buffer position
* src/dispnew.c (buffer_posn_from_coords): Adapt to
auto-hscroll-mode == current-line.
Diffstat (limited to 'src')
| -rw-r--r-- | src/dispnew.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/dispnew.c b/src/dispnew.c index cb32f09b7c6..065d06813b8 100644 --- a/src/dispnew.c +++ b/src/dispnew.c | |||
| @@ -5149,6 +5149,29 @@ buffer_posn_from_coords (struct window *w, int *x, int *y, struct display_pos *p | |||
| 5149 | include the hscroll. */ | 5149 | include the hscroll. */ |
| 5150 | to_x += it.first_visible_x; | 5150 | to_x += it.first_visible_x; |
| 5151 | 5151 | ||
| 5152 | /* If we are hscrolling only the current line, and Y is at the line | ||
| 5153 | containing point, augment TO_X with the hscroll amount of the | ||
| 5154 | current line. */ | ||
| 5155 | if (it.line_wrap == TRUNCATE | ||
| 5156 | && EQ (automatic_hscrolling, Qcurrent_line) && IT_CHARPOS (it) < PT) | ||
| 5157 | { | ||
| 5158 | struct it it2 = it; | ||
| 5159 | void *it2data = bidi_shelve_cache (); | ||
| 5160 | it2.last_visible_x = 1000000; | ||
| 5161 | /* If the line at Y shows point, the call below to | ||
| 5162 | move_it_in_display_line will succeed in reaching point. */ | ||
| 5163 | move_it_in_display_line (&it2, PT, -1, MOVE_TO_POS); | ||
| 5164 | if (IT_CHARPOS (it2) >= PT) | ||
| 5165 | { | ||
| 5166 | to_x += (w->hscroll - w->min_hscroll) * FRAME_COLUMN_WIDTH (it.f); | ||
| 5167 | /* We need to pretend the window is hscrolled, so that | ||
| 5168 | move_it_in_display_line below will DTRT with TO_X. */ | ||
| 5169 | it.first_visible_x += w->hscroll * FRAME_COLUMN_WIDTH (it.f); | ||
| 5170 | it.last_visible_x += w->hscroll * FRAME_COLUMN_WIDTH (it.f); | ||
| 5171 | } | ||
| 5172 | bidi_unshelve_cache (it2data, 0); | ||
| 5173 | } | ||
| 5174 | |||
| 5152 | /* Now move horizontally in the row to the glyph under *X. Second | 5175 | /* Now move horizontally in the row to the glyph under *X. Second |
| 5153 | argument is ZV to prevent move_it_in_display_line from matching | 5176 | argument is ZV to prevent move_it_in_display_line from matching |
| 5154 | based on buffer positions. */ | 5177 | based on buffer positions. */ |