;; This file exists to help understand xterm-mouse's bug. It is *not* ;; dependent on xterm-mouse-mode being enabled. ;; ;; Try running (test-xterm-coord-x) both with and without the text ;; marked "From patch:" enabled. (defun test-xterm-coord-x () (let (l0 ; menu bar l1 ; first row ) (dotimes (x (frame-width)) (push (posn-x-y (xterm-coords-to-posn x 0)) l0) (push (posn-x-y (xterm-coords-to-posn x 1)) l1)) (list (mapcar 'car (nreverse l0)) (mapcar 'car (nreverse l1))))) (defun test-xterm-coord-w () (let (l0 ; menu bar l1 ; first row ) (dotimes (x (frame-width)) (push (posn-window (xterm-coords-to-posn x 0)) l0) (push (posn-window (xterm-coords-to-posn x 1)) l1)) (list (nreverse l0) (nreverse l1)))) (defun xterm-coords-to-posn (x y) "posn creation parts of `xterm-mouse-event'." (let* ((w (window-at x y)) (ltrb (window-edges w)) (left (nth 0 ltrb)) (top (nth 1 ltrb)) (posn (if w (posn-at-x-y (- x left) (- y top) w t) (append (list nil (if (and tab-bar-mode (or (not menu-bar-mode) ;; The tab-bar is on the ;; second row below menu-bar (eq y 1))) 'tab-bar 'menu-bar)) (nthcdr 2 (posn-at-x-y x y ;From patch: (selected-frame) )))))) (setcar (nthcdr 3 posn) -1) posn))