Function: touch-screen-handle-aux-point-update

touch-screen-handle-aux-point-update is a byte-compiled function defined in touch-screen.el.gz.

Signature

(touch-screen-handle-aux-point-update POINT NUMBER)

Documentation

Notice that a point being observed has moved.

Register motion from either the current or ancillary tool while an ancillary tool is present.

POINT must be the cdr of an element of a touchscreen-update event's list of touch points. NUMBER must be its touch ID.

Calculate the distance between POINT's position and that of the other tool (which is to say the ancillary tool of POINT is the current tool, and vice versa). Compare this distance to that between both points at the time they were placed on the screen, and signal a pinch event to adjust the text scale and scroll the window by the factor so derived. Such events are lists formed as so illustrated:

    (touchscreen-pinch CENTRUM RATIO PAN-X PAN-Y RATIO-DIFF)

in which CENTRUM is a posn representing the midpoint of a line between the present locations of both tools, RATIO is the said factor, PAN-X is the number of pixels on the X axis that centrum has moved since the last event, PAN-Y is that on the Y axis, and RATIO-DIFF is the difference between RATIO and the ratio in the last such event.

Source Code

;; Defined in /usr/src/emacs/lisp/touch-screen.el.gz
(defun touch-screen-handle-aux-point-update (point number)
  "Notice that a point being observed has moved.
Register motion from either the current or ancillary tool while
an ancillary tool is present.

POINT must be the cdr of an element of a `touchscreen-update'
event's list of touch points.  NUMBER must be its touch ID.

Calculate the distance between POINT's position and that of the
other tool (which is to say the ancillary tool of POINT is the
current tool, and vice versa).  Compare this distance to that
between both points at the time they were placed on the screen,
and signal a pinch event to adjust the text scale and scroll the
window by the factor so derived.  Such events are lists formed as
so illustrated:

    (touchscreen-pinch CENTRUM RATIO PAN-X PAN-Y RATIO-DIFF)

in which CENTRUM is a posn representing the midpoint of a line
between the present locations of both tools, RATIO is the said
factor, PAN-X is the number of pixels on the X axis that centrum
has moved since the last event, PAN-Y is that on the Y axis, and
RATIO-DIFF is the difference between RATIO and the ratio in the
last such event."
  (let (this-point-position
        other-point-position
        (window (cadr touch-screen-current-tool)))
    (when (windowp window)
      (if (eq number (aref touch-screen-aux-tool 0))
          (progn
            ;; The point pressed is the ancillary tool.  Set
            ;; other-point-position to that of the current tool.
            (setq other-point-position (nth 9 touch-screen-current-tool))
            ;; Update the position within touch-screen-aux-tool.
            (aset touch-screen-aux-tool 3
                  (setq this-point-position
                        (touch-screen-relative-xy point window))))
        (setq other-point-position (aref touch-screen-aux-tool 3))
        (setcar (nthcdr 2 touch-screen-current-tool)
                (setq this-point-position
                      (touch-screen-relative-xy point window)))
        (setcar (nthcdr 9 touch-screen-current-tool)
                this-point-position))
      ;; Now compute, and take the absolute of, this distance.
      (let ((distance (touch-screen-distance this-point-position
                                             other-point-position))
            (centrum (touch-screen-centrum this-point-position
                                           other-point-position))
            (initial-distance (aref touch-screen-aux-tool 4))
            (initial-centrum (aref touch-screen-aux-tool 5)))
        (let* ((ratio (/ distance initial-distance))
               (ratio-diff (- ratio (aref touch-screen-aux-tool 6))))
          ;; Update the internal record of its position and generate an
          ;; event.
          (aset touch-screen-aux-tool 5 centrum)
          (aset touch-screen-aux-tool 6 ratio)
          (throw 'input-event
                 (list 'touchscreen-pinch
                       (if (or (<= (car centrum) 0)
                               (<= (cdr centrum) 0))
                           (list window nil centrum nil nil
                                 nil nil nil nil nil)
                         (let ((posn (posn-at-x-y (car centrum)
                                                  (cdr centrum)
                                                  window)))
                           (if (eq (posn-window posn)
                                   window)
                               posn
                             ;; Return a placeholder outside the window
                             ;; if the centrum has moved beyond the
                             ;; confines of the window where the gesture
                             ;; commenced.
                             (list window nil centrum nil nil
                                   nil nil nil nil nil))))
                       ratio
                       (- (car centrum)
                          (car initial-centrum))
                       (- (cdr centrum)
                          (cdr initial-centrum))
                       ratio-diff)))))))