Function: touch-screen-translate-touch

touch-screen-translate-touch is an autoloaded and byte-compiled function defined in touch-screen.el.gz.

Signature

(touch-screen-translate-touch PROMPT)

Documentation

Translate touch screen events into a sequence of mouse events.

PROMPT is the prompt string given to read-key-sequence, or nil if this function is being called from the keyboard command loop. Value is a new key sequence.

Read the touch screen event within current-key-remap-sequence and give it to touch-screen-handle-touch. Return any key sequence signaled.

If touch-screen-handle-touch does not signal for an event to be returned after the last element of the key sequence is read, continue reading touch screen events until touch-screen-handle-touch signals. Return a sequence consisting of the first event encountered that is not a touch screen event.

In addition to non-touchscreen events read, key sequences returned may contain any one of the following events:

  (touchscreen-scroll WINDOW DX DY)

where WINDOW specifies a window to scroll, and DX and DY are integers describing how many pixels to be scrolled horizontally and vertically,

  (touchscreen-hold POSN)
  (touchscreen-drag POSN)

where POSN is the position of the long-press or touchpoint motion,

  (touchscreen-restart-drag POSN)

where POSN is the position of the tap,

  (down-mouse-1 POSN)
  (drag-mouse-1 POSN)

where POSN is the position of the mouse button press or click,

  (mouse-1 POSN)
  (mouse-2 POSN)

where POSN is the position of the mouse click, either mouse-2 if POSN is on a link or a button, or mouse-1 otherwise.

Source Code

;; Defined in /usr/src/emacs/lisp/touch-screen.el.gz
;;;###autoload
(defun touch-screen-translate-touch (prompt)
  "Translate touch screen events into a sequence of mouse events.
PROMPT is the prompt string given to `read-key-sequence', or nil
if this function is being called from the keyboard command loop.
Value is a new key sequence.

Read the touch screen event within `current-key-remap-sequence'
and give it to `touch-screen-handle-touch'.  Return any key
sequence signaled.

If `touch-screen-handle-touch' does not signal for an event to be
returned after the last element of the key sequence is read,
continue reading touch screen events until
`touch-screen-handle-touch' signals.  Return a sequence
consisting of the first event encountered that is not a touch
screen event.

In addition to non-touchscreen events read, key sequences
returned may contain any one of the following events:

  (touchscreen-scroll WINDOW DX DY)

where WINDOW specifies a window to scroll, and DX and DY are
integers describing how many pixels to be scrolled horizontally
and vertically,

  (touchscreen-hold POSN)
  (touchscreen-drag POSN)

where POSN is the position of the long-press or touchpoint
motion,

  (touchscreen-restart-drag POSN)

where POSN is the position of the tap,

  (down-mouse-1 POSN)
  (drag-mouse-1 POSN)

where POSN is the position of the mouse button press or click,

  (mouse-1 POSN)
  (mouse-2 POSN)

where POSN is the position of the mouse click, either `mouse-2'
if POSN is on a link or a button, or `mouse-1' otherwise."
  (unwind-protect
      ;; Save the virtual function key if this is a mode line event.
      (let* ((prefix-specified
              ;; Virtual prefix keys can be nil for events that fall
              ;; outside a frame or within its internal border.
              (> (length current-key-remap-sequence) 1))
             (prefix (and prefix-specified
                          (aref current-key-remap-sequence 0)))
             (touch-screen-translate-prompt prompt)
             (event (catch 'input-event
                      ;; First, process the one event already within
                      ;; `current-key-remap-sequence'.
                      (touch-screen-handle-touch
                       (aref current-key-remap-sequence
                             (if prefix-specified 1 0))
                       prefix)
                      ;; Next, continue reading input events.
                      (while t
                        (let ((event1 (read-event)))
                          ;; If event1 is a virtual function key, make
                          ;; it the new prefix.
                          (if (memq event1 '(mode-line tab-line nil
                                             vertical-line
                                             header-line tool-bar tab-bar
                                             left-fringe right-fringe
                                             left-margin right-margin
                                             right-divider bottom-divider))
                              (setq prefix event1)
                            ;; If event1 is not a touch screen event,
                            ;; return it.
                            (if (not (memq (car-safe event1)
                                           '(touchscreen-begin
                                             touchscreen-end
                                             touchscreen-update)))
                                (throw 'input-event event1)
                              ;; Process this event as well.
                              (touch-screen-handle-touch event1 prefix))))))))
        ;; Return a key sequence consisting of event
        ;; or an empty vector if it is nil, meaning that
        ;; no key events have been translated.
        (if event (or (and prefix (consp event)
                           ;; Only generate virtual function keys for
                           ;; mouse events...
                           (memq (car event)
                                 '(down-mouse-1 mouse-1
                                   mouse-2 mouse-movement))
                           ;; .. and provided that Emacs has never
                           ;; previously encountered an event of this
                           ;; description, so that its `event-kind'
                           ;; property has yet to be initialized and
                           ;; keyboard.c will not understand whether and
                           ;; how to append a function key prefix.
                           (null (get (car event) 'event-kind))
                           ;; If this is a mode line event, then
                           ;; generate the appropriate function key.
                           (vector prefix event))
                      (vector event))
          ""))
    ;; Cancel the touch screen long-press timer, if it is still there
    ;; by any chance.  If the timer is to operate correctly, it must
    ;; fire within the catch block above.
    (when touch-screen-current-timer
      (cancel-timer touch-screen-current-timer)
      (setq touch-screen-current-timer nil))))