diff options
| author | Alan Third | 2017-09-08 19:26:47 +0100 |
|---|---|---|
| committer | Alan Third | 2017-09-19 20:08:51 +0100 |
| commit | a5fec62b519ae8c0a6528366ac8b71cd0c7ac52e (patch) | |
| tree | f9b300285aacb4df9995ea5e4559663f2afee735 /lisp | |
| parent | 7b3d1c6beb54ef6c423a93df88aebfd6fecbe2c2 (diff) | |
| download | emacs-a5fec62b519ae8c0a6528366ac8b71cd0c7ac52e.tar.gz emacs-a5fec62b519ae8c0a6528366ac8b71cd0c7ac52e.zip | |
Provide native touchpad scrolling on macOS
* etc/NEWS: Describe changes.
* lisp/term/ns-win.el (mouse-wheel-scroll-amount,
mouse-wheel-progressive-speed): Set to smarter values for macOS
touchpads.
* src/nsterm.m (emacsView::mouseDown): Use precise scrolling deltas to
calculate scrolling for touchpads and mouse wheels.
(syms_of_nsterm): Add variables 'ns-use-system-mwheel-acceleration',
'ns-touchpad-scroll-line-height' and 'ns-touchpad-use-momentum'.
* src/keyboard.c (make_lispy_event): Pass on .arg when relevant.
* src/termhooks.h (event_kind): Update comments re. WHEEL_EVENT.
* lisp/mwheel.el (mwheel-scroll): Use line count.
* lisp/subr.el (event-line-count): New function.
Diffstat (limited to 'lisp')
| -rw-r--r-- | lisp/mwheel.el | 1 | ||||
| -rw-r--r-- | lisp/subr.el | 5 | ||||
| -rw-r--r-- | lisp/term/ns-win.el | 19 |
3 files changed, 25 insertions, 0 deletions
diff --git a/lisp/mwheel.el b/lisp/mwheel.el index 2956ba55162..0c0dcb3beb1 100644 --- a/lisp/mwheel.el +++ b/lisp/mwheel.el | |||
| @@ -232,6 +232,7 @@ non-Windows systems." | |||
| 232 | ;; When the double-mouse-N comes in, a mouse-N has been executed already, | 232 | ;; When the double-mouse-N comes in, a mouse-N has been executed already, |
| 233 | ;; So by adding things up we get a squaring up (1, 3, 6, 10, 15, ...). | 233 | ;; So by adding things up we get a squaring up (1, 3, 6, 10, 15, ...). |
| 234 | (setq amt (* amt (event-click-count event)))) | 234 | (setq amt (* amt (event-click-count event)))) |
| 235 | (when (numberp amt) (setq amt (* amt (event-line-count event)))) | ||
| 235 | (unwind-protect | 236 | (unwind-protect |
| 236 | (let ((button (mwheel-event-button event))) | 237 | (let ((button (mwheel-event-button event))) |
| 237 | (cond ((eq button mouse-wheel-down-event) | 238 | (cond ((eq button mouse-wheel-down-event) |
diff --git a/lisp/subr.el b/lisp/subr.el index 96b1ac19b4b..cf15ec287ff 100644 --- a/lisp/subr.el +++ b/lisp/subr.el | |||
| @@ -1270,6 +1270,11 @@ See `event-start' for a description of the value returned." | |||
| 1270 | "Return the multi-click count of EVENT, a click or drag event. | 1270 | "Return the multi-click count of EVENT, a click or drag event. |
| 1271 | The return value is a positive integer." | 1271 | The return value is a positive integer." |
| 1272 | (if (and (consp event) (integerp (nth 2 event))) (nth 2 event) 1)) | 1272 | (if (and (consp event) (integerp (nth 2 event))) (nth 2 event) 1)) |
| 1273 | |||
| 1274 | (defsubst event-line-count (event) | ||
| 1275 | "Return the line count of EVENT, a mousewheel event. | ||
| 1276 | The return value is a positive integer." | ||
| 1277 | (if (and (consp event) (integerp (nth 3 event))) (nth 3 event) 1)) | ||
| 1273 | 1278 | ||
| 1274 | ;;;; Extracting fields of the positions in an event. | 1279 | ;;;; Extracting fields of the positions in an event. |
| 1275 | 1280 | ||
diff --git a/lisp/term/ns-win.el b/lisp/term/ns-win.el index 68b659bf751..bc211ea9589 100644 --- a/lisp/term/ns-win.el +++ b/lisp/term/ns-win.el | |||
| @@ -736,6 +736,25 @@ See the documentation of `create-fontset-from-fontset-spec' for the format.") | |||
| 736 | (global-unset-key [horizontal-scroll-bar drag-mouse-1]) | 736 | (global-unset-key [horizontal-scroll-bar drag-mouse-1]) |
| 737 | 737 | ||
| 738 | 738 | ||
| 739 | ;;;; macOS-like defaults for trackpad and mouse wheel scrolling on | ||
| 740 | ;;;; macOS 10.7+. | ||
| 741 | |||
| 742 | ;; FIXME: This doesn't look right. Is there a better way to do this | ||
| 743 | ;; that keeps customize happy? | ||
| 744 | (let ((appkit-version (progn | ||
| 745 | (string-match "^appkit-\\([^\s-]*\\)" ns-version-string) | ||
| 746 | (string-to-number (match-string 1 ns-version-string))))) | ||
| 747 | ;; Appkit 1138 ~= macOS 10.7. | ||
| 748 | (when (and (featurep 'cocoa) (>= appkit-version 1138)) | ||
| 749 | (setq mouse-wheel-scroll-amount '(1 ((shift) . 5) ((control)))) | ||
| 750 | (put 'mouse-wheel-scroll-amount 'customized-value | ||
| 751 | (list (custom-quote (symbol-value 'mouse-wheel-scroll-amount)))) | ||
| 752 | |||
| 753 | (setq mouse-wheel-progressive-speed nil) | ||
| 754 | (put 'mouse-wheel-progressive-speed 'customized-value | ||
| 755 | (list (custom-quote (symbol-value 'mouse-wheel-progressive-speed)))))) | ||
| 756 | |||
| 757 | |||
| 739 | ;;;; Color support. | 758 | ;;;; Color support. |
| 740 | 759 | ||
| 741 | ;; Functions for color panel + drag | 760 | ;; Functions for color panel + drag |