Function: touch-screen-relative-xy

touch-screen-relative-xy is a byte-compiled function defined in touch-screen.el.gz.

Signature

(touch-screen-relative-xy POSN WINDOW)

Documentation

Return the coordinates of POSN, a mouse position list, relative to WINDOW.

If (posn-window POSN) is the same as window, simply return the coordinates in POSN. Otherwise, translate these coordinates into that window's frame's coordinate system and from there into that of WINDOW.

If WINDOW is the symbol frame, just convert these coordinates to the coordinate system of the frame containing POSN or its window.

Source Code

;; Defined in /usr/src/emacs/lisp/touch-screen.el.gz
;;; Scroll gesture.

(defun touch-screen-relative-xy (posn window)
  "Return the coordinates of POSN, a mouse position list, relative to WINDOW.

If (posn-window POSN) is the same as window, simply return the
coordinates in POSN.  Otherwise, translate these coordinates
into that window's frame's coordinate system and from there into
that of WINDOW.

If WINDOW is the symbol `frame', just convert these coordinates
to the coordinate system of the frame containing POSN or its
window."
  (if (or (eq (posn-window posn) window)
          (and (eq window 'frame)
               (framep (posn-window posn))))
      (posn-x-y posn)
    (let ((xy (posn-x-y posn))
          (edges (and (windowp window)
                      (window-inside-pixel-edges window))))
      ;; Make the X and Y positions frame relative.
      (when (windowp (posn-window posn))
        (let ((edges (window-inside-pixel-edges
                      (posn-window posn))))
          (setq xy (cons (+ (car xy) (car edges))
                         (+ (cdr xy) (cadr edges))))))
      (if (eq window 'frame)
          xy
        ;; Make the X and Y positions window relative again.
        (cons (- (car xy) (car edges))
              (- (cdr xy) (cadr edges)))))))