Changeset 85831 in vbox
- Timestamp:
- Aug 19, 2020 1:50:45 PM (4 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/VBox/GuestHost/SharedClipboard-x11.h
r82968 r85831 92 92 93 93 /** The best text format X11 has to offer, as an index into the formats table. */ 94 SHCLX11FMTIDX X11TextFormat;94 SHCLX11FMTIDX idxFmtText; 95 95 /** The best bitmap format X11 has to offer, as an index into the formats table. */ 96 SHCLX11FMTIDX X11BitmapFormat;96 SHCLX11FMTIDX idxFmtBmp; 97 97 /** The best HTML format X11 has to offer, as an index into the formats table. */ 98 SHCLX11FMTIDX X11HTMLFormat;98 SHCLX11FMTIDX idxFmtHTML; 99 99 #ifdef VBOX_WITH_SHARED_CLIPBOARD_TRANSFERS 100 100 /** The best HTML format X11 has to offer, as an index into the formats table. */ 101 SHCLX11FMTIDX X11URIListFormat;101 SHCLX11FMTIDX idxFmtURI; 102 102 #endif 103 103 /** What kind of formats does VBox have to offer? */ -
trunk/src/VBox/GuestHost/SharedClipboard/clipboard-x11.cpp
r85828 r85831 172 172 { 173 173 /** The format VBox would like the data in. */ 174 SHCLFORMAT mFormat;174 SHCLFORMAT uFmtVBox; 175 175 /** The format we requested from X11. */ 176 SHCLX11FMTIDX mX11Format;176 SHCLX11FMTIDX idxFmtX11; 177 177 /** The clipboard context this request is associated with. */ 178 SHCLX11CTX * mpCtx;178 SHCLX11CTX *pCtx; 179 179 /** The request structure passed in from the backend. */ 180 CLIPREADCBREQ * mpReq;180 CLIPREADCBREQ *pReq; 181 181 } CLIPREADX11CBREQ; 182 182 … … 423 423 static void clipReportFormatsToVBox(PSHCLX11CTX pCtx) 424 424 { 425 uint32_t fFormats = clipVBoxFormatForX11Format(pCtx->X11TextFormat);426 fFormats |= clipVBoxFormatForX11Format(pCtx->X11BitmapFormat);427 fFormats |= clipVBoxFormatForX11Format(pCtx->X11HTMLFormat);425 SHCLFORMATS vboxFmt = clipVBoxFormatForX11Format(pCtx->idxFmtText); 426 vboxFmt |= clipVBoxFormatForX11Format(pCtx->idxFmtBmp); 427 vboxFmt |= clipVBoxFormatForX11Format(pCtx->idxFmtHTML); 428 428 #ifdef VBOX_WITH_SHARED_CLIPBOARD_TRANSFERS 429 fFormats |= clipVBoxFormatForX11Format(pCtx->X11URIListFormat); 430 #endif 431 432 LogFlowFunc(("fFormats=0x%x\n", fFormats)); 433 LogFlowFunc(("txt: %u, bmp: %u, html: %u\n", 434 pCtx->X11TextFormat, pCtx->X11BitmapFormat, pCtx->X11HTMLFormat)); 429 vboxFmt |= clipVBoxFormatForX11Format(pCtx->idxFmtURI); 430 #endif 431 432 LogFlowFunc(("idxFmtText=%u ('%s'), idxFmtBmp=%u ('%s'), idxFmtHTML=%u ('%s')", 433 pCtx->idxFmtText, g_aFormats[pCtx->idxFmtText].pcszAtom, 434 pCtx->idxFmtBmp, g_aFormats[pCtx->idxFmtBmp].pcszAtom, 435 pCtx->idxFmtHTML, g_aFormats[pCtx->idxFmtHTML].pcszAtom)); 435 436 #ifdef VBOX_WITH_SHARED_CLIPBOARD_TRANSFERS 436 LogFlowFunc(("uri list: %u\n", pCtx->X11URIListFormat)); 437 #endif 438 439 LogRel2(("Shared Clipboard: X11 reported available formats 0x%x\n", fFormats)); 440 441 ShClX11ReportFormatsCallback(pCtx->pFrontend, fFormats); 437 LogFlowFunc((", idxFmtURI=%u ('%s')", pCtx->idxFmtURI, g_aFormats[pCtx->idxFmtURI].pcszAtom)); 438 #endif 439 LogFlow((" -> vboxFmt=%#x\n", vboxFmt)); 440 441 LogRel2(("Shared Clipboard: X11 reported available VBox formats: %#x\n", vboxFmt)); 442 443 ShClX11ReportFormatsCallback(pCtx->pFrontend, vboxFmt); 442 444 } 443 445 … … 452 454 LogFlowFuncEnter(); 453 455 454 pCtx-> X11TextFormat = SHCLX11FMT_INVALID;455 pCtx-> X11BitmapFormat = SHCLX11FMT_INVALID;456 pCtx-> X11HTMLFormat = SHCLX11FMT_INVALID;456 pCtx->idxFmtText = 0; 457 pCtx->idxFmtBmp = 0; 458 pCtx->idxFmtHTML = 0; 457 459 #ifdef VBOX_WITH_SHARED_CLIPBOARD_TRANSFERS 458 pCtx-> X11URIListFormat = SHCLX11FMT_INVALID;460 pCtx->idxFmtURI = 0; 459 461 #endif 460 462 } … … 478 480 * @return Index to supported X clipboard format. 479 481 * @param pCtx The X11 clipboard context to use. 480 * @param p TargetsThe list of targets.482 * @param paIdxFmtTargets The list of targets. 481 483 * @param cTargets The size of the list in @a pTargets. 482 484 */ 483 485 SHCL_X11_DECL(SHCLX11FMTIDX) clipGetTextFormatFromTargets(PSHCLX11CTX pCtx, 484 SHCLX11FMTIDX *p Targets,486 SHCLX11FMTIDX *paIdxFmtTargets, 485 487 size_t cTargets) 486 488 { 487 489 AssertPtrReturn(pCtx, NIL_CLIPX11FORMAT); 488 AssertReturn(VALID_PTR(p Targets) || cTargets == 0, NIL_CLIPX11FORMAT);489 490 SHCLX11FMTIDX bestTextFormat = NIL_CLIPX11FORMAT;491 SHCLX11FMT enmBestTextTarget= SHCLX11FMT_INVALID;490 AssertReturn(VALID_PTR(paIdxFmtTargets) || cTargets == 0, NIL_CLIPX11FORMAT); 491 492 SHCLX11FMTIDX idxFmtText = NIL_CLIPX11FORMAT; 493 SHCLX11FMT fmtTextX11 = SHCLX11FMT_INVALID; 492 494 for (unsigned i = 0; i < cTargets; ++i) 493 495 { 494 SHCLX11FMTIDX format = pTargets[i];495 if ( format != NIL_CLIPX11FORMAT)496 { 497 if ( (clipVBoxFormatForX11Format( format) == VBOX_SHCL_FMT_UNICODETEXT)498 && enmBestTextTarget < clipRealFormatForX11Format(format))496 SHCLX11FMTIDX idxFmt = paIdxFmtTargets[i]; 497 if (idxFmt != NIL_CLIPX11FORMAT) 498 { 499 if ( (clipVBoxFormatForX11Format(idxFmt) == VBOX_SHCL_FMT_UNICODETEXT) 500 && fmtTextX11 < clipRealFormatForX11Format(idxFmt)) 499 501 { 500 enmBestTextTarget = clipRealFormatForX11Format(format);501 bestTextFormat = format;502 fmtTextX11 = clipRealFormatForX11Format(idxFmt); 503 idxFmtText = idxFmt; 502 504 } 503 505 } 504 506 } 505 return bestTextFormat;507 return idxFmtText; 506 508 } 507 509 … … 513 515 * @return Supported X clipboard format. 514 516 * @param pCtx The X11 clipboard context to use. 515 * @param p TargetsThe list of targets.517 * @param paIdxFmtTargets The list of targets. 516 518 * @param cTargets The size of the list in @a pTargets. 517 519 */ 518 520 static SHCLX11FMTIDX clipGetBitmapFormatFromTargets(PSHCLX11CTX pCtx, 519 SHCLX11FMTIDX *p Targets,521 SHCLX11FMTIDX *paIdxFmtTargets, 520 522 size_t cTargets) 521 523 { 522 524 AssertPtrReturn(pCtx, NIL_CLIPX11FORMAT); 523 AssertReturn(VALID_PTR(p Targets) || cTargets == 0, NIL_CLIPX11FORMAT);524 525 SHCLX11FMTIDX bestBitmapFormat= NIL_CLIPX11FORMAT;526 SHCLX11FMT enmBestBitmapTarget= SHCLX11FMT_INVALID;525 AssertReturn(VALID_PTR(paIdxFmtTargets) || cTargets == 0, NIL_CLIPX11FORMAT); 526 527 SHCLX11FMTIDX idxFmtBmp = NIL_CLIPX11FORMAT; 528 SHCLX11FMT fmtBmpX11 = SHCLX11FMT_INVALID; 527 529 for (unsigned i = 0; i < cTargets; ++i) 528 530 { 529 SHCLX11FMTIDX format = pTargets[i];530 if ( format != NIL_CLIPX11FORMAT)531 { 532 if ( (clipVBoxFormatForX11Format( format) == VBOX_SHCL_FMT_BITMAP)533 && enmBestBitmapTarget < clipRealFormatForX11Format(format))531 SHCLX11FMTIDX idxFmt = paIdxFmtTargets[i]; 532 if (idxFmt != NIL_CLIPX11FORMAT) 533 { 534 if ( (clipVBoxFormatForX11Format(idxFmt) == VBOX_SHCL_FMT_BITMAP) 535 && fmtBmpX11 < clipRealFormatForX11Format(idxFmt)) 534 536 { 535 enmBestBitmapTarget = clipRealFormatForX11Format(format);536 bestBitmapFormat = format;537 fmtBmpX11 = clipRealFormatForX11Format(idxFmt); 538 idxFmtBmp = idxFmt; 537 539 } 538 540 } 539 541 } 540 return bestBitmapFormat;542 return idxFmtBmp; 541 543 } 542 544 … … 546 548 * 547 549 * @return Supported X clipboard format. 548 * @param pCtxThe X11 clipboard context to use.549 * @param p TargetsThe list of targets.550 * @param pCtx The X11 clipboard context to use. 551 * @param paIdxFmtTargets The list of targets. 550 552 * @param cTargets The size of the list in @a pTargets. 551 553 */ 552 554 static SHCLX11FMTIDX clipGetHtmlFormatFromTargets(PSHCLX11CTX pCtx, 553 SHCLX11FMTIDX *p Targets,555 SHCLX11FMTIDX *paIdxFmtTargets, 554 556 size_t cTargets) 555 557 { 556 558 AssertPtrReturn(pCtx, NIL_CLIPX11FORMAT); 557 AssertReturn(VALID_PTR(p Targets) || cTargets == 0, NIL_CLIPX11FORMAT);558 559 SHCLX11FMTIDX bestHTMLFormat= NIL_CLIPX11FORMAT;560 SHCLX11FMT enmBestHtmlTarget= SHCLX11FMT_INVALID;559 AssertReturn(VALID_PTR(paIdxFmtTargets) || cTargets == 0, NIL_CLIPX11FORMAT); 560 561 SHCLX11FMTIDX idxFmtHTML = NIL_CLIPX11FORMAT; 562 SHCLX11FMT fmxHTMLX11 = SHCLX11FMT_INVALID; 561 563 for (unsigned i = 0; i < cTargets; ++i) 562 564 { 563 SHCLX11FMTIDX format = pTargets[i];564 if ( format != NIL_CLIPX11FORMAT)565 { 566 if ( (clipVBoxFormatForX11Format( format) == VBOX_SHCL_FMT_HTML)567 && enmBestHtmlTarget < clipRealFormatForX11Format(format))565 SHCLX11FMTIDX idxFmt = paIdxFmtTargets[i]; 566 if (idxFmt != NIL_CLIPX11FORMAT) 567 { 568 if ( (clipVBoxFormatForX11Format(idxFmt) == VBOX_SHCL_FMT_HTML) 569 && fmxHTMLX11 < clipRealFormatForX11Format(idxFmt)) 568 570 { 569 enmBestHtmlTarget = clipRealFormatForX11Format(format);570 bestHTMLFormat = format;571 fmxHTMLX11 = clipRealFormatForX11Format(idxFmt); 572 idxFmtHTML = idxFmt; 571 573 } 572 574 } 573 575 } 574 return bestHTMLFormat;576 return idxFmtHTML; 575 577 } 576 578 … … 582 584 * @return Supported X clipboard format. 583 585 * @param pCtx The X11 clipboard context to use. 584 * @param p TargetsThe list of targets.586 * @param paIdxFmtTargets The list of targets. 585 587 * @param cTargets The size of the list in @a pTargets. 586 588 */ 587 589 static SHCLX11FMTIDX clipGetURIListFormatFromTargets(PSHCLX11CTX pCtx, 588 SHCLX11FMTIDX *p Targets,590 SHCLX11FMTIDX *paIdxFmtTargets, 589 591 size_t cTargets) 590 592 { 591 593 AssertPtrReturn(pCtx, NIL_CLIPX11FORMAT); 592 AssertReturn(VALID_PTR(p Targets) || cTargets == 0, NIL_CLIPX11FORMAT);593 594 SHCLX11FMTIDX bestURIListFormat= NIL_CLIPX11FORMAT;595 SHCLX11FMT enmBestURIListTarget= SHCLX11FMT_INVALID;594 AssertReturn(VALID_PTR(paIdxFmtTargets) || cTargets == 0, NIL_CLIPX11FORMAT); 595 596 SHCLX11FMTIDX idxFmtURI = NIL_CLIPX11FORMAT; 597 SHCLX11FMT fmtURIX11 = SHCLX11FMT_INVALID; 596 598 for (unsigned i = 0; i < cTargets; ++i) 597 599 { 598 SHCLX11FMTIDX format = pTargets[i];599 if ( format != NIL_CLIPX11FORMAT)600 { 601 if ( (clipVBoxFormatForX11Format( format) == VBOX_SHCL_FMT_URI_LIST)602 && enmBestURIListTarget < clipRealFormatForX11Format(format))600 SHCLX11FMTIDX idxFmt = paIdxFmtTargets[i]; 601 if (idxFmt != NIL_CLIPX11FORMAT) 602 { 603 if ( (clipVBoxFormatForX11Format(idxFmt) == VBOX_SHCL_FMT_URI_LIST) 604 && fmtURIX11 < clipRealFormatForX11Format(idxFmt)) 603 605 { 604 enmBestURIListTarget = clipRealFormatForX11Format(format);605 bestURIListFormat = format;606 fmtURIX11 = clipRealFormatForX11Format(idxFmt); 607 idxFmtURI = idxFmt; 606 608 } 607 609 } 608 610 } 609 return bestURIListFormat;611 return idxFmtURI; 610 612 } 611 613 # endif /* VBOX_WITH_SHARED_CLIPBOARD_TRANSFERS */ … … 617 619 * 618 620 * @param pCtx The X11 clipboard context to use. 619 * @param p TargetsThe list of targets.621 * @param paIdxFmtTargets The list of targets. 620 622 * @param cTargets The size of the list in @a pTargets. 621 623 */ 622 624 static void clipGetFormatsFromTargets(PSHCLX11CTX pCtx, 623 SHCLX11FMTIDX *p Targets, size_t cTargets)625 SHCLX11FMTIDX *paIdxFmtTargets, size_t cTargets) 624 626 { 625 627 AssertPtrReturnVoid(pCtx); 626 AssertPtrReturnVoid(p Targets);627 628 SHCLX11FMTIDX bestTextFormat = clipGetTextFormatFromTargets(pCtx, pTargets, cTargets);629 if (pCtx-> X11TextFormat != bestTextFormat)630 pCtx-> X11TextFormat = bestTextFormat;631 632 pCtx-> X11BitmapFormat= SHCLX11FMT_INVALID; /* not yet supported */ /** @todo r=andy Check this. */633 SHCLX11FMTIDX bestBitmapFormat = clipGetBitmapFormatFromTargets(pCtx, pTargets, cTargets);634 if (pCtx-> X11BitmapFormat != bestBitmapFormat)635 pCtx-> X11BitmapFormat = bestBitmapFormat;636 637 SHCLX11FMTIDX bestHtmlFormat = clipGetHtmlFormatFromTargets(pCtx, pTargets, cTargets);638 if (pCtx-> X11HTMLFormat != bestHtmlFormat)639 pCtx-> X11HTMLFormat = bestHtmlFormat;628 AssertPtrReturnVoid(paIdxFmtTargets); 629 630 SHCLX11FMTIDX idxFmtText = clipGetTextFormatFromTargets(pCtx, paIdxFmtTargets, cTargets); 631 if (pCtx->idxFmtText != idxFmtText) 632 pCtx->idxFmtText = idxFmtText; 633 634 pCtx->idxFmtBmp = SHCLX11FMT_INVALID; /* not yet supported */ /** @todo r=andy Check this. */ 635 SHCLX11FMTIDX idxFmtBmp = clipGetBitmapFormatFromTargets(pCtx, paIdxFmtTargets, cTargets); 636 if (pCtx->idxFmtBmp != idxFmtBmp) 637 pCtx->idxFmtBmp = idxFmtBmp; 638 639 SHCLX11FMTIDX idxFmtHTML = clipGetHtmlFormatFromTargets(pCtx, paIdxFmtTargets, cTargets); 640 if (pCtx->idxFmtHTML != idxFmtHTML) 641 pCtx->idxFmtHTML = idxFmtHTML; 640 642 641 643 #ifdef VBOX_WITH_SHARED_CLIPBOARD_TRANSFERS 642 SHCLX11FMTIDX bestURIListFormat = clipGetURIListFormatFromTargets(pCtx, pTargets, cTargets);643 if (pCtx-> X11URIListFormat != bestURIListFormat)644 pCtx-> X11URIListFormat = bestURIListFormat;644 SHCLX11FMTIDX idxFmtURI = clipGetURIListFormatFromTargets(pCtx, paIdxFmtTargets, cTargets); 645 if (pCtx->idxFmtURI != idxFmtURI) 646 pCtx->idxFmtURI = idxFmtURI; 645 647 #endif 646 648 } … … 654 656 * @param cTargets The size of the array @a pTargets. 655 657 */ 656 SHCL_X11_DECL(void) clipUpdateX11Targets(PSHCLX11CTX pCtx, SHCLX11FMTIDX *p Targets, size_t cTargets)658 SHCL_X11_DECL(void) clipUpdateX11Targets(PSHCLX11CTX pCtx, SHCLX11FMTIDX *paIdxFmtTargets, size_t cTargets) 657 659 { 658 660 LogFlowFuncEnter(); 659 661 660 if (p Targets == NULL)662 if (paIdxFmtTargets == NULL) 661 663 { 662 664 /* No data available */ … … 665 667 } 666 668 667 clipGetFormatsFromTargets(pCtx, p Targets, cTargets);669 clipGetFormatsFromTargets(pCtx, paIdxFmtTargets, cTargets); 668 670 clipReportFormatsToVBox(pCtx); 669 671 } … … 715 717 LogRel2(("Shared Clipboard: %u formats were found\n", cFormats)); 716 718 717 SHCLX11FMTIDX *p Formats= NULL;719 SHCLX11FMTIDX *paIdxFmt = NULL; 718 720 if ( cFormats 719 721 && pValue … … 721 723 { 722 724 /* Allocated array to hold the format indices. */ 723 p Formats= (SHCLX11FMTIDX *)RTMemAllocZ(cFormats * sizeof(SHCLX11FMTIDX));725 paIdxFmt = (SHCLX11FMTIDX *)RTMemAllocZ(cFormats * sizeof(SHCLX11FMTIDX)); 724 726 } 725 727 … … 741 743 #endif 742 744 743 if (p Formats)745 if (paIdxFmt) 744 746 { 745 747 for (unsigned i = 0; i < cFormats; ++i) … … 750 752 g_aFormats[j].pcszAtom, False); 751 753 if (*(pAtoms + i) == target) 752 p Formats[i] = j;754 paIdxFmt[i] = j; 753 755 } 754 756 #if !defined(TESTCASE) 755 if (p Formats[i] != SHCLX11FMT_INVALID)756 LogRel2(("Shared Clipboard: Reporting format '%s'\n", g_aFormats[p Formats[i]].pcszAtom));757 if (paIdxFmt[i] != SHCLX11FMT_INVALID) 758 LogRel2(("Shared Clipboard: Reporting format '%s'\n", g_aFormats[paIdxFmt[i]].pcszAtom)); 757 759 #endif 758 760 } … … 761 763 LogFunc(("Reporting empty targets (none reported or allocation failure)\n")); 762 764 763 clipUpdateX11Targets(pCtx, p Formats, cFormats);764 RTMemFree(p Formats);765 clipUpdateX11Targets(pCtx, paIdxFmt, cFormats); 766 RTMemFree(paIdxFmt); 765 767 766 768 XtFree(reinterpret_cast<char *>(pValue)); … … 1248 1250 Atom *atomTargets = (Atom *)XtMalloc((SHCL_MAX_X11_FORMATS + cFixedTargets) * sizeof(Atom)); 1249 1251 unsigned cTargets = 0; 1250 SHCLX11FMTIDX format = NIL_CLIPX11FORMAT;1252 SHCLX11FMTIDX idxFmt = NIL_CLIPX11FORMAT; 1251 1253 do 1252 1254 { 1253 format = clipEnumX11Formats(pCtx->vboxFormats, format);1254 if ( format != NIL_CLIPX11FORMAT)1255 { 1256 atomTargets[cTargets] = clipAtomForX11Format(pCtx, format);1255 idxFmt = clipEnumX11Formats(pCtx->vboxFormats, idxFmt); 1256 if (idxFmt != NIL_CLIPX11FORMAT) 1257 { 1258 atomTargets[cTargets] = clipAtomForX11Format(pCtx, idxFmt); 1257 1259 ++cTargets; 1258 1260 } 1259 } while ( format != NIL_CLIPX11FORMAT);1261 } while (idxFmt != NIL_CLIPX11FORMAT); 1260 1262 1261 1263 /* We always offer these fixed targets. */ … … 1453 1455 int rc = VINF_SUCCESS; 1454 1456 1455 SHCLX11FMTIDX x11Format = clipFindX11FormatByAtom(pCtx, *atomTarget); 1456 SHCLX11FMT clipFormat = clipRealFormatForX11Format(x11Format); 1457 1458 LogFlowFunc(("fFormats=0x%x, x11Format=%u, clipFormat=%u\n", pCtx->vboxFormats, x11Format, clipFormat)); 1459 1460 if ( ((clipFormat == SHCLX11FMT_UTF8) || (clipFormat == SHCLX11FMT_TEXT)) 1457 SHCLX11FMTIDX idxFmtX11 = clipFindX11FormatByAtom(pCtx, *atomTarget); 1458 SHCLX11FMT fmtX11 = clipRealFormatForX11Format(idxFmtX11); 1459 1460 LogFlowFunc(("vboxFormats=0x%x, idxFmtX11=%u ('%s'), fmtX11=%u\n", 1461 pCtx->vboxFormats, idxFmtX11, g_aFormats[idxFmtX11].pcszAtom, fmtX11)); 1462 1463 LogRel2(("Shared Clipboard: Converting VBox formats %#x to '%s' for X11\n", 1464 pCtx->vboxFormats, g_aFormats[idxFmtX11].pcszAtom)); 1465 1466 if ( ((fmtX11 == SHCLX11FMT_UTF8) || (fmtX11 == SHCLX11FMT_TEXT)) 1461 1467 && (pCtx->vboxFormats & VBOX_SHCL_FMT_UNICODETEXT)) 1462 1468 { … … 1466 1472 if (RT_SUCCESS(rc) && (cb == 0)) 1467 1473 rc = VERR_NO_DATA; 1468 if (RT_SUCCESS(rc) && (( clipFormat == SHCLX11FMT_UTF8) || (clipFormat== SHCLX11FMT_TEXT)))1474 if (RT_SUCCESS(rc) && ((fmtX11 == SHCLX11FMT_UTF8) || (fmtX11 == SHCLX11FMT_TEXT))) 1469 1475 rc = clipUtf16CRLFToUtf8LF(XtDisplay(pCtx->pWidget), 1470 1476 (PRTUTF16)pv, cb, atomTarget, … … 1472 1478 pcLenReturn, piFormatReturn); 1473 1479 if (RT_SUCCESS(rc)) 1474 clipTrimTrailingNul(*(XtPointer *)pValReturn, pcLenReturn, clipFormat);1480 clipTrimTrailingNul(*(XtPointer *)pValReturn, pcLenReturn, fmtX11); 1475 1481 1476 1482 RTMemFree(pv); 1477 1483 } 1478 else if ( ( clipFormat== SHCLX11FMT_BMP)1484 else if ( (fmtX11 == SHCLX11FMT_BMP) 1479 1485 && (pCtx->vboxFormats & VBOX_SHCL_FMT_BITMAP)) 1480 1486 { … … 1484 1490 if (RT_SUCCESS(rc) && (cb == 0)) 1485 1491 rc = VERR_NO_DATA; 1486 if (RT_SUCCESS(rc) && ( clipFormat== SHCLX11FMT_BMP))1492 if (RT_SUCCESS(rc) && (fmtX11 == SHCLX11FMT_BMP)) 1487 1493 { 1488 1494 /* Create a full BMP from it */ … … 1501 1507 RTMemFree(pv); 1502 1508 } 1503 else if ( ( clipFormat== SHCLX11FMT_HTML)1509 else if ( (fmtX11 == SHCLX11FMT_HTML) 1504 1510 && (pCtx->vboxFormats & VBOX_SHCL_FMT_HTML)) 1505 1511 { … … 1524 1530 pcLenReturn, piFormatReturn); 1525 1531 if (RT_SUCCESS(rc)) 1526 clipTrimTrailingNul(*(XtPointer *)pValReturn, pcLenReturn, clipFormat);1532 clipTrimTrailingNul(*(XtPointer *)pValReturn, pcLenReturn, fmtX11); 1527 1533 1528 1534 RTMemFree(pv); … … 1532 1538 else if (pCtx->vboxFormats & VBOX_SHCL_FMT_URI_LIST) 1533 1539 { 1534 switch ( clipFormat)1540 switch (fmtX11) 1535 1541 { 1536 1542 case SHCLX11FMT_TEXT: … … 1560 1566 1561 1567 if (RT_FAILURE(rc)) 1562 LogRel 2(("Shared Clipboard: Converting format 0x%x for X11 (x11Format=%u, clipFormat=%u) failed, rc=%Rrc\n",1563 pCtx->vboxFormats, x11Format, clipFormat, rc));1568 LogRel(("Shared Clipboard: Converting VBox formats %#x to '%s' for X11 (idxFmtX11=%u, fmtX11=%u) failed, rc=%Rrc\n", 1569 pCtx->vboxFormats, g_aFormats[idxFmtX11].pcszAtom, idxFmtX11, fmtX11, rc)); 1564 1570 1565 1571 LogFlowFuncLeaveRC(rc); … … 1597 1603 pValReturn, pcLenReturn, piFormatReturn); 1598 1604 1599 LogFlowFunc(("returning %RTbool, internal status code%Rrc\n", RT_SUCCESS(rc), rc));1605 LogFlowFunc(("returning %RTbool, rc=%Rrc\n", RT_SUCCESS(rc), rc)); 1600 1606 return RT_SUCCESS(rc) ? True : False; 1601 1607 } … … 1721 1727 { 1722 1728 CLIPREADX11CBREQ *pReq = (CLIPREADX11CBREQ *)pClient; 1723 1724 LogFlowFunc(("pReq->mFormat=%02X, pReq->mX11Format=%u, pReq->mCtx=%p\n", pReq->mFormat, pReq->mX11Format, pReq->mpCtx)); 1725 1726 AssertPtr(pReq->mpCtx); 1727 Assert(pReq->mFormat != VBOX_SHCL_FMT_NONE); /* Sanity. */ 1729 AssertPtrReturnVoid(pReq); 1730 1731 LogFlowFunc(("pReq->uFmtVBox=%#x, pReq->idxFmtX11=%u, pReq->pCtx=%p\n", pReq->uFmtVBox, pReq->idxFmtX11, pReq->pCtx)); 1732 1733 LogRel2(("Shared Clipboard: Converting X11 format '%s' to VBox format %#x\n", 1734 g_aFormats[pReq->idxFmtX11].pcszAtom, pReq->uFmtVBox)); 1735 1736 AssertPtr(pReq->pCtx); 1737 Assert(pReq->uFmtVBox != VBOX_SHCL_FMT_NONE); /* Sanity. */ 1728 1738 1729 1739 int rc = VINF_SUCCESS; … … 1737 1747 rc = VERR_NO_DATA; 1738 1748 } 1739 else if (pReq-> mFormat== VBOX_SHCL_FMT_UNICODETEXT)1749 else if (pReq->uFmtVBox == VBOX_SHCL_FMT_UNICODETEXT) 1740 1750 { 1741 1751 /* In which format is the clipboard data? */ 1742 switch (clipRealFormatForX11Format(pReq-> mX11Format))1752 switch (clipRealFormatForX11Format(pReq->idxFmtX11)) 1743 1753 { 1744 1754 case SHCLX11FMT_UTF8: … … 1770 1780 } 1771 1781 } 1772 else if (pReq-> mFormat== VBOX_SHCL_FMT_BITMAP)1782 else if (pReq->uFmtVBox == VBOX_SHCL_FMT_BITMAP) 1773 1783 { 1774 1784 /* In which format is the clipboard data? */ 1775 switch (clipRealFormatForX11Format(pReq-> mX11Format))1785 switch (clipRealFormatForX11Format(pReq->idxFmtX11)) 1776 1786 { 1777 1787 case SHCLX11FMT_BMP: … … 1802 1812 } 1803 1813 } 1804 else if (pReq-> mFormat== VBOX_SHCL_FMT_HTML)1814 else if (pReq->uFmtVBox == VBOX_SHCL_FMT_HTML) 1805 1815 { 1806 1816 /* In which format is the clipboard data? */ 1807 switch (clipRealFormatForX11Format(pReq-> mX11Format))1817 switch (clipRealFormatForX11Format(pReq->idxFmtX11)) 1808 1818 { 1809 1819 case SHCLX11FMT_HTML: … … 1865 1875 } 1866 1876 # ifdef VBOX_WITH_SHARED_CLIPBOARD_TRANSFERS 1867 else if (pReq-> mFormat== VBOX_SHCL_FMT_URI_LIST)1877 else if (pReq->uFmtVBox == VBOX_SHCL_FMT_URI_LIST) 1868 1878 { 1869 1879 /* In which format is the clipboard data? */ 1870 switch (clipRealFormatForX11Format(pReq-> mX11Format))1880 switch (clipRealFormatForX11Format(pReq->idxFmtX11)) 1871 1881 { 1872 1882 case SHCLX11FMT_URI_LIST: … … 1916 1926 rc = VERR_NOT_SUPPORTED; 1917 1927 1918 ShClX11RequestFromX11CompleteCallback(pReq->mpCtx->pFrontend, rc, pReq->mpReq, 1928 if (RT_FAILURE(rc)) 1929 LogRel(("Shared Clipboard: Converting X11 format '%s' (idxFmtX11=%u) to VBox format %#x failed, rc=%Rrc\n", 1930 g_aFormats[pReq->idxFmtX11].pcszAtom, pReq->idxFmtX11, pReq->uFmtVBox, rc)); 1931 1932 ShClX11RequestFromX11CompleteCallback(pReq->pCtx->pFrontend, rc, pReq->pReq, 1919 1933 pvDst, cbDst); 1920 1934 RTMemFree(pvDst); … … 1948 1962 } 1949 1963 1950 static int clipGetSelectionValue(PSHCLX11CTX pCtx, SHCLX11FMTIDX format,1964 static int clipGetSelectionValue(PSHCLX11CTX pCtx, SHCLX11FMTIDX idxFmt, 1951 1965 CLIPREADX11CBREQ *pReq) 1952 1966 { 1953 1967 #ifndef TESTCASE 1954 1968 XtGetSelectionValue(pCtx->pWidget, clipGetAtom(pCtx, "CLIPBOARD"), 1955 clipAtomForX11Format(pCtx, format),1969 clipAtomForX11Format(pCtx, idxFmt), 1956 1970 clipConvertDataFromX11Callback, 1957 1971 reinterpret_cast<XtPointer>(pReq), 1958 1972 CurrentTime); 1959 1973 #else 1960 tstClipRequestData(pCtx, format, (void *)pReq);1974 tstClipRequestData(pCtx, idxFmt, (void *)pReq); 1961 1975 #endif 1962 1976 … … 1972 1986 1973 1987 CLIPREADX11CBREQ *pReq = (CLIPREADX11CBREQ *)pvUserData; 1974 SHCLX11CTX *pCtx = pReq-> mpCtx;1975 1976 LogFlowFunc(("pReq->mFormat = %02x\n", pReq-> mFormat));1988 SHCLX11CTX *pCtx = pReq->pCtx; 1989 1990 LogFlowFunc(("pReq->mFormat = %02x\n", pReq->uFmtVBox)); 1977 1991 1978 1992 int rc = VERR_NO_DATA; /* VBox thinks we have data and we don't. */ 1979 1993 1980 if (pReq-> mFormat& VBOX_SHCL_FMT_UNICODETEXT)1981 { 1982 pReq-> mX11Format = pCtx->X11TextFormat;1983 if (pReq-> mX11Format!= SHCLX11FMT_INVALID)1994 if (pReq->uFmtVBox & VBOX_SHCL_FMT_UNICODETEXT) 1995 { 1996 pReq->idxFmtX11 = pCtx->idxFmtText; 1997 if (pReq->idxFmtX11 != SHCLX11FMT_INVALID) 1984 1998 { 1985 1999 /* Send out a request for the data to the current clipboard owner. */ 1986 rc = clipGetSelectionValue(pCtx, pCtx-> X11TextFormat, pReq);1987 } 1988 } 1989 else if (pReq-> mFormat& VBOX_SHCL_FMT_BITMAP)1990 { 1991 pReq-> mX11Format = pCtx->X11BitmapFormat;1992 if (pReq-> mX11Format!= SHCLX11FMT_INVALID)2000 rc = clipGetSelectionValue(pCtx, pCtx->idxFmtText, pReq); 2001 } 2002 } 2003 else if (pReq->uFmtVBox & VBOX_SHCL_FMT_BITMAP) 2004 { 2005 pReq->idxFmtX11 = pCtx->idxFmtBmp; 2006 if (pReq->idxFmtX11 != SHCLX11FMT_INVALID) 1993 2007 { 1994 2008 /* Send out a request for the data to the current clipboard owner. */ 1995 rc = clipGetSelectionValue(pCtx, pCtx-> X11BitmapFormat, pReq);1996 } 1997 } 1998 else if (pReq-> mFormat& VBOX_SHCL_FMT_HTML)1999 { 2000 pReq-> mX11Format = pCtx->X11HTMLFormat;2001 if (pReq-> mX11Format!= SHCLX11FMT_INVALID)2009 rc = clipGetSelectionValue(pCtx, pCtx->idxFmtBmp, pReq); 2010 } 2011 } 2012 else if (pReq->uFmtVBox & VBOX_SHCL_FMT_HTML) 2013 { 2014 pReq->idxFmtX11 = pCtx->idxFmtHTML; 2015 if (pReq->idxFmtX11 != SHCLX11FMT_INVALID) 2002 2016 { 2003 2017 /* Send out a request for the data to the current clipboard owner. */ 2004 rc = clipGetSelectionValue(pCtx, pCtx-> X11HTMLFormat, pReq);2018 rc = clipGetSelectionValue(pCtx, pCtx->idxFmtHTML, pReq); 2005 2019 } 2006 2020 } 2007 2021 #ifdef VBOX_WITH_SHARED_CLIPBOARD_TRANSFERS 2008 else if (pReq-> mFormat& VBOX_SHCL_FMT_URI_LIST)2009 { 2010 pReq-> mX11Format = pCtx->X11URIListFormat;2011 if (pReq-> mX11Format!= SHCLX11FMT_INVALID)2022 else if (pReq->uFmtVBox & VBOX_SHCL_FMT_URI_LIST) 2023 { 2024 pReq->idxFmtX11 = pCtx->idxFmtURI; 2025 if (pReq->idxFmtX11 != SHCLX11FMT_INVALID) 2012 2026 { 2013 2027 /* Send out a request for the data to the current clipboard owner. */ 2014 rc = clipGetSelectionValue(pCtx, pCtx-> X11URIListFormat, pReq);2028 rc = clipGetSelectionValue(pCtx, pCtx->idxFmtURI, pReq); 2015 2029 } 2016 2030 } … … 2025 2039 /* The clipboard callback was never scheduled, so we must signal 2026 2040 * that the request processing is finished and clean up ourselves. */ 2027 ShClX11RequestFromX11CompleteCallback(pReq-> mpCtx->pFrontend, rc, pReq->mpReq,2041 ShClX11RequestFromX11CompleteCallback(pReq->pCtx->pFrontend, rc, pReq->pReq, 2028 2042 NULL /* pv */ ,0 /* cb */); 2029 2043 RTMemFree(pReq); … … 2059 2073 if (pX11Req) 2060 2074 { 2061 pX11Req-> mpCtx= pCtx;2062 pX11Req-> mFormat= Format;2063 pX11Req-> mpReq= pReq;2075 pX11Req->pCtx = pCtx; 2076 pX11Req->uFmtVBox = Format; 2077 pX11Req->pReq = pReq; 2064 2078 2065 2079 /* We use this to schedule a worker function on the event thread. */
Note:
See TracChangeset
for help on using the changeset viewer.