aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--doc/emacs/input.texi84
-rw-r--r--lisp/touch-screen.el35
2 files changed, 68 insertions, 51 deletions
diff --git a/doc/emacs/input.texi b/doc/emacs/input.texi
index db0e88a1c9c..5b559652896 100644
--- a/doc/emacs/input.texi
+++ b/doc/emacs/input.texi
@@ -23,56 +23,56 @@ which is detailed here.
23@section Using Emacs on Touchscreens 23@section Using Emacs on Touchscreens
24@cindex touchscreen input 24@cindex touchscreen input
25 25
26 Touchscreen input works by pressing and moving tools (which include 26 Touchscreen input is the manipulation of a frame's contents by the
27fingers and some pointing devices--styluses, for example) onto a frame 27placement and motion of tools (instanced by fingers and such pointing
28in order to manipulate its contents. 28devices as styluses) on a monitor or computer terminal where a frame
29is displayed.
29 30
30 When running under the X Window System or Android, Emacs 31 Under the X Window System or Android, Emacs detects and maps the
31automatically detects and maps the following sequences of movements 32following sequences of movements (``gestures'') to common actions:
32(``gestures'') to common actions:
33 33
34@itemize @bullet 34@itemize @bullet
35@item 35@item
36@cindex tapping, touchscreens 36@cindex tapping, touchscreens
37 ``Tapping'', briefly placing and lifting a tool from the display, 37 @dfn{Tapping}, briefly placing and lifting a tool from the display,
38will result in Emacs selecting the window that was tapped, and 38will select the window that was tapped, and execute any command bound
39executing any command bound to @code{mouse-1} at that location in the 39to @code{mouse-1} at that location in the window. If a link
40window. If the tap happened on top of a link (@pxref{Mouse 40(@pxref{Mouse References}) exists there, then Emacs will follow that
41References}), then Emacs will follow the link instead. 41link instead (insofar as such action differs from that taken upon the
42 42simulation of a @code{mouse-1} event).
43 If a command bound to @code{down-mouse-1} is bound to the location
44where the tap took place, Emacs will execute that command as well.
45 43
46@item 44@item
47@cindex scrolling, touchscreens 45@cindex scrolling, touchscreens
48 ``Scrolling'', meaning to place a tool on the display and move it up 46@vindex touch-screen-enable-hscroll
49or down, will result in Emacs scrolling the window contents in the 47 @dfn{Scrolling}, which is continuous vertical or horizontal motion
50direction where the tool moves. 48on the screen, will scroll the contents of the window beneath the
51 49tool's initial location in the direction of movement. The user option
52 If the tool is moved left or right, Emacs additionally scrolls the 50@code{touch-screen-enable-hscroll} governs whether horizontal
53window horizontally to follow (@pxref{Horizontal Scrolling}.) 51scrolling (@pxref{Horizontal Scrolling}) is performed in reaction to
52this gesture.
54 53
55@item 54@item
56@cindex dragging, touchscreens 55@cindex dragging, touchscreens
57@cindex long-press, touchscreens 56@cindex long-press, touchscreens
58 ``Dragging'', which is performing a @dfn{long-press} by placing a 57 @dfn{Dragging}, which is performing a @dfn{long-press} by placing a
59tool on the display and leaving it there for a while prior to moving 58tool on the display and leaving it there awhile before moving it to
60the tool around will make Emacs set the point to where the tool was 59another position, will move point to the tool's initial position, and
61and begin selecting text under the tool as it moves around, as if 60commence selecting text under the tool as it continues its motion, as
62@code{mouse-1} were to be held down. @xref{Mouse Commands}. 61if @code{mouse-1} were to be held down and a mouse moved anologously.
62@xref{Mouse Commands}.
63 63
64@vindex touch-screen-word-select 64@vindex touch-screen-word-select
65@cindex word selection mode, touchscreens 65@cindex word selection mode, touchscreens
66 Some people find it difficult to position a tool accurately on a 66 To the detriment of text selection, it can prove challenging to
67touch screen display, to the detriment of text selection. The user 67position a tool accurately on a touch screen display. The user option
68option @code{touch-screen-word-select} enables ``word selection 68@code{touch-screen-word-select}, which when enabled, prompts dragging
69mode'', causing dragging to select the complete word, not only the 69to select the complete word under the tool. (Normally, the selection
70character containing the position of the tool. 70is only extended to encompass the character beneath the tool.)
71 71
72@vindex touch-screen-extend-selection 72@vindex touch-screen-extend-selection
73@cindex extending the selection, touchscreens 73@cindex extending the selection, touchscreens
74 Similarly, it may be difficult to select all of the text intended 74 In the same vein, it may be difficult to select all of the text
75within a single gesture. If the user option 75intended within a single gesture. If the user option
76@code{touch-screen-extend-selection} is enabled, taps on the locations 76@code{touch-screen-extend-selection} is enabled, taps on the locations
77of the point or the mark within a window will begin a new ``drag'' 77of the point or the mark within a window will begin a new ``drag''
78gesture, where the region will be extended in the direction of any 78gesture, where the region will be extended in the direction of any
@@ -80,21 +80,19 @@ subsequent movement.
80 80
81@vindex touch-screen-preview-select 81@vindex touch-screen-preview-select
82@cindex previewing the region during selection, touchscreens 82@cindex previewing the region during selection, touchscreens
83 Difficulties in making accurate adjustments to the region can also 83 Difficulties in making accurate adjustments to the region from the
84be alleviated by indicating the position of the point relative to its 84cursor being physically obscured by the tool can be mitigated by
85containing line within the echo area, since the window cursor may be 85indicating the position of the point within the echo area. If
86physically obscured by the tool. If
87@code{touch-screen-preview-select} is non-@code{nil}, the line 86@code{touch-screen-preview-select} is non-@code{nil}, the line
88containing point is displayed in the echo area (@pxref{Echo Area}) 87surrounding point is displayed in the echo area (@pxref{Echo Area})
89during the motion of the tool, followed by another line indicating the 88during the motion of the tool, below which is another line indicating
90position of point within the first line. 89the position of point relative to the first.
91@end itemize 90@end itemize
92 91
93@vindex touch-screen-delay 92@vindex touch-screen-delay
94 By default, Emacs considers a tool as having been left on the 93 Emacs registers a long-press after the time a tool has been placed
95display long enough to trigger a ``long-press'' after 0.7 seconds, but 94upon the screen exceeds 0.7 seconds. This delay can be adjusted
96this can be changed by customizing the variable 95through customizing the variable @code{touch-screen-delay}.
97@code{touch-screen-delay}.
98 96
99@node On-Screen Keyboards 97@node On-Screen Keyboards
100@section Using Emacs with Virtual Keyboards 98@section Using Emacs with Virtual Keyboards
diff --git a/lisp/touch-screen.el b/lisp/touch-screen.el
index 2621aebf037..ea1e27a263b 100644
--- a/lisp/touch-screen.el
+++ b/lisp/touch-screen.el
@@ -58,25 +58,30 @@ This is always cleared upon any significant state change.")
58If non-nil, the touch screen key event translation machinery 58If non-nil, the touch screen key event translation machinery
59is being called from `read-sequence' or some similar function.") 59is being called from `read-sequence' or some similar function.")
60 60
61(defgroup touch-screen nil
62 "Interact with Emacs from touch screen devices."
63 :group 'mouse
64 :version "30.0")
65
61(defcustom touch-screen-display-keyboard nil 66(defcustom touch-screen-display-keyboard nil
62 "If non-nil, always display the on screen keyboard. 67 "If non-nil, always display the on screen keyboard.
63A buffer local value means to always display the on screen 68A buffer local value means to always display the on screen
64keyboard when the buffer is selected." 69keyboard when the buffer is selected."
65 :type 'boolean 70 :type 'boolean
66 :group 'mouse 71 :group 'touch-screen
67 :version "30.1") 72 :version "30.1")
68 73
69(defcustom touch-screen-delay 0.7 74(defcustom touch-screen-delay 0.7
70 "Delay in seconds before Emacs considers a touch to be a long-press." 75 "Delay in seconds before Emacs considers a touch to be a long-press."
71 :type 'number 76 :type 'number
72 :group 'mouse 77 :group 'touch-screen
73 :version "30.1") 78 :version "30.1")
74 79
75(defcustom touch-screen-precision-scroll nil 80(defcustom touch-screen-precision-scroll nil
76 "Whether or not to use precision scrolling for touch screens. 81 "Whether or not to use precision scrolling for touch screens.
77See `pixel-scroll-precision-mode' for more details." 82See `pixel-scroll-precision-mode' for more details."
78 :type 'boolean 83 :type 'boolean
79 :group 'mouse 84 :group 'touch-screen
80 :version "30.1") 85 :version "30.1")
81 86
82(defcustom touch-screen-word-select nil 87(defcustom touch-screen-word-select nil
@@ -84,7 +89,7 @@ See `pixel-scroll-precision-mode' for more details."
84If non-nil, long-press events (see `touch-screen-delay') followed 89If non-nil, long-press events (see `touch-screen-delay') followed
85by dragging will try to select entire words." 90by dragging will try to select entire words."
86 :type 'boolean 91 :type 'boolean
87 :group 'mouse 92 :group 'touch-screen
88 :version "30.1") 93 :version "30.1")
89 94
90(defcustom touch-screen-extend-selection nil 95(defcustom touch-screen-extend-selection nil
@@ -93,7 +98,7 @@ When enabled, tapping on the character containing the point or
93mark will resume dragging where it left off while the region is 98mark will resume dragging where it left off while the region is
94active." 99active."
95 :type 'boolean 100 :type 'boolean
96 :group 'mouse 101 :group 'touch-screen
97 :version "30.1") 102 :version "30.1")
98 103
99(defcustom touch-screen-preview-select nil 104(defcustom touch-screen-preview-select nil
@@ -102,7 +107,15 @@ When enabled, a preview of the visible line within the window
102will be displayed in the echo area while dragging combined with 107will be displayed in the echo area while dragging combined with
103an indication of the position of point within that line." 108an indication of the position of point within that line."
104 :type 'boolean 109 :type 'boolean
105 :group 'mouse 110 :group 'touch-screen
111 :version "30.1")
112
113(defcustom touch-screen-enable-hscroll t
114 "If non-nil, hscroll can be changed from the touch screen.
115When enabled, tapping on a window and dragging your finger left
116or right will scroll that window horizontally."
117 :type 'boolean
118 :group 'touch-screen
106 :version "30.1") 119 :version "30.1")
107 120
108(defvar-local touch-screen-word-select-bounds nil 121(defvar-local touch-screen-word-select-bounds nil
@@ -229,7 +242,12 @@ horizontal scrolling according to the movement in DX."
229 (>= (- accumulator) column-width)) 242 (>= (- accumulator) column-width))
230 (progn 243 (progn
231 (setq accumulator (+ accumulator column-width)) 244 (setq accumulator (+ accumulator column-width))
232 (scroll-right 1) 245 ;; Maintain both hscroll counters even when
246 ;; it's disabled to prevent unintentional or
247 ;; patently horizontal gestures from
248 ;; scrolling the window vertically.
249 (when touch-screen-enable-hscroll
250 (scroll-right 1))
233 (setq lines-hscrolled (1+ lines-hscrolled)) 251 (setq lines-hscrolled (1+ lines-hscrolled))
234 (when (not (zerop accumulator)) 252 (when (not (zerop accumulator))
235 ;; If there is still an outstanding amount 253 ;; If there is still an outstanding amount
@@ -238,7 +256,8 @@ horizontal scrolling according to the movement in DX."
238 (when (and (> accumulator 0) 256 (when (and (> accumulator 0)
239 (>= accumulator column-width)) 257 (>= accumulator column-width))
240 (setq accumulator (- accumulator column-width)) 258 (setq accumulator (- accumulator column-width))
241 (scroll-left 1) 259 (when touch-screen-enable-hscroll
260 (scroll-left 1))
242 (setq lines-hscrolled (1+ lines-hscrolled)) 261 (setq lines-hscrolled (1+ lines-hscrolled))
243 (when (not (zerop accumulator)) 262 (when (not (zerop accumulator))
244 ;; If there is still an outstanding amount to 263 ;; If there is still an outstanding amount to