[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/scroll-on-drag d8582732d1 29/35: Scroll the window under t
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/scroll-on-drag d8582732d1 29/35: Scroll the window under the mouse cursor |
Date: |
Thu, 7 Jul 2022 12:02:52 -0400 (EDT) |
branch: elpa/scroll-on-drag
commit d8582732d1eb03c7f6bba62f39ba66af365dde2c
Author: Campbell Barton <ideasman42@gmail.com>
Commit: Campbell Barton <ideasman42@gmail.com>
Scroll the window under the mouse cursor
Useful to quickly scroll other windows without having to focus
them first.
This can be disabled using `scroll-on-drag-follow-mouse`.
---
readme.rst | 3 +++
scroll-on-drag.el | 24 +++++++++++++++++++++---
2 files changed, 24 insertions(+), 3 deletions(-)
diff --git a/readme.rst b/readme.rst
index d0adb9ff03..f26d2410c8 100644
--- a/readme.rst
+++ b/readme.rst
@@ -83,3 +83,6 @@ While the defaults seem to work well, these values can be
customized.
Values greater than 0.0 apply non-linear scaling,
this gives control when scrolling individual lines while allowing much
greater speed without having to move the mouse a long distance.
+``scroll-on-drag-follow-mouse``
+ When non-nil, scroll the window under the mouse cursor (even when it's not
active)
+ returning focus on completion.
diff --git a/scroll-on-drag.el b/scroll-on-drag.el
index 085daeebdf..92e7805252 100644
--- a/scroll-on-drag.el
+++ b/scroll-on-drag.el
@@ -51,6 +51,10 @@
(defcustom scroll-on-drag-smooth t "Use smooth (pixel) scrolling." :type
'boolean)
+(defcustom scroll-on-drag-follow-mouse t
+ "Scroll the window under the mouse cursor (instead of the current active
window)."
+ :type 'boolean)
+
(defcustom scroll-on-drag-pre-hook nil
"List of functions to be called when `scroll-on-drag' starts."
:type 'hook)
@@ -147,11 +151,9 @@ Argument ALSO-MOVE-POINT When non-nil, move the POINT as
well."
;; ---------------------------------------------------------------------------
;; Public Functions
-;;;###autoload
-(defun scroll-on-drag ()
+(defun scroll-on-drag-impl ()
"Interactively scroll (typically on click event).
Returns true when scrolling took place, otherwise nil."
- (interactive)
(let*
(
;; Don't run unnecessary logic when scrolling.
@@ -402,6 +404,22 @@ Returns true when scrolling took place, otherwise nil."
;; allowing a fallback action on 'click'.
has-scrolled-real))
+(defun scroll-on-drag (&optional event)
+ "Main scroll on drag function.
+
+EVENT is optionally used to find the active window
+when `scroll-on-drag-follow-mouse' is non-nil."
+ (interactive "e")
+ (let ((scroll-win nil))
+ (when scroll-on-drag-follow-mouse
+ (setq scroll-win (posn-window (or (event-start event)
last-input-event))))
+
+ (cond
+ (scroll-win
+ (with-selected-window scroll-win (scroll-on-drag-impl)))
+ (t
+ (scroll-on-drag-impl)))))
+
;;;###autoload
(defmacro scroll-on-drag-with-fallback (&rest body)
"A macro to scroll and perform a different action on click.
- [nongnu] elpa/scroll-on-drag 42d96a60a2 22/35: Cleanup: simplify some logic using 'line-beginning-position', (continued)
- [nongnu] elpa/scroll-on-drag 42d96a60a2 22/35: Cleanup: simplify some logic using 'line-beginning-position', ELPA Syncer, 2022/07/07
- [nongnu] elpa/scroll-on-drag ad94790492 24/35: readme: link to melpa, tweak title level, ELPA Syncer, 2022/07/07
- [nongnu] elpa/scroll-on-drag 31f322554d 31/35: Cleanup: move force-redisplay into an inline function, ELPA Syncer, 2022/07/07
- [nongnu] elpa/scroll-on-drag d93b69eed6 33/35: Cleanup: use brief SPDX license, ELPA Syncer, 2022/07/07
- [nongnu] elpa/scroll-on-drag 64445dd96f 15/35: Apply auto-formatting, ELPA Syncer, 2022/07/07
- [nongnu] elpa/scroll-on-drag a717d58f31 01/35: Add license file, ELPA Syncer, 2022/07/07
- [nongnu] elpa/scroll-on-drag a668537a8d 02/35: Initial modal scroll, ELPA Syncer, 2022/07/07
- [nongnu] elpa/scroll-on-drag 494de949d5 04/35: Restore indent level, ELPA Syncer, 2022/07/07
- [nongnu] elpa/scroll-on-drag 6cf8c0d81e 06/35: Enable smooth scrolling by default, ELPA Syncer, 2022/07/07
- [nongnu] elpa/scroll-on-drag 888abd04c3 09/35: Add melpa link, ELPA Syncer, 2022/07/07
- [nongnu] elpa/scroll-on-drag d8582732d1 29/35: Scroll the window under the mouse cursor,
ELPA Syncer <=
- [nongnu] elpa/scroll-on-drag 31c3baed1d 08/35: Check x-pointer-shape is available before setting, ELPA Syncer, 2022/07/07
- [nongnu] elpa/scroll-on-drag fa6a293c74 14/35: Correct macro, ELPA Syncer, 2022/07/07
- [nongnu] elpa/scroll-on-drag 81623ccc59 10/35: Add pre/post hooks, ELPA Syncer, 2022/07/07
- [nongnu] elpa/scroll-on-drag fb9af98461 34/35: Change URL to codeberg, ELPA Syncer, 2022/07/07
- [nongnu] elpa/scroll-on-drag d6257b2fb7 05/35: Prevent cursor changing over text, ELPA Syncer, 2022/07/07
- [nongnu] elpa/scroll-on-drag 823aab7938 27/35: Cleanup: replace 'if' with 'cond', ELPA Syncer, 2022/07/07
- [nongnu] elpa/scroll-on-drag be3c43b74e 21/35: Fix restoring the point with mixed tabs/spaces, ELPA Syncer, 2022/07/07
- [nongnu] elpa/scroll-on-drag 3cd1e1801a 23/35: Update URL, ELPA Syncer, 2022/07/07
- [nongnu] elpa/scroll-on-drag 2fbd643ea9 16/35: Add .elisp-autofmt to enable auto-formatting, ELPA Syncer, 2022/07/07
- [nongnu] elpa/scroll-on-drag 01c14f4c02 35/35: Cleanup: quiet checkdoc warning, ELPA Syncer, 2022/07/07