Changeset 15883 in vbox for trunk/src/VBox
- Timestamp:
- Jan 8, 2009 8:10:33 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/HostServices/SharedClipboard/x11.cpp
r14303 r15883 182 182 183 183 /** 184 * Send a request to the guest to transfer the contents of its clipboard to the host. 185 * 186 * @param pCtx Pointer to the host clipboard structure 187 * @param u32Format The format in which the data should be transfered 188 */ 189 static int vboxClipboardReadDataFromClient (VBOXCLIPBOARDCONTEXT *pCtx, uint32_t u32Format) 184 * Send a request to VBox to transfer the contents of its clipboard to X11. 185 * 186 * @param pCtx Pointer to the host clipboard structure 187 * @param u32Format The format in which the data should be transfered 188 * @thread clipboard X11 event thread 189 * @note called by vboxClipboardConvert* 190 */ 191 static int vboxClipboardReadDataFromVBox (VBOXCLIPBOARDCONTEXT *pCtx, uint32_t u32Format) 190 192 { 191 193 VBOXCLIPBOARDCLIENTDATA *pClient = pCtx->pClient; … … 194 196 if (pClient == 0) 195 197 { 196 Log (("vboxClipboardReadDataFromClient:host requested guest clipboard data after guest had disconnected.\n"));198 LogFunc(("host requested guest clipboard data after guest had disconnected.\n")); 197 199 pCtx->guestFormats = 0; 198 200 pCtx->waiter = 0; … … 276 278 /** 277 279 * Convert the UTF-8 text returned from the X11 clipboard to UTF-16LE with Windows EOLS. 278 * We are reading the host clipboard to make it available to the guest.280 * We are reading the X11 clipboard to make it available to VBox. 279 281 * 280 282 * @param pValue Source UTF-8 text … … 284 286 * @param pcbActual Where to store the size of the converted data 285 287 * @param pClient Pointer to the client context structure 286 */ 287 static void vboxClipboardGetUtf8(XtPointer pValue, unsigned cbSrcLen, void *pv, unsigned cb, 288 uint32_t *pcbActual) 288 * @thread clipboard X11 event thread 289 * @note called by vboxClipboardGetDataFromX11 290 */ 291 static void vboxClipboardGetUtf8FromX11(XtPointer pValue, unsigned cbSrcLen, 292 void *pv, unsigned cb, 293 uint32_t *pcbActual) 289 294 { 290 295 size_t cwSrcLen, cwDestLen; … … 325 330 /** 326 331 * Convert the COMPOUND_TEXT text returned from the X11 clipboard to UTF-16LE with Windows 327 * EOLS. We are reading the host clipboard to make it available to the guest.332 * EOLS. We are reading the X11 clipboard to make it available to VBox. 328 333 * 329 334 * @param pValue Source COMPOUND_TEXT text … … 333 338 * @param pcbActual Where to store the size of the converted data 334 339 * @param pClient Pointer to the client context structure 335 */ 336 static void vboxClipboardGetCText(XtPointer pValue, unsigned cbSrcLen, void *pv, unsigned cb, 337 uint32_t *pcbActual) 340 * @thread clipboard X11 event thread 341 * @note called by vboxClipboardGetDataFromX11 342 */ 343 static void vboxClipboardGetCTextFromX11(XtPointer pValue, unsigned cbSrcLen, 344 void *pv, unsigned cb, 345 uint32_t *pcbActual) 338 346 { 339 347 size_t cwSrcLen, cwDestLen; … … 403 411 /** 404 412 * Convert the Latin1 text returned from the X11 clipboard to UTF-16LE with Windows EOLS 405 * and place it in the global g_pcClipboardText variable. We are reading the hostclipboard to406 * make it available to the guest.413 * and place it in the global g_pcClipboardText variable. We are reading the X11 clipboard to 414 * make it available to VBox. 407 415 * 408 416 * @param pValue Source Latin1 text … … 412 420 * @param pcbActual Where to store the size of the converted data 413 421 * @param pClient Pointer to the client context structure 414 */ 415 static void vboxClipboardGetLatin1(XtPointer pValue, unsigned cbSourceLen, void *pv, unsigned cb, 422 * @thread clipboard X11 event thread 423 * @note called by vboxClipboardGetDataFromX11 424 */ 425 static void vboxClipboardGetLatin1FromX11(XtPointer pValue, unsigned cbSourceLen, void *pv, unsigned cb, 416 426 uint32_t *pcbActual) 417 427 { … … 421 431 int rc = VINF_SUCCESS; 422 432 423 LogFlow (("vboxClipboardGetLatin1:converting Latin1 to Utf-16LE. Original is %.*s\n",424 cbSourceLen, pu8SourceText));433 LogFlowFunc (("converting Latin1 to Utf-16LE. Original is %.*s\n", 434 cbSourceLen, pu8SourceText)); 425 435 *pcbActual = 0; /* Only set this to the right value on success. */ 426 436 for (unsigned i = 0; i < cbSourceLen; i++) … … 454 464 } 455 465 456 /** Convert the clipboard text from the current format to Utf-16 with Windows line breaks. 457 We are reading the host clipboard to make it available to the guest. */ 458 static void vboxClipboardGetProc(Widget, XtPointer pClientData, Atom * /* selection */, 459 Atom *atomType, XtPointer pValue, long unsigned int *pcLen, 460 int *piFormat) 466 /** 467 * Convert the clipboard text from the current format to Utf-16 with Windows line breaks. 468 * We are reading the X11 clipboard to make it available to VBox. 469 * @thread clipboard X11 event thread 470 * @note Callback for XtGetSelectionValue, called from vboxClipboardReadData 471 */ 472 static void vboxClipboardGetDataFromX11(Widget, XtPointer pClientData, 473 Atom * /* selection */, Atom *atomType, 474 XtPointer pValue, 475 long unsigned int *pcLen, 476 int *piFormat) 461 477 { 462 478 LogFlowFunc(("pClientData=%p, *pcLen=%lu, *piFormat=%d\n", pClientData, *pcLen, *piFormat)); … … 490 506 break; 491 507 case CTEXT: 492 vboxClipboardGetCText (pValue, cTextLen, g_ctx.requestBuffer, g_ctx.requestBufferSize,508 vboxClipboardGetCTextFromX11(pValue, cTextLen, g_ctx.requestBuffer, g_ctx.requestBufferSize, 493 509 g_ctx.requestActualSize); 494 510 break; … … 502 518 && (RTStrUniLenEx(pu8SourceText, *pcLen, &cStringLen) == VINF_SUCCESS)) 503 519 { 504 vboxClipboardGetUtf8 (pValue, cTextLen, g_ctx.requestBuffer, g_ctx.requestBufferSize,520 vboxClipboardGetUtf8FromX11(pValue, cTextLen, g_ctx.requestBuffer, g_ctx.requestBufferSize, 505 521 g_ctx.requestActualSize); 506 522 break; … … 508 524 else 509 525 { 510 vboxClipboardGetLatin1 (pValue, cTextLen, g_ctx.requestBuffer, g_ctx.requestBufferSize,526 vboxClipboardGetLatin1FromX11(pValue, cTextLen, g_ctx.requestBuffer, g_ctx.requestBufferSize, 511 527 g_ctx.requestActualSize); 512 528 break; … … 514 530 } 515 531 default: 516 Log (("vboxClipboardGetProc:bad target format\n"));532 LogFunc (("bad target format\n")); 517 533 XtFree(reinterpret_cast<char *>(pValue)); 518 534 RTSemMutexRelease(g_ctx.asyncMutex); … … 523 539 } 524 540 525 /** Callback to handle a reply to a request for the targets the current clipboard holder can 526 handle. We are reading the host clipboard to make it available to the guest. */ 527 static void vboxClipboardTargetsProc(Widget, XtPointer pClientData, Atom * /* selection */, 528 Atom *atomType, XtPointer pValue, long unsigned int *pcLen, 529 int *piFormat) 541 /** 542 * Find out what targets the current X11 clipboard holder can handle. We are 543 * reading the X11 clipboard to make it available to VBox. 544 * @thread clipboard X11 event thread 545 * @note Callback for XtGetSelectionValue, called from vboxClipboardPollX11ForTargets 546 */ 547 static void vboxClipboardGetTargetsFromX11(Widget, XtPointer pClientData, 548 Atom * /* selection */, 549 Atom *atomType, 550 XtPointer pValue, 551 long unsigned int *pcLen, 552 int *piFormat) 530 553 { 531 554 Atom *atomTargets = reinterpret_cast<Atom *>(pValue); … … 534 557 Atom atomBestTarget = None; 535 558 536 Log3 ((" vboxClipboardTargetsProc called\n"));559 Log3 (("%s: called\n", __PRETTY_FUNCTION__)); 537 560 if (*atomType == XT_CONVERT_FAIL) 538 561 { 539 Log (("vboxClipboardTargetsProc:reading clipboard from host, X toolkit failed to convert the selection\n"));562 LogFunc (("reading clipboard from host, X toolkit failed to convert the selection\n")); 540 563 return; 541 564 } … … 568 591 if (szAtomName != 0) 569 592 { 570 Log2 (("vboxClipboardTargetsProc: the host offers target %s\n", szAtomName)); 593 Log2 (("%s: the host offers target %s\n", __PRETTY_FUNCTION__, 594 szAtomName)); 571 595 XFree(szAtomName); 572 596 } … … 582 606 { 583 607 char *szAtomName = XGetAtomName(XtDisplay(g_ctx.widget), atomBestTarget); 584 Log2 ((" vboxClipboardTargetsProc: switching to host text target %s. Available targets are:\n",585 szAtomName));608 Log2 (("%s: switching to host text target %s. Available targets are:\n", 609 __PRETTY_FUNCTION__, szAtomName)); 586 610 XFree(szAtomName); 587 611 } 588 612 else 589 { 590 Log2(("vboxClipboardTargetsProc: no supported host text target found. Available targets are:\n")); 591 } 613 Log2(("%s: no supported host text target found. Available targets are:\n", 614 __PRETTY_FUNCTION__)); 592 615 for (unsigned i = 0; i < cAtoms; ++i) 593 616 { … … 595 618 if (szAtomName != 0) 596 619 { 597 Log2 ((" vboxClipboardTargetsProc: %s\n", szAtomName));620 Log2 (("%s: %s\n", __PRETTY_FUNCTION__, szAtomName)); 598 621 XFree(szAtomName); 599 622 } … … 612 635 613 636 /** 614 * This callback is called every 200ms to check the contents of the host clipboard. 615 */ 616 static void vboxClipboardTimerProc(XtPointer /* pUserData */, XtIntervalId * /* hTimerId */) 617 { 618 Log3 (("vboxClipboardTimerProc called\n")); 637 * This callback is called every 200ms to check the contents of the X11 clipboard. 638 * @thread clipboard X11 event thread 639 * @note Callback for XtAppAddTimeOut, called from vboxClipboardThread and 640 * recursively retriggered 641 */ 642 static void vboxClipboardPollX11ForTargets(XtPointer /* pUserData */, XtIntervalId * /* hTimerId */) 643 { 644 Log3 (("%s: called\n", __PRETTY_FUNCTION__)); 619 645 /* Get the current clipboard contents */ 620 646 if (g_ctx.eOwner == HOST && g_ctx.pClient != 0) 621 647 { 622 Log3 (("vboxClipboardTimerProc: requesting the targets that the host clipboard offers\n")); 648 Log3 (("%s: requesting the targets that the host clipboard offers\n", 649 __PRETTY_FUNCTION__)); 623 650 XtGetSelectionValue(g_ctx.widget, g_ctx.atomClipboard, g_ctx.atomTargets, 624 vboxClipboard TargetsProc, reinterpret_cast<XtPointer>(g_ctx.pClient),651 vboxClipboardGetTargetsFromX11, reinterpret_cast<XtPointer>(g_ctx.pClient), 625 652 CurrentTime); 626 653 } 627 654 /* Re-arm our timer */ 628 XtAppAddTimeOut(g_ctx.appContext, 200 /* ms */, vboxClipboard TimerProc, 0);655 XtAppAddTimeOut(g_ctx.appContext, 200 /* ms */, vboxClipboardPollX11ForTargets, 0); 629 656 } 630 657 … … 646 673 /** 647 674 * The main loop of our clipboard reader. 675 * @thread clipboard X11 event thread 648 676 */ 649 677 static int vboxClipboardThread(RTTHREAD self, void * /* pvUser */) … … 652 680 653 681 /* Set up a timer to poll the host clipboard */ 654 XtAppAddTimeOut(g_ctx.appContext, 200 /* ms */, vboxClipboard TimerProc, 0);682 XtAppAddTimeOut(g_ctx.appContext, 200 /* ms */, vboxClipboardPollX11ForTargets, 0); 655 683 656 684 XtAppMainLoop(g_ctx.appContext); … … 662 690 } 663 691 692 /** X11 specific initialisation for the shared clipboard. */ 664 693 int vboxClipboardInitX11 (void) 665 694 { … … 737 766 } 738 767 739 /** Initialise the host side of the shared clipboard - called by the hgcm layer. */ 768 /** 769 * Initialise the host side of the shared clipboard. 770 * @note Called by the HGCM clipboard service 771 * @thread HGCM clipboard service thread 772 */ 740 773 int vboxClipboardInit (void) 741 774 { … … 796 829 } 797 830 798 /** Terminate the host side of the shared clipboard - called by the hgcm layer. */ 831 /** 832 * Terminate the host side of the shared clipboard. 833 * @note Called by the HGCM clipboard service 834 * @thread HGCM clipboard service thread 835 */ 799 836 void vboxClipboardDestroy (void) 800 837 { … … 804 841 805 842 /* 806 * Imme tiately return if we are not connected to the host X server.843 * Immediately return if we are not connected to the host X server. 807 844 */ 808 845 if (!g_fHaveX11) … … 834 871 835 872 /** 836 * Enable the shared clipboard - called by the hgcm clipboard subsystem. 837 * 838 * @param pClient Structure containing context information about the guest system 839 * @returns RT status code 840 */ 873 * Connect a guest the shared clipboard. 874 * 875 * @param pClient Structure containing context information about the guest system 876 * @returns RT status code 877 * @note Called by the HGCM clipboard service 878 * @thread HGCM clipboard service thread 879 */ 841 880 int vboxClipboardConnect (VBOXCLIPBOARDCLIENTDATA *pClient) 842 881 { 843 882 /* 844 * Imme tiately return if we are not connected to the host X server.883 * Immediately return if we are not connected to the host X server. 845 884 */ 846 885 if (!g_fHaveX11) … … 864 903 865 904 /** 866 * Synchronise the contents of the host clipboard with the guest, called by the HGCM layer905 * Synchronise the contents of the host clipboard with the guest, called 867 906 * after a save and restore of the guest. 907 * @note Called by the HGCM clipboard service 908 * @thread HGCM clipboard service thread 868 909 */ 869 910 int vboxClipboardSync (VBOXCLIPBOARDCLIENTDATA *pClient) 870 911 { 871 912 /* 872 * Imme tiately return if we are not connected to the host X server.913 * Immediately return if we are not connected to the host X server. 873 914 */ 874 915 if (!g_fHaveX11) … … 886 927 887 928 /** 888 * Shut down the shared clipboard subsystem and "disconnect" the guest. 889 */ 890 void vboxClipboardDisconnect (VBOXCLIPBOARDCLIENTDATA *pClient) 929 * Shut down the shared clipboard service and "disconnect" the guest. 930 * @note Called by the HGCM clipboard service 931 * @thread HGCM clipboard service thread 932 */ 933 void vboxClipboardDisconnect (VBOXCLIPBOARDCLIENTDATA *) 891 934 { 892 935 /* 893 * Imme tiately return if we are not connected to the host X server.936 * Immediately return if we are not connected to the host X server. 894 937 */ 895 938 if (!g_fHaveX11) … … 907 950 908 951 /** 909 * Satisfy a request from the host for available clipboard targets.952 * Satisfy a request from X11 for clipboard targets supported by VBox. 910 953 * 911 954 * @returns true if we successfully convert the data to the format requested, false otherwise. 912 955 * 913 * @param atomTypeReturn The type of the data we are returning 914 * @param pValReturn A pointer to the data we are returning. This should be to memory 915 * allocated by XtMalloc, which will be freed by the toolkit later 916 * @param pcLenReturn The length of the data we are returning 917 * @param piFormatReturn The format (8bit, 16bit, 32bit) of the data we are returning 918 */ 919 static Boolean vboxClipboardConvertTargets(Atom *atomTypeReturn, XtPointer *pValReturn, 920 unsigned long *pcLenReturn, int *piFormatReturn) 956 * @param atomTypeReturn The type of the data we are returning 957 * @param pValReturn A pointer to the data we are returning. This should be to memory 958 * allocated by XtMalloc, which will be freed by the toolkit later 959 * @param pcLenReturn The length of the data we are returning 960 * @param piFormatReturn The format (8bit, 16bit, 32bit) of the data we are returning 961 * @thread clipboard X11 event thread 962 * @note called by vboxClipboardConvertForX11 963 */ 964 static Boolean vboxClipboardConvertTargetsForX11(Atom *atomTypeReturn, XtPointer *pValReturn, 965 unsigned long *pcLenReturn, int *piFormatReturn) 921 966 { 922 967 unsigned uListSize = g_ctx.formatList.size(); … … 924 969 unsigned cTargets = 0; 925 970 926 LogFlow (("vboxClipboardConvertTargetscalled\n"));971 LogFlowFunc (("called\n")); 927 972 for (unsigned i = 0; i < uListSize; ++i) 928 973 { … … 944 989 if (szAtomName != 0) 945 990 { 946 Log2 (("vboxClipboardConvertTargets: returning target %s\n", szAtomName)); 991 Log2 (("%s: returning target %s\n", __PRETTY_FUNCTION__, 992 szAtomName)); 947 993 XFree(szAtomName); 948 994 } 949 995 else 950 996 { 951 Log(("vboxClipboardConvertTargets: invalid atom %d in the list!\n", atomTargets[i])); 997 Log(("%s: invalid atom %d in the list!\n", __PRETTY_FUNCTION__, 998 atomTargets[i])); 952 999 } 953 1000 } … … 961 1008 962 1009 /** 963 * Reset the contents of the buffer used to pass clipboard data from the guest to the host.1010 * Reset the contents of the buffer used to pass clipboard data from VBox to X11. 964 1011 * This must be done after every clipboard transfer. 965 1012 */ … … 993 1040 994 1041 LogFlowFunc (("called\n")); 995 rc = vboxClipboardReadDataFrom Client(&g_ctx, VBOX_SHARED_CLIPBOARD_FMT_UNICODETEXT);1042 rc = vboxClipboardReadDataFromVBox(&g_ctx, VBOX_SHARED_CLIPBOARD_FMT_UNICODETEXT); 996 1043 if ((RT_FAILURE(rc)) || (g_ctx.pClient->data.cb == 0)) 997 1044 { 998 /* If vboxClipboardReadDataFrom Clientfails then pClient may be invalid */999 LogRelFunc (("vboxClipboardReadDataFrom Clientreturned %Rrc%s\n", rc,1045 /* If vboxClipboardReadDataFromVBox fails then pClient may be invalid */ 1046 LogRelFunc (("vboxClipboardReadDataFromVBox returned %Rrc%s\n", rc, 1000 1047 RT_SUCCESS(rc) ? ", g_ctx.pClient->data.cb == 0" : "")); 1001 1048 vboxClipboardEmptyGuestBuffer(); … … 1048 1095 * @returns true if we successfully convert the data to the format requested, false otherwise. 1049 1096 * 1050 * @param atomTypeReturn The type of the data we are returning 1051 * @param pValReturn A pointer to the data we are returning. This should be to memory 1052 * allocated by XtMalloc, which will be freed by the toolkit later 1053 * @param pcLenReturn The length of the data we are returning 1054 * @param piFormatReturn The format (8bit, 16bit, 32bit) of the data we are returning 1055 */ 1056 static Boolean vboxClipboardConvertUtf8(Atom *atomTypeReturn, XtPointer *pValReturn, 1057 unsigned long *pcLenReturn, int *piFormatReturn) 1097 * @param atomTypeReturn The type of the data we are returning 1098 * @param 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 * @param pcLenReturn The length of the data we are returning 1101 * @param piFormatReturn The format (8bit, 16bit, 32bit) of the data we are returning 1102 * @thread clipboard X11 event thread 1103 * @note called by vboxClipboardConvertForX11 1104 */ 1105 static Boolean vboxClipboardConvertToUtf8ForX11(Atom *atomTypeReturn, 1106 XtPointer *pValReturn, 1107 unsigned long *pcLenReturn, 1108 int *piFormatReturn) 1058 1109 { 1059 1110 PRTUTF16 pu16SrcText, pu16DestText; … … 1064 1115 LogFlowFunc (("called\n")); 1065 1116 /* Read the clipboard data from the guest. */ 1066 rc = vboxClipboardReadDataFrom Client(&g_ctx, VBOX_SHARED_CLIPBOARD_FMT_UNICODETEXT);1117 rc = vboxClipboardReadDataFromVBox(&g_ctx, VBOX_SHARED_CLIPBOARD_FMT_UNICODETEXT); 1067 1118 if ((rc != VINF_SUCCESS) || (g_ctx.pClient->data.cb == 0)) 1068 1119 { 1069 /* If vboxClipboardReadDataFrom Clientfails then pClient may be invalid */1070 LogRelFunc (("vboxClipboardReadDataFrom Clientreturned %Rrc%s\n", rc,1071 RT_SUCCESS(rc) ? ", g_ctx.pClient->data.cb == 0" : ""));1120 /* If vboxClipboardReadDataFromVBox fails then pClient may be invalid */ 1121 LogRelFunc (("vboxClipboardReadDataFromVBox returned %Rrc%s\n", rc, 1122 RT_SUCCESS(rc) ? ", g_ctx.pClient->data.cb == 0" : "")); 1072 1123 vboxClipboardEmptyGuestBuffer(); 1073 1124 return false; … … 1079 1130 if (RT_FAILURE(rc)) 1080 1131 { 1081 LogRel (("vboxClipboardConvertUtf8:clipboard conversion failed. vboxClipboardUtf16GetLinSize returned %Rrc. Abandoning.\n", rc));1132 LogRelFunc (("clipboard conversion failed. vboxClipboardUtf16GetLinSize returned %Rrc. Abandoning.\n", rc)); 1082 1133 vboxClipboardEmptyGuestBuffer(); 1083 1134 AssertRCReturn(rc, false); … … 1092 1143 if (pu16DestText == 0) 1093 1144 { 1094 LogRel (("vboxClipboardConvertUtf8:failed to allocate %d bytes\n", cwDestLen * 2));1145 LogRelFunc (("failed to allocate %d bytes\n", cwDestLen * 2)); 1095 1146 vboxClipboardEmptyGuestBuffer(); 1096 1147 return false; … … 1100 1151 if (RT_FAILURE(rc)) 1101 1152 { 1102 LogRel (("vboxClipboardConvertUtf8:clipboard conversion failed. vboxClipboardUtf16WinToLin() returned %Rrc. Abandoning.\n", rc));1153 LogRelFunc (("clipboard conversion failed. vboxClipboardUtf16WinToLin() returned %Rrc. Abandoning.\n", rc)); 1103 1154 RTMemFree(reinterpret_cast<void *>(pu16DestText)); 1104 1155 vboxClipboardEmptyGuestBuffer(); … … 1110 1161 if (pu8DestText == 0) 1111 1162 { 1112 LogRel (("vboxClipboardConvertUtf8:failed to allocate %d bytes\n", cwDestLen * 4));1163 LogRelFunc (("failed to allocate %d bytes\n", cwDestLen * 4)); 1113 1164 RTMemFree(reinterpret_cast<void *>(pu16DestText)); 1114 1165 vboxClipboardEmptyGuestBuffer(); … … 1121 1172 if (RT_FAILURE(rc)) 1122 1173 { 1123 LogRel (("vboxClipboardConvertUtf8:clipboard conversion failed. RTUtf16ToUtf8Ex() returned %Rrc. Abandoning.\n", rc));1174 LogRelFunc (("clipboard conversion failed. RTUtf16ToUtf8Ex() returned %Rrc. Abandoning.\n", rc)); 1124 1175 XtFree(pu8DestText); 1125 1176 vboxClipboardEmptyGuestBuffer(); … … 1140 1191 * @returns true if we successfully convert the data to the format requested, false otherwise. 1141 1192 * 1142 * @param atomTypeReturn The type of the data we are returning 1143 * @param pValReturn A pointer to the data we are returning. This should be to memory 1144 * allocated by XtMalloc, which will be freed by the toolkit later 1145 * @param pcLenReturn The length of the data we are returning 1146 * @param piFormatReturn The format (8bit, 16bit, 32bit) of the data we are returning 1147 */ 1148 static Boolean vboxClipboardConvertCText(Atom *atomTypeReturn, XtPointer *pValReturn, 1149 unsigned long *pcLenReturn, int *piFormatReturn) 1193 * @param atomTypeReturn The type of the data we are returning 1194 * @param pValReturn A pointer to the data we are returning. This should be to memory 1195 * allocated by XtMalloc, which will be freed by the toolkit later 1196 * @param pcLenReturn The length of the data we are returning 1197 * @param piFormatReturn The format (8bit, 16bit, 32bit) of the data we are returning 1198 * @thread clipboard X11 event thread 1199 * @note called by vboxClipboardConvertForX11 1200 */ 1201 static Boolean vboxClipboardConvertToCTextForX11(Atom *atomTypeReturn, 1202 XtPointer *pValReturn, 1203 unsigned long *pcLenReturn, 1204 int *piFormatReturn) 1150 1205 { 1151 1206 PRTUTF16 pu16SrcText, pu16DestText; … … 1157 1212 LogFlowFunc (("called\n")); 1158 1213 /* Read the clipboard data from the guest. */ 1159 rc = vboxClipboardReadDataFrom Client(&g_ctx, VBOX_SHARED_CLIPBOARD_FMT_UNICODETEXT);1214 rc = vboxClipboardReadDataFromVBox(&g_ctx, VBOX_SHARED_CLIPBOARD_FMT_UNICODETEXT); 1160 1215 if ((rc != VINF_SUCCESS) || (g_ctx.pClient->data.cb == 0)) 1161 1216 { 1162 /* If vboxClipboardReadDataFrom Clientfails then pClient may be invalid */1163 LogRelFunc (("vboxClipboardReadDataFrom Clientreturned %Rrc%s\n", rc,1164 RT_SUCCESS(rc) ? ", g_ctx.pClient->data.cb == 0" : ""));1217 /* If vboxClipboardReadDataFromVBox fails then pClient may be invalid */ 1218 LogRelFunc (("vboxClipboardReadDataFromVBox returned %Rrc%s\n", rc, 1219 RT_SUCCESS(rc) ? ", g_ctx.pClient->data.cb == 0" : "")); 1165 1220 vboxClipboardEmptyGuestBuffer(); 1166 1221 return false; … … 1172 1227 if (RT_FAILURE(rc)) 1173 1228 { 1174 LogRel (("vboxClipboardConvertCText:clipboard conversion failed. vboxClipboardUtf16GetLinSize returned %Rrc. Abandoning.\n", rc));1229 LogRelFunc (("clipboard conversion failed. vboxClipboardUtf16GetLinSize returned %Rrc. Abandoning.\n", rc)); 1175 1230 vboxClipboardEmptyGuestBuffer(); 1176 1231 AssertRCReturn(rc, false); … … 1185 1240 if (pu16DestText == 0) 1186 1241 { 1187 LogRel (("vboxClipboardConvertCText:failed to allocate %d bytes\n", cwDestLen * 2));1242 LogRelFunc (("failed to allocate %d bytes\n", cwDestLen * 2)); 1188 1243 vboxClipboardEmptyGuestBuffer(); 1189 1244 return false; … … 1193 1248 if (RT_FAILURE(rc)) 1194 1249 { 1195 LogRel (("vboxClipboardConvertCText:clipboard conversion failed. vboxClipboardUtf16WinToLin() returned %Rrc. Abandoning.\n", rc));1250 LogRelFunc (("clipboard conversion failed. vboxClipboardUtf16WinToLin() returned %Rrc. Abandoning.\n", rc)); 1196 1251 RTMemFree(reinterpret_cast<void *>(pu16DestText)); 1197 1252 vboxClipboardEmptyGuestBuffer(); … … 1203 1258 if (RT_FAILURE(rc)) 1204 1259 { 1205 LogRel (("vboxClipboardConvertCText:clipboard conversion failed. RTUtf16ToUtf8Ex() returned %Rrc. Abandoning.\n", rc));1260 LogRelFunc (("clipboard conversion failed. RTUtf16ToUtf8Ex() returned %Rrc. Abandoning.\n", rc)); 1206 1261 vboxClipboardEmptyGuestBuffer(); 1207 1262 return false; … … 1233 1288 pcReason = "unknown error"; 1234 1289 } 1235 LogRel (("vboxClipboardConvertCText:Xutf8TextListToTextProperty failed. Reason: %s\n",1290 LogRelFunc (("Xutf8TextListToTextProperty failed. Reason: %s\n", 1236 1291 pcReason)); 1237 1292 XFree(property.value); … … 1249 1304 1250 1305 /** 1251 * Callback to convert the guests clipboard data for an application on the host. Called by the1306 * Callback to request VBox's clipboard data for an X11 client. Called by the 1252 1307 * X Toolkit. 1253 * @returns true if we successfully convert the data to the format requested, false otherwise. 1254 * 1255 * @param atomSelection The selection which is being requested. We only handle the clipboard. 1256 * @param atomTarget The format we should convert the data to 1257 * @param atomTypeReturn The type of the data we are returning 1258 * @param pValReturn A pointer to the data we are returning. This should be to memory 1259 * allocated by XtMalloc, which will be freed by the toolkit later 1260 * @param pcLenReturn The length of the data we are returning 1261 * @param piFormatReturn The format (8bit, 16bit, 32bit) of the data we are returning 1262 */ 1263 static Boolean vboxClipboardConvertProc(Widget, Atom *atomSelection, Atom *atomTarget, 1264 Atom *atomTypeReturn, XtPointer *pValReturn, 1265 unsigned long *pcLenReturn, int *piFormatReturn) 1308 * @thread clipboard X11 event thread 1309 * @note callback for XtOwnSelection, called by vboxClipboardFormatAnnounce 1310 */ 1311 static Boolean vboxClipboardConvertForX11(Widget, Atom *atomSelection, 1312 Atom *atomTarget, 1313 Atom *atomTypeReturn, 1314 XtPointer *pValReturn, 1315 unsigned long *pcLenReturn, 1316 int *piFormatReturn) 1266 1317 { 1267 1318 g_eClipboardFormats eFormat = INVALID; … … 1280 1331 if (szAtomName != 0) 1281 1332 { 1282 Log2 ((" vboxClipboardConvertProc: request for format %s\n", szAtomName));1333 Log2 (("%s: request for format %s\n", __PRETTY_FUNCTION__, szAtomName)); 1283 1334 XFree(szAtomName); 1284 1335 } 1285 1336 else 1286 1337 { 1287 Log (("vboxClipboardConvertProc:request for invalid target atom %d!\n", *atomTarget));1338 LogFunc (("request for invalid target atom %d!\n", *atomTarget)); 1288 1339 } 1289 1340 } … … 1306 1357 { 1307 1358 case TARGETS: 1308 return vboxClipboardConvertTargets (atomTypeReturn, pValReturn, pcLenReturn,1309 piFormatReturn);1359 return vboxClipboardConvertTargetsForX11(atomTypeReturn, pValReturn, 1360 pcLenReturn, piFormatReturn); 1310 1361 case UTF16: 1311 1362 return vboxClipboardConvertUtf16(atomTypeReturn, pValReturn, pcLenReturn, 1312 1363 piFormatReturn); 1313 1364 case UTF8: 1314 return vboxClipboardConvert Utf8(atomTypeReturn, pValReturn, pcLenReturn,1315 piFormatReturn);1365 return vboxClipboardConvertToUtf8ForX11(atomTypeReturn, pValReturn, 1366 pcLenReturn, piFormatReturn); 1316 1367 case CTEXT: 1317 return vboxClipboardConvert CText(atomTypeReturn, pValReturn, pcLenReturn,1318 piFormatReturn);1368 return vboxClipboardConvertToCTextForX11(atomTypeReturn, pValReturn, 1369 pcLenReturn, piFormatReturn); 1319 1370 default: 1320 Log(("vboxClipboardConvertProc: bad format\n")); 1321 return false; 1322 } 1323 } 1324 1325 static void vboxClipboardLoseProc(Widget, Atom *) 1326 { 1327 LogFlow (("vboxClipboardLoseProc: called, giving the host clipboard ownership\n")); 1371 LogFunc (("bad format\n")); 1372 return false; 1373 } 1374 } 1375 1376 /** 1377 * This is called by the X toolkit intrinsics to let us know that another 1378 * X11 client has taken the clipboard. 1379 * @note callback for XtOwnSelection, called from vboxClipboardFormatAnnounce 1380 * @thread clipboard X11 event thread 1381 */ 1382 static void vboxClipboardReturnToX11(Widget, Atom *) 1383 { 1384 LogFlowFunc (("called, giving VBox clipboard ownership\n")); 1328 1385 g_ctx.eOwner = HOST; 1329 1386 g_ctx.notifyGuest = true; … … 1331 1388 1332 1389 /** 1333 * The guest is taking possession of the shared clipboard. Called by the HGCM clipboard 1334 * subsystem. 1390 * VBox is taking possession of the shared clipboard. 1335 1391 * 1336 1392 * @param pClient Context data for the guest system 1337 1393 * @param u32Formats Clipboard formats the guest is offering 1394 * @note Called by the HGCM clipboard service 1395 * @thread HGCM clipboard service thread 1338 1396 */ 1339 1397 void vboxClipboardFormatAnnounce (VBOXCLIPBOARDCLIENTDATA *pClient, uint32_t u32Formats) 1340 1398 { 1341 1399 /* 1342 * Imme tiately return if we are not connected to the host X server.1400 * Immediately return if we are not connected to the host X server. 1343 1401 */ 1344 1402 if (!g_fHaveX11) … … 1361 1419 return; 1362 1420 } 1363 Log2 ((" vboxClipboardFormatAnnounce: giving the guest clipboard ownership\n"));1421 Log2 (("%s: giving the guest clipboard ownership\n", __PRETTY_FUNCTION__)); 1364 1422 g_ctx.eOwner = GUEST; 1365 1423 g_ctx.hostTextFormat = INVALID; 1366 1424 g_ctx.hostBitmapFormat = INVALID; 1367 if (XtOwnSelection(g_ctx.widget, g_ctx.atomClipboard, CurrentTime, vboxClipboardConvert Proc,1368 vboxClipboard LoseProc, 0) != True)1369 { 1370 Log2 ((" vboxClipboardFormatAnnounce: returning clipboard ownership to the host\n"));1425 if (XtOwnSelection(g_ctx.widget, g_ctx.atomClipboard, CurrentTime, vboxClipboardConvertForX11, 1426 vboxClipboardReturnToX11, 0) != True) 1427 { 1428 Log2 (("%s: returning clipboard ownership to the host\n", __PRETTY_FUNCTION__)); 1371 1429 /* We set this so that the guest gets notified when we take the clipboard, even if no 1372 1430 guest formats are found which we understand. */ … … 1374 1432 g_ctx.eOwner = HOST; 1375 1433 } 1376 XtOwnSelection(g_ctx.widget, g_ctx.atomPrimary, CurrentTime, vboxClipboardConvert Proc,1434 XtOwnSelection(g_ctx.widget, g_ctx.atomPrimary, CurrentTime, vboxClipboardConvertForX11, 1377 1435 NULL, 0); 1378 1436 LogFlowFunc(("returning\n")); … … 1381 1439 1382 1440 /** 1383 * Called by the HGCM clipboard subsystem when the guest wants to read the hostclipboard.1441 * Called when VBox wants to read the X11 clipboard. 1384 1442 * 1385 1443 * @param pClient Context information about the guest VM … … 1388 1446 * @param cb The size of the buffer to write the data to 1389 1447 * @param pcbActual Where to write the actual size of the written data 1448 * @note Called by the HGCM clipboard service 1449 * @thread HGCM clipboard service thread 1390 1450 */ 1391 1451 int vboxClipboardReadData (VBOXCLIPBOARDCLIENTDATA *pClient, uint32_t u32Format, void *pv, … … 1393 1453 { 1394 1454 /* 1395 * Imme tiately return if we are not connected to the host X server.1455 * Immediately return if we are not connected to the host X server. 1396 1456 */ 1397 1457 if (!g_fHaveX11) … … 1402 1462 } 1403 1463 1404 LogFlow (("vboxClipboardReadData:u32Format = %d, cb = %d\n", u32Format, cb));1464 LogFlowFunc (("u32Format = %d, cb = %d\n", u32Format, cb)); 1405 1465 1406 1466 /* … … 1430 1490 /* Send out a request for the data to the current clipboard owner */ 1431 1491 XtGetSelectionValue(g_ctx.widget, g_ctx.atomClipboard, g_ctx.atomHostTextFormat, 1432 vboxClipboardGet Proc, reinterpret_cast<XtPointer>(g_ctx.pClient),1492 vboxClipboardGetDataFromX11, reinterpret_cast<XtPointer>(g_ctx.pClient), 1433 1493 CurrentTime); 1434 1494 /* When the data arrives, the vboxClipboardGetProc callback will be called. The … … 1466 1526 1467 1527 /** 1468 * Called by the HGCM clipboard subsystem when we have requested data and that data arrives.1528 * Called when we have requested data from VBox and that data has arrived. 1469 1529 * 1470 1530 * @param pClient Context information about the guest VM … … 1472 1532 * @param cb The size of the data written 1473 1533 * @param u32Format The format of the data written 1534 * @note Called by the HGCM clipboard service 1535 * @thread HGCM clipboard service thread 1474 1536 */ 1475 1537 void vboxClipboardWriteData (VBOXCLIPBOARDCLIENTDATA *pClient, void *pv, uint32_t cb, uint32_t u32Format) … … 1478 1540 return; 1479 1541 1480 LogFlow (("vboxClipboardWriteData\n"));1542 LogFlowFunc (("called\n")); 1481 1543 1482 1544 /*
Note:
See TracChangeset
for help on using the changeset viewer.