CopyAndPaste
Overview
Wine mostly relies on X's selection framework to exchange clipboard data with other applications. This includes other applications running under Wine as well.
The X selection model is very different than the Window clipboard model. One primary difference is that under X, selection data is maintained and stored in the application owning the selection. Under Windows the data is stored in "global" memory and persists outside of the application owning the clipboard. Windows applications can simultaneously access clipboard data set by multiple applications.
Another difference is that X provides two different clipboard streams. PRIMARY is generally used for data that is selected by the mouse and pasted with the middle mouse button. CLIPBOARD is generally used for data that is explicitly copied and pasted using keyboard or menu commands.
X applications may support either CLIPBOARD or PRIMARY or both and they don't necessary have to refer to the same data. For example, you can select a word and explicitly copy it and this will be serviced by CLIPBOARD. Now select something else without explicitly copying it and it will be serviced by PRIMARY. Under Window you only have one stream. By default we only pay attention to CLIPBOARD. For applications that don't support CLIPBOARD such as xterm there is a registry setting that will interrogate PRIMARY if it's available otherwise revert to CLIPBOARD. This setting will also force us to grab *both* PRIMARY and CLIPBOARD when data is copied in a Wine application. Likewise we will lose *both* PRIMARY and CLIPBOARD when either stream is grabbed by another application.
Current Status
Copying and pasting data from/to applications running under Wine should mostly work. The following are known issues;
- In order to make clipboard data available we must have an X window and a message loop to service it so threads with no message loop cannot make their clipboard data available to other processes.
- Only the process owning the clipboard can make data available to other processes. Under Windows you can still add data to the clipboard even if you're not the owner and it will be available to other applications. Currently if you don't own the clipboard and you add data it will only be available locally to the process.
To solve the current limitations the clipboard data will need to be stored in the wineserver. Hopefully with some careful design this will allow us to remove all X selection code from winex11.drv and have the explorer.exe process handle of this for us. In theory this should simply things.
