Subject: bug#8421: 23.3; Strange handling of mouse events in Nextstep/Cocoa port of Emacs23

From: Jan Djärv <[email-masked]>
Date: Sat, 22 Oct 2011 10:33:50 +0200

Hello.

18 okt 2011 kl. 22:23 skrev Konrad Podczeck:

> Here the steps in more detail.
> 
> (1) Open Emacs from the finder.
> 
> (2) Via Apple-O, open some file, say A, and have the cursor in row 1 and column 1.
> 
> (3) Via Apple-O, open another file, say B, and have the cursor in row 1 and column 1.
> 
> (4) Position the frame of B so that it has the same vertical coordinates on the screen as B, and horizontally overlaps the right half of the frame of A. The frame with B thus remains the active one, with the cursor position as given on (3).
> 
> (5) With mouse1, click on the frame of A at the cursor position there, so that the frame with A becomes active, then click somewhere on the visible part of the frame with B, but at vertical coordinate below row 1, so that, in particular, the frame with B becomes active again, and finally click somewhere in the frame with B, but at a vertical coordinate below that of the previous click and horizontal coordinate in the middle between column 1 and the horizontal coordinate of the previous click.
> 
> This gives me an unintended selection in the frame of B.

Using this steps, I can now reproduce it, even in the trunk.

> 
> I the file keyboard.c of the source code of Emacs23, lines 1495 to 1499 are:
> 
> FOR_EACH_FRAME (tail, frame)
>   {
>     if (XFRAME (frame)->mouse_moved)
>      	return XFRAME (frame); 
>  }
> 
> I have inserted a new line of code before the closing brace so as to have:
> 
> FOR_EACH_FRAME (tail, frame)
>   {
>     if (XFRAME (frame)->mouse_moved)
>      	return XFRAME (frame); 
>  return 0;
>  }
> 
> 
> Could this make any sense? I found it just by trial and error, and have no theoretical explanation. In any case, I worked with a Emacs23 build with this hack for several mounts now and didn't encounter any problem,

As keyboard.c contains generic code and the problem does not show up on X11 for example, I do not think this is the right fix. The problem must be in the NS-specific code.

	Jan D.