Changeset 82510 in vbox for trunk/src/VBox
- Timestamp:
- Dec 9, 2019 12:15:16 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/GuestHost/SharedClipboard/clipboard-win.cpp
r82504 r82510 829 829 /** 830 830 * Announces a clipboard format to the Windows clipboard. 831 * The actual rendering (setting) of the clipboard data will be done later with a separate WM_RENDERFORMAT message. 831 * 832 * The actual rendering (setting) of the clipboard data will be done later with 833 * a separate WM_RENDERFORMAT message. 832 834 * 833 835 * @returns VBox status code. VERR_NOT_SUPPORTED if the format is not supported / handled. … … 839 841 LogFunc(("fFormats=0x%x\n", fFormats)); 840 842 841 HANDLE hClip = NULL; 842 UINT cfFormat = 0; 843 844 int rc = VINF_SUCCESS; 845 846 /** @todo r=andy Only one clipboard format can be set at once, at least on Windows. 847 * r=bird: Where did you get that misconception from? That's utter 848 * non-sense. */ 849 /** @todo Implement more flexible clipboard precedence for supported formats. */ 850 851 if (fFormats & VBOX_SHCL_FMT_UNICODETEXT) 852 { 853 LogFunc(("CF_UNICODETEXT\n")); 854 hClip = SetClipboardData(CF_UNICODETEXT, NULL); 855 } 856 else if (fFormats & VBOX_SHCL_FMT_BITMAP) 857 { 858 LogFunc(("CF_DIB\n")); 859 hClip = SetClipboardData(CF_DIB, NULL); 860 } 861 else if (fFormats & VBOX_SHCL_FMT_HTML) 862 { 863 LogFunc(("VBOX_SHCL_FMT_HTML\n")); 864 cfFormat = RegisterClipboardFormat(SHCL_WIN_REGFMT_HTML); 865 if (cfFormat != 0) 866 hClip = SetClipboardData(cfFormat, NULL); 867 } 868 else 869 { 870 LogRel(("Shared Clipboard: Unsupported format(s) (0x%x), skipping\n", fFormats)); 843 /* 844 * Set the clipboard formats. 845 */ 846 static struct 847 { 848 uint32_t fVBoxFormat; 849 UINT uWinFormat; 850 const char *pszWinFormat; 851 const char *pszLog; 852 } s_aFormats[] = 853 { 854 { VBOX_SHCL_FMT_UNICODETEXT, CF_UNICODETEXT, NULL, "CF_UNICODETEXT" }, 855 { VBOX_SHCL_FMT_BITMAP, CF_DIB, NULL, "CF_DIB" }, 856 { VBOX_SHCL_FMT_HTML, 0, SHCL_WIN_REGFMT_HTML, "SHCL_WIN_REGFMT_HTML" }, 857 }; 858 unsigned cSuccessfullySet = 0; 859 SHCLFORMATS fFormatsLeft = fFormats; 860 int rc = VINF_SUCCESS; 861 for (uintptr_t i = 0; i < RT_ELEMENTS(s_aFormats) && fFormatsLeft != 0; i++) 862 { 863 if (fFormatsLeft & s_aFormats[i].fVBoxFormat) 864 { 865 LogFunc(("%s\n", s_aFormats[i].pszLog)); 866 fFormatsLeft &= ~s_aFormats[i].fVBoxFormat; 867 868 /* Reg format if needed: */ 869 UINT uWinFormat = s_aFormats[i].uWinFormat; 870 if (!uWinFormat) 871 { 872 uWinFormat = RegisterClipboardFormat(s_aFormats[i].pszWinFormat); 873 AssertContinue(uWinFormat != 0); 874 } 875 876 /* Tell the clipboard we've got data upon a request. We check the 877 last error here as hClip will be NULL even on success (despite 878 what MSDN says). */ 879 SetLastError(NO_ERROR); 880 HANDLE hClip = SetClipboardData(uWinFormat, NULL); 881 DWORD dwErr = GetLastError(); 882 if (dwErr == NO_ERROR || hClip != NULL) 883 cSuccessfullySet++; 884 else 885 { 886 AssertMsgFailed(("%s/%u: %u\n", s_aFormats[i].pszLog, uWinFormat, dwErr)); 887 rc = RTErrConvertFromWin32(dwErr); 888 } 889 } 890 } 891 892 /* 893 * Consider setting anything a success, converting any error into 894 * informational status. Unsupport error only happens if all formats 895 * were unsupported. 896 */ 897 if (cSuccessfullySet > 0) 898 { 899 pWinCtx->hWndClipboardOwnerUs = GetClipboardOwner(); 900 if (RT_FAILURE(rc)) 901 rc = -rc; 902 } 903 else if (RT_SUCCESS(rc) && fFormatsLeft != 0) 904 { 905 LogFunc(("Unsupported formats: %#x (%#x)\n", fFormatsLeft, fFormats)); 871 906 rc = VERR_NOT_SUPPORTED; 872 }873 874 if (RT_SUCCESS(rc))875 {876 pWinCtx->hWndClipboardOwnerUs = GetClipboardOwner();877 907 } 878 908
Note:
See TracChangeset
for help on using the changeset viewer.