Log in

No account? Create an account

Firefox and Clipboard-clobbering

I often find that my PRIMARY clipboard (the one associated with mouse selections in the X Window System, not to be confused with the CLIPBOARD clipboard used for menu-driven cut'n'paste) gets stuck with something that I selected sometime back, even after I select something new to put into it.

Being aware of this has led me to become more observant; enough to finally fully understand the problem and culprit.

It's Firefox. The old text that gets stuck is usually still selected in some Firefox window somewhere, and even when I haven't done anything with Firefox for half an hour, it'll still wake up occasionally, notice that some text is selected in one of its windows, and reassociate that with the clipboard, which actually has the visual effect of deselecting the text in whatever other app (usually a terminal) I'm trying to cut'n'paste from. I can see that deselection happen if I'm careful.

I think I can understand why Firefox behaves wierdly here; it has its own widget library that are going through a platform later called NSPR (Netscape Portable Runtime), and that layer probably is not very X11-savvy; it's a platform abstraction library, and those have the job of hiding differences between operating systems. IIRC, Firefox doesn't use native X11 widgets; there's some weird Xlib stuff in NSPR that does portable widgets, and so there's a lot of room for non-ICCCM-compliant behaviour. Somebody might've thought having a thread that pokes around the windows for currently-selected text and periodically associates it with the PRIMARY clipboard would be an adequate solution.

Unfortunately, it's frustrating as hell. When I can't reliably use the clipboard on my system because firefox is running, it's a problem. If anyone knows whether this is an unfixable design flaw, a known problem, or something somehow specific to me (I do use a weird X environment and it's possible there are WMHints that should allow Firefox to be smarter that are not happening), I'd be grateful for some poking around. I don't see myself leaving Firefox over this; it remains my favourite browser, none of the alternatives really interest me, and my past personal involvement with the Mozilla project has bought my loyalty for the forseeable future. I'd still love not to see the problem anymore.

(Crossposted to G+)