- ;; Convert XTerm mouse event to Emacs mouse event.
- (let* ((type (- (read-char) ? ))
- (x (- (read-char) ? 1))
- (y (- (read-char) ? 1))
- (point (cons x y))
- (window (window-at x y))
- (where (if window
- (coordinates-in-window-p point window)
- 'menu-bar))
- (pos (if (consp where)
- (progn
- (select-window window)
- (goto-char (window-start window))
- (move-to-window-line (cdr where))
- (move-to-column (+ (car where) (current-column)
- (max 0 (1- (window-hscroll)))))
- (point))
- where))
- (mouse (intern (if (eq type 3)
- (concat "mouse-" (+ 1 last))
- (setq last type)
- (concat "down-mouse-" (+ 1 type))))))
+ "Convert XTerm mouse event to Emacs mouse event."
+ (let* ((type (- (xterm-mouse-event-read) #o40))
+ (x (- (xterm-mouse-event-read) #o40 1))
+ (y (- (xterm-mouse-event-read) #o40 1))
+ (mouse (intern
+ ;; For buttons > 3, the release-event looks
+ ;; differently (see xc/programs/xterm/button.c,
+ ;; function EditorButton), and there seems to come in
+ ;; a release-event only, no down-event.
+ (cond ((>= type 64)
+ (format "mouse-%d" (- type 60)))
+ ((= type 3)
+ (format "mouse-%d" (+ 1 xterm-mouse-last)))
+ (t
+ (setq xterm-mouse-last type)
+ (format "down-mouse-%d" (+ 1 type))))))
+ (w (window-at x y))
+ (ltrb (window-edges w))
+ (left (nth 0 ltrb))
+ (top (nth 1 ltrb)))
+