Changeset 93495 in vbox for trunk/include/VBox
- Timestamp:
- Jan 31, 2022 1:08:33 PM (3 years ago)
- svn:sync-xref-src-repo-rev:
- 149618
- Location:
- trunk/include/VBox/GuestHost
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/VBox/GuestHost/SharedClipboard-x11.h
r93321 r93495 92 92 { 93 93 /** Opaque data structure describing the front-end. */ 94 PSHCLCONTEXT pFrontend; 94 PSHCLCONTEXT pFrontend; 95 /** Our callback table to use. */ 96 SHCLCALLBACKS Callbacks; 95 97 /** Is an X server actually available? */ 96 bool fHaveX11;98 bool fHaveX11; 97 99 /** The X Toolkit application context structure. */ 98 XtAppContext pAppContext; 99 100 XtAppContext pAppContext; 100 101 /** We have a separate thread to wait for window and clipboard events. */ 101 RTTHREAD Thread;102 RTTHREAD Thread; 102 103 /** Flag indicating that the thread is in a started state. */ 103 bool fThreadStarted; 104 104 bool fThreadStarted; 105 105 /** The X Toolkit widget which we use as our clipboard client. It is never made visible. */ 106 Widget pWidget; 107 106 Widget pWidget; 108 107 /** Should we try to grab the clipboard on startup? */ 109 bool fGrabClipboardOnStart; 110 108 bool fGrabClipboardOnStart; 111 109 /** The best text format X11 has to offer, as an index into the formats table. */ 112 SHCLX11FMTIDX idxFmtText;110 SHCLX11FMTIDX idxFmtText; 113 111 /** The best bitmap format X11 has to offer, as an index into the formats table. */ 114 SHCLX11FMTIDX idxFmtBmp;112 SHCLX11FMTIDX idxFmtBmp; 115 113 /** The best HTML format X11 has to offer, as an index into the formats table. */ 116 SHCLX11FMTIDX idxFmtHTML;114 SHCLX11FMTIDX idxFmtHTML; 117 115 #ifdef VBOX_WITH_SHARED_CLIPBOARD_TRANSFERS 118 116 /** The best HTML format X11 has to offer, as an index into the formats table. */ 119 SHCLX11FMTIDX idxFmtURI;117 SHCLX11FMTIDX idxFmtURI; 120 118 # ifdef VBOX_WITH_SHARED_CLIPBOARD_TRANSFERS_HTTP 121 119 /** HTTP transfer context data. */ 122 SHCLHTTPCONTEXT HttpCtx;120 SHCLHTTPCONTEXT HttpCtx; 123 121 # endif 124 122 #endif 125 123 /** What kind of formats does VBox have to offer? */ 126 SHCLFORMATS vboxFormats;124 SHCLFORMATS vboxFormats; 127 125 /** Cache of the last unicode data that we received. */ 128 void *pvUnicodeCache;126 void *pvUnicodeCache; 129 127 /** Size of the unicode data in the cache. */ 130 uint32_t cbUnicodeCache;128 uint32_t cbUnicodeCache; 131 129 /** When we wish the clipboard to exit, we have to wake up the event 132 130 * loop. We do this by writing into a pipe. This end of the pipe is 133 131 * the end that another thread can write to. */ 134 int wakeupPipeWrite;132 int wakeupPipeWrite; 135 133 /** The reader end of the pipe. */ 136 int wakeupPipeRead;134 int wakeupPipeRead; 137 135 /** A pointer to the XFixesSelectSelectionInput function. */ 138 136 void (*fixesSelectInput)(Display *, Window, Atom, unsigned long); 139 137 /** The first XFixes event number. */ 140 int fixesEventBase;138 int fixesEventBase; 141 139 #ifdef VBOX_WITH_SHARED_CLIPBOARD_XT_BUSY 142 140 /** XtGetSelectionValue on some versions of libXt isn't re-entrant 143 141 * so block overlapping requests on this flag. */ 144 bool fXtBusy;142 bool fXtBusy; 145 143 /** If a request is blocked on the previous flag, set this flag to request 146 144 * an update later - the first callback should check and clear this flag 147 145 * before processing the callback event. */ 148 bool fXtNeedsUpdate;146 bool fXtNeedsUpdate; 149 147 #endif 150 148 } SHCLX11CTX, *PSHCLX11CTX; 149 150 /** 151 * Structure for keeping a X11 read data request. 152 */ 153 typedef struct _SHCLX11READDATAREQ 154 { 155 /** Actual read request to handle. */ 156 CLIPREADCBREQ *pReq; 157 /** Result code of the operation on completion. */ 158 int rcCompletion; 159 } SHCLX11READDATAREQ; 160 /** Pointer to a send data request. */ 161 typedef SHCLX11READDATAREQ *PSHCLX11READDATAREQ; 151 162 152 163 /** @name Shared Clipboard APIs for X11. 153 164 * @{ 154 165 */ 155 int ShClX11Init(PSHCLX11CTX pCtx, PSHCLC ONTEXT pParent, bool fHeadless);166 int ShClX11Init(PSHCLX11CTX pCtx, PSHCLCALLBACKS pCallbacks, PSHCLCONTEXT pParent, bool fHeadless); 156 167 void ShClX11Destroy(PSHCLX11CTX pCtx); 157 168 int ShClX11ThreadStart(PSHCLX11CTX pCtx, bool grab); 169 int ShClX11ThreadStartEx(PSHCLX11CTX pCtx, const char *pszName, bool fGrab); 158 170 int ShClX11ThreadStop(PSHCLX11CTX pCtx); 159 171 int ShClX11ReportFormatsToX11(PSHCLX11CTX pCtx, SHCLFORMATS vboxFormats); 160 172 int ShClX11ReadDataFromX11(PSHCLX11CTX pCtx, SHCLFORMATS vboxFormat, CLIPREADCBREQ *pReq); 161 /** @} */ 162 163 /** @name Shared Clipboard callbacks which have to be implemented by tools using the X11 164 * clipboard, e.g. VBoxClient (on guest side) or the X11 host service backend. 165 * @{ 166 */ 167 /** 168 * Callback for reporting supported formats of current clipboard data from X11 to VBox. 169 * 170 * @note Runs in Xt event thread. 171 * 172 * @param pCtx Opaque context pointer for the glue code. 173 * @param fFormats The formats available. 174 */ 175 DECLCALLBACK(void) ShClX11ReportFormatsCallback(PSHCLCONTEXT pCtx, SHCLFORMATS fFormats); 176 177 /** 178 * Callback for requesting clipboard data for X11. 179 * The function will be invoked for every single target the clipboard requests. 180 * 181 * @note Runs in Xt event thread. 182 * 183 * @returns VBox status code. VERR_NO_DATA if no data available. 184 * @param pCtx Pointer to the host clipboard structure. 185 * @param uFmt The format in which the data should be transferred 186 * (VBOX_SHCL_FMT_XXX). 187 * @param ppv Returns an allocated buffer with data read from the guest on success. 188 * Needs to be free'd with RTMemFree() by the caller. 189 * @param pcb Returns the amount of data read (in bytes) on success. 190 */ 191 DECLCALLBACK(int) ShClX11RequestDataCallback(PSHCLCONTEXT pCtx, SHCLFORMAT uFmt, void **ppv, uint32_t *pcb); 192 193 /** 194 * Callback for reporting that clipboard data from X11 is available. 195 * 196 * @param pCtx Our context information. 197 * @param rcCompletion The completion status of the request. 198 * @param pReq The request structure that we passed in when we started 199 * the request. We RTMemFree() this in this function. 200 * @param pv The clipboard data returned from X11 if the request succeeded (see @a rcCompletion). 201 * @param cb The size of the data in @a pv. 202 */ 203 DECLCALLBACK(void) ShClX11ReportDataCallback(PSHCLCONTEXT pCtx, int rcCompletion, 204 CLIPREADCBREQ *pReq, void *pv, uint32_t cb); 173 void ShClX11SetCallbacks(PSHCLX11CTX pCtx, PSHCLCALLBACKS pCallbacks); 205 174 /** @} */ 206 175 -
trunk/include/VBox/GuestHost/SharedClipboard.h
r93115 r93495 232 232 typedef SHCLCONTEXT *PSHCLCONTEXT; 233 233 234 /** 235 * @name Shared Clipboard callback table. 236 * 237 * This table gets used by 238 * - the backends on the host (where required) 239 * - guest side implementations (e.g. VBoxClient) 240 * - by the underlying core code (e.g. X11 backend -> X11 common code -> callback) 241 * 242 * Some clipboard mechanisms (e.g. X11) require asynchronous and/or event-driven handling 243 * of clipboard data, making it hard to control our program flow when testing stuff. 244 * 245 * So overriding required callbacks on runtime for testing purposes makes this approach much 246 * more flexible without implementing separate code paths for production code and test units. 247 * 248 * @{ 249 */ 250 typedef struct _SHCLCALLBACKS 251 { 252 /** 253 * Callback for reporting supported clipoard formats of current clipboard data. 254 * 255 * @note On X11: 256 * Runs in Xt event thread for the X11 code. 257 * 258 * @returns VBox status code. 259 * @param pCtx Opaque context pointer for the glue code. 260 * @param fFormats The formats available. 261 */ 262 DECLCALLBACKMEMBER(int, pfnReportFormats, (PSHCLCONTEXT pCtx, SHCLFORMATS fFormats, void *pvUser)); 263 264 /** 265 * Callback for reading data from the clipboard. 266 * Optional and can be NULL. 267 * 268 * @note Used for testing X11 clipboard code. 269 * 270 * @returns VBox status code. 271 * @param pCtx Opaque context pointer for the glue code. 272 * @param uFmt The format in which the data should be read 273 * (VBOX_SHCL_FMT_XXX). 274 * @param ppv Returns an allocated buffer with data from on success. 275 * Needs to be free'd with RTMemFree() by the caller. 276 * @param pcb Returns the amount of data read (in bytes) on success. 277 * @param pvUser Implementation-dependent pointer to data for fullfilling the request. 278 * Optional and can be NULL. 279 */ 280 DECLCALLBACKMEMBER(int, pfnOnClipboardRead, (PSHCLCONTEXT pCtx, SHCLFORMAT uFmt, void **ppv, size_t *pcb, void *pvUser)); 281 282 /** 283 * Callback for writing data to the clipboard. 284 * Optional and can be NULL. 285 * 286 * @note Used for testing X11 clipboard code. 287 * 288 * @returns VBox status code. 289 * @param pCtx Opaque context pointer for the glue code. 290 * @param uFmt The format in which the data should be written as 291 * (VBOX_SHCL_FMT_XXX). 292 * @param pv The clipboard data to write. 293 * @param cb The size of the data in @a pv. 294 * @param pvUser Implementation-dependent pointer to data for fullfilling the request. 295 * Optional and can be NULL. 296 */ 297 DECLCALLBACKMEMBER(int, pfnOnClipboardWrite, (PSHCLCONTEXT pCtx, SHCLFORMAT uFmt, void *pv, size_t cb, void *pvUser)); 298 299 /** 300 * Callback for requesting clipboard data from the source. 301 * 302 * @note On X11: 303 * The function will be invoked for every single target the clipboard requests. 304 * Runs in Xt event thread for the X11 code. 305 * 306 * @returns VBox status code. VERR_NO_DATA if no data available. 307 * @param pCtx Opaque context pointer for the glue code. 308 * @param uFmt The format in which the data should be transferred 309 * (VBOX_SHCL_FMT_XXX). 310 * @param ppv Returns an allocated buffer with data read from the guest on success. 311 * Needs to be free'd with RTMemFree() by the caller. 312 * @param pcb Returns the amount of data read (in bytes) on success. 313 * @param pvUser Implementation-dependent pointer to data for fullfilling the request. 314 * Optional and can be NULL. 315 * On X11: Of type PSHCLX11READDATAREQ; We RTMemFree() this in this function. 316 */ 317 DECLCALLBACKMEMBER(int, pfnOnRequestDataFromSource, (PSHCLCONTEXT pCtx, SHCLFORMAT uFmt, void **ppv, uint32_t *pcb, void *pvUser)); 318 319 /** 320 * Callback for sending clipboard data to the destination. 321 * 322 * @note On X11: 323 * (see @a rcCompletion) 324 * 325 * @returns VBox status code. 326 * @param pCtx Opaque context pointer for the glue code. 327 * @param pv The clipboard data returned if the request succeeded. 328 * @param cb The size of the data in @a pv. 329 * @param pvUser Implementation-dependent pointer to data for fullfilling the request. 330 * Optional and can be NULL. 331 */ 332 DECLCALLBACKMEMBER(int, pfnOnSendDataToDest, (PSHCLCONTEXT pCtx, void *pv, uint32_t cb, void *pvUser)); 333 } SHCLCALLBACKS; 334 typedef SHCLCALLBACKS *PSHCLCALLBACKS; 335 /** @} */ 336 234 337 /** Opaque request structure for X11 clipboard data. 235 338 * @{ */
Note:
See TracChangeset
for help on using the changeset viewer.