jpayne@69
|
1 /*
|
jpayne@69
|
2 * tkSelect.h --
|
jpayne@69
|
3 *
|
jpayne@69
|
4 * Declarations of types shared among the files that implement selection
|
jpayne@69
|
5 * support.
|
jpayne@69
|
6 *
|
jpayne@69
|
7 * Copyright (c) 1995 Sun Microsystems, Inc.
|
jpayne@69
|
8 *
|
jpayne@69
|
9 * See the file "license.terms" for information on usage and redistribution of
|
jpayne@69
|
10 * this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
jpayne@69
|
11 */
|
jpayne@69
|
12
|
jpayne@69
|
13 #ifndef _TKSELECT
|
jpayne@69
|
14 #define _TKSELECT
|
jpayne@69
|
15
|
jpayne@69
|
16 /*
|
jpayne@69
|
17 * When a selection is owned by a window on a given display, one of the
|
jpayne@69
|
18 * following structures is present on a list of current selections in the
|
jpayne@69
|
19 * display structure. The structure is used to record the current owner of a
|
jpayne@69
|
20 * selection for use in later retrieval requests. There is a list of such
|
jpayne@69
|
21 * structures because a display can have multiple different selections active
|
jpayne@69
|
22 * at the same time.
|
jpayne@69
|
23 */
|
jpayne@69
|
24
|
jpayne@69
|
25 typedef struct TkSelectionInfo {
|
jpayne@69
|
26 Atom selection; /* Selection name, e.g. XA_PRIMARY. */
|
jpayne@69
|
27 Tk_Window owner; /* Current owner of this selection. */
|
jpayne@69
|
28 int serial; /* Serial number of last XSelectionSetOwner
|
jpayne@69
|
29 * request made to server for this selection
|
jpayne@69
|
30 * (used to filter out redundant
|
jpayne@69
|
31 * SelectionClear events). */
|
jpayne@69
|
32 Time time; /* Timestamp used to acquire selection. */
|
jpayne@69
|
33 Tk_LostSelProc *clearProc; /* Procedure to call when owner loses
|
jpayne@69
|
34 * selection. */
|
jpayne@69
|
35 ClientData clearData; /* Info to pass to clearProc. */
|
jpayne@69
|
36 struct TkSelectionInfo *nextPtr;
|
jpayne@69
|
37 /* Next in list of current selections on this
|
jpayne@69
|
38 * display. NULL means end of list. */
|
jpayne@69
|
39 } TkSelectionInfo;
|
jpayne@69
|
40
|
jpayne@69
|
41 /*
|
jpayne@69
|
42 * One of the following structures exists for each selection handler created
|
jpayne@69
|
43 * for a window by calling Tk_CreateSelHandler. The handlers are linked in a
|
jpayne@69
|
44 * list rooted in the TkWindow structure.
|
jpayne@69
|
45 */
|
jpayne@69
|
46
|
jpayne@69
|
47 typedef struct TkSelHandler {
|
jpayne@69
|
48 Atom selection; /* Selection name, e.g. XA_PRIMARY. */
|
jpayne@69
|
49 Atom target; /* Target type for selection conversion, such
|
jpayne@69
|
50 * as TARGETS or STRING. */
|
jpayne@69
|
51 Atom format; /* Format in which selection info will be
|
jpayne@69
|
52 * returned, such as STRING or ATOM. */
|
jpayne@69
|
53 Tk_SelectionProc *proc; /* Procedure to generate selection in this
|
jpayne@69
|
54 * format. */
|
jpayne@69
|
55 ClientData clientData; /* Argument to pass to proc. */
|
jpayne@69
|
56 int size; /* Size of units returned by proc (8 for
|
jpayne@69
|
57 * STRING, 32 for almost anything else). */
|
jpayne@69
|
58 struct TkSelHandler *nextPtr;
|
jpayne@69
|
59 /* Next selection handler associated with same
|
jpayne@69
|
60 * window (NULL for end of list). */
|
jpayne@69
|
61 } TkSelHandler;
|
jpayne@69
|
62
|
jpayne@69
|
63 /*
|
jpayne@69
|
64 * When the selection is being retrieved, one of the following structures is
|
jpayne@69
|
65 * present on a list of pending selection retrievals. The structure is used to
|
jpayne@69
|
66 * communicate between the background procedure that requests the selection
|
jpayne@69
|
67 * and the foreground event handler that processes the events in which the
|
jpayne@69
|
68 * selection is returned. There is a list of such structures so that there can
|
jpayne@69
|
69 * be multiple simultaneous selection retrievals (e.g. on different displays).
|
jpayne@69
|
70 */
|
jpayne@69
|
71
|
jpayne@69
|
72 typedef struct TkSelRetrievalInfo {
|
jpayne@69
|
73 Tcl_Interp *interp; /* Interpreter for error reporting. */
|
jpayne@69
|
74 TkWindow *winPtr; /* Window used as requestor for selection. */
|
jpayne@69
|
75 Atom selection; /* Selection being requested. */
|
jpayne@69
|
76 Atom property; /* Property where selection will appear. */
|
jpayne@69
|
77 Atom target; /* Desired form for selection. */
|
jpayne@69
|
78 Tk_GetSelProc *proc; /* Procedure to call to handle pieces of
|
jpayne@69
|
79 * selection. */
|
jpayne@69
|
80 ClientData clientData; /* Argument for proc. */
|
jpayne@69
|
81 int result; /* Initially -1. Set to a Tcl return value
|
jpayne@69
|
82 * once the selection has been retrieved. */
|
jpayne@69
|
83 Tcl_TimerToken timeout; /* Token for current timeout procedure. */
|
jpayne@69
|
84 int idleTime; /* Number of seconds that have gone by without
|
jpayne@69
|
85 * hearing anything from the selection
|
jpayne@69
|
86 * owner. */
|
jpayne@69
|
87 Tcl_EncodingState encState; /* Holds intermediate state during translations
|
jpayne@69
|
88 * of data that cross buffer boundaries. */
|
jpayne@69
|
89 int encFlags; /* Encoding translation state flags. */
|
jpayne@69
|
90 Tcl_DString buf; /* Buffer to hold translation data. */
|
jpayne@69
|
91 struct TkSelRetrievalInfo *nextPtr;
|
jpayne@69
|
92 /* Next in list of all pending selection
|
jpayne@69
|
93 * retrievals. NULL means end of list. */
|
jpayne@69
|
94 } TkSelRetrievalInfo;
|
jpayne@69
|
95
|
jpayne@69
|
96 /*
|
jpayne@69
|
97 * The clipboard contains a list of buffers of various types and formats. All
|
jpayne@69
|
98 * of the buffers of a given type will be returned in sequence when the
|
jpayne@69
|
99 * CLIPBOARD selection is retrieved. All buffers of a given type on the same
|
jpayne@69
|
100 * clipboard must have the same format. The TkClipboardTarget structure is
|
jpayne@69
|
101 * used to record the information about a chain of buffers of the same type.
|
jpayne@69
|
102 */
|
jpayne@69
|
103
|
jpayne@69
|
104 typedef struct TkClipboardBuffer {
|
jpayne@69
|
105 char *buffer; /* Null terminated data buffer. */
|
jpayne@69
|
106 long length; /* Length of string in buffer. */
|
jpayne@69
|
107 struct TkClipboardBuffer *nextPtr;
|
jpayne@69
|
108 /* Next in list of buffers. NULL means end of
|
jpayne@69
|
109 * list . */
|
jpayne@69
|
110 } TkClipboardBuffer;
|
jpayne@69
|
111
|
jpayne@69
|
112 typedef struct TkClipboardTarget {
|
jpayne@69
|
113 Atom type; /* Type conversion supported. */
|
jpayne@69
|
114 Atom format; /* Representation used for data. */
|
jpayne@69
|
115 TkClipboardBuffer *firstBufferPtr;
|
jpayne@69
|
116 /* First in list of data buffers. */
|
jpayne@69
|
117 TkClipboardBuffer *lastBufferPtr;
|
jpayne@69
|
118 /* Last in list of clipboard buffers. Used to
|
jpayne@69
|
119 * speed up appends. */
|
jpayne@69
|
120 struct TkClipboardTarget *nextPtr;
|
jpayne@69
|
121 /* Next in list of targets on clipboard. NULL
|
jpayne@69
|
122 * means end of list. */
|
jpayne@69
|
123 } TkClipboardTarget;
|
jpayne@69
|
124
|
jpayne@69
|
125 /*
|
jpayne@69
|
126 * It is possible for a Tk_SelectionProc to delete the handler that it
|
jpayne@69
|
127 * represents. If this happens, the code that is retrieving the selection
|
jpayne@69
|
128 * needs to know about it so it doesn't use the now-defunct handler structure.
|
jpayne@69
|
129 * One structure of the following form is created for each retrieval in
|
jpayne@69
|
130 * progress, so that the retriever can find out if its handler is deleted. All
|
jpayne@69
|
131 * of the pending retrievals (if there are more than one) are linked into a
|
jpayne@69
|
132 * list.
|
jpayne@69
|
133 */
|
jpayne@69
|
134
|
jpayne@69
|
135 typedef struct TkSelInProgress {
|
jpayne@69
|
136 TkSelHandler *selPtr; /* Handler being executed. If this handler is
|
jpayne@69
|
137 * deleted, the field is set to NULL. */
|
jpayne@69
|
138 struct TkSelInProgress *nextPtr;
|
jpayne@69
|
139 /* Next higher nested search. */
|
jpayne@69
|
140 } TkSelInProgress;
|
jpayne@69
|
141
|
jpayne@69
|
142 /*
|
jpayne@69
|
143 * Chunk size for retrieving selection. It's defined both in words and in
|
jpayne@69
|
144 * bytes; the word size is used to allocate buffer space that's guaranteed to
|
jpayne@69
|
145 * be word-aligned and that has an extra character for the terminating NULL.
|
jpayne@69
|
146 */
|
jpayne@69
|
147
|
jpayne@69
|
148 #define TK_SEL_BYTES_AT_ONCE 4000
|
jpayne@69
|
149 #define TK_SEL_WORDS_AT_ONCE 1001
|
jpayne@69
|
150
|
jpayne@69
|
151 /*
|
jpayne@69
|
152 * Declarations for procedures that are used by the selection-related files
|
jpayne@69
|
153 * but shouldn't be used anywhere else in Tk (or by Tk clients):
|
jpayne@69
|
154 */
|
jpayne@69
|
155
|
jpayne@69
|
156 MODULE_SCOPE TkSelInProgress *TkSelGetInProgress(void);
|
jpayne@69
|
157 MODULE_SCOPE void TkSelSetInProgress(TkSelInProgress *pendingPtr);
|
jpayne@69
|
158 MODULE_SCOPE void TkSelClearSelection(Tk_Window tkwin, XEvent *eventPtr);
|
jpayne@69
|
159 MODULE_SCOPE int TkSelDefaultSelection(TkSelectionInfo *infoPtr,
|
jpayne@69
|
160 Atom target, char *buffer, int maxBytes,
|
jpayne@69
|
161 Atom *typePtr);
|
jpayne@69
|
162 #ifndef TkSelUpdateClipboard
|
jpayne@69
|
163 MODULE_SCOPE void TkSelUpdateClipboard(TkWindow *winPtr,
|
jpayne@69
|
164 TkClipboardTarget *targetPtr);
|
jpayne@69
|
165 #endif
|
jpayne@69
|
166
|
jpayne@69
|
167 #endif /* _TKSELECT */
|