diff options
| author | Po Lu | 2023-10-24 21:12:32 +0800 |
|---|---|---|
| committer | Po Lu | 2023-10-24 21:12:32 +0800 |
| commit | 4bf6f8d99765851e46f58488bae75c19bcc6c797 (patch) | |
| tree | b6e1d73fb4cab190b52f8886c171be7f37a537ec | |
| parent | 408c904d6602cf269c128a5b5e7b9d0e0b4f7d69 (diff) | |
| download | emacs-4bf6f8d99765851e46f58488bae75c19bcc6c797.tar.gz emacs-4bf6f8d99765851e46f58488bae75c19bcc6c797.zip | |
Introduce an option which controls touch screen hscroll
* doc/emacs/input.texi (Touchscreens): Document this new
function and revise this node for clarity and pithiness.
* lisp/touch-screen.el (touch-screen): New custom group.
(touch-screen-display-keyboard, touch-screen-delay)
(touch-screen-precision-scroll, touch-screen-word-select)
(touch-screen-extend-selection, touch-screen-preview-select):
Move such options to that group.
(touch-screen-enable-hscroll): New user option.
(touch-screen-handle-scroll): If it is disabled, maintain the
hscroll accumulators but refrain from scrolling the window.
| -rw-r--r-- | doc/emacs/input.texi | 84 | ||||
| -rw-r--r-- | lisp/touch-screen.el | 35 |
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 |
| 27 | fingers and some pointing devices--styluses, for example) onto a frame | 27 | placement and motion of tools (instanced by fingers and such pointing |
| 28 | in order to manipulate its contents. | 28 | devices as styluses) on a monitor or computer terminal where a frame |
| 29 | is 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 |
| 31 | automatically detects and maps the following sequences of movements | 32 | following 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, |
| 38 | will result in Emacs selecting the window that was tapped, and | 38 | will select the window that was tapped, and execute any command bound |
| 39 | executing any command bound to @code{mouse-1} at that location in the | 39 | to @code{mouse-1} at that location in the window. If a link |
| 40 | window. If the tap happened on top of a link (@pxref{Mouse | 40 | (@pxref{Mouse References}) exists there, then Emacs will follow that |
| 41 | References}), then Emacs will follow the link instead. | 41 | link instead (insofar as such action differs from that taken upon the |
| 42 | 42 | simulation of a @code{mouse-1} event). | |
| 43 | If a command bound to @code{down-mouse-1} is bound to the location | ||
| 44 | where 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 |
| 49 | or down, will result in Emacs scrolling the window contents in the | 47 | @dfn{Scrolling}, which is continuous vertical or horizontal motion |
| 50 | direction where the tool moves. | 48 | on the screen, will scroll the contents of the window beneath the |
| 51 | 49 | tool'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 |
| 53 | window horizontally to follow (@pxref{Horizontal Scrolling}.) | 51 | scrolling (@pxref{Horizontal Scrolling}) is performed in reaction to |
| 52 | this 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 |
| 59 | tool on the display and leaving it there for a while prior to moving | 58 | tool on the display and leaving it there awhile before moving it to |
| 60 | the tool around will make Emacs set the point to where the tool was | 59 | another position, will move point to the tool's initial position, and |
| 61 | and begin selecting text under the tool as it moves around, as if | 60 | commence selecting text under the tool as it continues its motion, as |
| 62 | @code{mouse-1} were to be held down. @xref{Mouse Commands}. | 61 | if @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 |
| 67 | touch screen display, to the detriment of text selection. The user | 67 | position a tool accurately on a touch screen display. The user option |
| 68 | option @code{touch-screen-word-select} enables ``word selection | 68 | @code{touch-screen-word-select}, which when enabled, prompts dragging |
| 69 | mode'', causing dragging to select the complete word, not only the | 69 | to select the complete word under the tool. (Normally, the selection |
| 70 | character containing the position of the tool. | 70 | is 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 |
| 75 | within a single gesture. If the user option | 75 | intended 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 |
| 77 | of the point or the mark within a window will begin a new ``drag'' | 77 | of the point or the mark within a window will begin a new ``drag'' |
| 78 | gesture, where the region will be extended in the direction of any | 78 | gesture, 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 |
| 84 | be alleviated by indicating the position of the point relative to its | 84 | cursor being physically obscured by the tool can be mitigated by |
| 85 | containing line within the echo area, since the window cursor may be | 85 | indicating the position of the point within the echo area. If |
| 86 | physically 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 |
| 88 | containing point is displayed in the echo area (@pxref{Echo Area}) | 87 | surrounding point is displayed in the echo area (@pxref{Echo Area}) |
| 89 | during the motion of the tool, followed by another line indicating the | 88 | during the motion of the tool, below which is another line indicating |
| 90 | position of point within the first line. | 89 | the 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 |
| 95 | display long enough to trigger a ``long-press'' after 0.7 seconds, but | 94 | upon the screen exceeds 0.7 seconds. This delay can be adjusted |
| 96 | this can be changed by customizing the variable | 95 | through 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.") | |||
| 58 | If non-nil, the touch screen key event translation machinery | 58 | If non-nil, the touch screen key event translation machinery |
| 59 | is being called from `read-sequence' or some similar function.") | 59 | is 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. |
| 63 | A buffer local value means to always display the on screen | 68 | A buffer local value means to always display the on screen |
| 64 | keyboard when the buffer is selected." | 69 | keyboard 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. |
| 77 | See `pixel-scroll-precision-mode' for more details." | 82 | See `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." | |||
| 84 | If non-nil, long-press events (see `touch-screen-delay') followed | 89 | If non-nil, long-press events (see `touch-screen-delay') followed |
| 85 | by dragging will try to select entire words." | 90 | by 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 | |||
| 93 | mark will resume dragging where it left off while the region is | 98 | mark will resume dragging where it left off while the region is |
| 94 | active." | 99 | active." |
| 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 | |||
| 102 | will be displayed in the echo area while dragging combined with | 107 | will be displayed in the echo area while dragging combined with |
| 103 | an indication of the position of point within that line." | 108 | an 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. | ||
| 115 | When enabled, tapping on a window and dragging your finger left | ||
| 116 | or 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 |