Commit ed627e08 authored by Richard M. Stallman's avatar Richard M. Stallman
Browse files

(posn-col-row): Do something useful for scroll bar event.

parent 524587f2
...@@ -420,17 +420,27 @@ POSITION should be a list of the form ...@@ -420,17 +420,27 @@ POSITION should be a list of the form
as returned by the `event-start' and `event-end' functions." as returned by the `event-start' and `event-end' functions."
(nth 2 position)) (nth 2 position))
(defsubst posn-col-row (position) (defun posn-col-row (position)
"Return the column and row in POSITION, measured in characters. "Return the row and column in POSITION, measured in characters.
POSITION should be a list of the form POSITION should be a list of the form
(WINDOW BUFFER-POSITION (X . Y) TIMESTAMP) (WINDOW BUFFER-POSITION (X . Y) TIMESTAMP)
as returned by the `event-start' and `event-end' functions." as returned by the `event-start' and `event-end' functions.
(let* ((pair (nth 2 position)) For a scroll-bar event, the result column is 0, and the row
(window (posn-window position)) corresponds to the vertical position of the click in the scroll bar."
(frame (if (framep window) window (window-frame window))) (let ((pair (nth 2 position))
(x (/ (car pair) (frame-char-width frame))) (window (posn-window position)))
(y (/ (cdr pair) (frame-char-height frame)))) (if (eq (if (symbolp (nth 1 position)) (nth 1 position)
(cons x y))) (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) (defsubst posn-timestamp (position)
"Return the timestamp of POSITION. "Return the timestamp of POSITION.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment