From: Kruti Pendharkar Date: Tue, 3 Jun 2025 06:30:25 +0000 (-0700) Subject: Change to common source files not applicable to open-vm-tools at this time. X-Git-Tag: stable-13.1.0~170 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=841948918e2f79f1ad3ce5d7093ec20abf217ca4;p=thirdparty%2Fopen-vm-tools.git Change to common source files not applicable to open-vm-tools at this time. --- diff --git a/open-vm-tools/services/plugins/dndcp/copyPasteDnDX11.cpp b/open-vm-tools/services/plugins/dndcp/copyPasteDnDX11.cpp index 8d94bdbad..14e6f8e6a 100644 --- a/open-vm-tools/services/plugins/dndcp/copyPasteDnDX11.cpp +++ b/open-vm-tools/services/plugins/dndcp/copyPasteDnDX11.cpp @@ -24,12 +24,13 @@ */ #define G_LOG_DOMAIN "dndcp" +#define VMTOOLS_USE_LEGACY_GTK #include "copyPasteDnDWrapper.h" #include "copyPasteDnDX11.h" -#include "dndPluginIntX11.h" #include "copyPasteUIX11.h" #include "tracer.hh" +#include "dndPluginIntX11.h" Window gXRoot; Display *gXDisplay; @@ -194,12 +195,15 @@ BlockService::Shutdown() * Constructor. */ + +#ifdef VMTOOLS_USE_LEGACY_GTK CopyPasteDnDX11::CopyPasteDnDX11() : m_main(NULL), m_copyPasteUI(NULL), m_dndUI(NULL) { } +#endif /** @@ -229,12 +233,18 @@ CopyPasteDnDX11::Init(ToolsAppCtx *ctx) CopyPasteDnDWrapper *wrapper = CopyPasteDnDWrapper::GetInstance(); ASSERT(ctx); + +#ifdef VMTOOLS_USE_LEGACY_GTK int argc = 1; const char *argv[] = {"", NULL}; m_main = new Gtk::Main(&argc, (char ***) &argv, false); +#endif + if (wrapper) { BlockService::GetInstance()->Init(ctx); } + +#ifdef VMTOOLS_USE_LEGACY_GTK gUserMainWidget = gtk_invisible_new(); #ifndef GTK3 gXDisplay = GDK_WINDOW_XDISPLAY(gUserMainWidget->window); @@ -242,6 +252,7 @@ CopyPasteDnDX11::Init(ToolsAppCtx *ctx) gXDisplay = GDK_WINDOW_XDISPLAY(gtk_widget_get_window(gUserMainWidget)); #endif gXRoot = RootWindow(gXDisplay, DefaultScreen(gXDisplay)); +#endif /* * Register legacy (backdoor) version of copy paste. @@ -260,15 +271,12 @@ CopyPasteDnDX11::Init(ToolsAppCtx *ctx) CopyPasteDnDX11::~CopyPasteDnDX11() { - if (m_copyPasteUI) { - delete m_copyPasteUI; - } - if (m_dndUI) { - delete m_dndUI; - } - if (m_main) { - delete m_main; - } + delete m_copyPasteUI; + +#ifdef VMTOOLS_USE_LEGACY_GTK + delete m_dndUI; + delete m_main; +#endif /* * Legacy CP. @@ -276,7 +284,11 @@ CopyPasteDnDX11::~CopyPasteDnDX11() CopyPaste_Unregister(gUserMainWidget); if (gUserMainWidget) { - gtk_widget_destroy(gUserMainWidget); + +#ifdef VMTOOLS_USE_LEGACY_GTK + gtk_widget_destroy(gUserMainWidget); +#endif + } } @@ -341,6 +353,8 @@ CopyPasteDnDX11::RegisterDnD() TRACE_CALL(); CopyPasteDnDWrapper *wrapper = CopyPasteDnDWrapper::GetInstance(); + +#ifdef VMTOOLS_USE_LEGACY_GTK if (!wrapper->IsDnDEnabled()) { return FALSE; } @@ -367,6 +381,7 @@ CopyPasteDnDX11::RegisterDnD() g_debug("%s: dnd is registered? %d\n", __FUNCTION__, (int) wrapper->IsDnDRegistered()); return wrapper->IsDnDRegistered(); +#endif } @@ -381,10 +396,7 @@ CopyPasteDnDX11::UnregisterCP() TRACE_CALL(); CopyPasteDnDWrapper *wrapper = CopyPasteDnDWrapper::GetInstance(); if (wrapper->IsCPRegistered()) { - if (m_copyPasteUI) { - delete m_copyPasteUI; - m_copyPasteUI = NULL; - } + delete m_copyPasteUI; wrapper->SetCPIsRegistered(FALSE); wrapper->SetCPVersion(-1); } @@ -402,10 +414,11 @@ CopyPasteDnDX11::UnregisterDnD() TRACE_CALL(); CopyPasteDnDWrapper *wrapper = CopyPasteDnDWrapper::GetInstance(); if (wrapper->IsDnDRegistered()) { - if (m_dndUI) { - delete m_dndUI; - m_dndUI = NULL; - } + +#ifdef VMTOOLS_USE_LEGACY_GTK + delete m_dndUI; +#endif + wrapper->SetDnDIsRegistered(false); wrapper->SetDnDVersion(-1); return; @@ -423,9 +436,11 @@ CopyPasteDnDX11::UnregisterDnD() void CopyPasteDnDX11::SetDnDAllowed(bool allowed) { +#ifdef VMTOOLS_USE_LEGACY_GTK ASSERT(m_dndUI); TRACE_CALL(); m_dndUI->SetDnDAllowed(allowed); +#endif } @@ -480,8 +495,10 @@ CopyPasteDnDX11::DnDVersionChanged(int version) g_debug("%s: calling VmxDnDVersionChanged (version %d)\n", __FUNCTION__, version); ASSERT(ctx); +#ifdef VMTOOLS_USE_LEGACY_GTK ASSERT(m_dndUI); m_dndUI->VmxDnDVersionChanged(ctx->rpc, version); +#endif } diff --git a/open-vm-tools/services/plugins/dndcp/copyPasteUIX11.cpp b/open-vm-tools/services/plugins/dndcp/copyPasteUIX11.cpp index a4a02c578..517ebe810 100644 --- a/open-vm-tools/services/plugins/dndcp/copyPasteUIX11.cpp +++ b/open-vm-tools/services/plugins/dndcp/copyPasteUIX11.cpp @@ -1,5 +1,6 @@ /********************************************************* - * Copyright (c) 2009-2021 VMware, Inc. All rights reserved. + * Copyright (c) 2009-2025 Broadcom. All Rights Reserved. + * The term "Broadcom" refers to Broadcom Inc. and/or its subsidiaries. * * 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 diff --git a/open-vm-tools/services/plugins/dndcp/copyPasteUIX11.h b/open-vm-tools/services/plugins/dndcp/copyPasteUIX11.h index 91db7d679..28c3d8bf7 100644 --- a/open-vm-tools/services/plugins/dndcp/copyPasteUIX11.h +++ b/open-vm-tools/services/plugins/dndcp/copyPasteUIX11.h @@ -1,5 +1,6 @@ /********************************************************* - * Copyright (c) 2009-2018 VMware, Inc. All rights reserved. + * Copyright (c) 2009-2025 Broadcom. All Rights Reserved. + * The term "Broadcom" refers to Broadcom Inc. and/or its subsidiaries. * * 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 @@ -47,7 +48,7 @@ extern "C" { /* * Make sure exception types are public and therefore shared between libg*mm - * and this plugin. + * and this plugin. * * See * http://gcc.gnu.org/wiki/Visibility#Problems_with_C.2B-.2B-_exceptions_.28please_read.21.29 @@ -61,7 +62,13 @@ extern "C" { #include #include + +#define VMTOOLS_USE_LEGACY_GTK + +#ifdef VMTOOLS_USE_LEGACY_GTK #include +#endif + #include "vmware/guestrpc/tclodefs.h" class CopyPasteUIX11; @@ -98,25 +105,29 @@ private: /* hg */ void GetRemoteClipboardCB(const CPClipboard *clip); - void RemoteGetFilesDone(void); + +#ifdef VMTOOLS_USE_LEGACY_GTK void LocalGetFileRequestCB(Gtk::SelectionData& selection_data, guint info); void LocalGetTextOrRTFRequestCB(Gtk::SelectionData& sd, guint info); void LocalGetSelectionFileList(const Gtk::SelectionData& sd); void LocalGetFileContentsRequestCB(Gtk::SelectionData& sd, guint info); void LocalClearClipboardCB(void); +#endif /* gh */ void GetLocalClipboard(void); +#ifdef VMTOOLS_USE_LEGACY_GTK void LocalClipboardTimestampCB(const Gtk::SelectionData& sd); void LocalPrimTimestampCB(const Gtk::SelectionData& sd); void LocalReceivedFileListCB(const Gtk::SelectionData& selection_data); + bool LocalPrepareFileContents(const CPClipboard *clip); +#endif void GetLocalFilesDone(bool success); void SendClipNotChanged(void); /* Conversion methods. */ utf::utf8string GetNextPath(utf::utf8string &str, size_t& index); utf::string GetLastDirName(const utf::string &str); - bool LocalPrepareFileContents(const CPClipboard *clip); VmTimeType GetCurrentTime(void); @@ -127,29 +138,35 @@ private: GuestCopyPasteMgr *mCP; bool mClipboardEmpty; utf::string mHGStagingDir; +#ifdef VMTOOLS_USE_LEGACY_GTK std::vector mListTargets; + GdkAtom mGHSelection; bool mIsClipboardOwner; uint64 mClipTime; uint64 mPrimTime; uint64 mLastTimestamp; - GdkAtom mGHSelection; +#endif CPClipboard mClipboard; ThreadParams mThreadParams; pthread_t mThread; /* File vars. */ VmTimeType mHGGetListTime; - utf::string mHGCopiedUriList; utf::utf8string mHGFCPData; + +#ifdef VMTOOLS_USE_LEGACY_GTK + utf::string mHGCopiedUriList; utf::string mHGTextData; std::string mHGRTFData; + bool mGetTimestampOnly; std::vector mHGFileContentsList; +#endif + DND_FILE_TRANSFER_STATUS mHGGetFileStatus; bool mBlockAdded; DnDBlockControl *mBlockCtrl; bool mInited; uint64 mTotalFileSize; - bool mGetTimestampOnly; }; #endif // __COPYPASTE_UI_X11_H__ diff --git a/open-vm-tools/services/plugins/dndcp/dnd/dnd.h b/open-vm-tools/services/plugins/dndcp/dnd/dnd.h index 913cf5c11..f15c6b228 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-2024 Broadcom. All Rights Reserved. + * Copyright (c) 2005-2025 Broadcom. All Rights Reserved. * The term "Broadcom" refers to Broadcom Inc. and/or its subsidiaries. * * This program is free software; you can redistribute it and/or modify it @@ -83,6 +83,7 @@ extern "C" { #define FCP_TARGET_INFO_URI_LIST 1 /* FCP target used for nautilus 3.30 or later. */ #define FCP_TARGET_NAME_NAUTILUS_FILES "UTF8_STRING" +#define FCP_TARGET_NAME_NAUTILUS_GTK4_UTF8 "text/plain;charset=utf-8" #define FCP_TARGET_MIME_NAUTILUS_FILES "x-special/nautilus-clipboard" #define FCP_TARGET_INFO_NAUTILUS_FILES 2 /* Number of FCP targets. */ @@ -94,6 +95,7 @@ extern "C" { #define TARGET_NAME_TIMESTAMP "TIMESTAMP" #define TARGET_NAME_STRING "STRING" #define TARGET_NAME_TEXT_PLAIN "text/plain" +#define TARGET_NAME_TEXT_PLAIN_UTF8 "text/plain;charset=utf-8" #define TARGET_NAME_UTF8_STRING "UTF8_STRING" #define TARGET_NAME_COMPOUND_TEXT "COMPOUND_TEXT" #define TARGET_NAME_APPLICATION_RTF "application/rtf" diff --git a/open-vm-tools/services/plugins/dndcp/dndGuestBase/copyPasteDnDX11.h b/open-vm-tools/services/plugins/dndcp/dndGuestBase/copyPasteDnDX11.h index 3797c59c1..0d023f790 100644 --- a/open-vm-tools/services/plugins/dndcp/dndGuestBase/copyPasteDnDX11.h +++ b/open-vm-tools/services/plugins/dndcp/dndGuestBase/copyPasteDnDX11.h @@ -27,8 +27,15 @@ #ifndef __COPYPASTEDNDX11_H__ #define __COPYPASTEDNDX11_H__ +#define VMTOOLS_USE_LEGACY_GTK + + #include "dnd.h" /* for DnDBlockControl */ + +#ifdef VMTOOLS_USE_LEGACY_GTK #include "dndUIX11.h" +#endif + #include #include "vm_basic_types.h" #include "copyPasteDnDImpl.h" @@ -53,13 +60,18 @@ public: virtual void DnDVersionChanged(int version); virtual void CopyPasteVersionChanged(int version); virtual uint32 GetCaps(); +#ifdef VMTOOLS_USE_LEGACY_GTK void SetUnityMode(Bool mode) {m_dndUI->SetUnityMode(mode);}; +#endif void SetDnDAllowed(bool allowed); void SetCopyPasteAllowed(bool allowed); private: + +#ifdef VMTOOLS_USE_LEGACY_GTK Gtk::Main *m_main; CopyPasteUIX11 *m_copyPasteUI; DnDUIX11 *m_dndUI; +#endif }; #endif // __COPYPASTEDNDX11_H__ diff --git a/open-vm-tools/services/plugins/dndcp/dndGuestBase/dndUIX11.h b/open-vm-tools/services/plugins/dndcp/dndGuestBase/dndUIX11.h index 3c328adf7..15a917891 100644 --- a/open-vm-tools/services/plugins/dndcp/dndGuestBase/dndUIX11.h +++ b/open-vm-tools/services/plugins/dndcp/dndGuestBase/dndUIX11.h @@ -28,6 +28,9 @@ #ifndef __DND_UI_X11_H__ #define __DND_UI_X11_H__ +#define VMTOOLS_USE_LEGACY_GTK + + #include "stringxx/string.hh" #include "dnd.h" #include "str.h" @@ -120,6 +123,7 @@ private: /* * Gtk+ Callbacks: Drag Destination. */ +#ifdef VMTOOLS_USE_LEGACY_GTK void OnGtkDragDataReceived(const Glib::RefPtr &dc, int x, int y, const Gtk::SelectionData &sd, guint info, guint time); @@ -142,6 +146,7 @@ private: */ void SourceDragStartDone(); void SourceUpdateFeedback(DND_DROPEFFECT effect); +#endif /* end VMTOOLS_USE_LEGACY_GTK */ /* * Target function for GH DnD. Makes call to common layer. */ diff --git a/open-vm-tools/services/plugins/dndcp/dndPluginIntX11.h b/open-vm-tools/services/plugins/dndcp/dndPluginIntX11.h index 173af9ed0..0f2c31cce 100644 --- a/open-vm-tools/services/plugins/dndcp/dndPluginIntX11.h +++ b/open-vm-tools/services/plugins/dndcp/dndPluginIntX11.h @@ -25,9 +25,16 @@ #ifndef __DNDPLUGIN_INTX11_H__ #define __DNDPLUGIN_INTX11_H__ +#define VMTOOLS_USE_LEGACY_GTK + + #include #include + +#ifdef VMTOOLS_USE_LEGACY_GTK #include +#endif + #undef Bool #include "vm_basic_types.h" #include "dnd.h" diff --git a/open-vm-tools/services/plugins/dndcp/dndUIX11.cpp b/open-vm-tools/services/plugins/dndcp/dndUIX11.cpp index e9b435c3c..57bf7a3a2 100644 --- a/open-vm-tools/services/plugins/dndcp/dndUIX11.cpp +++ b/open-vm-tools/services/plugins/dndcp/dndUIX11.cpp @@ -26,7 +26,13 @@ #define G_LOG_DOMAIN "dndcp" +#define VMTOOLS_USE_LEGACY_GTK + + +#ifdef VMTOOLS_USE_LEGACY_GTK +/* TODO: support xutils with GTK4 */ #include "xutils/xutils.hh" +#endif #include "dndUIX11.h" #include "guestDnDCPMgr.hh" @@ -35,7 +41,10 @@ extern "C" { #include /* for XTest*() */ #include +#ifdef VMTOOLS_USE_LEGACY_GTK #include +#endif + #include #include "vmware/guestrpc/tclodefs.h" @@ -102,8 +111,10 @@ DnDUIX11::DnDUIX11(ToolsAppCtx *ctx) { TRACE_CALL(); +#ifdef VMTOOLS_USE_LEGACY_GTK xutils::Init(); xutils::workAreaChanged.connect(sigc::mem_fun(this, &DnDUIX11::OnWorkAreaChanged)); +#endif /* * XXX Hard coded use of default screen means this doesn't work in dual- @@ -2742,6 +2753,7 @@ DnDUIX11::OnWorkAreaChanged(Glib::RefPtr screen) // IN { TRACE_CALL(); +#ifdef VMTOOLS_USE_LEGACY_GTK std::vector values; if (xutils::GetCardinalList(screen->get_root_window(), "_NET_WORKAREA", values) && values.size() > 0 @@ -2762,6 +2774,7 @@ DnDUIX11::OnWorkAreaChanged(Glib::RefPtr screen) // IN mOrigin.set_x(0); mOrigin.set_y(0); } +#endif g_debug("%s: new origin at (%d, %d)\n", __FUNCTION__, mOrigin.get_x(), mOrigin.get_y());