diff options
| author | Po Lu | 2023-11-24 10:39:49 +0800 |
|---|---|---|
| committer | Po Lu | 2023-11-24 10:39:49 +0800 |
| commit | 0858d10aebed44f7d66548d061af03b3cb136d04 (patch) | |
| tree | 9600fd032a6e737b63b26b30c89a0acc44ffcbee | |
| parent | 354a2958f9ae547529b8f35cbd8659a0136d0d56 (diff) | |
| download | emacs-0858d10aebed44f7d66548d061af03b3cb136d04.tar.gz emacs-0858d10aebed44f7d66548d061af03b3cb136d04.zip | |
Prevent touch screen translation from entering invalid state
* lisp/subr.el (touch-screen-events-received): New variable.
(read--potential-mouse-event): If a touch screen event's been
registered thus far, continue as though xterm-mouse-mode is
enabled.
* lisp/touch-screen.el (touch-screen-handle-touch): Set that
variable. If t-s-c-t already exists but the new touch point was
assigned the same number by the system, replace the current tool
with it rather than installing it as the anciliary tool.
| -rw-r--r-- | lisp/subr.el | 26 | ||||
| -rw-r--r-- | lisp/touch-screen.el | 23 |
2 files changed, 38 insertions, 11 deletions
diff --git a/lisp/subr.el b/lisp/subr.el index 304b71e6168..7f2dcdc4d90 100644 --- a/lisp/subr.el +++ b/lisp/subr.el | |||
| @@ -3332,22 +3332,30 @@ only unbound fallback disabled is downcasing of the last event." | |||
| 3332 | (message nil) | 3332 | (message nil) |
| 3333 | (use-global-map old-global-map)))) | 3333 | (use-global-map old-global-map)))) |
| 3334 | 3334 | ||
| 3335 | (defvar touch-screen-events-received nil | ||
| 3336 | "Whether a touch screen event has ever been translated. | ||
| 3337 | The value of this variable governs whether | ||
| 3338 | `read--potential-mouse-event' calls read-key or read-event.") | ||
| 3339 | |||
| 3335 | ;; FIXME: Once there's a safe way to transition away from read-event, | 3340 | ;; FIXME: Once there's a safe way to transition away from read-event, |
| 3336 | ;; callers to this function should be updated to that way and this | 3341 | ;; callers to this function should be updated to that way and this |
| 3337 | ;; function should be deleted. | 3342 | ;; function should be deleted. |
| 3338 | (defun read--potential-mouse-event () | 3343 | (defun read--potential-mouse-event () |
| 3339 | "Read an event that might be a mouse event. | 3344 | "Read an event that might be a mouse event. |
| 3340 | 3345 | ||
| 3341 | This function exists for backward compatibility in code packaged | 3346 | This function exists for backward compatibility in code packaged |
| 3342 | with Emacs. Do not call it directly in your own packages." | 3347 | with Emacs. Do not call it directly in your own packages." |
| 3343 | ;; `xterm-mouse-mode' events must go through `read-key' as they | 3348 | ;; `xterm-mouse-mode' events must go through `read-key' as they |
| 3344 | ;; are decoded via `input-decode-map'. | 3349 | ;; are decoded via `input-decode-map'. |
| 3345 | (if xterm-mouse-mode | 3350 | (if (or xterm-mouse-mode |
| 3346 | (read-key nil | 3351 | ;; If a touch screen is being employed, then mouse events |
| 3347 | ;; Normally `read-key' discards all mouse button | 3352 | ;; are subject to translation as well. |
| 3348 | ;; down events. However, we want them here. | 3353 | touch-screen-events-received) |
| 3349 | t) | 3354 | (read-key nil |
| 3350 | (read-event))) | 3355 | ;; Normally `read-key' discards all mouse button |
| 3356 | ;; down events. However, we want them here. | ||
| 3357 | t) | ||
| 3358 | (read-event))) | ||
| 3351 | 3359 | ||
| 3352 | (defvar read-passwd-map | 3360 | (defvar read-passwd-map |
| 3353 | ;; BEWARE: `defconst' would purecopy it, breaking the sharing with | 3361 | ;; BEWARE: `defconst' would purecopy it, breaking the sharing with |
diff --git a/lisp/touch-screen.el b/lisp/touch-screen.el index f6a47e69d81..56adb75cefc 100644 --- a/lisp/touch-screen.el +++ b/lisp/touch-screen.el | |||
| @@ -1456,8 +1456,15 @@ If INTERACTIVE, execute the command associated with any event | |||
| 1456 | generated instead of throwing `input-event'. Otherwise, throw | 1456 | generated instead of throwing `input-event'. Otherwise, throw |
| 1457 | `input-event' with a single input event if that event should take | 1457 | `input-event' with a single input event if that event should take |
| 1458 | the place of EVENT within the key sequence being translated, or | 1458 | the place of EVENT within the key sequence being translated, or |
| 1459 | `nil' if all tools have been released." | 1459 | `nil' if all tools have been released. |
| 1460 | |||
| 1461 | Set `touch-screen-events-received' to `t' to indicate that touch | ||
| 1462 | screen events have been received, and thus by extension require | ||
| 1463 | functions undertaking event management themselves to call | ||
| 1464 | `read-key' rather than `read-event'." | ||
| 1460 | (interactive "e\ni\np") | 1465 | (interactive "e\ni\np") |
| 1466 | (unless touch-screen-events-received | ||
| 1467 | (setq touch-screen-events-received t)) | ||
| 1461 | (if interactive | 1468 | (if interactive |
| 1462 | ;; Called interactively (probably from wid-edit.el.) | 1469 | ;; Called interactively (probably from wid-edit.el.) |
| 1463 | ;; Add any event generated to `unread-command-events'. | 1470 | ;; Add any event generated to `unread-command-events'. |
| @@ -1484,7 +1491,19 @@ the place of EVENT within the key sequence being translated, or | |||
| 1484 | (cancel-timer touch-screen-current-timer) | 1491 | (cancel-timer touch-screen-current-timer) |
| 1485 | (setq touch-screen-current-timer nil)) | 1492 | (setq touch-screen-current-timer nil)) |
| 1486 | ;; If a tool already exists... | 1493 | ;; If a tool already exists... |
| 1487 | (if touch-screen-current-tool | 1494 | (if (and touch-screen-current-tool |
| 1495 | ;; ..and the number of this tool is at variance with | ||
| 1496 | ;; that of the current tool: if a `touchscreen-end' | ||
| 1497 | ;; event is delivered that is somehow withheld from | ||
| 1498 | ;; this function and the system does not assign | ||
| 1499 | ;; monotonically increasing touch point identifiers, | ||
| 1500 | ;; then the ancillary tool will be set to a tool | ||
| 1501 | ;; bearing the same number as the current tool, and | ||
| 1502 | ;; consequently the mechanism for detecting | ||
| 1503 | ;; erroneously retained touch points upon the | ||
| 1504 | ;; registration of `touchscreen-update' events will | ||
| 1505 | ;; not be activated. | ||
| 1506 | (not (eq touchpoint (car touch-screen-current-tool)))) | ||
| 1488 | ;; Then record this tool as the ``auxiliary tool''. | 1507 | ;; Then record this tool as the ``auxiliary tool''. |
| 1489 | ;; Updates to the auxiliary tool are considered in unison | 1508 | ;; Updates to the auxiliary tool are considered in unison |
| 1490 | ;; with those to the current tool; the distance between | 1509 | ;; with those to the current tool; the distance between |