From: Oliver Kurth Date: Wed, 7 Jun 2017 00:17:04 +0000 (-0700) Subject: Add support for the new selection target name "text/rtf" for copy/paste. X-Git-Tag: stable-10.1.10~8 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6e88d52301ad3ec943f5d296e64c6352024082b3;p=thirdparty%2Fopen-vm-tools.git Add support for the new selection target name "text/rtf" for copy/paste. --- diff --git a/open-vm-tools/services/plugins/dndcp/copyPasteUIX11.cpp b/open-vm-tools/services/plugins/dndcp/copyPasteUIX11.cpp index cef64c1b2..95ec6cb68 100644 --- a/open-vm-tools/services/plugins/dndcp/copyPasteUIX11.cpp +++ b/open-vm-tools/services/plugins/dndcp/copyPasteUIX11.cpp @@ -1,5 +1,5 @@ /********************************************************* - * Copyright (C) 2009-2016 VMware, Inc. All rights reserved. + * Copyright (C) 2009-2017 VMware, Inc. All rights reserved. * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published @@ -266,7 +266,7 @@ CopyPasteUIX11::VmxCopyPasteVersionChanged(RpcChannel *chan, // IN * CopyPasteUIX11::GetLocalClipboard -- * * Retrives the data from local clipboard and sends it to host. Send empty - * data back if there is no data or can not get data successfully. For + * data back if there is no data or can not get data successfully. For * guest->host copy/paste. * * Results: @@ -313,7 +313,7 @@ CopyPasteUIX11::GetLocalClipboard(void) * * CopyPasteUIX11::GetCurrentTime -- * - * Get current time in microseconds. + * Get current time in microseconds. * * Results: * Time in microseconds. @@ -546,7 +546,8 @@ CopyPasteUIX11::LocalGetTextOrRTFRequestCB(Gtk::SelectionData& sd, // IN/OUT __FUNCTION__, target.c_str()); if (target == TARGET_NAME_APPLICATION_RTF || - target == TARGET_NAME_TEXT_RICHTEXT) { + target == TARGET_NAME_TEXT_RICHTEXT || + target == TARGET_NAME_TEXT_RTF) { if (0 == mHGRTFData.size()) { g_debug("%s: Can not get valid RTF data\n", __FUNCTION__); return; @@ -753,7 +754,7 @@ again: /* Try to get RTF data from clipboard. */ bool haveRTF = false; if (refClipboard->wait_is_target_available(TARGET_NAME_APPLICATION_RTF)) { - g_debug("%s: RTF is available\n", __FUNCTION__); + g_debug("%s: APP RTF is available\n", __FUNCTION__); format = TARGET_NAME_APPLICATION_RTF; haveRTF = true; } @@ -762,6 +763,11 @@ again: format = TARGET_NAME_TEXT_RICHTEXT; haveRTF = true; } + if (refClipboard->wait_is_target_available(TARGET_NAME_TEXT_RTF)) { + g_debug("%s: TEXT_RTF is available\n", __FUNCTION__); + format = TARGET_NAME_TEXT_RTF; + haveRTF = true; + } if (mCP->CheckCapability(DND_CP_CAP_RTF_CP) && haveRTF) { /* @@ -1200,9 +1206,11 @@ CopyPasteUIX11::GetRemoteClipboardCB(const CPClipboard *clip) // IN if (CPClipboard_GetItem(clip, CPFORMAT_RTF, &buf, &sz)) { g_debug("%s: RTF data, size %" FMTSZ "u.\n", __FUNCTION__, sz); Gtk::TargetEntry appRtf(TARGET_NAME_APPLICATION_RTF); - Gtk::TargetEntry textRtf(TARGET_NAME_TEXT_RICHTEXT); + Gtk::TargetEntry textRichText(TARGET_NAME_TEXT_RICHTEXT); + Gtk::TargetEntry textRtf(TARGET_NAME_TEXT_RTF); targets.push_back(appRtf); + targets.push_back(textRichText); targets.push_back(textRtf); mHGRTFData = std::string((const char *)buf); mIsClipboardOwner = true; diff --git a/open-vm-tools/services/plugins/dndcp/dnd/dnd.h b/open-vm-tools/services/plugins/dndcp/dnd/dnd.h index a40db1912..0cfb4e1e4 100644 --- a/open-vm-tools/services/plugins/dndcp/dnd/dnd.h +++ b/open-vm-tools/services/plugins/dndcp/dnd/dnd.h @@ -1,5 +1,5 @@ /********************************************************* - * Copyright (C) 2005-2016 VMware, Inc. All rights reserved. + * Copyright (C) 2005-2017 VMware, Inc. All rights reserved. * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published @@ -86,6 +86,7 @@ #define TARGET_NAME_COMPOUND_TEXT "COMPOUND_TEXT" #define TARGET_NAME_APPLICATION_RTF "application/rtf" #define TARGET_NAME_TEXT_RICHTEXT "text/richtext" +#define TARGET_NAME_TEXT_RTF "text/rtf" #define DRAG_TARGET_NAME_URI_LIST "text/uri-list" #define DRAG_LEAVE_TIMEOUT 500 diff --git a/open-vm-tools/services/plugins/dndcp/dndUIX11.cpp b/open-vm-tools/services/plugins/dndcp/dndUIX11.cpp index 231479a99..6a06e7d16 100644 --- a/open-vm-tools/services/plugins/dndcp/dndUIX11.cpp +++ b/open-vm-tools/services/plugins/dndcp/dndUIX11.cpp @@ -1,5 +1,5 @@ /********************************************************* - * Copyright (C) 2009-2016 VMware, Inc. All rights reserved. + * Copyright (C) 2009-2017 VMware, Inc. All rights reserved. * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published @@ -259,6 +259,7 @@ DnDUIX11::InitGtk() /* RTF text DnD. */ targets.push_back(Gtk::TargetEntry(TARGET_NAME_APPLICATION_RTF)); targets.push_back(Gtk::TargetEntry(TARGET_NAME_TEXT_RICHTEXT)); + targets.push_back(Gtk::TargetEntry(TARGET_NAME_TEXT_RTF)); /* Plain text DnD. */ targets.push_back(Gtk::TargetEntry(TARGET_NAME_UTF8_STRING)); @@ -400,6 +401,7 @@ DnDUIX11::OnSrcDragBegin(const CPClipboard *clip, // IN if (CPClipboard_ItemExists(&mClipboard, CPFORMAT_RTF)) { targets->add(Glib::ustring(TARGET_NAME_APPLICATION_RTF)); targets->add(Glib::ustring(TARGET_NAME_TEXT_RICHTEXT)); + targets->add(Glib::ustring(TARGET_NAME_TEXT_RTF)); } actions = Gdk::ACTION_COPY | Gdk::ACTION_MOVE; @@ -1559,9 +1561,11 @@ DnDUIX11::RequestData( /* Then check RTF. */ targets->add(Glib::ustring(TARGET_NAME_APPLICATION_RTF)); targets->add(Glib::ustring(TARGET_NAME_TEXT_RICHTEXT)); + targets->add(Glib::ustring(TARGET_NAME_TEXT_RTF)); target = mDetWnd->drag_dest_find_target(dc, targets); targets->remove(Glib::ustring(TARGET_NAME_APPLICATION_RTF)); targets->remove(Glib::ustring(TARGET_NAME_TEXT_RICHTEXT)); + targets->remove(Glib::ustring(TARGET_NAME_TEXT_RTF)); if (target != "") { mDetWnd->drag_get_data(dc, target, time); mNumPendingRequest++; diff --git a/open-vm-tools/services/plugins/dndcp/dndUIX11.h b/open-vm-tools/services/plugins/dndcp/dndUIX11.h index 4c2ba6c03..4363420fa 100644 --- a/open-vm-tools/services/plugins/dndcp/dndUIX11.h +++ b/open-vm-tools/services/plugins/dndcp/dndUIX11.h @@ -1,5 +1,5 @@ /********************************************************* - * Copyright (C) 2009-2016 VMware, Inc. All rights reserved. + * Copyright (C) 2009-2017 VMware, Inc. All rights reserved. * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published @@ -192,7 +192,8 @@ private: static inline bool TargetIsRichText(const utf::string& target) { return target == TARGET_NAME_APPLICATION_RTF - || target == TARGET_NAME_TEXT_RICHTEXT; + || target == TARGET_NAME_TEXT_RICHTEXT + || target == TARGET_NAME_TEXT_RTF; } void OnWorkAreaChanged(Glib::RefPtr screen);