From: VMware, Inc <> Date: Thu, 24 Feb 2011 22:38:21 +0000 (-0800) Subject: Internal branch sync. Included in this change: X-Git-Tag: 2011.02.23-368700~33 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=bcd25e4914e07d89650e104a3ada954c5a0dbd51;p=thirdparty%2Fopen-vm-tools.git Internal branch sync. Included in this change: . DnD text from Windows guest to Linux guest is not working. . changes in shared code that don't affect open-vm-tools functionality. Signed-off-by: Marcelo Vanzin --- diff --git a/open-vm-tools/lib/include/loglevel_user.h b/open-vm-tools/lib/include/loglevel_user.h index 5cba625ad..10f9a00b7 100644 --- a/open-vm-tools/lib/include/loglevel_user.h +++ b/open-vm-tools/lib/include/loglevel_user.h @@ -241,6 +241,7 @@ LOGLEVEL_VAR(digestlib), \ LOGLEVEL_VAR(svgadevtap), \ LOGLEVEL_VAR(ssl), \ + LOGLEVEL_VAR(vmrc), \ /* end of list */ LOGLEVEL_EXTENSION_DECLARE(LOGLEVEL_USER); diff --git a/open-vm-tools/services/plugins/dndcp/dndUIX11.cpp b/open-vm-tools/services/plugins/dndcp/dndUIX11.cpp index 94fb6f4d2..a83312619 100644 --- a/open-vm-tools/services/plugins/dndcp/dndUIX11.cpp +++ b/open-vm-tools/services/plugins/dndcp/dndUIX11.cpp @@ -75,6 +75,7 @@ DnDUIX11::DnDUIX11(ToolsAppCtx *ctx) m_mousePosX(0), m_mousePosY(0), m_dc(NULL), + m_numPendingRequest(0), m_destDropTime(0) { g_debug("%s: enter\n", __FUNCTION__); @@ -758,7 +759,7 @@ DnDUIX11::GtkDestDragMotionCB(const Glib::RefPtr &dc, m_GHDnDInProgress = true; /* only begin drag enter after we get the data */ /* Need to grab all of the data. */ - m_detWnd->drag_get_data(dc, target, timeValue); + ASSERT(RequestData(dc, timeValue)); } else { g_debug("%s: Multiple drag motions before gh data has been received.\n", __FUNCTION__); @@ -1039,8 +1040,6 @@ DnDUIX11::GtkDestDragDataReceivedCB(const Glib::RefPtr &dc, return; } - CPClipboard_Clear(&m_clipboard); - /* * Try to get data provided from the source. If we cannot get any data, * there is no need to inform the guest of anything. If there is no data, @@ -1052,6 +1051,12 @@ DnDUIX11::GtkDestDragDataReceivedCB(const Glib::RefPtr &dc, CommonResetCB(); return; } + + m_numPendingRequest--; + if (m_numPendingRequest > 0) { + return; + } + if (CPClipboard_IsEmpty(&m_clipboard)) { g_debug("%s: Failed getting item.\n", __FUNCTION__); CommonResetCB(); @@ -1260,6 +1265,68 @@ DnDUIX11::SetCPClipboardFromGtk(const Gtk::SelectionData& sd) // IN } +/** + * + * Ask for clipboard data from drag source. + * + * @param[in] dc Associated drag context + * @param[in] time Time of the request + * + * @return true if there is any data request, false otherwise. + */ + +bool +DnDUIX11::RequestData(const Glib::RefPtr &dc, + guint time) +{ + Glib::RefPtr targets; + targets = Gtk::TargetList::create(std::list()); + + CPClipboard_Clear(&m_clipboard); + m_numPendingRequest = 0; + + /* + * First check file list. If file list is available, all other formats will + * be ignored. + */ + targets->add(Glib::ustring(DRAG_TARGET_NAME_URI_LIST)); + Glib::ustring target = m_detWnd->drag_dest_find_target(dc, targets); + targets->remove(Glib::ustring(DRAG_TARGET_NAME_URI_LIST)); + if (target != "") { + m_detWnd->drag_get_data(dc, target, time); + m_numPendingRequest++; + return true; + } + + /* Then check plain text. */ + targets->add(Glib::ustring(TARGET_NAME_STRING)); + targets->add(Glib::ustring(TARGET_NAME_TEXT_PLAIN)); + targets->add(Glib::ustring(TARGET_NAME_UTF8_STRING)); + targets->add(Glib::ustring(TARGET_NAME_COMPOUND_TEXT)); + target = m_detWnd->drag_dest_find_target(dc, targets); + targets->remove(Glib::ustring(TARGET_NAME_STRING)); + targets->remove(Glib::ustring(TARGET_NAME_TEXT_PLAIN)); + targets->remove(Glib::ustring(TARGET_NAME_UTF8_STRING)); + targets->remove(Glib::ustring(TARGET_NAME_COMPOUND_TEXT)); + if (target != "") { + m_detWnd->drag_get_data(dc, target, time); + m_numPendingRequest++; + } + + /* Then check RTF. */ + targets->add(Glib::ustring(TARGET_NAME_APPLICATION_RTF)); + targets->add(Glib::ustring(TARGET_NAME_TEXT_RICHTEXT)); + target = m_detWnd->drag_dest_find_target(dc, targets); + targets->remove(Glib::ustring(TARGET_NAME_APPLICATION_RTF)); + targets->remove(Glib::ustring(TARGET_NAME_TEXT_RICHTEXT)); + if (target != "") { + m_detWnd->drag_get_data(dc, target, time); + m_numPendingRequest++; + } + return (m_numPendingRequest > 0); +} + + /** * * Try to get last directory name from a full path name. diff --git a/open-vm-tools/services/plugins/dndcp/dndUIX11.h b/open-vm-tools/services/plugins/dndcp/dndUIX11.h index e532ef6e4..859ad8941 100644 --- a/open-vm-tools/services/plugins/dndcp/dndUIX11.h +++ b/open-vm-tools/services/plugins/dndcp/dndUIX11.h @@ -168,6 +168,8 @@ private: * Misc methods. */ bool SetCPClipboardFromGtk(const Gtk::SelectionData& sd); + bool RequestData(const Glib::RefPtr &dc, + guint timeValue); std::string GetLastDirName(const std::string &str); utf::utf8string GetNextPath(utf::utf8string &str, size_t& index); DND_DROPEFFECT ToDropEffect(Gdk::DragAction action); @@ -204,6 +206,7 @@ private: int32 m_mousePosX; int32 m_mousePosY; GdkDragContext *m_dc; + int m_numPendingRequest; unsigned long m_destDropTime; };