]> git.ipfire.org Git - thirdparty/open-vm-tools.git/commitdiff
Add support for the new selection target name "text/rtf" for copy/paste.
authorOliver Kurth <okurth@vmware.com>
Wed, 7 Jun 2017 00:17:04 +0000 (17:17 -0700)
committerOliver Kurth <okurth@vmware.com>
Wed, 7 Jun 2017 00:17:04 +0000 (17:17 -0700)
open-vm-tools/services/plugins/dndcp/copyPasteUIX11.cpp
open-vm-tools/services/plugins/dndcp/dnd/dnd.h
open-vm-tools/services/plugins/dndcp/dndUIX11.cpp
open-vm-tools/services/plugins/dndcp/dndUIX11.h

index cef64c1b2d1a9b3589fbb35c2eb46161282cc58d..95ec6cb68adc61241a7916cbd8102961f79bdedb 100644 (file)
@@ -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;
index a40db19126173fe9a465d2a445e86d946485c330..0cfb4e1e4ae0f6d9c8a26f776d1efe97a1a3c8b5 100644 (file)
@@ -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
index 231479a99b72cc6d76c14606f205d3772240b6ec..6a06e7d166445e2000af80db01f198f238cbd809 100644 (file)
@@ -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++;
index 4c2ba6c03d2eb925029ae23f9de1d049a39d56e1..4363420facfb60090c0523406c5131a9e27280ff 100644 (file)
@@ -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<Gdk::Screen> screen);