X Window selection

Last updated

Selections, cut buffers, and drag-and-drop are the mechanisms used in the X Window System to allow a user to transfer data from one 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.

Contents

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 System 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 selections

The 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:

Passive
When some data is selected, the client handling the window where this selection is done transfers it somewhere, and no longer needs to care about it;
Active
Transfer of data to a client requires the client "holding" the selection to actively participate in the exchange.

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, it 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 requires the xclipboard client to actively support any subsequent data transfer.

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, the receiver can request a different format. For example, a piece of text rendering HTML code can be transferred as text to a requester that can only handle text, but can also be transferred as HTML code if the requester can handle it. Such negotiation of format cannot be done by passive mechanisms, in which the client holding the selection (and giving it semantics) transfers the selection and 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.

Selections

The X Window System supports an arbitrary number of selections; every selection is identified by a string (more precisely, an atom). The most used selection is the PRIMARY selection.

The following requests are specific to selection transfer, although transfer also involves other requests:

  1. request to know which window owns the selection
  2. request to set the window that owns the selection
  3. request to convert the selection

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, and 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:

  1. the recipient of the selection requests the selection to be converted, specifying a property of a window (this may be the window where the text has to be pasted)
  2. in response, the server sends to the current owner of the selection a SelectionRequest event;
  3. the owner places the selected text in the property of the window that the requestor has specified by sending a ChangeProperty; request to the server
  4. the owner sends a request to the server to send the requester a SelectionNotify to notify that the selection has been transferred
  5. the requester can now read the selection in the property of the window by sending one or more GetProperty requests to the server;
  6. the requester destroys the property; if the owner has requested to be informed of this, it is sent a PropertyNotify event.

If the content is large, it should be transferred in chunks. In this case, both clients express interest in PropertyNotify events: this way, the selection owner knows when the selection has been read, and the requester knows when another chunk has been placed in the property.

The XFixes extension allow clients to listen for selection changes. [1]

Clipboard

The most used selection is the PRIMARY selection, and is used when the user selects some data. The CLIPBOARD selection is used when the user selects some data and explicitly requests it to be "copied" to the clipboard, such as by invoking "Copy" under the "Edit" menu of an application. An associated request of "Paste" results in the data of the CLIPBOARD selection being used.

At the level of the core protocol, the PRIMARY and CLIPBOARD selections do not differ. But the xclipboard client makes them behave differently. In particular, when another client asserts the ownership of the CLIPBOARD selection, this program requests and displays it in a window. Any further request for this selection are handled by xclipboard. This way, the content of the selection survives the client having copied it.

Cut buffers

Cut buffers are another mechanism to transfer data, in particular selected text. They are window properties of the root window, named CUT_BUFFER1, etc. Unlike selections, cut buffers do not involve a direct interaction between clients. Rather, when text is selected in a window, the window owner copies this text into the property of the root window called CUT_BUFFER1. When the user pastes the text in another window, the window owner reads this property of the root window.

The xcutsel program transfers data between selections and cut buffers, and the xcb program allows various kinds of access to the cut buffers.

Cut buffers are considered obsolete. [2]

XDND

Drag-and-drop in the X Window System is regulated by the Xdnd convention. [3] 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 to different parts of the desktop or a window, the user expects to be able to tell whether text can be dropped or not. In particular, the target should display visual feedback on whether or not it will accept the drop, and the cursor should change to indicate the action that will be taken; e.g., copy or move.

In the Xdnd protocol, the window where the text is selected and the drag begins is called the source; the window over which the cursor hovers is called the target. The communication between the source and the target is driven by the source because the source "grabs" the cursor. An exchange between source and target is therefore necessary in order for the target to even know that drag-and-drop is happening. Since the source decides the shape of the cursor, the source must receive a response from the target in order to update the cursor. In addition, since the target may need to draw a bombsight to indicate where the drop will occur, and since acceptance of the drop may depend on the exact location of the cursor, this exchange must happen repeatedly as the cursor moves. In fact, even if the cursor does not move, messages must be exchanged to allow the target to scroll when the cursor is near an edge of the viewing area. Otherwise, the user will only be able to drop on the visible portion of the target.

A program can state that a window can be the target of a drop by creating a property named XdndAware which contains the highest version of the protocol that the program supports. This way, applications which support newer versions can fall back to older versions in order to interoperate correctly. In addition, all applications that are written without support for Xdnd will be ignored.

When the cursor enters the target window, the source checks the presence of the XdndAware property on that window. If this property is present, an exchange begins:

While the cursor is inside the target window:

If the user drops, the target requests the selection from the source as usual. When the transfer of the selection is concluded, the target sends an XdndFinish event to tell the source that the transfer has been successful.

In summary, 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.

XDS

The Direct Save Protocol, abbreviated XDS (for X Window Direct Save Protocol), is a software protocol that supports saving files by dragging them to file manager windows. XDS is built on top of the XDND protocol. [4] [5]

Programs

The following programs specifically operate on data transfer mechanisms:

See also

Related Research Articles

A file manager or file browser is a computer program that provides a user interface to manage files and folders. The most common operations performed on files or groups of files include creating, opening, renaming, copying, moving, deleting and searching for files, as well as modifying file attributes, properties and file permissions. Folders and files may be displayed in a hierarchical tree based on their directory structure.

<span class="mw-page-title-main">HTTP</span> Application protocol for distributed, collaborative, hypermedia information systems

HTTP is an application layer protocol in the Internet protocol suite model for distributed, collaborative, hypermedia information systems. HTTP is the foundation of data communication for the World Wide Web, where hypertext documents include hyperlinks to other resources that the user can easily access, for example by a mouse click or by tapping the screen in a web browser.

The File Transfer Protocol (FTP) is a standard communication protocol used for the transfer of computer files from a server to a client on a computer network. FTP is built on a client–server model architecture using separate control and data connections between the client and the server. FTP users may authenticate themselves with a plain-text sign-in protocol, normally in the form of a username and password, but can connect anonymously if the server is configured to allow it. For secure transmission that protects the username and password, and encrypts the content, FTP is often secured with SSL/TLS (FTPS) or replaced with SSH File Transfer Protocol (SFTP).

Object Linking and Embedding (OLE) is a proprietary technology developed by Microsoft that allows embedding and linking to documents and other objects. For developers, it brought OLE Control Extension (OCX), a way to develop and use custom user interface elements. On a technical level, an OLE object is any object that implements the IOleObject interface, possibly along with a wide range of other interfaces, depending on the object's needs.

Cut, copy, and paste are essential commands of modern human–computer interaction and user interface design. They offer an interprocess communication technique for transferring data through a computer's user interface. The cut command removes the selected data from its original position, and the copy command creates a duplicate; in both cases the selected data is kept in temporary storage called the clipboard. Clipboard data is later inserted wherever a paste command is issued. The data remains available to any application supporting the feature, thus allowing easy data transfer between applications.

Direct Client-to-Client (DCC) is an IRC-related sub-protocol enabling peers to interconnect using an IRC server for handshaking in order to exchange files or perform non-relayed chats. Once established, a typical DCC session runs independently from the IRC server. Originally designed to be used with ircII it is now supported by many IRC clients. Some peer-to-peer clients on napster-protocol servers also have DCC send/get capability, including TekNap, SunshineUN and Lopster. A variation of the DCC protocol called SDCC, also known as DCC SCHAT supports encrypted connections. An RFC specification on the use of DCC does not exist.

<span class="mw-page-title-main">VNC</span> Graphical desktop-sharing system

VNC is a graphical desktop-sharing system that uses the Remote Frame Buffer protocol (RFB) to remotely control another computer. It transmits the keyboard and mouse input from one computer to another, relaying the graphical-screen updates, over a network. Popular uses for this technology include remote technical support and accessing files on one's work computer from one's home computer, or vice versa.

<span class="mw-page-title-main">Drag and drop</span> Action in computer graphic user interfaces

In computer graphical user interfaces, drag and drop is a pointing device gesture in which the user selects a virtual object by "grabbing" it and dragging it to a different location or onto another virtual object. In general, it can be used to invoke many kinds of actions, or create various types of associations between two abstract objects.

Secure copy protocol (SCP) is a means of securely transferring computer files between a local host and a remote host or between two remote hosts. It is based on the Secure Shell (SSH) protocol. "SCP" commonly refers to both the Secure Copy Protocol and the program itself.

A clipboard manager or clipboard extender, is a computer program that adds functionality to an operating system's clipboard. Many clipboards provide only one buffer for the "copy and paste" function, and it is overwritten by each new "copy" operation. The main task of a clipboard manager is to store data copied to the clipboard in a way that permits extended use of the data.

Client-to-client protocol (CTCP) is a special type of communication between Internet Relay Chat (IRC) clients.

In computing, the Inter-Client Communication Conventions Manual is a standard protocol for the X Window System. It specifies conventions for clients of a common X server about selections and cut buffers, communication with the window manager and session manager, manipulation of shared resources, and color characterization.

<span class="mw-page-title-main">Direct Rendering Infrastructure</span> Framework

The Direct Rendering Infrastructure (DRI) is the framework comprising the modern Linux graphics stack which allows unprivileged user-space programs to issue commands to graphics hardware without conflicting with other programs. The main use of DRI is to provide hardware acceleration for the Mesa implementation of OpenGL. DRI has also been adapted to provide OpenGL acceleration on a framebuffer console without a display server running.

In computing, the X Window System is a network-transparent windowing system for bitmap displays. This article details the protocols and technical structure of X11.

The X Window System core protocol is the base protocol of the X Window System, which is a networked windowing system for bitmap displays used to build graphical user interfaces on Unix, Unix-like, and other operating systems. The X Window System is based on a client–server model: a single server controls the input/output hardware, such as the screen, the keyboard, and the mouse; all application programs act as clients, interacting with the user and with the other clients via the server. This interaction is regulated by the X Window System core protocol. Other protocols related to the X Window System exist, both built at the top of the X Window System core protocol or as separate protocols.

The clipboard is a buffer that some operating systems provide for short-term storage and transfer within and between application programs. The clipboard is usually temporary and unnamed, and its contents reside in the computer's RAM.

The Services menu is a user interface element in macOS. The services are programs that accept input from the user selection, process it, and optionally put the result back in the clipboard. The concept originated in the NeXTSTEP operating system, from which it was carried over into macOS and GNUstep. Similar features can be emulated on other operating systems.

In computing, Microsoft's Windows Vista and Windows Server 2008 introduced in 2007/2008 a new networking stack named Next Generation TCP/IP stack, to improve on the previous stack in several ways. The stack includes native implementation of IPv6, as well as a complete overhaul of IPv4. The new TCP/IP stack uses a new method to store configuration settings that enables more dynamic control and does not require a computer restart after a change in settings. The new stack, implemented as a dual-stack model, depends on a strong host-model and features an infrastructure to enable more modular components that one can dynamically insert and remove.

<span class="mw-page-title-main">Wayland (protocol)</span> Display system intended to replace X11

Wayland is a communication protocol that specifies the communication between a display server and its clients, as well as a C library implementation of that protocol. A display server using the Wayland protocol is called a Wayland compositor, because it additionally performs the task of a compositing window manager.

Upload components are software products that are designed to be embedded into a web site to add upload functionality to it. Upload components are designed to replace the standard HTML4 upload mechanism. Compared with HTML4, Upload Components have a more user-friendly interface and support a wider range of features.

References

  1. "c - X11 Wait for and Get Clipboard Text". Stack Overflow. Retrieved 2021-07-27.
  2. Zawinski, J. W. (2002). X selections, cut buffers, and kill rings. Retrieved July 13, 2010, from http://www.jwz.org/doc/x-cut-and-paste.html
  3. Drag-and-Drop Protocol for the X Window System, from http://johnlindal.wix.com/xdnd
  4. Lindal, John. "Saving Files Via Drag-and-Drop: The Direct Save Protocol for the X Window System". Archived from the original on 5 March 2016.
  5. "Saving Files Via Drag-and-Drop: The Direct Save Protocol for the X Window System". freedesktop.org. Archived from the original on 22 March 2015.