1
/*********************************************************
2
* Copyright (C) 2009 VMware, Inc. All rights reserved.
4
* This program is free software; you can redistribute it and/or modify it
5
* under the terms of the GNU Lesser General Public License as published
6
* by the Free Software Foundation version 2.1 and no later version.
8
* This program is distributed in the hope that it will be useful, but
9
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
10
* or FITNESS FOR A PARTICULAR PURPOSE. See the Lesser GNU General Public
11
* License for more details.
13
* You should have received a copy of the GNU Lesser General Public License
14
* along with this program; if not, write to the Free Software Foundation, Inc.,
15
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
17
*********************************************************/
22
* Implement the methods that allow DnD between host and guest for
23
* protocols V3 or greater.
27
#ifndef __DND_UI_X11_H__
28
#define __DND_UI_X11_H__
30
#include "stringxx/string.hh"
38
#include "dndClipboard.h"
40
#include "../dnd/dndFileContentsUtil.h"
42
#include "cpNameUtil.h"
44
#include "vmware/tools/guestrpc.h"
45
#include "vmware/tools/plugin.h"
48
#include "guestDnD.hh"
49
#include "dndFileList.hh"
50
#include "dragDetWndX11.h"
52
struct DblLnkLst_Links;
55
* The DnDUI class implements the UI portion of DnD V3 and greater
56
* versions of the protocol.
59
: public sigc::trackable
62
DnDUIX11(ToolsAppCtx *ctx);
65
void VmxDnDVersionChanged(RpcChannel *chan, uint32 version);
66
void SetDnDAllowed(bool isDnDAllowed)
67
{ASSERT(m_DnD); m_DnD->SetDnDAllowed(isDnDAllowed);}
68
void SetBlockControl(DnDBlockControl *blockCtrl);
69
void SetUnityMode(Bool mode)
70
{m_unityMode = mode;};
72
DragDetWnd *GetFullDetWnd() {return m_detWnd;}
73
GtkWidget *GetDetWndAsWidget();
78
* Blocking FS Helper Functions.
83
bool TryXTestFakeDeviceButtonEvent(void);
86
* Callbacks from Common DnD layer.
89
void CommonUpdateMouseCB(int32 x, int32 y);
92
* Source functions for HG DnD.
94
void CommonDragStartCB(const CPClipboard *clip, std::string stagingDir);
95
void CommonSourceDropCB(void);
98
* Called when HG Dnd is completed.
100
void CommonSourceCancelCB(void);
103
* Called when GH DnD is completed.
105
void CommonDestPrivateDropCB(int32 x, int32 y);
106
void CommonDestCancelCB(void);
109
* Source functions for file transfer.
111
void CommonSourceFileCopyDoneCB(bool success);
114
* Callbacks for showing/hiding detection window.
116
void CommonUpdateDetWndCB(bool bShow, int32 x, int32 y);
117
void CommonUpdateUnityDetWndCB(bool bShow, uint32 unityWndId, bool bottom);
118
void CommonMoveDetWndToMousePos(void);
121
* Gtk+ Callbacks: Drag Destination.
123
void GtkDestDragDataReceivedCB(const Glib::RefPtr<Gdk::DragContext> &dc,
124
int x, int y, const Gtk::SelectionData &sd,
125
guint info, guint time);
126
bool GtkDestDragDropCB(const Glib::RefPtr<Gdk::DragContext> &dc,
127
int x, int y, guint time);
128
void GtkDestDragLeaveCB(const Glib::RefPtr<Gdk::DragContext> &dc,
130
bool GtkDestDragMotionCB(const Glib::RefPtr<Gdk::DragContext> &dc, int x,
134
* Gtk+ Callbacks: Drag Source.
136
void GtkSourceDragBeginCB(const Glib::RefPtr<Gdk::DragContext>& context);
137
void GtkSourceDragDataGetCB(const Glib::RefPtr<Gdk::DragContext>& context,
138
Gtk::SelectionData& selection_data, guint info,
140
void GtkSourceDragEndCB(const Glib::RefPtr<Gdk::DragContext>& context);
142
* Source functions for HG DnD. Makes calls to common layer.
144
void SourceDragStartDone(void);
145
void SourceUpdateFeedback(DND_DROPEFFECT effect);
148
* Target function for GH DnD. Makes call to common layer.
150
void TargetDragEnter(void);
153
* Other signal handlers for tracing.
156
bool GtkEnterEventCB(GdkEventCrossing *event);
157
bool GtkLeaveEventCB(GdkEventCrossing *event);
158
bool GtkMapEventCB(GdkEventAny *event);
159
bool GtkUnmapEventCB(GdkEventAny *event);
160
void GtkRealizeEventCB();
161
void GtkUnrealizeEventCB();
162
bool GtkMotionNotifyEventCB(GdkEventMotion *event);
163
bool GtkConfigureEventCB(GdkEventConfigure *event);
164
bool GtkButtonPressEventCB(GdkEventButton *event);
165
bool GtkButtonReleaseEventCB(GdkEventButton *event);
170
bool SetCPClipboardFromGtk(const Gtk::SelectionData& sd);
171
bool RequestData(const Glib::RefPtr<Gdk::DragContext> &dc,
173
std::string GetLastDirName(const std::string &str);
174
utf::utf8string GetNextPath(utf::utf8string &str, size_t& index);
175
DND_DROPEFFECT ToDropEffect(Gdk::DragAction action);
176
void SetTargetsAndCallbacks();
177
bool SendFakeXEvents(const bool showWidget, const bool buttonEvent,
178
const bool buttonPress, const bool moveWindow,
179
const bool coordsProvided,
180
const int xCoord, const int yCoord);
181
bool SendFakeMouseMove(const int x, const int y);
182
bool WriteFileContentsToStagingDir();
183
unsigned long GetTimeInMillis();
187
std::string m_HGStagingDir;
188
utf::string m_HGFileContentsUriList;
189
DragDetWnd *m_detWnd;
190
CPClipboard m_clipboard;
191
DnDBlockControl *m_blockCtrl;
192
bool m_HGGetDataInProgress;
196
/* State to determine if drag motion is a drag enter. */
197
bool m_GHDnDInProgress;
198
/* Icon updates from the guest. */
199
/* Only update mouse when we have clipboard contents from the host. */
200
bool m_GHDnDDataReceived;
201
bool m_GHDnDDropOccurred;
204
DND_DROPEFFECT m_effect;
205
bool m_fileTransferStarted;
208
GdkDragContext *m_dc;
209
int m_numPendingRequest;
210
unsigned long m_destDropTime;
213
#endif // __DND_UI_X11_H__