Desktop Integration Guide
只搜尋這本書
以 PDF 格式下載這本書

The Selection Mechanism

2

2.1 Overview

The X11 selection mechanism is a means of copying data between or within applications running under the OpenWindows Desktop. The term selection is taken from the paradigm in graphic user interfaces by which the user selects an object (such as a block of text or a file icon) by highlighting it, before moving or copying it.
Here are two examples of how the selection mechanism is used to copy data:
Besides copying, the selection mechanism is also used to move data. For instance, here is how an OpenWindows Desktop application would allow you to move a sentence from one location to another location:
  1. Make the selection. Use the mouse to place the insertion point at the start of the sentence and momentarily press the Select mouse button. Move the pointer to the end of the sentence and press the Adjust mouse button; the selection will be highlighted in reverse video.1

  2. Store the selection. Press the Cut key on the keyboard to temporarily store the selection in the clipboard.


1. Another selection method is to place the insert point at the beginning of the sentence, press the Select mouse button and hold it down as you "wipe" across the text to the end of the sentence, then release the button.
  1. Insert the data. Use the mouse to place the insertion point at the desired location. Insert the text by pressing the Paste key.

For the remainder of this manual, the selection mechanism is referred to as selections, a common usage in the X11 developer community. Selections provide a communications link between a holder client (the client which owns the data) and a requestor client (the client that receives the data). All data transferred through selections is transferred through the X server. Each toolkit (XView or OLIT) provides a selections API. Although the API for each toolkit are somewhat different, selections between the toolkits is seamless and invisible.
User interface conventions for selections are outlined in the OPEN LOOK Functional Specification. For further selections programming instructions, refer to the XView Programming Manual and XView Reference Manual from O'Reilly and Associates, and The X Window System Programming and Applications with Xt, OPEN LOOK Edition from Prentice Hall.
XView and OLIT selection examples are at $OPENWINHOME/share/src/dig_samples/
as
selection_olit/olit_sel.c
selection_xview/xview_sel.c.

2.2 Selections Outline

Selections provide a well-defined method of implementing the Copy and Paste keys. The following outline describes the generic steps for implementing Copy and Paste with any of the OpenWindows toolkits.
Selections communicate between an owner client and a requestor client. The owner client has the data representing the value of the selection. The requestor client desires the value that the selection provides. Selection code is required for both the owner and requestor clients. Refer to the Inter-Client Communications Conventions Manual (ICCCM) for a detailed discussion of the selections protocol. The ICCCM can be found in Appendix L of X Protocol Reference Manual from O'Reilly and Associates.

2.2.1 Selection Owner

  1. Mark Selection

Visual feedback of the selected object should be provided to the user. For example, the selection can be shown by displaying the selected text in reverse video.
  1. Make Selection

When the user presses the Copy key, create a selection holder and set the other attributes required by the application.
Note that a conversion procedure must be written to handle conversion requests from the selection requestor. The request for text is handled automatically.
  1. Associate Data

Associate selection (highlighted text) with the owner client. If the selection is currently owned, the owner receives an event and is expected to do the following:
  • Convert the contents of the selection to the requested data type
  • Place this data in the named property on the named window
  • Send the requestor an event to let it know the property is available

2.2.2 Selection Requestor

  1. Paste Event

The event handler must detect the Paste event, so that the Paste operation (selection request) can be initiated.
  1. Request Data

Request data from the owner client. Post a request to get data from the selection owner. The owner has the data representing the value of its selection, and the requestor client wishing to obtain the value of a selection provides:
  • The name of the selection
  • The name of a property
  • A window
  • An atom representing the data type required

2.3 Implementing Selections with DeskSet

Call the SunSoft Catalyst Information Center (see Appendix C, "Vendor Data Type Registration") for information on the selection protocol for DeskSet. Note, however, that ICCCM currently does not specify the protocol supported by DeskSet. The current DeskSet selection protocol may change to comply with future ICCCM specifications.