aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard M. Stallman1994-05-22 20:55:15 +0000
committerRichard M. Stallman1994-05-22 20:55:15 +0000
commited627e08bdc16618e83941a1e3526434319fccb9 (patch)
tree31b52dbe8e8d5b04e6edf6b7ca90a846fea93fe6
parent524587f216a9d1a09f19fc8f72741e195f3a9493 (diff)
downloademacs-ed627e08bdc16618e83941a1e3526434319fccb9.tar.gz
emacs-ed627e08bdc16618e83941a1e3526434319fccb9.zip
(posn-col-row): Do something useful for scroll bar event.
-rw-r--r--lisp/subr.el28
1 files changed, 19 insertions, 9 deletions
diff --git a/lisp/subr.el b/lisp/subr.el
index b5b7a8d620d..c281a64843d 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -420,17 +420,27 @@ POSITION should be a list of the form
420as returned by the `event-start' and `event-end' functions." 420as returned by the `event-start' and `event-end' functions."
421 (nth 2 position)) 421 (nth 2 position))
422 422
423(defsubst posn-col-row (position) 423(defun posn-col-row (position)
424 "Return the column and row in POSITION, measured in characters. 424 "Return the row and column in POSITION, measured in characters.
425POSITION should be a list of the form 425POSITION should be a list of the form
426 (WINDOW BUFFER-POSITION (X . Y) TIMESTAMP) 426 (WINDOW BUFFER-POSITION (X . Y) TIMESTAMP)
427as returned by the `event-start' and `event-end' functions." 427as returned by the `event-start' and `event-end' functions.
428 (let* ((pair (nth 2 position)) 428For a scroll-bar event, the result column is 0, and the row
429 (window (posn-window position)) 429corresponds to the vertical position of the click in the scroll bar."
430 (frame (if (framep window) window (window-frame window))) 430 (let ((pair (nth 2 position))
431 (x (/ (car pair) (frame-char-width frame))) 431 (window (posn-window position)))
432 (y (/ (cdr pair) (frame-char-height frame)))) 432 (if (eq (if (symbolp (nth 1 position)) (nth 1 position)
433 (cons x y))) 433 (car (nth 1 position)))
434 'vertical-scroll-bar)
435 (cons 0 (scroll-bar-scale pair (1- (window-height window))))
436 (if (eq (if (symbolp (nth 1 position)) (nth 1 position)
437 (car (nth 1 position)))
438 'horizontal-scroll-bar)
439 (cons (scroll-bar-scale pair (window-width window)) 0)
440 (let ((frame (if (framep window) window (window-frame window)))
441 (x (/ (car pair) (frame-char-width frame)))
442 (y (/ (cdr pair) (frame-char-height frame))))
443 (cons x y))))))
434 444
435(defsubst posn-timestamp (position) 445(defsubst posn-timestamp (position)
436 "Return the timestamp of POSITION. 446 "Return the timestamp of POSITION.