[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
View-size peculiarities
- To: info-macl@cambridge.apple.com
- Subject: View-size peculiarities
- From: Timothy Koschmann <tdk@camis.stanford.edu>
- Date: Tue, 4 Jun 1991 16:38:37 PDT
I was trying to duplicate the old InterLisp WHICHW function and ran into a
couple of problems. Apparently the value returned by the view-size method is
different from the value that is returned by calling slot-value on the
view-size slot of a window object. Is the slot value not getting updated for
some reason?
The WHICHW function is quite useful, incidentally, as a convenient means of
referencing windows on the screen. It returns the window object of the
window currently under the cursor. For example, pointing to a window and then
evaluting the expression
(window-close (whichw))
is an easy way of getting rid of a window that has no close box.
It can be implemented as follows:
(defun whichw ()
(find-if #'mouse-in-window-p
(windows :include-invisibles nil)))
(defun mouse-in-window-p (window)
(let ((mouse-coord (view-mouse-position window))
(window-dim (view-size window)))
(and (>= (point-v mouse-coord) 0)
(>= (point-h mouse-coord) 0)
(<= (point-h mouse-coord)
(point-h window-dim))
(<= (point-h mouse-coord)
(point-v window-dim)))))
This seems to work just fine, unless the cursor happens to be in the title
bar of the window. Apparently, the title bar isn't factored into value
returned by view-mouse-position?
Tim