Subject: bug#8996: Set PRIMARY from last selection, not last selected window

From: David De La Harpe Golden <[email-masked]>
Date: Mon, 04 Jul 2011 20:11:53 +0100

On 04/07/11 18:19, Stefan Monnier wrote:
> With focus-follows-mouse (and/or mouse-autoselect-window), I often get
> surprising results in my PRIMARY.  E.g.:
>
> 1- in window/frame 1 I select a piece of text "test" with the mouse.
> 2- I move the mouse to an xterm
> 3- I middle click, and lo and behold rather than "test" I see some
>     unrelated selection inserted.
>
> What happened is that at step 2 I happened to move the mouse over some
> other Emacs window which happens to also have an active region, and my
> focus-follows-mouse window manager (and/or mouse-autoselect-window
> setting) caused Emacs to temporarily select this other region, changing
> the PRIMARY selection from the "test" I just selected to something
> completely different.
>

Erk. Sorry, yes, this AFAIK sounds like a known (to some people...) 
problem that is apparently still present in at least some circumstances. 
I actually meant to check if it was still occurring after the 
customization vs. binding thing was decided and if so file it as a bug.

I had previously mentioned the subtlety under #6774 (at least) [1], and 
ISTR Chong Yidong also being aware of it, though I'm having some trouble 
finding the relevant email, so hopefully I'm not unjustly saying that.

A fair bit of the implementation has AFAIK changed since #6774, but I 
guess the issue was carried forward.

[1]
http://debbugs.gnu.org/cgi/bugreport.cgi?bug=6774#32

"""
Try it between two kate windows both with selected text, say - note how
the selection doesn't change depending on which window you're currently
in, it depends on the last text the user actively selected.
"""