From: Po Lu Date: Thu, 2 Dec 2021 02:27:24 +0000 (+0800) Subject: Add `touch-end' event type X-Git-Tag: emacs-29.0.90~3629^2~9 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=5001f4f91b9a959ddc345de36153689174df67a9;p=emacs.git 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. --- diff --git a/doc/lispref/commands.texi b/doc/lispref/commands.texi index 073cdd8aa7b..cc1c216d578 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 f1f1512a672..d783fc019cf 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 e28b06a1dcd..578406dd988 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 b3e6e5029be..899c9109c20 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 1cf9863f3a1..f64c19e0397 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 d633953018c..fe26e41421f 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);