emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master e37eb7f: Add support for pixel wheel deltas on NS


From: Po Lu
Subject: master e37eb7f: Add support for pixel wheel deltas on NS
Date: Wed, 24 Nov 2021 22:09:23 -0500 (EST)

branch: master
commit e37eb7f5c67f7da2c78688eda8968562fe75b767
Author: Po Lu <luangruo@yahoo.com>
Commit: Po Lu <luangruo@yahoo.com>

    Add support for pixel wheel deltas on NS
    
    * src/xterm.c (x_coalesce_scroll_events): Update doc string.
    * src/nsterm.c (- mouseDown): Report pixel scroll deltas.
    (x_coalesce_scroll_events): New variable
---
 src/nsterm.m | 24 +++++++++++++++++++-----
 src/xterm.c  |  2 +-
 2 files changed, 20 insertions(+), 6 deletions(-)

diff --git a/src/nsterm.m b/src/nsterm.m
index e29dda6..17f5b98 100644
--- a/src/nsterm.m
+++ b/src/nsterm.m
@@ -6529,6 +6529,7 @@ not_in_argv (NSString *arg)
 {
   struct ns_display_info *dpyinfo = FRAME_DISPLAY_INFO (emacsframe);
   NSPoint p = [self convertPoint: [theEvent locationInWindow] fromView: nil];
+  int x = 0, y = 0;
 
   NSTRACE ("[EmacsView mouseDown:]");
 
@@ -6595,22 +6596,26 @@ not_in_argv (NSString *arg)
                * reset the total delta for the direction we're NOT
                * scrolling so that small movements don't add up.  */
               if (abs (totalDeltaX) > abs (totalDeltaY)
-                  && abs (totalDeltaX) > lineHeight)
+                  && (!x_coalesce_scroll_events
+                     || abs (totalDeltaX) > lineHeight))
                 {
                   horizontal = YES;
                   scrollUp = totalDeltaX > 0;
 
                   lines = abs (totalDeltaX / lineHeight);
-                  totalDeltaX = totalDeltaX % lineHeight;
+                 x = totalDeltaX;
+                 totalDeltaX = totalDeltaX % lineHeight;
                   totalDeltaY = 0;
                 }
               else if (abs (totalDeltaY) >= abs (totalDeltaX)
-                       && abs (totalDeltaY) > lineHeight)
+                       && (!x_coalesce_scroll_events
+                          || abs (totalDeltaY) > lineHeight))
                 {
                   horizontal = NO;
                   scrollUp = totalDeltaY > 0;
 
                   lines = abs (totalDeltaY / lineHeight);
+                 y = totalDeltaY;
                   totalDeltaY = totalDeltaY % lineHeight;
                   totalDeltaX = 0;
                 }
@@ -6637,13 +6642,17 @@ not_in_argv (NSString *arg)
                 ? ceil (fabs (delta)) : 1;
 
               scrollUp = delta > 0;
+             x = [theEvent scrollingDeltaX];
+             y = [theEvent scrollingDeltaY];
             }
 
-          if (lines == 0)
+          if (lines == 0 && x_coalesce_scroll_events)
             return;
 
           emacs_event->kind = horizontal ? HORIZ_WHEEL_EVENT : WHEEL_EVENT;
-          emacs_event->arg = (make_fixnum (lines));
+          emacs_event->arg = list3 (make_fixnum (lines),
+                                   make_float (x),
+                                   make_float (y));
 
           emacs_event->code = 0;
           emacs_event->modifiers = EV_MODIFIERS (theEvent) |
@@ -10005,6 +10014,11 @@ This variable is ignored on macOS < 10.7 and GNUstep.  
Default is t.  */);
               x_underline_at_descent_line,
      doc: /* SKIP: real doc in xterm.c.  */);
   x_underline_at_descent_line = 0;
+
+  DEFVAR_BOOL ("x-coalesce-scroll-events", x_coalesce_scroll_events,
+              doc: /* SKIP: real doc in xterm.c.  */);
+  x_coalesce_scroll_events = true;
+
   DEFSYM (Qx_underline_at_descent_line, "x-underline-at-descent-line");
 
   /* Tell Emacs about this window system.  */
diff --git a/src/xterm.c b/src/xterm.c
index 7e0d587..346cd0c 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -15165,6 +15165,6 @@ always uses gtk_window_move and ignores the value of 
this variable.  */);
               doc: /* Non-nil means send a wheel event only for scrolling at 
least one screen line.
 Otherwise, a wheel event will be sent every time the mouse wheel is
 moved.  This option is only effective when Emacs is built with XInput
-2 or with Haiku windowing support.  */);
+2, with Haiku windowing support, or with NS.  */);
   x_coalesce_scroll_events = true;
 }



reply via email to

[Prev in Thread] Current Thread [Next in Thread]