diff options
| author | Po Lu | 2023-07-16 15:30:01 +0800 |
|---|---|---|
| committer | Po Lu | 2023-07-16 15:30:01 +0800 |
| commit | 7b346b92b4c30c634d094e6162b65a22a52b93bb (patch) | |
| tree | b6a81b1e8b27c007205280750ff6ebbcf9ac7209 /src | |
| parent | d78d7aa78391c84e3d5536514d245d844c08d43d (diff) | |
| download | emacs-7b346b92b4c30c634d094e6162b65a22a52b93bb.tar.gz emacs-7b346b92b4c30c634d094e6162b65a22a52b93bb.zip | |
Improve touch-screen support
* doc/emacs/emacs.texi (Top):
* doc/emacs/input.texi (Other Input Devices): Correctly
capitalize subsection name.
(Touchscreens): Document additional translation.
* doc/lispref/commands.texi (Touchscreen Events): Document that
`touchscreen-end' events now have prefix keys. Also, describe
mouse emulation and `touchscreen-scroll' events.
* doc/lispref/keymaps.texi (Translation Keymaps): Document
`current-key-remap-sequence'.
* lisp/touch-screen.el (touch-screen-translate-prompt): New
function.
(touch-screen-scroll): New command. Bind to
`touchscreen-scroll'.
(touch-screen-handle-point-update, touch-screen-handle-point-up)
(touch-screen-handle-touch): Refactor to actually translate
touch screen event sequences, as opposed to looking up commands
and executing them.
(touch-screen-translate-touch): New function. Bind in
function-key-map to all touch screen events.
(touch-screen-drag-mode-line-1, touch-screen-drag-mode-line)
(touch-screen-tap-header-line): Remove special commands for
dragging the mode line and clicking on the header line.
* lisp/wid-edit.el (widget-button-click): Adjust accordingly.
* src/keyboard.c (access_keymap_keyremap): Bind
`current-key-remap-sequence' to the key sequence being remapped.
(keyremap_step): Give fkey->start and fkey->end to
access_keymap_keyremap.
(head_table): Add imaginary prefix to touchscreen-end events as
well.
(syms_of_keyboard): New variable Vcurrent_key_remap_sequence.
Diffstat (limited to 'src')
| -rw-r--r-- | src/keyboard.c | 39 |
1 files changed, 34 insertions, 5 deletions
diff --git a/src/keyboard.c b/src/keyboard.c index ea07c538aa2..e10128def13 100644 --- a/src/keyboard.c +++ b/src/keyboard.c | |||
| @@ -9994,13 +9994,18 @@ typedef struct keyremap | |||
| 9994 | If the mapping is a function and DO_FUNCALL is true, | 9994 | If the mapping is a function and DO_FUNCALL is true, |
| 9995 | the function is called with PROMPT as parameter and its return | 9995 | the function is called with PROMPT as parameter and its return |
| 9996 | value is used as the return value of this function (after checking | 9996 | value is used as the return value of this function (after checking |
| 9997 | that it is indeed a vector). */ | 9997 | that it is indeed a vector). |
| 9998 | |||
| 9999 | START and END are the indices of the first and last key of the | ||
| 10000 | sequence being remapped within the keyboard buffer KEYBUF. */ | ||
| 9998 | 10001 | ||
| 9999 | static Lisp_Object | 10002 | static Lisp_Object |
| 10000 | access_keymap_keyremap (Lisp_Object map, Lisp_Object key, Lisp_Object prompt, | 10003 | access_keymap_keyremap (Lisp_Object map, Lisp_Object key, Lisp_Object prompt, |
| 10001 | bool do_funcall) | 10004 | bool do_funcall, ptrdiff_t start, ptrdiff_t end, |
| 10005 | Lisp_Object *keybuf) | ||
| 10002 | { | 10006 | { |
| 10003 | Lisp_Object next; | 10007 | Lisp_Object next; |
| 10008 | specpdl_ref count; | ||
| 10004 | 10009 | ||
| 10005 | next = access_keymap (map, key, 1, 0, 1); | 10010 | next = access_keymap (map, key, 1, 0, 1); |
| 10006 | 10011 | ||
| @@ -10016,10 +10021,18 @@ access_keymap_keyremap (Lisp_Object map, Lisp_Object key, Lisp_Object prompt, | |||
| 10016 | its value instead. */ | 10021 | its value instead. */ |
| 10017 | if (do_funcall && FUNCTIONP (next)) | 10022 | if (do_funcall && FUNCTIONP (next)) |
| 10018 | { | 10023 | { |
| 10019 | Lisp_Object tem; | 10024 | Lisp_Object tem, remap; |
| 10020 | tem = next; | 10025 | tem = next; |
| 10021 | 10026 | ||
| 10022 | next = call1 (next, prompt); | 10027 | /* Build Vcurrent_key_remap_sequence. */ |
| 10028 | remap = Fvector (end - start + 1, keybuf + start); | ||
| 10029 | |||
| 10030 | /* Bind `current-key-remap-sequence' to the key sequence being | ||
| 10031 | remapped. */ | ||
| 10032 | count = SPECPDL_INDEX (); | ||
| 10033 | specbind (Qcurrent_key_remap_sequence, remap); | ||
| 10034 | next = unbind_to (count, call1 (next, prompt)); | ||
| 10035 | |||
| 10023 | /* If the function returned something invalid, | 10036 | /* If the function returned something invalid, |
| 10024 | barf--don't ignore it. */ | 10037 | barf--don't ignore it. */ |
| 10025 | if (! (NILP (next) || VECTORP (next) || STRINGP (next))) | 10038 | if (! (NILP (next) || VECTORP (next) || STRINGP (next))) |
| @@ -10044,11 +10057,17 @@ keyremap_step (Lisp_Object *keybuf, volatile keyremap *fkey, | |||
| 10044 | int input, bool doit, int *diff, Lisp_Object prompt) | 10057 | int input, bool doit, int *diff, Lisp_Object prompt) |
| 10045 | { | 10058 | { |
| 10046 | Lisp_Object next, key; | 10059 | Lisp_Object next, key; |
| 10060 | ptrdiff_t buf_start, buf_end; | ||
| 10061 | |||
| 10062 | /* Save the key sequence being translated. */ | ||
| 10063 | buf_start = fkey->start; | ||
| 10064 | buf_end = fkey->end; | ||
| 10047 | 10065 | ||
| 10048 | key = keybuf[fkey->end++]; | 10066 | key = keybuf[fkey->end++]; |
| 10049 | 10067 | ||
| 10050 | if (KEYMAPP (fkey->parent)) | 10068 | if (KEYMAPP (fkey->parent)) |
| 10051 | next = access_keymap_keyremap (fkey->map, key, prompt, doit); | 10069 | next = access_keymap_keyremap (fkey->map, key, prompt, doit, |
| 10070 | buf_start, buf_end, keybuf); | ||
| 10052 | else | 10071 | else |
| 10053 | next = Qnil; | 10072 | next = Qnil; |
| 10054 | 10073 | ||
| @@ -12479,6 +12498,7 @@ static const struct event_head head_table[] = { | |||
| 12479 | {SYMBOL_INDEX (Qselect_window), SYMBOL_INDEX (Qswitch_frame)}, | 12498 | {SYMBOL_INDEX (Qselect_window), SYMBOL_INDEX (Qswitch_frame)}, |
| 12480 | /* Touchscreen events should be prefixed by the posn. */ | 12499 | /* Touchscreen events should be prefixed by the posn. */ |
| 12481 | {SYMBOL_INDEX (Qtouchscreen_begin), SYMBOL_INDEX (Qtouchscreen)}, | 12500 | {SYMBOL_INDEX (Qtouchscreen_begin), SYMBOL_INDEX (Qtouchscreen)}, |
| 12501 | {SYMBOL_INDEX (Qtouchscreen_end), SYMBOL_INDEX (Qtouchscreen)}, | ||
| 12482 | }; | 12502 | }; |
| 12483 | 12503 | ||
| 12484 | static Lisp_Object | 12504 | static Lisp_Object |
| @@ -13575,6 +13595,15 @@ If non-nil, text conversion will continue to happen after a prefix | |||
| 13575 | key has been read inside `read-key-sequence'. */); | 13595 | key has been read inside `read-key-sequence'. */); |
| 13576 | disable_inhibit_text_conversion = false; | 13596 | disable_inhibit_text_conversion = false; |
| 13577 | 13597 | ||
| 13598 | DEFVAR_LISP ("current-key-remap-sequence", | ||
| 13599 | Vcurrent_key_remap_sequence, | ||
| 13600 | doc: /* The key sequence currently being remap, or nil. | ||
| 13601 | Bound to a vector containing the sub-sequence matching a binding | ||
| 13602 | within `input-decode-map' or `local-function-key-map' when its bound | ||
| 13603 | function is called to remap that sequence. */); | ||
| 13604 | Vcurrent_key_remap_sequence = Qnil; | ||
| 13605 | DEFSYM (Qcurrent_key_remap_sequence, "current-key-remap-sequence"); | ||
| 13606 | |||
| 13578 | pdumper_do_now_and_after_load (syms_of_keyboard_for_pdumper); | 13607 | pdumper_do_now_and_after_load (syms_of_keyboard_for_pdumper); |
| 13579 | } | 13608 | } |
| 13580 | 13609 | ||