]> git.eshelyaron.com Git - emacs.git/commitdiff
Add `touch-end' event type
authorPo Lu <luangruo@yahoo.com>
Thu, 2 Dec 2021 02:27:24 +0000 (10:27 +0800)
committerPo Lu <luangruo@yahoo.com>
Thu, 2 Dec 2021 02:27:24 +0000 (10:27 +0800)
* 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
etc/NEWS
lisp/bindings.el
src/keyboard.c
src/termhooks.h
src/xterm.c

index 073cdd8aa7ba428230a2ce77166796ef5f2838f1..cc1c216d578c0d9aaf24428d51c49fe78311f5e4 100644 (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})
index f1f1512a672bf5f9e7e1bb2aa107fa8de2a5614b..d783fc019cf1d92f73f37106993683a37dbb33b1 100644 (file)
--- 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
 
 +++
index e28b06a1dcd924551d74ad9ee02b831d8577c460..578406dd988b2a31d43051d89aa7292f30191c2a 100644 (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,
index b3e6e5029bea7b6600c6f6e605e85f0de29d1372..899c9109c2038308bcb6258fc501a8ae4d11f2ba 100644 (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");
index 1cf9863f3a13cab83b44ab74eed4662d03c623ad..f64c19e0397eea4051b373388d9c17045d5b96c7 100644 (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.  */
index d633953018c25849f0c21eef20064ef1a2b7de37..fe26e41421ff887ecb70657f2c709fe63d7cd670 100644 (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);