Changeset 18551 in vbox
- Timestamp:
- Mar 30, 2009 2:37:40 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/HostServices/SharedClipboard/x11-clipboard.cpp
r18417 r18551 95 95 } VBOXBITMAPFILEHEADER; 96 96 97 /** Global context information used by the host clipboard subsystem */ 97 /** Global context information used by the host glue for the X11 clipboard 98 * backend */ 98 99 struct _VBOXCLIPBOARDCONTEXT 99 100 { … … 108 109 /** This mutex is grabbed during any critical operations on the clipboard 109 110 * which might clash with others. */ 110 /** @todo this is still used in X11 backend parts, disentangle it. */111 111 RTSEMMUTEX clipboardMutex; 112 113 /** @todo both the VBox subsystem and the X11 backend need the following114 * members, so we need to transfer them between the two contexts at115 * an appropriate time */116 /** Format which we are reading from the X11 clipboard (valid during a117 * request for its contents) */118 g_eClipboardFormats requestX11Format;119 /** The buffer to write X11 clipboard data to (valid during a request120 * for the clipboard contents) */121 void *requestBuffer;122 /** The size of the buffer to write X11 clipboard data to (valid during123 * a request for the clipboard contents) */124 unsigned requestBufferSize;125 /** The size of the X11 clipboard data written to the buffer (valid126 * during a request for the clipboard contents) */127 uint32_t *requestActualSize;128 112 129 113 /** Pointer to the client data structure */ … … 187 171 * when the data arrives. */ 188 172 RTSEMEVENT waitForData; 189 190 /** Format which we are reading from the X11 clipboard (valid during a 191 * request for its contents) */ 192 g_eClipboardFormats requestX11Format; 173 }; 174 175 typedef struct _VBOXCLIPBOARDCONTEXTX11 VBOXCLIPBOARDCONTEXTX11; 176 177 /** A structure containing information about where to store a request 178 * for the X11 clipboard contents. */ 179 struct _VBOXCLIPBOARDREQUEST 180 { 193 181 /** The buffer to write X11 clipboard data to (valid during a request 194 182 * for the clipboard contents) */ 195 void * requestBuffer;183 void *pv; 196 184 /** The size of the buffer to write X11 clipboard data to (valid during 197 185 * a request for the clipboard contents) */ 198 unsigned requestBufferSize;186 unsigned cb; 199 187 /** The size of the X11 clipboard data written to the buffer (valid 200 188 * during a request for the clipboard contents) */ 201 uint32_t * requestActualSize;189 uint32_t *pcbActual; 202 190 }; 203 191 204 typedef struct _VBOXCLIPBOARD CONTEXTX11 VBOXCLIPBOARDCONTEXTX11;192 typedef struct _VBOXCLIPBOARDREQUEST VBOXCLIPBOARDREQUEST; 205 193 206 194 /* Only one client is supported. There seems to be no need for more clients. … … 222 210 * @param pcb On success, this contains the number of bytes of data 223 211 * returned 212 * @note Host glue code. 224 213 */ 225 214 static int vboxClipboardReadDataFromVBox (VBOXCLIPBOARDCONTEXT *pCtx, uint32_t u32Format, void **ppv, uint32_t *pcb) … … 290 279 291 280 /** 292 * Convert the UTF-16 text returned from the X11 clipboard to UTF-16LE with Windows EOLs293 * and place it in the global g_pcClipboardText variable. We are reading the host clipboard to294 * make it available to the guest.281 * Convert the UTF-16 text obtained from the X11 clipboard to UTF-16LE with 282 * Windows EOLs, place it in the buffer supplied and signal that data has 283 * arrived. 295 284 * 296 285 * @param pValue Source UTF-16 text … … 300 289 * @param pcbActual Where to store the size of the converted data 301 290 * @param pClient Pointer to the client context structure 302 */ 303 static void vboxClipboardGetUtf16(XtPointer pValue, unsigned cwSrcLen, void *pv, unsigned cb, 291 * @note X11 backend code, called from the Xt callback when we wish to read 292 * the X11 clipboard. 293 */ 294 static void vboxClipboardGetUtf16(XtPointer pValue, unsigned cwSrcLen, 295 void *pv, unsigned cb, 304 296 uint32_t *pcbActual) 305 297 { … … 336 328 337 329 /** 338 * Convert the UTF-8 text returned from the X11 clipboard to UTF-16LE with Windows EOLS. 339 * We are reading the X11 clipboard to make it available to VBox. 330 * Convert the UTF-8 text obtained from the X11 clipboard to UTF-16LE with 331 * Windows EOLs, place it in the buffer supplied and signal that data has 332 * arrived. 340 333 * 341 334 * @param pValue Source UTF-8 text … … 345 338 * @param pcbActual Where to store the size of the converted data 346 339 * @param pClient Pointer to the client context structure 347 * @ thread clipboard X11 event thread348 * @note called by vboxClipboardGetDataFromX11340 * @note X11 backend code, called from the Xt callback when we wish to read 341 * the X11 clipboard. 349 342 */ 350 343 static void vboxClipboardGetUtf8FromX11(XtPointer pValue, unsigned cbSrcLen, … … 388 381 389 382 /** 390 * Convert the COMPOUND_TEXT text returned from the X11 clipboard to UTF-16LE with Windows 391 * EOLS. We are reading the X11 clipboard to make it available to VBox. 392 * 393 * @param pValue Source COMPOUND_TEXT text 383 * Convert the COMPOUND_TEXT obtained from the X11 clipboard to UTF-16LE with 384 * Windows EOLs, place it in the buffer supplied and signal that data has 385 * arrived. 386 * 387 * @param pValue Source COMPOUND_TEXT 394 388 * @param cbSourceLen Length in 8-bit bytes of the source text 395 389 * @param pv Where to store the converted data … … 397 391 * @param pcbActual Where to store the size of the converted data 398 392 * @param pClient Pointer to the client context structure 399 * @ thread clipboard X11 event thread400 * @note called by vboxClipboardGetDataFromX11393 * @note X11 backend code, called from the Xt callback when we wish to read 394 * the X11 clipboard. 401 395 */ 402 396 static void vboxClipboardGetCTextFromX11(XtPointer pValue, unsigned cbSrcLen, … … 469 463 470 464 /** 471 * Convert the Latin1 text returned from the X11 clipboard to UTF-16LE with Windows EOLS472 * and place it in the global g_pcClipboardText variable. We are reading the X11 clipboard to473 * make it available to VBox.465 * Convert the Latin1 text obtained from the X11 clipboard to UTF-16LE with 466 * Windows EOLs, place it in the buffer supplied and signal that data has 467 * arrived. 474 468 * 475 469 * @param pValue Source Latin1 text … … 479 473 * @param pcbActual Where to store the size of the converted data 480 474 * @param pClient Pointer to the client context structure 481 * @thread clipboard X11 event thread 482 * @note called by vboxClipboardGetDataFromX11 483 */ 484 static void vboxClipboardGetLatin1FromX11(XtPointer pValue, unsigned cbSourceLen, void *pv, unsigned cb, 485 uint32_t *pcbActual) 475 * @note X11 backend code, called from the Xt callback when we wish to read 476 * the X11 clipboard. 477 */ 478 static void vboxClipboardGetLatin1FromX11(XtPointer pValue, 479 unsigned cbSourceLen, void *pv, 480 unsigned cb, uint32_t *pcbActual) 486 481 { 487 482 unsigned cwDestLen = cbSourceLen + 1; … … 524 519 525 520 /** 526 * Convert the clipboard text from the current format to Utf-16 with Windows line breaks.527 * We are reading the X11 clipboard to make it available to VBox.528 * @ thread clipboard X11 event thread529 * @note Callback for XtGetSelectionValue, called from vboxClipboardReadData521 * Convert the text obtained from the X11 clipboard to UTF-16LE with Windows 522 * EOLs, place it in the buffer supplied and signal that data has arrived. 523 * @note X11 backend code, callback for XtGetSelectionValue, for use when 524 * the X11 clipboard contains a text format we understand. 530 525 */ 531 526 static void vboxClipboardGetDataFromX11(Widget, XtPointer pClientData, 532 Atom * /* selection */, Atom *atomType, 527 Atom * /* selection */, 528 Atom *atomType, 533 529 XtPointer pValue, 534 530 long unsigned int *pcLen, 535 531 int *piFormat) 536 532 { 537 LogFlowFunc(("pClientData=%p, *pcLen=%lu, *piFormat=%d\n", pClientData, *pcLen, *piFormat)); 538 LogFlowFunc(("g_ctxHost.requestX11Format=%d, g_ctxHost.requestBufferSize=%d\n", 539 g_ctxHost.requestX11Format, g_ctxHost.requestBufferSize)); 533 VBOXCLIPBOARDREQUEST *pRequest 534 = reinterpret_cast<VBOXCLIPBOARDREQUEST *>(pClientData); 535 LogFlowFunc(("pClientData=%p, *pcLen=%lu, *piFormat=%d\n", pClientData, 536 *pcLen, *piFormat)); 537 LogFlowFunc(("g_ctxX11.X11TextFormat=%d, pRequest->cb=%d\n", 538 g_ctxX11.X11TextFormat, pRequest->cb)); 540 539 unsigned cTextLen = (*pcLen) * (*piFormat) / 8; 541 540 /* The X Toolkit may have failed to get the clipboard selection for us. */ … … 545 544 if (NULL == pValue) 546 545 return; 547 /* We grab this mutex whenever an asynchronous clipboard operation completes and while 548 disconnecting a client from the clipboard to stop these operations colliding. */ 549 RTSemMutexRequest(g_ctxHost.clipboardMutex, RT_INDEFINITE_WAIT); 550 if (reinterpret_cast<VBOXCLIPBOARDCLIENTDATA *>(pClientData) != g_ctxHost.pClient) 551 { 552 /* If the client is no longer connected, just return. */ 553 XtFree(reinterpret_cast<char *>(pValue)); 554 LogFlowFunc(("client is no longer connected, returning\n")); 555 RTSemMutexRelease(g_ctxHost.clipboardMutex); 556 return; 557 } 558 559 /* In which format did we request the clipboard data? */ 560 switch (g_ctxHost.requestX11Format) 546 /* In which format is the clipboard data? */ 547 switch (g_ctxX11.X11TextFormat) 561 548 { 562 549 case UTF16: 563 vboxClipboardGetUtf16(pValue, cTextLen / 2, g_ctxHost.requestBuffer, g_ctxHost.requestBufferSize,564 g_ctxHost.requestActualSize);550 vboxClipboardGetUtf16(pValue, cTextLen / 2, pRequest->pv, 551 pRequest->cb, pRequest->pcbActual); 565 552 break; 566 553 case CTEXT: 567 vboxClipboardGetCTextFromX11(pValue, cTextLen, g_ctxHost.requestBuffer, g_ctxHost.requestBufferSize,568 g_ctxHost.requestActualSize);554 vboxClipboardGetCTextFromX11(pValue, cTextLen, pRequest->pv, 555 pRequest->cb, pRequest->pcbActual); 569 556 break; 570 557 case UTF8: … … 574 561 char *pu8SourceText = reinterpret_cast<char *>(pValue); 575 562 576 if ((g_ctx Host.requestX11Format == UTF8)563 if ((g_ctxX11.X11TextFormat == UTF8) 577 564 && (RTStrUniLenEx(pu8SourceText, *pcLen, &cStringLen) == VINF_SUCCESS)) 578 565 { 579 vboxClipboardGetUtf8FromX11(pValue, cTextLen, g_ctxHost.requestBuffer, g_ctxHost.requestBufferSize,580 g_ctxHost.requestActualSize);566 vboxClipboardGetUtf8FromX11(pValue, cTextLen, pRequest->pv, 567 pRequest->cb, pRequest->pcbActual); 581 568 break; 582 569 } 583 570 else 584 571 { 585 vboxClipboardGetLatin1FromX11(pValue, cTextLen, g_ctxHost.requestBuffer, g_ctxHost.requestBufferSize,586 g_ctxHost.requestActualSize);572 vboxClipboardGetLatin1FromX11(pValue, cTextLen, pRequest->pv, 573 pRequest->cb, pRequest->pcbActual); 587 574 break; 588 575 } … … 591 578 LogFunc (("bad target format\n")); 592 579 XtFree(reinterpret_cast<char *>(pValue)); 593 RTSemMutexRelease(g_ctxHost.clipboardMutex);594 580 return; 595 581 } 596 582 g_ctxX11.notifyVBox = true; 597 RTSemMutexRelease(g_ctxHost.clipboardMutex); 598 } 599 600 /** 601 * Find out what targets the current X11 clipboard holder can handle. We are 602 * reading the X11 clipboard to make it available to VBox. 603 * @thread clipboard X11 event thread 604 * @note Callback for XtGetSelectionValue, called from vboxClipboardPollX11ForTargets 605 */ 606 static void vboxClipboardGetTargetsFromX11(Widget, XtPointer pClientData, 583 } 584 585 /** 586 * Notify the host clipboard about the data formats we support, based on the 587 * "targets" (available data formats) information obtained from the X11 588 * clipboard. 589 * @note X11 backend code, callback for XtGetSelectionValue, called when we 590 * poll for available targets. 591 * @todo This function still references host-specific data and calls host 592 * frontend APIs. Fix. 593 */ 594 static void vboxClipboardGetTargetsFromX11(Widget, 595 XtPointer /* pClientData */, 607 596 Atom * /* selection */, 608 597 Atom *atomType, … … 620 609 { 621 610 LogFunc (("reading clipboard from host, X toolkit failed to convert the selection\n")); 622 return;623 }624 /* We grab this mutex whenever an asynchronous clipboard operation completes and while625 disconnecting a client from the clipboard to stop these operations colliding. */626 RTSemMutexRequest(g_ctxHost.clipboardMutex, RT_INDEFINITE_WAIT);627 if (reinterpret_cast<VBOXCLIPBOARDCLIENTDATA *>(pClientData) != g_ctxHost.pClient)628 {629 /* If the client is no longer connected, just return. */630 LogFlowFunc(("client is no longer connected, returning\n"));631 RTSemMutexRelease(g_ctxHost.clipboardMutex);632 611 return; 633 612 } … … 690 669 } 691 670 XtFree(reinterpret_cast<char *>(pValue)); 692 RTSemMutexRelease(g_ctxHost.clipboardMutex); 693 } 694 695 /** 696 * This callback is called every 200ms to check the contents of the X11 clipboard. 697 * @thread clipboard X11 event thread 698 * @note Callback for XtAppAddTimeOut, called from vboxClipboardThread and 699 * recursively retriggered 671 } 672 673 /** 674 * This timer callback is called every 200ms to check the contents of the X11 675 * clipboard. 676 * @note X11 backend code, callback for XtAppAddTimeOut, recursively 677 * re-armed. 678 * @todo This function still references host-specific data. Fix. 679 * @todo Use the XFIXES extension to check for new clipboard data when 680 * available. 700 681 */ 701 682 static void vboxClipboardPollX11ForTargets(XtPointer /* pUserData */, XtIntervalId * /* hTimerId */) … … 715 696 } 716 697 717 /** We store information about the target formats we can handle in a global vector for internal 718 use. */ 698 /** We store information about the target formats we can handle in a global 699 * vector for internal use. 700 * @note X11 backend code. 701 */ 719 702 static void vboxClipboardAddFormat(const char *pszName, g_eClipboardFormats eFormat, 720 703 unsigned guestFormat) … … 732 715 /** 733 716 * The main loop of our clipboard reader. 734 * @ thread clipboard X11 event thread717 * @note X11 backend code. 735 718 */ 736 719 static int vboxClipboardThread(RTTHREAD self, void * /* pvUser */) … … 747 730 } 748 731 749 /** X11 specific initialisation for the shared clipboard. */ 732 /** X11 specific initialisation for the shared clipboard. 733 * @note X11 backend code. 734 */ 750 735 int vboxClipboardInitX11 (void) 751 736 { … … 825 810 /** 826 811 * Initialise the host side of the shared clipboard. 827 * @ note Called by the HGCM clipboard service828 * @thread HGCM clipboard service thread812 * @todo This mixes host glue and X11 backend code, separate into two 813 * functions. 829 814 */ 830 815 int vboxClipboardInit (void) … … 890 875 /** 891 876 * Terminate the host side of the shared clipboard. 892 * @ note Called by the HGCM clipboard service893 * @thread HGCM clipboard service thread877 * @todo This mixes host glue and X11 backend code, separate into two 878 * functions. 894 879 */ 895 880 void vboxClipboardDestroy (void) … … 958 943 /** 959 944 * Connect a guest the shared clipboard. 960 * 961 * @param pClient Structure containing context information about the guest system 962 * @returns RT status code 963 * @note Called by the HGCM clipboard service 964 * @thread HGCM clipboard service thread 945 * @todo This mixes host glue and X11 backend code, separate into two 946 * functions. 965 947 */ 966 948 int vboxClipboardConnect (VBOXCLIPBOARDCLIENTDATA *pClient) … … 987 969 * Synchronise the contents of the host clipboard with the guest, called 988 970 * after a save and restore of the guest. 989 * @ note Called by the HGCM clipboard service990 * @thread HGCM clipboard service thread971 * @todo This mixes host glue and X11 backend code and calls host frontend 972 * APIs. Separate into two functions. 991 973 */ 992 974 int vboxClipboardSync (VBOXCLIPBOARDCLIENTDATA *pClient) … … 1010 992 /** 1011 993 * Shut down the shared clipboard service and "disconnect" the guest. 1012 * @ note Called by the HGCM clipboard service1013 * @thread HGCM clipboard service thread994 * @todo This mixes host glue and X11 backend code, separate into two 995 * functions. 1014 996 */ 1015 997 void vboxClipboardDisconnect (VBOXCLIPBOARDCLIENTDATA *) … … 1034 1016 * Satisfy a request from X11 for clipboard targets supported by VBox. 1035 1017 * 1036 * @returns true if we successfully convert the data to the format requested, false otherwise. 1018 * @returns true if we successfully convert the data to the format 1019 * requested, false otherwise. 1037 1020 * 1038 1021 * @param atomTypeReturn The type of the data we are returning 1039 * @param pValReturn A pointer to the data we are returning. This should be to memory 1040 * allocated by XtMalloc, which will be freed by the toolkit later 1022 * @param pValReturn A pointer to the data we are returning. This 1023 * should be set to memory allocated by XtMalloc, 1024 * which will be freed later by the Xt toolkit. 1041 1025 * @param pcLenReturn The length of the data we are returning 1042 * @param piFormatReturn The format (8bit, 16bit, 32bit) of the data we are returning 1043 * @thread clipboard X11 event thread 1044 * @note called by vboxClipboardConvertForX11 1045 */ 1046 static Boolean vboxClipboardConvertTargetsForX11(Atom *atomTypeReturn, XtPointer *pValReturn, 1047 unsigned long *pcLenReturn, int *piFormatReturn) 1026 * @param piFormatReturn The format (8bit, 16bit, 32bit) of the data we are 1027 * returning 1028 * @note X11 backend code, called by the XtOwnSelection callback. 1029 */ 1030 static Boolean vboxClipboardConvertTargetsForX11(Atom *atomTypeReturn, 1031 XtPointer *pValReturn, 1032 unsigned long *pcLenReturn, 1033 int *piFormatReturn) 1048 1034 { 1049 1035 unsigned uListSize = g_ctxX11.formatList.size(); … … 1090 1076 1091 1077 /** 1092 * Satisfy a request from X11 to convert the clipboard text to Utf16. We return non-zero 1093 * terminated text. 1094 * 1095 * @returns true if we successfully convert the data to the format requested, false otherwise. 1096 * 1097 * @retval atomTypeReturn The type of the data we are returning 1098 * @retval pValReturn A pointer to the data we are returning. This should be to memory 1099 * allocated by XtMalloc, which will be freed by the toolkit later 1100 * @retval pcLenReturn The length of the data we are returning 1101 * @retval piFormatReturn The format (8bit, 16bit, 32bit) of the data we are returning 1102 */ 1103 static Boolean vboxClipboardConvertUtf16(Atom *atomTypeReturn, XtPointer *pValReturn, 1104 unsigned long *pcLenReturn, int *piFormatReturn) 1078 * Satisfy a request from X11 to convert the clipboard text to Utf16. We 1079 * return non-zero terminated text. 1080 * @todo that works, but it is bad. Change it to return zero-terminated 1081 * text. 1082 * 1083 * @returns true if we successfully convert the data to the format 1084 * requested, false otherwise. 1085 * 1086 * @param atomTypeReturn Where to store the atom for the type of the data 1087 * we are returning 1088 * @param pValReturn Where to store the pointer to the data we are 1089 * returning. This should be to memory allocated by 1090 * XtMalloc, which will be freed by the Xt toolkit 1091 * later. 1092 * @param pcLenReturn Where to store the length of the data we are 1093 * returning 1094 * @param piFormatReturn Where to store the bit width (8, 16, 32) of the 1095 * data we are returning 1096 * @note X11 backend code, called by the callback for XtOwnSelection. 1097 * @todo this function uses host-specific data and APIs. Fix. 1098 */ 1099 static Boolean vboxClipboardConvertUtf16(Atom *atomTypeReturn, 1100 XtPointer *pValReturn, 1101 unsigned long *pcLenReturn, 1102 int *piFormatReturn) 1105 1103 { 1106 1104 PRTUTF16 pu16SrcText, pu16DestText; … … 1162 1160 1163 1161 /** 1164 * Satisfy a request from X11 to convert the clipboard text to Utf8. 1165 * 1166 * @returns true if we successfully convert the data to the format requested, false otherwise. 1167 * 1168 * @param atomTypeReturn The type of the data we are returning 1169 * @param pValReturn A pointer to the data we are returning. This should be to memory 1170 * allocated by XtMalloc, which will be freed by the toolkit later 1171 * @param pcLenReturn The length of the data we are returning 1172 * @param piFormatReturn The format (8bit, 16bit, 32bit) of the data we are returning 1173 * @thread clipboard X11 event thread 1174 * @note called by vboxClipboardConvertForX11 1162 * Satisfy a request from X11 to convert the clipboard text to Utf8. We 1163 * return non-zero terminated text. 1164 * @todo that works, but it is bad. Change it to return zero-terminated 1165 * text. 1166 * 1167 * @returns true if we successfully convert the data to the format 1168 * requested, false otherwise. 1169 * 1170 * @param atomTypeReturn Where to store the atom for the type of the data 1171 * we are returning 1172 * @param pValReturn Where to store the pointer to the data we are 1173 * returning. This should be to memory allocated by 1174 * XtMalloc, which will be freed by the Xt toolkit 1175 * later. 1176 * @param pcLenReturn Where to store the length of the data we are 1177 * returning 1178 * @param piFormatReturn Where to store the bit width (8, 16, 32) of the 1179 * data we are returning 1180 * @note X11 backend code, called by the callback for XtOwnSelection. 1181 * @todo this function uses host-specific data and APIs. Fix. 1175 1182 */ 1176 1183 static Boolean vboxClipboardConvertToUtf8ForX11(Atom *atomTypeReturn, … … 1260 1267 1261 1268 /** 1262 * Satisfy a request from X11 to convert the clipboard text to COMPOUND_TEXT. 1263 * 1264 * @returns true if we successfully convert the data to the format requested, false otherwise. 1265 * 1266 * @param atomTypeReturn The type of the data we are returning 1267 * @param pValReturn A pointer to the data we are returning. This should be to memory 1268 * allocated by XtMalloc, which will be freed by the toolkit later 1269 * @param pcLenReturn The length of the data we are returning 1270 * @param piFormatReturn The format (8bit, 16bit, 32bit) of the data we are returning 1271 * @thread clipboard X11 event thread 1272 * @note called by vboxClipboardConvertForX11 1269 * Satisfy a request from X11 to convert the clipboard text to 1270 * COMPOUND_TEXT. We return non-zero terminated text. 1271 * @todo that works, but it is bad. Change it to return zero-terminated 1272 * text. 1273 * 1274 * @returns true if we successfully convert the data to the format 1275 * requested, false otherwise. 1276 * 1277 * @param atomTypeReturn Where to store the atom for the type of the data 1278 * we are returning 1279 * @param pValReturn Where to store the pointer to the data we are 1280 * returning. This should be to memory allocated by 1281 * XtMalloc, which will be freed by the Xt toolkit 1282 * later. 1283 * @param pcLenReturn Where to store the length of the data we are 1284 * returning 1285 * @param piFormatReturn Where to store the bit width (8, 16, 32) of the 1286 * data we are returning 1287 * @note X11 backend code, called by the callback for XtOwnSelection. 1288 * @todo this function uses host-specific data and APIs. Fix. 1273 1289 */ 1274 1290 static Boolean vboxClipboardConvertToCTextForX11(Atom *atomTypeReturn, … … 1378 1394 1379 1395 /** 1380 * Callback to request VBox's clipboard data for an X11 client. Called by the 1381 * X Toolkit. 1382 * @thread clipboard X11 event thread 1383 * @note callback for XtOwnSelection, called by vboxClipboardFormatAnnounce 1396 * Return VBox's clipboard data for an X11 client. 1397 * @note X11 backend code, callback for XtOwnSelection 1384 1398 */ 1385 1399 static Boolean vboxClipboardConvertForX11(Widget, Atom *atomSelection, … … 1453 1467 /** 1454 1468 * This is called by the X toolkit intrinsics to let us know that another 1455 * X11 client has taken the clipboard. 1456 * @note callback for XtOwnSelection, called from vboxClipboardFormatAnnounce1457 * @ thread clipboard X11 event thread1469 * X11 client has taken the clipboard. In this case we notify VBox that 1470 * we want ownership of the clipboard. 1471 * @note X11 backend code, callback for XtOwnSelection 1458 1472 */ 1459 1473 static void vboxClipboardReturnToX11(Widget, Atom *) … … 1518 1532 * Called when VBox wants to read the X11 clipboard. 1519 1533 * 1520 * @param pClient Context information about the guest VM 1521 * @param u32Format The format that the guest would like to receive the data in 1522 * @param pv Where to write the data to 1523 * @param cb The size of the buffer to write the data to 1524 * @param pcbActual Where to write the actual size of the written data 1525 * @note Called by the HGCM clipboard service 1526 * @thread HGCM clipboard service thread 1527 */ 1528 int vboxClipboardReadData (VBOXCLIPBOARDCLIENTDATA *pClient, uint32_t u32Format, void *pv, 1529 uint32_t cb, uint32_t *pcbActual) 1530 { 1534 * @param pClient Context information about the guest VM 1535 * @param u32Format The format that the guest would like to receive the data in 1536 * @param pv Where to write the data to 1537 * @param cb The size of the buffer to write the data to 1538 * @param pcbActual Where to write the actual size of the written data 1539 * @note Host glue code 1540 * @todo Separate this into a host and an X11-specific function 1541 */ 1542 int vboxClipboardReadData (VBOXCLIPBOARDCLIENTDATA *pClient, 1543 uint32_t u32Format, void *pv, uint32_t cb, 1544 uint32_t *pcbActual) 1545 { 1546 VBOXCLIPBOARDREQUEST request; 1531 1547 /* 1532 1548 * Immediately return if we are not connected to the host X server. … … 1556 1572 * grabbed the clipboard, so it should not be waiting for data from us. */ 1557 1573 AssertLogRelReturn (ASMAtomicCmpXchgU32(&g_ctxHost.waiter, VB, NONE), VERR_DEADLOCK); 1558 g_ctxHost.requestX11Format = g_ctxX11.X11TextFormat; 1559 g_ctxHost.requestBuffer = pv; 1560 g_ctxHost.requestBufferSize = cb; 1561 g_ctxHost.requestActualSize = pcbActual; 1574 request.pv = pv; 1575 request.cb = cb; 1576 request.pcbActual = pcbActual; 1562 1577 /* Initially set the size of the data read to zero in case we fail 1563 1578 * somewhere. */ 1564 1579 *pcbActual = 0; 1565 1580 /* Send out a request for the data to the current clipboard owner */ 1566 XtGetSelectionValue(g_ctxX11.widget, g_ctxX11.atomClipboard, g_ctxX11.atomX11TextFormat, 1567 vboxClipboardGetDataFromX11, reinterpret_cast<XtPointer>(g_ctxHost.pClient), 1581 XtGetSelectionValue(g_ctxX11.widget, g_ctxX11.atomClipboard, 1582 g_ctxX11.atomX11TextFormat, 1583 vboxClipboardGetDataFromX11, 1584 reinterpret_cast<XtPointer>(&request), 1568 1585 CurrentTime); 1569 1586 /* When the data arrives, the vboxClipboardGetDataFromX11 callback will be called. The … … 1588 1605 * Called when we have requested data from VBox and that data has arrived. 1589 1606 * 1590 * @param pClient Context information about the guest VM 1591 * @param pv Buffer to which the data was written 1592 * @param cb The size of the data written 1593 * @param u32Format The format of the data written 1594 * @note Called by the HGCM clipboard service 1595 * @thread HGCM clipboard service thread 1607 * @param pClient Context information about the guest VM 1608 * @param pv Buffer to which the data was written 1609 * @param cb The size of the data written 1610 * @param u32Format The format of the data written 1611 * @note Host glue code 1596 1612 */ 1597 1613 void vboxClipboardWriteData (VBOXCLIPBOARDCLIENTDATA *pClient, void *pv, uint32_t cb, uint32_t u32Format)
Note:
See TracChangeset
for help on using the changeset viewer.

