windmove-constrain-loc-for-movement

windmove-constrain-loc-for-movement is a compiled Lisp function in `windmove.el'.

(windmove-constrain-loc-for-movement COORD WINDOW DIR)

Constrain COORD so that it is reasonable for the given movement.
This involves two things: first, make sure that the "off" coordinate
-- the one not being moved on, e.g., y for horizontal movement -- is
within frame boundaries; second, if the movement is down and we're not
moving from the minibuffer, make sure that the y coordinate does not
exceed the frame max-y, so that we don't overshoot the minibuffer
accidentally. WINDOW is the window that movement is relative to; DIR
is the direction of the movement, one of `left', `up', `right',
or `down'.
Returns the constrained coordinate.