1
0
mirror of https://git.savannah.gnu.org/git/emacs.git synced 2024-11-21 06:55:39 +00:00

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.
This commit is contained in:
Po Lu 2024-05-01 15:57:29 +08:00
parent c00105626a
commit 54dbd8b4fa
2 changed files with 35 additions and 12 deletions

View File

@ -5363,6 +5363,12 @@ If several parents are listed, go to the first of them."
(setq-local widget-link-suffix ""))
(setq show-trailing-whitespace nil))
(defvar touch-screen-keyboard-function) ; In touch-screen.el.
(defun Custom-display-on-screen-keyboard-p ()
"Return whether it is okay to display the virtual keyboard at point."
(get-char-property (point) 'field))
(define-derived-mode Custom-mode nil "Custom"
"Major mode for editing customization buffers.
@ -5401,6 +5407,8 @@ if that value is non-nil."
custom--hidden-state 'hidden)
(setq-local revert-buffer-function #'custom--revert-buffer)
(setq-local text-conversion-style 'action)
(setq-local touch-screen-keyboard-function
#'Custom-display-on-screen-keyboard-p)
(make-local-variable 'custom-options)
(make-local-variable 'custom-local-buffer)
(custom--initialize-widget-variables)

View File

@ -154,6 +154,17 @@ selected.")
Used in an attempt to keep this word selected during later
dragging.")
;; Should this variable be documented?
(defvar-local touch-screen-keyboard-function nil
"Function that decides whether to display the on screen keyboard.
If set, this function is called with point set to the position of the
tap involved when a command listed in `touch-screen-set-point-commands'
is about to be invoked in response to a tap, the current buffer, or the
text beneath point (in the case of an `inhibit-read-only' text
property), is not read only, and `touch-screen-display-keyboard' is nil,
and should return non-nil if it is appropriate to display the on-screen
keyboard afterwards.")
;;; Scroll gesture.
@ -1374,18 +1385,22 @@ is not read-only."
;; caller of `read-key-sequence' such as
;; `describe-key'.
(throw 'input-event event)
(if (and (or (not buffer-read-only)
;; Display the on screen
;; keyboard even if just the
;; text under point is not
;; read-only.
(get-text-property point
'inhibit-read-only)
touch-screen-display-keyboard)
;; Detect the splash screen and
;; avoid displaying the on screen
;; keyboard there.
(not (equal (buffer-name) "*GNU Emacs*")))
(if (or touch-screen-display-keyboard
(and (or (not buffer-read-only)
inhibit-read-only
;; Display the on screen
;; keyboard even if just the
;; text under point is not
;; read-only.
(get-text-property
point 'inhibit-read-only))
;; If the major mode has defined
;; bespoke criteria for
;; displaying the on screen
;; keyboard, consult it here.
(or (not touch-screen-keyboard-function)
(funcall
touch-screen-keyboard-function))))
;; Once the on-screen keyboard has been
;; opened, add
;; `touch-screen-window-selection-changed'