[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master 5001f4f: Add `touch-end' event type
From: |
Po Lu |
Subject: |
master 5001f4f: Add `touch-end' event type |
Date: |
Wed, 1 Dec 2021 21:30:13 -0500 (EST) |
branch: master
commit 5001f4f91b9a959ddc345de36153689174df67a9
Author: Po Lu <luangruo@yahoo.com>
Commit: Po Lu <luangruo@yahoo.com>
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.
---
doc/lispref/commands.texi | 7 +++++++
etc/NEWS | 5 +++++
lisp/bindings.el | 2 ++
src/keyboard.c | 17 +++++++++++++++++
src/termhooks.h | 7 +++++++
src/xterm.c | 35 ++++++++++++++++++++++-------------
6 files changed, 60 insertions(+), 13 deletions(-)
diff --git a/doc/lispref/commands.texi b/doc/lispref/commands.texi
index 073cdd8..cc1c216 100644
--- a/doc/lispref/commands.texi
+++ b/doc/lispref/commands.texi
@@ -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})
diff --git a/etc/NEWS b/etc/NEWS
index f1f1512..d783fc0 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -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
+++
diff --git a/lisp/bindings.el b/lisp/bindings.el
index e28b06a..578406d 100644
--- a/lisp/bindings.el
+++ b/lisp/bindings.el
@@ -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,
diff --git a/src/keyboard.c b/src/keyboard.c
index b3e6e50..899c910 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -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");
diff --git a/src/termhooks.h b/src/termhooks.h
index 1cf9863..f64c19e 100644
--- a/src/termhooks.h
+++ b/src/termhooks.h
@@ -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. */
diff --git a/src/xterm.c b/src/xterm.c
index d633953..fe26e41 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -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);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- master 5001f4f: Add `touch-end' event type,
Po Lu <=