From f49ef939a21c583291b154c19654a8d646bef326 Mon Sep 17 00:00:00 2001 From: Daneel Date: Sun, 22 Feb 2026 21:26:42 +0100 Subject: [PATCH] fix: warp uses posn-at-point+window-pixel-edges (frame-relative, not display-absolute) --- config.el | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/config.el b/config.el index c705f4c..b68dfca 100644 --- a/config.el +++ b/config.el @@ -978,16 +978,23 @@ Keeps the status bar and tab bar fully visible at any zoom level.") (defun my/warp-mouse-to-cursor () "Move mouse pointer to current text cursor position. -Skips if last input was a mouse event (let user pan freely with mouse)." +Skips if last input was a mouse event (let user pan freely with mouse). + +Uses posn-at-point + window-pixel-edges to get frame-relative coordinates. +window-absolute-pixel-position is NOT used: on macOS it returns +display-absolute coordinates, but set-mouse-pixel-position expects +frame-relative — causing incorrect warps to screen corners." (when (and my/cursor-warp-enabled (display-graphic-p) (not (my/last-input-was-mouse-p)) (not (window-minibuffer-p (selected-window)))) - (when-let* ((pos (window-absolute-pixel-position)) - (x (car pos)) - ;; Place mouse at vertical center of cursor line. - (y (+ (cdr pos) (/ (line-pixel-height) 2)))) - (set-mouse-pixel-position (selected-frame) x y)))) + (when-let* ((posn (posn-at-point)) + (xy (posn-x-y posn))) + (let* ((edges (window-pixel-edges (selected-window))) + (x (+ (nth 0 edges) (car xy))) + ;; Place mouse at vertical center of cursor line. + (y (+ (nth 1 edges) (cdr xy) (/ (line-pixel-height) 2)))) + (set-mouse-pixel-position (selected-frame) x y))))) (add-hook 'post-command-hook #'my/warp-mouse-to-cursor)