aboutsummaryrefslogtreecommitdiffstats
path: root/lisp
diff options
context:
space:
mode:
authorRichard M. Stallman <[email protected]>1994-05-22 20:55:15 +0000
committerRichard M. Stallman <[email protected]>1994-05-22 20:55:15 +0000
commited627e08bdc16618e83941a1e3526434319fccb9 (patch)
tree31b52dbe8e8d5b04e6edf6b7ca90a846fea93fe6 /lisp
parent524587f216a9d1a09f19fc8f72741e195f3a9493 (diff)
(posn-col-row): Do something useful for scroll bar event.
Diffstat (limited to 'lisp')
-rw-r--r--lisp/subr.el28
1 files changed, 19 insertions, 9 deletions
diff --git a/lisp/subr.el b/lisp/subr.el
index b5b7a8d620..c281a64843 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -420,17 +420,27 @@ POSITION should be a list of the form
as returned by the `event-start' and `event-end' functions."
(nth 2 position))
-(defsubst posn-col-row (position)
- "Return the column and row in POSITION, measured in characters.
+(defun posn-col-row (position)
+ "Return the row and column in POSITION, measured in characters.
POSITION should be a list of the form
(WINDOW BUFFER-POSITION (X . Y) TIMESTAMP)
-as returned by the `event-start' and `event-end' functions."
- (let* ((pair (nth 2 position))
- (window (posn-window position))
- (frame (if (framep window) window (window-frame window)))
- (x (/ (car pair) (frame-char-width frame)))
- (y (/ (cdr pair) (frame-char-height frame))))
- (cons x y)))
+as returned by the `event-start' and `event-end' functions.
+For a scroll-bar event, the result column is 0, and the row
+corresponds to the vertical position of the click in the scroll bar."
+ (let ((pair (nth 2 position))
+ (window (posn-window position)))
+ (if (eq (if (symbolp (nth 1 position)) (nth 1 position)
+ (car (nth 1 position)))
+ 'vertical-scroll-bar)
+ (cons 0 (scroll-bar-scale pair (1- (window-height window))))
+ (if (eq (if (symbolp (nth 1 position)) (nth 1 position)
+ (car (nth 1 position)))
+ 'horizontal-scroll-bar)
+ (cons (scroll-bar-scale pair (window-width window)) 0)
+ (let ((frame (if (framep window) window (window-frame window)))
+ (x (/ (car pair) (frame-char-width frame)))
+ (y (/ (cdr pair) (frame-char-height frame))))
+ (cons x y))))))
(defsubst posn-timestamp (position)
"Return the timestamp of POSITION.