>> > But then we are back at the problem which the buffer-position check >> > tries to address: >> > >> > /* Maybe the mouse has moved a lot, caused scrolling, and >> > eventually ended up at the same screen position (but >> > not buffer position) in which case it is a drag, not >> > a click. */ >> > >> > IOW, just testing the screen coordinates is not enough. >> >> In my "in short is approximately" I used `mouse_has_moved` but that >> was an oversimplification: in the new code `mouse_has_moved` doesn't >> revert to "false" when the mouse returns to the original position, >> contrary to what happen in the current code. > > How exactly does that happen? Because as soon as `note_mouse_highlight` receives information that the mouse is outside of the fuzz, the var is set to `false` [ And it's only set to true when we get the mouse-down event ]. >> The comment above talks about buffer positions (i.e. the Fcar+Fcdr >> part of the positions), whereas this `EQ` tests the windows, and the >> only relevant comment I see is >> >> /* Different window */ >> >> which reminds the reader that it's comparing windows but doesn't say why. >> Did I miss something? > > Yes: we can be at the same buffer position, but a different window. Right, but what's the problem with that? IIUC the current code can generate a drag between windows if the mouse has moved to a new screen position, but we never generate a drag between windows if the mouse ends at the same screen position as it started. I see now that this was done (in commit 6e2d3bce087d30a535b1f01715d7820576ffe390) to handle the case where a mouse click causes some window-shuffle, so the up event ends up pointing into another window. IOW, a similar problem to the display-line-number one you just fixed. I think my code is immune to this problem since with it we only ever generate a drag event if the mouse actually moved. Which leads to a further simplification of the code, see patch below. Stefan