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.

However, return the coordinates relative to WINDOW.

If (posn-window posn) is the same as window, simply return the coordinates in POSN. Otherwise, convert them to the frame, and then back again.

If WINDOW is the symbol frame, simply convert the coordinates to the frame that they belong in.

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.
However, return the coordinates relative to WINDOW.

If (posn-window posn) is the same as window, simply return the
coordinates in POSN.  Otherwise, convert them to the frame, and
then back again.

If WINDOW is the symbol `frame', simply convert the coordinates
to the frame that they belong in."
  (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)))))))