Add `touch-end' event type

* etc/NEWS:
* doc/lispref/commands.texi (Misc Events): Document new
`touch-end' event type.

* lisp/bindings.el: Ignore touch-end events by default.

* src/keyboard.c (make_lispy_event): Add support for
TOUCH_END_EVENT events.
(syms_of_keyboard): New symbol `touch-end'.

* src/termhooks.h (enum event_kind): New member
`TOUCH_END_EVENT'.

* src/xterm.c (handle_one_xevent): Send touch-end events when
appropriate.
This commit is contained in:
Po Lu 2021-12-02 10:27:24 +08:00
parent a4ff841154
commit 5001f4f91b
6 changed files with 60 additions and 13 deletions

View file

@ -1992,6 +1992,13 @@ This kind of event indicates that the user deiconified @var{frame} using
the window manager. Its standard definition is @code{ignore}; since the
frame has already been made visible, Emacs has no work to do.
@cindex @code{touch-end} event
@item (touch-end (@var{position}))
This kind of event indicates that the user's finger moved off the
mouse wheel or the touchpad. The @var{position} element is a mouse
position list (@pxref{Click Events}), specifying the position of the
mouse cursor when the finger moved off the mouse wheel.
@cindex @code{wheel-up} event
@cindex @code{wheel-down} event
@item (wheel-up @var{position} @var{clicks} @var{lines} @var{pixel-delta})

View file

@ -758,6 +758,11 @@ property.
** New 'min-width' 'display' property.
This allows setting a minimum display width for a region of text.
+++
** New event type 'touch-end'.
This event is sent whenever the user's finger moves off the mouse
wheel on some mice, and when the user's finger moves off the touchpad.
** Keymaps and key definitions
+++

View file

@ -1261,6 +1261,8 @@ if `inhibit-field-text-motion' is non-nil."
;; (define-key global-map [kp-9] 'function-key-error)
;; (define-key global-map [kp-equal] 'function-key-error)
(define-key global-map [touch-end] 'ignore)
;; X11 distinguishes these keys from the non-kp keys.
;; Make them behave like the non-kp keys unless otherwise bound.
;; FIXME: rather than list such mappings for every modifier-combination,

View file

@ -5994,6 +5994,21 @@ make_lispy_event (struct input_event *event)
return list2 (head, position);
}
case TOUCH_END_EVENT:
{
Lisp_Object position;
/* Build the position as appropriate for this mouse click. */
struct frame *f = XFRAME (event->frame_or_window);
if (! FRAME_LIVE_P (f))
return Qnil;
position = make_lispy_position (f, event->x, event->y,
event->timestamp);
return list2 (Qtouch_end, position);
}
#ifdef USE_TOOLKIT_SCROLL_BARS
@ -11745,6 +11760,8 @@ syms_of_keyboard (void)
DEFSYM (Qfile_notify, "file-notify");
#endif /* USE_FILE_NOTIFY */
DEFSYM (Qtouch_end, "touch-end");
/* Menu and tool bar item parts. */
DEFSYM (QCenable, ":enable");
DEFSYM (QCvisible, ":visible");

View file

@ -267,6 +267,13 @@ enum event_kind
/* File or directory was changed. */
, FILE_NOTIFY_EVENT
#endif
/* Either the mouse wheel has been released without it being
clicked, or the user has lifted his finger from a touchpad.
In the future, this may take into account other multi-touch
events generated from touchscreens and such. */
, TOUCH_END_EVENT
};
/* Bit width of an enum event_kind tag at the start of structs and unions. */

View file

@ -10029,9 +10029,11 @@ handle_one_xevent (struct x_display_info *dpyinfo,
continue;
bool s = signbit (val->emacs_value);
inev.ie.kind = (val->horizontal
? HORIZ_WHEEL_EVENT
: WHEEL_EVENT);
inev.ie.kind = (delta != 0.0
? (val->horizontal
? HORIZ_WHEEL_EVENT
: WHEEL_EVENT)
: TOUCH_END_EVENT);
inev.ie.timestamp = xev->time;
XSETINT (inev.ie.x, lrint (xev->event_x));
@ -10048,19 +10050,26 @@ handle_one_xevent (struct x_display_info *dpyinfo,
if (NUMBERP (Vx_scroll_event_delta_factor))
scroll_unit *= XFLOATINT (Vx_scroll_event_delta_factor);
if (val->horizontal)
if (delta != 0.0)
{
inev.ie.arg
= list3 (Qnil,
make_float (val->emacs_value
* scroll_unit),
make_float (0));
if (val->horizontal)
{
inev.ie.arg
= list3 (Qnil,
make_float (val->emacs_value
* scroll_unit),
make_float (0));
}
else
{
inev.ie.arg = list3 (Qnil, make_float (0),
make_float (val->emacs_value
* scroll_unit));
}
}
else
else
{
inev.ie.arg = list3 (Qnil, make_float (0),
make_float (val->emacs_value
* scroll_unit));
inev.ie.arg = Qnil;
}
kbd_buffer_store_event_hold (&inev.ie, hold_quit);