diff options
| author | Po Lu | 2021-11-25 11:01:19 +0800 |
|---|---|---|
| committer | Po Lu | 2021-11-25 11:09:08 +0800 |
| commit | e37eb7f5c67f7da2c78688eda8968562fe75b767 (patch) | |
| tree | 38da4d85725f3da400765a2dd0d97997c64394f4 | |
| parent | 82233c2c1dcf0c55cb56a65499e57a69a25f47bf (diff) | |
| download | emacs-e37eb7f5c67f7da2c78688eda8968562fe75b767.tar.gz emacs-e37eb7f5c67f7da2c78688eda8968562fe75b767.zip | |
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
| -rw-r--r-- | src/nsterm.m | 24 | ||||
| -rw-r--r-- | src/xterm.c | 2 |
2 files changed, 20 insertions, 6 deletions
diff --git a/src/nsterm.m b/src/nsterm.m index e29dda684a0..17f5b98c571 100644 --- a/src/nsterm.m +++ b/src/nsterm.m | |||
| @@ -6529,6 +6529,7 @@ not_in_argv (NSString *arg) | |||
| 6529 | { | 6529 | { |
| 6530 | struct ns_display_info *dpyinfo = FRAME_DISPLAY_INFO (emacsframe); | 6530 | struct ns_display_info *dpyinfo = FRAME_DISPLAY_INFO (emacsframe); |
| 6531 | NSPoint p = [self convertPoint: [theEvent locationInWindow] fromView: nil]; | 6531 | NSPoint p = [self convertPoint: [theEvent locationInWindow] fromView: nil]; |
| 6532 | int x = 0, y = 0; | ||
| 6532 | 6533 | ||
| 6533 | NSTRACE ("[EmacsView mouseDown:]"); | 6534 | NSTRACE ("[EmacsView mouseDown:]"); |
| 6534 | 6535 | ||
| @@ -6595,22 +6596,26 @@ not_in_argv (NSString *arg) | |||
| 6595 | * reset the total delta for the direction we're NOT | 6596 | * reset the total delta for the direction we're NOT |
| 6596 | * scrolling so that small movements don't add up. */ | 6597 | * scrolling so that small movements don't add up. */ |
| 6597 | if (abs (totalDeltaX) > abs (totalDeltaY) | 6598 | if (abs (totalDeltaX) > abs (totalDeltaY) |
| 6598 | && abs (totalDeltaX) > lineHeight) | 6599 | && (!x_coalesce_scroll_events |
| 6600 | || abs (totalDeltaX) > lineHeight)) | ||
| 6599 | { | 6601 | { |
| 6600 | horizontal = YES; | 6602 | horizontal = YES; |
| 6601 | scrollUp = totalDeltaX > 0; | 6603 | scrollUp = totalDeltaX > 0; |
| 6602 | 6604 | ||
| 6603 | lines = abs (totalDeltaX / lineHeight); | 6605 | lines = abs (totalDeltaX / lineHeight); |
| 6604 | totalDeltaX = totalDeltaX % lineHeight; | 6606 | x = totalDeltaX; |
| 6607 | totalDeltaX = totalDeltaX % lineHeight; | ||
| 6605 | totalDeltaY = 0; | 6608 | totalDeltaY = 0; |
| 6606 | } | 6609 | } |
| 6607 | else if (abs (totalDeltaY) >= abs (totalDeltaX) | 6610 | else if (abs (totalDeltaY) >= abs (totalDeltaX) |
| 6608 | && abs (totalDeltaY) > lineHeight) | 6611 | && (!x_coalesce_scroll_events |
| 6612 | || abs (totalDeltaY) > lineHeight)) | ||
| 6609 | { | 6613 | { |
| 6610 | horizontal = NO; | 6614 | horizontal = NO; |
| 6611 | scrollUp = totalDeltaY > 0; | 6615 | scrollUp = totalDeltaY > 0; |
| 6612 | 6616 | ||
| 6613 | lines = abs (totalDeltaY / lineHeight); | 6617 | lines = abs (totalDeltaY / lineHeight); |
| 6618 | y = totalDeltaY; | ||
| 6614 | totalDeltaY = totalDeltaY % lineHeight; | 6619 | totalDeltaY = totalDeltaY % lineHeight; |
| 6615 | totalDeltaX = 0; | 6620 | totalDeltaX = 0; |
| 6616 | } | 6621 | } |
| @@ -6637,13 +6642,17 @@ not_in_argv (NSString *arg) | |||
| 6637 | ? ceil (fabs (delta)) : 1; | 6642 | ? ceil (fabs (delta)) : 1; |
| 6638 | 6643 | ||
| 6639 | scrollUp = delta > 0; | 6644 | scrollUp = delta > 0; |
| 6645 | x = [theEvent scrollingDeltaX]; | ||
| 6646 | y = [theEvent scrollingDeltaY]; | ||
| 6640 | } | 6647 | } |
| 6641 | 6648 | ||
| 6642 | if (lines == 0) | 6649 | if (lines == 0 && x_coalesce_scroll_events) |
| 6643 | return; | 6650 | return; |
| 6644 | 6651 | ||
| 6645 | emacs_event->kind = horizontal ? HORIZ_WHEEL_EVENT : WHEEL_EVENT; | 6652 | emacs_event->kind = horizontal ? HORIZ_WHEEL_EVENT : WHEEL_EVENT; |
| 6646 | emacs_event->arg = (make_fixnum (lines)); | 6653 | emacs_event->arg = list3 (make_fixnum (lines), |
| 6654 | make_float (x), | ||
| 6655 | make_float (y)); | ||
| 6647 | 6656 | ||
| 6648 | emacs_event->code = 0; | 6657 | emacs_event->code = 0; |
| 6649 | emacs_event->modifiers = EV_MODIFIERS (theEvent) | | 6658 | emacs_event->modifiers = EV_MODIFIERS (theEvent) | |
| @@ -10005,6 +10014,11 @@ This variable is ignored on macOS < 10.7 and GNUstep. Default is t. */); | |||
| 10005 | x_underline_at_descent_line, | 10014 | x_underline_at_descent_line, |
| 10006 | doc: /* SKIP: real doc in xterm.c. */); | 10015 | doc: /* SKIP: real doc in xterm.c. */); |
| 10007 | x_underline_at_descent_line = 0; | 10016 | x_underline_at_descent_line = 0; |
| 10017 | |||
| 10018 | DEFVAR_BOOL ("x-coalesce-scroll-events", x_coalesce_scroll_events, | ||
| 10019 | doc: /* SKIP: real doc in xterm.c. */); | ||
| 10020 | x_coalesce_scroll_events = true; | ||
| 10021 | |||
| 10008 | DEFSYM (Qx_underline_at_descent_line, "x-underline-at-descent-line"); | 10022 | DEFSYM (Qx_underline_at_descent_line, "x-underline-at-descent-line"); |
| 10009 | 10023 | ||
| 10010 | /* Tell Emacs about this window system. */ | 10024 | /* Tell Emacs about this window system. */ |
diff --git a/src/xterm.c b/src/xterm.c index 7e0d58745e2..346cd0c38a4 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. */); | |||
| 15165 | doc: /* Non-nil means send a wheel event only for scrolling at least one screen line. | 15165 | doc: /* Non-nil means send a wheel event only for scrolling at least one screen line. |
| 15166 | Otherwise, a wheel event will be sent every time the mouse wheel is | 15166 | Otherwise, a wheel event will be sent every time the mouse wheel is |
| 15167 | moved. This option is only effective when Emacs is built with XInput | 15167 | moved. This option is only effective when Emacs is built with XInput |
| 15168 | 2 or with Haiku windowing support. */); | 15168 | 2, with Haiku windowing support, or with NS. */); |
| 15169 | x_coalesce_scroll_events = true; | 15169 | x_coalesce_scroll_events = true; |
| 15170 | } | 15170 | } |