- /* If position is above window start, it's not visible. */
- if (posint < CHARPOS (top))
- in_window = Qnil;
- else if (XFASTINT (w->last_modified) >= BUF_MODIFF (buf)
- && XFASTINT (w->last_overlay_modified) >= BUF_OVERLAY_MODIFF (buf)
- && posint < BUF_Z (buf) - XFASTINT (w->window_end_pos))
- {
- /* If frame is up-to-date, and POSINT is < window end pos, use
- that info. This doesn't work for POSINT == end pos, because
- the window end pos is actually the position _after_ the last
- char in the window. */
- if (NILP (partially))
- {
- pos_visible_p (w, posint, &fully_p, NILP (partially));
- in_window = fully_p ? Qt : Qnil;
- }
- else
- in_window = Qt;
- }
- else if (posint > BUF_ZV (buf))
- in_window = Qnil;
- else if (CHARPOS (top) < BUF_BEGV (buf) || CHARPOS (top) > BUF_ZV (buf))
- /* If window start is out of range, do something reasonable. */
- in_window = Qnil;
- else
- {
- if (pos_visible_p (w, posint, &fully_p, NILP (partially)))
- in_window = !NILP (partially) || fully_p ? Qt : Qnil;
- else
- in_window = Qnil;
- }
-
+ /* If position is above window start or outside buffer boundaries,
+ or if window start is out of range, position is not visible. */
+ if (posint >= CHARPOS (top)
+ && posint <= BUF_ZV (buf)
+ && CHARPOS (top) >= BUF_BEGV (buf)
+ && CHARPOS (top) <= BUF_ZV (buf)
+ && pos_visible_p (w, posint, &x, &y, &rtop, &rbot, NILP (partially))
+ && (fully_p = !rtop && !rbot, (!NILP (partially) || fully_p)))
+ in_window = Qt;
+
+ if (!NILP (in_window) && !NILP (partially))
+ in_window = Fcons (make_number (x),
+ Fcons (make_number (y),
+ Fcons ((fully_p ? Qnil
+ : Fcons (make_number (rtop),
+ make_number (rbot))),
+ Qnil)));