Commit graph

73 commits

Author SHA1 Message Date
Po Lu
94fe5894d9 ; * lisp/touch-screen.el: Correct commentary. 2024-08-03 08:14:59 +08:00
Stefan Kangas
4643672078 Checkdoc fixes in touch-screen.el
* lisp/touch-screen.el (touch-screen-handle-touch): Checkdoc fixes.
2024-07-18 09:49:23 +02:00
Po Lu
60b38c317b * lisp/touch-screen.el (touch-screen-inhibit-drag): Another typo. 2024-06-25 12:52:56 +08:00
Po Lu
0e43606b20 * lisp/touch-screen.el (touch-screen-inhibit-drag): Fix typo. 2024-06-25 12:27:08 +08:00
Andrea Corallo
a5a374014f * lisp/touch-screen.el (touch-screen-inhibit-drag): Fix 'not' arity use. 2024-06-17 15:42:24 +02:00
Po Lu
6aa5068ac7 Improve treatment of touch screen input by rmc and its callers
* lisp/emacs-lisp/rmc.el (read-multiple-choice--short-answers):
Run touch screen event translation on touch screen events
received, and respond to pinch, tap and scrolling gestures.

* lisp/net/nsm.el (nsm-query-user): Disable use-dialog-box in
the details window.

* lisp/touch-screen.el (touch-screen-translate-touch): Autoload.
2024-06-17 17:45:48 +08:00
Po Lu
4fa38af7c2 Remove touchscreen pinch event generation threshold
* lisp/touch-screen.el (touch-screen-handle-aux-point-update):
Remove the said threshold.
2024-06-08 15:18:27 +08:00
Po Lu
7af5d6fc9a Improve touch-screen support on PGTK
* lisp/touch-screen.el (touch-screen-translate-touch): Do not
prepend posn if the symbol is such that keyboard.c will do so
immediately after returning.

* src/pgtkterm.c (pgtk_toolkit_position): Remove mistakenly
ported code.
(pgtk_create_terminal): Remove toolkit_position hook.
(motion_notify_event, button_event): Ignore emulated pointer
events, and apply an additional test to circumvent a GDK
oversight.
(touch_event_cb): Correct return type, and provide touch
sequence initialization and removal events as
`last_click_event's.
2024-06-01 21:33:19 +08:00
Po Lu
2b7056db42 Implement touch screen events on PGTK
* etc/NEWS: Better qualify entry for touch screen events.

* lisp/loadup.el (featurep 'pgtk): Load touch-screen.el.

* lisp/touch-screen.el: Revise list of systems where touch
screen events are reported.

* src/gtkutil.c (xg_create_frame_widgets): Request
GDK_TOUCH_MASK.

* src/pgtkfns.c (pgtk_frame_parm_handlers, tip_window): Pacify
compiler warning.

* src/pgtkterm.c (pgtk_free_frame_resources): Free touch points
linked to this frame.
(pgtk_link_touch_point, pgtk_unlink_touch_point)
(pgtk_unlink_touch_points, pgtk_find_touch_point): New
functions, ported from X.
(touch_event_cb): New event callback.
(pgtk_set_event_handler): Register `touch_event_cb' as handler
for `touch-event'.
(pgtk_delete_display): Free residual touch points on this
display.

* src/pgtkterm.h (struct pgtk_touch_point): New structure.
(struct pgtk_display_info) <touchpoints>: New field.
2024-06-01 15:41:54 +08:00
Po Lu
1ebb9cb93b Don't set text scale to fractional values in touch-screen-pinch
* lisp/touch-screen.el (touch-screen-pinch): Take floor of
computed scale.
2024-05-30 21:31:50 +08:00
Po Lu
54dbd8b4fa 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.
2024-05-01 15:57:29 +08:00
Eli Zaretskii
f6ae5939b9 ; Fix documentation of recent commits.
* lisp/touch-screen.el (touch-screen-handle-point-up): Fix
comments.

* lisp/net/eww.el (eww-check-text-conversion, eww-select-file)
(eww-toggle-checkbox, eww-submit): Doc fixes.

* doc/emacs/input.texi (On-Screen Keyboards): Fix punctuation and
wording.
2024-04-29 15:32:12 +03:00
Po Lu
4c46066cb6 Adapt eww to touch screens, mice and text conversion
* doc/emacs/input.texi (On-Screen Keyboards): Update conditions
for displaying the virtual keyboard when t-s-d-k is enabled.

* etc/NEWS (Announce): Document changes.

* lisp/net/eww.el (eww-check-text-conversion): New function.
(eww-mode): Install it as a local post-command-hook.
(eww-submit-map, eww-submit-file, eww-checkbox-map): Bind
suitable commands to mouse-2.
(eww-form-submit, eww-form-checkbox, eww-form-file)
(eww-tag-select): Disguise inserted forms as buttons, that touch
event translation may prefer their bindings to mouse-2 over
mouse-1.
(eww-form-text, eww-tag-textarea): Insert field properties as
well.
(eww-select-file, eww-toggle-checkbox, eww-submit): New argument
EVENT, to whose position point is set.

* lisp/touch-screen.el (touch-screen-handle-point-up): Trivial
adjustments to the criteria for selecting mouse commands and
displaying the on screen keyboard.
2024-04-29 20:01:59 +08:00
Po Lu
d3d1be8ae5 Miscellaneous fixes for Android port
* lisp/touch-screen.el (touch-screen-hold, touch-screen-drag):
Clear deactivate-mark if the mark is activated to prevent undue
deactivation after completion.

* lisp/wid-edit.el (widget-field, widget-single-line-field):
Insert specifications suitable for monochrome displays.

* src/androidfns.c (Fxw_display_color_p, Fx_display_grayscale_p):
Report color and/or grayscale properly.

* src/image.c (image_create_bitmap_from_file)
[HAVE_ANDROID]: If a file with no extension cannot be located,
append .xbm and retry.
2024-04-24 11:42:48 +08:00
Po Lu
64eb4ce0af Improve treatment of aborted touch events in Speedbar and elsewhere
* lisp/dframe.el (dframe-popup-kludge): Mark as a
mouse-1-menu-command.

* lisp/touch-screen.el (touch-screen-handle-point-up): New
argument CANCELED.  Implement specific responses to cancellation
for each tool state.
(touch-screen-handle-touch): Adjust to match.
2024-04-09 10:39:36 +08:00
Po Lu
1db2255c7c * lisp/touch-screen.el (touch-screen): Fix defgroup version. 2024-02-08 13:20:28 +08:00
Stefan Kangas
9364c28959 ; Fix typos in symbol names 2024-01-21 15:28:06 +01:00
Po Lu
070cb32463 ; Add 2024 to copyright years 2024-01-02 10:30:05 +08:00
Stefan Kangas
06a12b0ccc ; Fix typos 2023-12-10 13:22:04 +01:00
Po Lu
451e00e786 ; Fix compiler warnings
* lisp/tab-bar.el (touch-screen-delay):

* lisp/tab-line.el (touch-screen-delay): Declare variables.

* lisp/touch-screen.el (touch-screen-hold): Autoload.
2023-12-07 13:14:51 +08:00
Po Lu
d8a0087930 Cease preloading touch-screen.el outside X and Android
* lisp/calc/calc.el (touch-screen-display-keyboard):

* lisp/minibuffer.el (clear-minibuffer-message):

* lisp/term.el (touch-screen-display-keyboard): Declare
touch-screen-display-keyboard before binding or setting it.

* lisp/loadup.el: Don't autoload touch-screen.el outside X and
Android.

* lisp/touch-screen.el: Autoload functions called from commands
responding to touch screen events.
2023-12-06 10:34:41 +08:00
Po Lu
0858d10aeb 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.
2023-11-24 10:39:49 +08:00
Po Lu
f50e54c01e ; * lisp/touch-screen.el (touch-screen-handle-touch): Correct typo. 2023-11-22 11:25:23 +08:00
Po Lu
148250f074 Update touch-screen.el
* lisp/touch-screen.el (touch-screen-handle-aux-point-update):
Wrap exceptionally wide form.
(touch-screen-handle-touch): Guarantee that only tools from the
same frame as the current tool will be considered ancillary
tools.  Further guarantee that normal gesture translation can
resume even if a touchscreen-end event is omitted or overlooked.
2023-11-22 11:10:13 +08:00
Po Lu
7751ef3a32 Properly avoid displaying the OSK for calls to read-key-sequence
* lisp/touch-screen.el (touch-screen-handle-point-up): If prompt
is set, throw the input event rather than execute its command.
2023-11-19 11:38:02 +08:00
Po Lu
7d6896253b Correct initial scale calculation when pinching nonselected window
* lisp/touch-screen.el (touch-screen-pinch): Retrieve present
scale within the window pinched.
(touch-screen-handle-point-update): Expunge inefficacious code
meant to disregard events sent during gesture navigation.
2023-11-17 11:36:58 +08:00
Po Lu
643c7fc851 Correct generation of touchscreen-pinch events
* lisp/touch-screen.el (touch-screen-pinch): Check that posn-x-y
is available before scrolling to it.
(touch-screen-handle-aux-point-update): Don't provide posns for
windows besides the window where the touch sequence started in
touchscreen-pinch events.
2023-11-17 11:16:23 +08:00
Po Lu
ef6622bf04 Disable generation of mouse-1 events after ancillary tool presses
* lisp/touch-screen.el (touch-screen-handle-scroll): Correct
typo in comment.
(touch-screen-handle-point-update): Attempt to detect scroll
gestures and the like also when what is ancillary-tool.
(touch-screen-handle-point-up): Don't needlessly compute
relative xy when transforming aux tool into current tool.
(touch-screen-handle-touch): Set what field to ancillary-tool
rather than clear it when initializing the ancillary tool,
indicating to t-s-h-p-u that it must not generate mouse up
events.
2023-11-16 21:07:01 +08:00
Po Lu
076c5f1f17 Don't pan horizontally when a pinch gesture represents a shrink
* lisp/touch-screen.el (touch-screen-pinch): Don't pan left if
the event represents a shrink.
2023-11-16 17:39:14 +08:00
Po Lu
d03677343e Pan during touch screen pinch gestures
* doc/lispref/commands.texi (Touchscreen Events): Document new
ratio-diff parameter to touchscreen-pinch events.

* lisp/completion-preview.el (completion-preview-commands):
Account text-conversion events preview commands as well.

* lisp/touch-screen.el (touch-screen-aux-tool): Introduce two
new elements.
(touch-screen-pinch): Scroll window in accord with event deltas.
(touch-screen-handle-aux-point-update): Supply the ratio
difference in generated events.
(touch-screen-handle-touch): Create a vector with those two new
elements.
2023-11-16 11:29:58 +08:00
Po Lu
a9a8d5e959 Register ``pinch to zoom'' touch screen gestures
* doc/emacs/input.texi (Touchscreens): Address pinch gestures.

* doc/lispref/commands.texi (Touchscreen Events): Address touch
screen pinch events and the process by which they are produced.

* java/org/gnu/emacs/EmacsWindow.java (figureChange)
<ACTION_POINTER_DOWN>: Supply pointer index to getX and getY,
correcting a mistake where the first touch point's coordinate
was saved here in lieu of the pointer that was pressed's.

* lisp/touch-screen.el (touch-screen-current-tool): Revise doc
string.
(touch-screen-aux-tool): New variable.
(touch-screen-scroll-point-to-y, touch-screen-pinch): New
functions.
(global-map): Bind [touchscreen-pinch] to touch-screen-pinch.
(touch-screen-handle-point-update): Revise doc string; set new
tenth field of t-s-c-t to POINT relative to its window, without
regard to whether an event has been sent.
(touch-screen-distance, touch-screen-centrum): New functions.
(touch-screen-handle-aux-point-update): New function; generate
and send touchscreen-pinch if need be.
(touch-screen-handle-point-up): If an ancillary tool exists,
transfer the information there into touch-screen-current-tool
and clear t-s-a-t.
(touch-screen-handle-touch): Call t-s-a-p-u as is proper; set
t-s-a-t if a touchscreen-down event arrives and t-s-c-t is set.

* src/androidterm.c (handle_one_android_event): Properly save
the event's X and Y when a new touch point is registered.
2023-11-15 21:07:14 +08:00
Po Lu
4594250814 ; * lisp/touch-screen.el (touch-screen-track-tap): Fix typo. 2023-11-11 18:05:35 +08:00
Po Lu
68b8df57c7 Enable canceling tap gestures
* doc/lispref/commands.texi (Touchscreen Events): Relate new
THRESHOLD argument to touch-screen-track-tap.

* lisp/button.el (push-button):

* lisp/wid-edit.el (widget-button--check-and-call-button):
Provide a threshold to enable canceling button presses.

* lisp/touch-screen.el (touch-screen-track-tap): Enable
canceling tap gestures and resuming touch sequence translation
if the touch point exceeds a set threshold.
2023-11-11 18:04:00 +08:00
Po Lu
4bf6f8d997 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.
2023-10-24 21:12:32 +08:00
Po Lu
ad2bb3e9f3 Properly translate touch screen events into mouse drag ones
* doc/lispref/commands.texi (Drag Events): Correct misleading
example form and reword subsequent elaboration.

* lisp/touch-screen.el (touch-screen-handle-point-up)
<mouse-drag>: Set posns representing drag start and terminus to
mouse position lists, in lieu of pairs between windows and posns
employed previously.
2023-10-02 15:38:30 +08:00
Po Lu
dc1ed3dbfa Update Android port
* lisp/touch-screen.el (touch-screen-handle-point-up) <held>:
Treat `held' as `drag' as well.

* src/android.c (android_is_special_directory): Return bool
rather than a pointer to the remainder of the file name, given
that said pointer is never used.

* src/android.h (android_is_special_directory): Modify
correspondingly.
2023-09-02 09:30:05 +08:00
Po Lu
6913612def Display the OSK after touch screen drag-to-select
* lisp/touch-screen.el (touch-screen-handle-point-up) <drag>:
New case.  Activate the on screen keyboard should the window
where the first touch screen event landed have selected a
writable buffer in which the region is active.
2023-09-01 14:50:49 +08:00
Po Lu
cca14e0253 Correct touch screen event translation
* lisp/touch-screen.el (touch-screen-handle-point-up)
<mouse-drag>: Provide for situations where both the old and new
posns land on a special area of the window by comparing their
nominal row, column, and area.
2023-08-14 16:45:44 +08:00
Po Lu
3ab81aa5fb Try harder to keep the initial word selected
* lisp/touch-screen.el (touch-screen-drag): If
touch-screen-word-select, also keep the initial word within the
region while scrolling.
2023-07-22 20:09:54 +08:00
Po Lu
c81bd0f60b Update Android port
* doc/lispref/commands.texi (Key Sequence Input): Describe which
events receive imaginary prefix keys.
* lisp/touch-screen.el (touch-screen-translate-touch): Consider
`vertical-line' a virtual function key.
(function-key-map): Translate events on vertical window borders.
2023-07-22 10:45:36 +08:00
Po Lu
ae174f266d Improve touch screen and text conversion behavior of many commands
* doc/lispref/commands.texi (Key Sequence Input): Document new
argument to `read-key-sequence' etc.
* lisp/help-macro.el (make-help-screen):
* lisp/subr.el (read-key, read-char-choice-with-read-key):
Disable text conversion and display the OSK before reading a key
sequence.
* lisp/touch-screen.el (touch-screen-window-selection-changed):
Only cancel the minibuffer OSK timer.
(touch-screen-handle-point-up): Update comment accordingly.
* src/keyboard.c (command_loop_1, read_menu_command)
(read_key_sequence, read_key_sequence_vs, Fread_key_sequence)
(Fread_key_sequence_vector): New arg DISABLE_TEXT_CONVERSION.
All callers changed.
2023-07-21 21:23:35 +08:00
Po Lu
2df3f89014 Correctly translate touchscreen-up events outside a frame
* lisp/touch-screen.el (touch-screen-translate-touch): Check if
a prefix is specified separately from prefix being non-nil.
Accept `nil' as an imaginary prefix key.
(function-key-map): Register translation functions on the tab
bar, tab lines and internal border.
2023-07-21 15:20:45 +08:00
Po Lu
5d89602e29 Improve touch screen scrolling support
* lisp/touch-screen.el (touch-screen-preview-select): Avoid
unnecessary redisplays.
(touch-screen-drag): Scroll at window margins using window
scrolling functions instead of relying on redisplay to recenter
the window around point.
2023-07-21 14:22:54 +08:00
Po Lu
e1761019a9 Update Android port
* doc/emacs/input.texi (Touchscreens): Document
`touch-screen-preview-select'.
* doc/lispref/commands.texi (Touchscreen Events): Fix typo in
the descriptions of two touch screen events.
* lisp/dired.el (dired-insert-set-properties): Adjust for
changes to file end computation.
* lisp/minibuffer.el (clear-minibuffer-message): Don't clear
minibuffer message if dragging.
* lisp/touch-screen.el (touch-screen-current-tool): Fix doc
string.
(touch-screen-preview-select): New function.
(touch-screen-drag): Call it if point changes.
2023-07-21 12:23:08 +08:00
Po Lu
b5121503e4 Update Android port
* lisp/touch-screen.el (touch-screen-handle-touch): Don't
restart dragging if point is at ZV and the tap falls on a
different row.
2023-07-20 12:48:37 +08:00
Po Lu
882e1d659f Introduce a `dired-click-select' mode
* doc/emacs/dired.texi (Marks vs Flags): Document command bound
to `touchscreen-hold'.
* doc/lispref/commands.texi (Touchscreen Events): Describe
`touch-screen-inhibit-drag'.
* etc/NEWS: Improve description of changes to touch screen
support.
* lisp/dired-aux.el (dired-do-chxxx, dired-do-chmod)
(dired-do-print, dired-do-shell-command, dired-do-compress-to)
(dired-do-create-files, dired-do-rename, dired-do-isearch)
(dired-do-isearch-regexp, dired-do-search)
(dired-do-query-replace-regexp, dired-do-find-regexp)
(dired-vc-next-action): Disable ``click to select'' after
running this command.
* lisp/dired.el (dired-insert-set-properties): Attach
click-to-select keymap to file names if necessary.
(dired-mode-map): Bind `touchscreen-hold' to click to select
mode.
(dired-post-do-command): New function.
(dired-do-delete): Call it.
(dired-mark-for-click, dired-enable-click-to-select-mode): New
functions.
(dired-click-to-select-mode): New minor mode.
* lisp/touch-screen.el (touch-screen-current-tool): Fix doc
string.
(touch-screen-inhibit-drag): New function.
2023-07-20 09:22:41 +08:00
Po Lu
b3054d69d8 Improve behavior of `restart-drag'
* lisp/touch-screen.el (touch-screen-handle-point-up): If what
is `restart-drag' (meaning that a drag has been restarted but
the touchpoint has not moved), translate the release into a
regular mouse click to deactivate the region.
2023-07-19 14:42:02 +08:00
Po Lu
db48c88e7e Update Android port
* build-aux/makecounter.sh (curcount): Rename `counter' to
`emacs_shortlisp_counter'.
* doc/emacs/input.texi (Touchscreens): Document
`touch-screen-extend-selection'.
* doc/lispref/commands.texi (Touchscreen Events): Document
`touchscreen-restart-drag'.
* lisp/touch-screen.el (touch-screen-extend-selection): New user
option.
(touch-screen-restart-drag): New function.
(touch-screen-handle-point-update): Handle `restart-drag'
gestures.
(touch-screen-handle-touch): Check if the prerequisites for
extending a previous drag gesture are met, and generate such
events if so.
(touch-screen-translate-touch): Update doc string.
* src/Makefile.in (otherobj): Remove BUILD_COUNTER_OBJ.
($(lispsource)/international/charprop.el):
(%.elc): Don't depend on bootstrap-emacs if cross configuring
for Android.
(libemacs.so): Directly depend on and link with
BUILD_COUNTER_OBJ.
2023-07-19 12:46:02 +08:00
Po Lu
f13c0464cc Fix typos in touch-screen.el
* lisp/touch-screen.el (touch-screen-handle-point-update)
(touch-screen-handle-point-up): Fix typos.
2023-07-18 22:01:17 +08:00
Po Lu
cf50cd99ce * lisp/touch-screen.el (touch-screen-handle-point-update): Fix typo. 2023-07-18 15:46:07 +08:00