1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2026-01-04 11:00:45 -08:00

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
This commit is contained in:
Po Lu 2021-11-25 11:01:19 +08:00
parent 82233c2c1d
commit e37eb7f5c6
2 changed files with 20 additions and 6 deletions

View file

@ -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. */

View file

@ -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;
}