diff options
| author | Po Lu | 2024-05-01 15:57:29 +0800 |
|---|---|---|
| committer | Po Lu | 2024-05-01 15:57:29 +0800 |
| commit | 54dbd8b4fa2253682d044cc53bd658e361bff8a0 (patch) | |
| tree | eac8faedcb8079b4c3e58d72b8db53adbde2817b | |
| parent | c00105626ace43919706819da4057a358e62bafe (diff) | |
| download | emacs-54dbd8b4fa2253682d044cc53bd658e361bff8a0.tar.gz emacs-54dbd8b4fa2253682d044cc53bd658e361bff8a0.zip | |
Disable on-screen keyboard outside fields in Custom buffers
* lisp/cus-edit.el (Custom-display-on-screen-keyboard-p): New
function.
(Custom-mode): Install it as the touch-screen-keyboard-function.
* lisp/touch-screen.el (touch-screen-keyboard-function): New
variable.
(touch-screen-handle-point-up): Don't special-case the splash
screen with respect to touch-screen-display-keyboard in keeping
with user feedback.
| -rw-r--r-- | lisp/cus-edit.el | 8 | ||||
| -rw-r--r-- | lisp/touch-screen.el | 39 |
2 files changed, 35 insertions, 12 deletions
diff --git a/lisp/cus-edit.el b/lisp/cus-edit.el index 1659c285d84..e7d0eaa9215 100644 --- a/lisp/cus-edit.el +++ b/lisp/cus-edit.el | |||
| @@ -5363,6 +5363,12 @@ If several parents are listed, go to the first of them." | |||
| 5363 | (setq-local widget-link-suffix "")) | 5363 | (setq-local widget-link-suffix "")) |
| 5364 | (setq show-trailing-whitespace nil)) | 5364 | (setq show-trailing-whitespace nil)) |
| 5365 | 5365 | ||
| 5366 | (defvar touch-screen-keyboard-function) ; In touch-screen.el. | ||
| 5367 | |||
| 5368 | (defun Custom-display-on-screen-keyboard-p () | ||
| 5369 | "Return whether it is okay to display the virtual keyboard at point." | ||
| 5370 | (get-char-property (point) 'field)) | ||
| 5371 | |||
| 5366 | (define-derived-mode Custom-mode nil "Custom" | 5372 | (define-derived-mode Custom-mode nil "Custom" |
| 5367 | "Major mode for editing customization buffers. | 5373 | "Major mode for editing customization buffers. |
| 5368 | 5374 | ||
| @@ -5401,6 +5407,8 @@ if that value is non-nil." | |||
| 5401 | custom--hidden-state 'hidden) | 5407 | custom--hidden-state 'hidden) |
| 5402 | (setq-local revert-buffer-function #'custom--revert-buffer) | 5408 | (setq-local revert-buffer-function #'custom--revert-buffer) |
| 5403 | (setq-local text-conversion-style 'action) | 5409 | (setq-local text-conversion-style 'action) |
| 5410 | (setq-local touch-screen-keyboard-function | ||
| 5411 | #'Custom-display-on-screen-keyboard-p) | ||
| 5404 | (make-local-variable 'custom-options) | 5412 | (make-local-variable 'custom-options) |
| 5405 | (make-local-variable 'custom-local-buffer) | 5413 | (make-local-variable 'custom-local-buffer) |
| 5406 | (custom--initialize-widget-variables) | 5414 | (custom--initialize-widget-variables) |
diff --git a/lisp/touch-screen.el b/lisp/touch-screen.el index e44b266a617..ca02ca3caf6 100644 --- a/lisp/touch-screen.el +++ b/lisp/touch-screen.el | |||
| @@ -154,6 +154,17 @@ selected.") | |||
| 154 | Used in an attempt to keep this word selected during later | 154 | Used in an attempt to keep this word selected during later |
| 155 | dragging.") | 155 | dragging.") |
| 156 | 156 | ||
| 157 | ;; Should this variable be documented? | ||
| 158 | (defvar-local touch-screen-keyboard-function nil | ||
| 159 | "Function that decides whether to display the on screen keyboard. | ||
| 160 | If set, this function is called with point set to the position of the | ||
| 161 | tap involved when a command listed in `touch-screen-set-point-commands' | ||
| 162 | is about to be invoked in response to a tap, the current buffer, or the | ||
| 163 | text beneath point (in the case of an `inhibit-read-only' text | ||
| 164 | property), is not read only, and `touch-screen-display-keyboard' is nil, | ||
| 165 | and should return non-nil if it is appropriate to display the on-screen | ||
| 166 | keyboard afterwards.") | ||
| 167 | |||
| 157 | 168 | ||
| 158 | 169 | ||
| 159 | ;;; Scroll gesture. | 170 | ;;; Scroll gesture. |
| @@ -1374,18 +1385,22 @@ is not read-only." | |||
| 1374 | ;; caller of `read-key-sequence' such as | 1385 | ;; caller of `read-key-sequence' such as |
| 1375 | ;; `describe-key'. | 1386 | ;; `describe-key'. |
| 1376 | (throw 'input-event event) | 1387 | (throw 'input-event event) |
| 1377 | (if (and (or (not buffer-read-only) | 1388 | (if (or touch-screen-display-keyboard |
| 1378 | ;; Display the on screen | 1389 | (and (or (not buffer-read-only) |
| 1379 | ;; keyboard even if just the | 1390 | inhibit-read-only |
| 1380 | ;; text under point is not | 1391 | ;; Display the on screen |
| 1381 | ;; read-only. | 1392 | ;; keyboard even if just the |
| 1382 | (get-text-property point | 1393 | ;; text under point is not |
| 1383 | 'inhibit-read-only) | 1394 | ;; read-only. |
| 1384 | touch-screen-display-keyboard) | 1395 | (get-text-property |
| 1385 | ;; Detect the splash screen and | 1396 | point 'inhibit-read-only)) |
| 1386 | ;; avoid displaying the on screen | 1397 | ;; If the major mode has defined |
| 1387 | ;; keyboard there. | 1398 | ;; bespoke criteria for |
| 1388 | (not (equal (buffer-name) "*GNU Emacs*"))) | 1399 | ;; displaying the on screen |
| 1400 | ;; keyboard, consult it here. | ||
| 1401 | (or (not touch-screen-keyboard-function) | ||
| 1402 | (funcall | ||
| 1403 | touch-screen-keyboard-function)))) | ||
| 1389 | ;; Once the on-screen keyboard has been | 1404 | ;; Once the on-screen keyboard has been |
| 1390 | ;; opened, add | 1405 | ;; opened, add |
| 1391 | ;; `touch-screen-window-selection-changed' | 1406 | ;; `touch-screen-window-selection-changed' |