Skip to content

Measure mouse cells with the buffer's font metrics - #684

Merged
dakra merged 1 commit into
mainfrom
fix/mouse-posn-text-scale
Sep 13, 2026
Merged

dakra merged 1 commit into
mainfrom
fix/mouse-posn-text-scale

Conversation

@dakra

@dakra dakra commented Sep 13, 2026

Copy link
Copy Markdown
Owner

Fixes #676.

The mouse handlers called posn-col-row without USE-WINDOW, which divides the event's pixel position by the frame's character size. That ignores buffer-local face remapping, so clicks, drags and wheel events forwarded to a TUI landed on the wrong cell under text-scale-mode, buffer-face-mode, or a theme that remaps the default face.

posn-col-row with USE-WINDOW is not a fix either: it uses window-font-height, which drops line-spacing, and ghostel sets that buffer-locally from ghostel-line-spacing.

The new ghostel--posn-cell divides posn-x-y by default-font-width and default-line-height of the event's window, with a frame-level posn resolving through the frame's selected window (drag motion can stray off any window). All five handlers use it.

Verified in a GUI Emacs with a bash shell under ghostel and text-scale-set 3: a click aimed at column 12, row 4 previously mapped to (23 . 7) and now maps to (12 . 4). An ERT test pins the buffer-metric math and the frame fallback.

posn-col-row divides by the frame's character size, which ignores
buffer-local face remapping, so clicks and wheel events landed on the
wrong cell under text-scale-mode, buffer-face-mode, or a theme that
remaps the default face.  Using posn-col-row with USE-WINDOW would
drop line-spacing instead.  Divide the event's pixel position by
default-font-width and default-line-height of the event's window.

Fixes #676
@dakra
dakra force-pushed the fix/mouse-posn-text-scale branch from afcf1cb to 2dbae58 Compare September 13, 2026 14:21
@dakra
dakra merged commit 2dbae58 into main Sep 13, 2026
33 checks passed
@dakra
dakra deleted the fix/mouse-posn-text-scale branch September 13, 2026 14:29

This branch was successfully deployed

1 active deployment
github-pages — 2dbae58f Deployed Sep 13, 2026 by dakra via deploy #187
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Mouse event positions broken under text scaling

1 participant