Function: touch-screen-handle-point-update

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

Signature

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

Documentation

Notice that the touch point POINT has changed position.

Perform the editing operations or throw to the input translation function with an input event tied to any gesture that is recognized.

Update the tenth element of touch-screen-current-tool with POINT relative to the window it was placed on. Update the third element in like fashion, once sufficient motion has accumulated that an event is generated.

POINT must be the touch point currently being tracked as touch-screen-current-tool.

If the fourth element of touch-screen-current-tool is nil, then the touch has just begun. In a related case, if it is ancillary-tool, then the ancillary tool has been removed and gesture translation must be resumed. Determine how much POINT has moved. If POINT has moved upwards or downwards by a significant amount, then set the fourth element to scroll. Then, generate a touchscreen-scroll event with the window that POINT was initially placed upon, and pixel deltas describing how much point has moved relative to its previous position in the X and Y axes.

If the fourth element of touch-screen-current-tool is scroll, then generate a touchscreen-scroll event with the window that POINT was initially placed upon, and pixel deltas describing how much point has moved relative to its previous position in the X and Y axes.

If the fourth element of touch-screen-current-tool is mouse-drag and track-mouse(var)/track-mouse(fun) is non-nil, then generate a mouse-movement event with the position of POINT.

If the fourth element of touch-screen-current-tool is held, then the touch has been held down for some time. If motion happens, set the field to drag. Then, generate a touchscreen-drag event.

If the fourth element of touch-screen-current-tool is restart-drag, set the field to drag and generate a touchscreen-drag.

If the fourth element of touch-screen-current-tool is drag, then move point to the position of POINT.

Source Code

;; Defined in /usr/src/emacs/lisp/touch-screen.el.gz
(defun touch-screen-handle-point-update (point)
  "Notice that the touch point POINT has changed position.
Perform the editing operations or throw to the input translation
function with an input event tied to any gesture that is
recognized.

Update the tenth element of `touch-screen-current-tool' with
POINT relative to the window it was placed on.  Update the third
element in like fashion, once sufficient motion has accumulated
that an event is generated.

POINT must be the touch point currently being tracked as
`touch-screen-current-tool'.

If the fourth element of `touch-screen-current-tool' is nil, then
the touch has just begun.  In a related case, if it is
`ancillary-tool', then the ancillary tool has been removed and
gesture translation must be resumed.  Determine how much POINT
has moved.  If POINT has moved upwards or downwards by a
significant amount, then set the fourth element to `scroll'.
Then, generate a `touchscreen-scroll' event with the window that
POINT was initially placed upon, and pixel deltas describing how
much point has moved relative to its previous position in the X
and Y axes.

If the fourth element of `touch-screen-current-tool' is `scroll',
then generate a `touchscreen-scroll' event with the window that
POINT was initially placed upon, and pixel deltas describing how
much point has moved relative to its previous position in the X
and Y axes.

If the fourth element of `touch-screen-current-tool' is
`mouse-drag' and `track-mouse' is non-nil, then generate a
`mouse-movement' event with the position of POINT.

If the fourth element of `touch-screen-current-tool' is `held',
then the touch has been held down for some time.  If motion
happens, set the field to `drag'.  Then, generate a
`touchscreen-drag' event.

If the fourth element of `touch-screen-current-tool' is
`restart-drag', set the field to `drag' and generate a
`touchscreen-drag'.

If the fourth element of `touch-screen-current-tool' is `drag',
then move point to the position of POINT."
  (let* ((window (nth 1 touch-screen-current-tool))
         (what (nth 3 touch-screen-current-tool))
         (posn (cdr point))
         ;; Now get the position of X and Y relative to WINDOW.
         (relative-xy
         (touch-screen-relative-xy posn window)))
    ;; Update the 10th field of the tool list with RELATIVE-XY.
    (setcar (nthcdr 9 touch-screen-current-tool) relative-xy)
    (cond ((or (null what)
               (eq what 'ancillary-tool))
           (let* ((last-posn (nth 2 touch-screen-current-tool))
                  (diff-x (- (car last-posn) (car relative-xy)))
                  (diff-y (- (cdr last-posn) (cdr relative-xy))))
             (when (or (> diff-y 10)
                       (> diff-x (frame-char-width))
                       (< diff-y -10)
                       (< diff-x (- (frame-char-width))))
               (setcar (nthcdr 3 touch-screen-current-tool)
                       'scroll)
               (setcar (nthcdr 2 touch-screen-current-tool)
                       relative-xy)
               ;; Cancel the touch screen long-press timer, if it is
               ;; still there by any chance.
               (when touch-screen-current-timer
                 (cancel-timer touch-screen-current-timer)
                 (setq touch-screen-current-timer nil))
               ;; Generate a `touchscreen-scroll' event with `diff-x'
               ;; and `diff-y'.
               (throw 'input-event
                      (list 'touchscreen-scroll
                            window diff-x diff-y)))))
          ((eq what 'scroll)
           ;; Cancel the touch screen long-press timer, if it is still
           ;; there by any chance.
           (when touch-screen-current-timer
             (cancel-timer touch-screen-current-timer)
             (setq touch-screen-current-timer nil))
           (let* ((last-posn (nth 2 touch-screen-current-tool))
                  (diff-x (- (car last-posn) (car relative-xy)))
                  (diff-y (- (cdr last-posn) (cdr relative-xy))))
             (setcar (nthcdr 3 touch-screen-current-tool)
                     'scroll)
             (setcar (nthcdr 2 touch-screen-current-tool)
                     relative-xy)
             (unless (and (zerop diff-x) (zerop diff-y))
               (throw 'input-event
                      ;; Generate a `touchscreen-scroll' event with
                      ;; `diff-x' and `diff-y'.
                      (list 'touchscreen-scroll
                            window diff-x diff-y)))))
          ((eq what 'mouse-drag)
           ;; There was a `down-mouse-1' event bound at the starting
           ;; point of the event.  Generate a mouse-motion event if
           ;; mouse movement is being tracked.
           (when track-mouse
             (throw 'input-event (list 'mouse-movement
                                       (cdr point)))))
          ((eq what 'held)
           (let* ((posn (cdr point)))
             ;; Now start dragging.
             (setcar (nthcdr 3 touch-screen-current-tool)
                     'drag)
             ;; Generate a (touchscreen-drag POSN) event.
             ;; `touchscreen-hold' was generated when the timeout
             ;; fired.
             (throw 'input-event (list 'touchscreen-drag posn))))
          ((eq what 'restart-drag)
           (let* ((posn (cdr point)))
             ;; Now start dragging.
             (setcar (nthcdr 3 touch-screen-current-tool)
                     'drag)
             ;; Generate a (touchscreen-drag POSN) event.
             ;; `touchscreen-restart-drag' was generated when the
             ;; timeout fired.
             (throw 'input-event (list 'touchscreen-drag posn))))
          ((eq what 'drag)
           (let* ((posn (cdr point)))
             ;; Generate a (touchscreen-drag POSN) event.
             (throw 'input-event (list 'touchscreen-drag posn)))))))