|
Selections, cut buffers, and drag-and-drop are the mechanisms used in the X Window System to allow a user to transfer data from a window to another. Selections and cut buffer are typically used when a user selects text or some other data in a window and pastes in another one. Drag-and-drop is used when a user selects something in a window, then clicks on the selection and drags it into another window. Since the two windows may be handled by two different applications, these mechanisms require two different clients connected with the same X server to exchange data. The X Window core protocol includes some requests and events that are specific to selection exchange, but the transfer is mainly done using event sending and window properties, which are not specific to selection transfer. Different types of data can be transferred: it is usually text, but can also be an image, a number, a list of objects, etc. In the following, only the case of text is considered.
Active and passive selectionsThe methods for transferring data can be classified into active and passive, depending on whether the client handling the selected data has to actively participate in the transfer to a client requesting it:
Selections and drag-and-drop are active mechanisms: after some text is selected in a window, the client handling the window must actively support a protocol for transferring the data to the application requesting it. By contrast, cut buffers are a passive mechanism: after some text is selected, its is transferred to a cut buffer and remains there even if the application handling the window terminates and the window is destroyed. The X clipboard is a passive mechanism as perceived by the client holding the selection, but require the An advantage of active mechanisms is that the data can be converted to a different format before the transfer. In particular, the client receiving the data can request the selection data to be converted into a suitable form. If the sending client refuses to do so, first client can request a different format. For example, a piece of text rendering HTML code can be transferred as text to a requestor that can only handle text, but can also be transferred as HTML code if the requestor can handle it. Such negotiation of format cannot be done by passive mechanisms, in which the client holding the selection (and giving it a semantics) transfers the selection is not involved in the further transfer into a client requesting it. Another advantage of the active mechanisms is that large pieces of data can be transferred in a sequence of transfers rather than a single one. Passive mechanisms instead require all data to be transferred somewhere from the selection owner, then transferred again to the client requesting it. The advantage of the passive mechanisms is that the transfer can be done even after the client holding the data terminates. This is not possible in the active mechanisms, which require the client holding the data to actively participate in the transfer. SelectionsThe X Window System supports an arbitrary number of selections; every selection is identified by a string (more precisely, an The following requests are specific to selection transfer, although transfer also involves other requests:
The owner of the selection is typically the window in which the selected text is located, if any. When the user selects some text in a window, the client handling the window must tell the server that the window is the owner of the selection. When the user tries to paste the selection into another window, that window's handler initiates a protocol for getting the selected text from the other client. This protocol involves the second and third requests of the list above, and is not specified by the X protocol but as a convention in the Inter-Client Communication Convention Manual (ICCCM). In particular, the destination client begins by asking the server which window owns the selection. Then the two clients transfer the selection via the server. This exchange involves a property of a window, an arbitrary piece of data attached to the window. If the content of the selection is considered small enough to be transferred all at once, the steps that take place are:
If the content is large, it should be transferred in chunks. In this case, both clients express interest in ClipboardThe most used selection is the At the level of the core protocol, the Cut buffersCut buffers are another mechanism to transfer data, in particular selected text. They are window properties of the root window, named The Cut buffers are considered obsolete. XdndDrag-and-drop in the X Window System is regulated by the Xdnd convention. When the user drags the selected text into a window and releases the mouse button, the exchange of data is done as for the primary selection. Drag-and-drop is complicated by what happens during the drag. Namely, when the user drags the selection in different parts of the screen or of a window, the user expects to be able to tell whether text can be dropped or not. In particular, the image of the cursor (which the user metaphorically identifies with the dragged text) should change depending on whether the text can be dropped in the current position or not. In the Xdnd protocol, the window where the text is selected and the drag begins is called the source; the window where the cursor is currently in is called the target. The communication between the source and the target is driven by the source client, which also decides the shape of the cursor. Since this shape is supposed to change depending on whether the text can be dropped in the current position of the target window, an exchange between source and target is necessary. A client can state that a window can be the target of a drop by creating a property of name When the cursor enters the target window, the source checks the presence of the
When the cursor is inside the target window:
In case of drop the target requests the selection to the source as usual. When the transfer of the selection is concluded, the target sends an Summarizing, the protocol is driven by the source, which keeps the target informed of what is happening with the cursor. In reply, the target tells the source whether a drop would be accepted or not. The target must also be informed when the user releases the mouse button, as this event starts a regular request for a selection, which is a protocol driven by the target. The above is the description of the Xdnd convention for drag-and-drop. Different conventions for drag-and-drop are used in Motif, OffiX, and Amulet. ProgramsThe following programs specifically operate on data transfer mechanisms:
See alsoExternal links
|
||||||||||||||||||||||||||||||||||||
This article is from Wikipedia. All text is available under the terms of the GNU Free Documentation License.
Mercedes Car
This site monitored by SitePinger.net