<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Hi!<div> Firstly, I'm not sure this will be right place to ask, so suggest is really appreciated!</div><div><div><div> I'm working on remote desktop protocol and I recently encountered a strange problem using X11 clipboard to interact with firefox. The firefox version I'm using is Firefox 64bit 29.0a1 nightly build (also tried 26.0 as well). My program can be considered as a remote clipboard proxy agent which interacts with firefox via X. As you probably know, it's called clipboard redirection. The program itself is very simple, and the general flow can be described as below:</div></div></div><div><br></div><div><br></div><div> 1. The agent receives notification from the client that there's incoming clipboard data available (here, we only use UTF8 text data)</div><div> 2. The agent sets the clipboard owner to itself (actually its created X window)</div><div> 3. In Firefox side, we do "C-v" or select "Paste" from the context menu. At this point, Firefox is the requestor to request clipboard content.</div><div> 4. The agent receives XSelectionRequest X event, and notifying the requestor its supported clipboard content format.</div><div> 5. Eventually, the agent will receive a XSelectionRequest for the text data. Then the agent will send a data request to the client side and keep the requestor in a pending queue.</div><div> 6. The agent receives incoming data response from the client, and provide the selection data to the pending requestor by setting the data as a property of requestor window, and notify it by sending XSelectionNotify event.</div><div> 7. The content then will be shown in Firefox side.</div><div><br></div><div><br></div><div> Well, this flow works well locally (client and agent are running on the same machine, or agent is running in a VM). However, when putting it in a real network environment, we've found sometimes, the paste doesn't at all. Actually, the pattern is I have to do the paste twice to make the content shown in firefox. I've spent two days trying to track it down without luck. But I managed to find a way to reproduce it in a local environment where it used to work perfectly. That is adding some delay (1 seconds for example) before providing the selection data to the requestor, either via "sleep(1)" call or via some extra time-consuming computation. I understood according to ICCCM, delay of responding to XConvertSelection request may incur some problems. But this problem seems only happening in firefox, not other X or gtk applications, such as geditor or gnome-terminal. That's why I have to post my question here to seek some help. It is worth mentioning that when that problem happens, my problem will receive an unique XSelectionRequest event which couldn't be handled. The event atom type seems being related with the firefox internal, as its name indicates - " <b>[20131215-22:59:13] [ERROR] clipboard_event_selection_request: unknown target text/x-moz-text-internal</b>". But I have no idea why the two are connected. Btw, I've tried to handle that selection request, but no any good as well. I hope someone could have some clue about this strange behavior and your suggest is much appreciated! Thanks!</div><div><br></div><div> I'd be happy to provide more details if needed!</div><div><br></div><div><br></div><div>Nevo</div><div><br></div></body></html>