Subject: bug#1372: posn-at-x-y reports wrong window

From: martin rudalics <[email-masked]>
Date: Wed, 19 Nov 2008 16:09:39 +0100

> (fringe-mode 0)
 > C-x 3 C-x 2 C-x o C-x o
 > (we're now in the large window on the right, with two small windows in
 > the left half of the frame).
 >
 > Insert enough newlines to be vertically just above the horizontal
 > divider on the left.
 >
 > M-: (posn-at-x-y 0 (cdr (posn-x-y (posn-at-point)))) RET
 >
 > Insert newline, now we're next to the divider line.
 >
 > M-: (posn-at-x-y 0 (cdr (posn-x-y (posn-at-point)))) RET
 >
 > --> wrong window (the window in the upper left) is given in the structure.
 > Instead of 0, the x value can be up to 6 ((frame-char-width) reports 7).

Can you try the attached patch?

martin
*** window.c.~1.634.~	2008-11-18 18:56:23.703125000 +0100
--- window.c	2008-11-19 16:04:02.078125000 +0100
***************
*** 774,780 ****
  	}
        else
  	{
! 	  if (eabs (*x - x1) < grabbable_width)
  	    {
  	      /* Convert X and Y to window relative coordinates.
  		 Vertical border is at the right edge of window.  */
--- 774,781 ----
  	}
        else
  	{
! 	  if ((WINDOW_RIGHTMOST_P (w) || *x < x1)
! 	      && eabs (*x - x1) < grabbable_width)
  	    {
  	      /* Convert X and Y to window relative coordinates.
  		 Vertical border is at the right edge of window.  */