#endif
}
-
-/*
- *----------------------------------------------------------------------------
- *
- * GuestApp_IsMouseAbsolute
- *
- * Are the host/guest capable of using absolute mouse mode?
- *
- * Results:
- * TRUE if host is in absolute mouse mode, FALSE otherwise.
- *
- * Side effects:
- * Issues Tools RPC.
- *
- *----------------------------------------------------------------------------
- */
-
-GuestAppAbsoluteMouseState
-GuestApp_GetAbsoluteMouseState(void)
-{
- Backdoor_proto bp;
- GuestAppAbsoluteMouseState state = GUESTAPP_ABSMOUSE_UNKNOWN;
-
- bp.in.cx.halfs.low = BDOOR_CMD_ISMOUSEABSOLUTE;
- Backdoor(&bp);
- if (bp.out.ax.word == 0) {
- state = GUESTAPP_ABSMOUSE_UNAVAILABLE;
- } else if (bp.out.ax.word == 1) {
- state = GUESTAPP_ABSMOUSE_AVAILABLE;
- }
-
- return state;
-}
-
-
-/*
- *-----------------------------------------------------------------------------
- *
- * GuestApp_GetPos --
- *
- * Retrieve the host notion of the guest pointer location. --hpreg
- *
- * Results:
- * '*x' and '*y' are the coordinates (top left corner is 0, 0) of the
- * host notion of the guest pointer location. (-100, -100) means that the
- * mouse is not grabbed on the host.
- *
- * Side effects:
- * None
- *
- *-----------------------------------------------------------------------------
- */
-
-void
-GuestApp_GetPos(int16 *x, // OUT
- int16 *y) // OUT
-{
- Backdoor_proto bp;
-
- bp.in.cx.halfs.low = BDOOR_CMD_GETPTRLOCATION;
- Backdoor(&bp);
- *x = bp.out.ax.word >> 16;
- *y = bp.out.ax.word;
-}
-
-
-/*
- *-----------------------------------------------------------------------------
- *
- * GuestApp_SetPos --
- *
- * Update the host notion of the guest pointer location. 'x' and 'y' are
- * the coordinates (top left corner is 0, 0). --hpreg
- *
- * Results:
- * None
- *
- * Side effects:
- * None
- *
- *-----------------------------------------------------------------------------
- */
-
-void
-GuestApp_SetPos(uint16 x, // IN
- uint16 y) // IN
-{
- Backdoor_proto bp;
-
- bp.in.cx.halfs.low = BDOOR_CMD_SETPTRLOCATION;
- bp.in.size = (x << 16) | y;
- Backdoor(&bp);
-}
-
-
-/*
- * XXX The 5 functions below should be re-implemented using the message layer,
- * to benefit from:
- * . The high-bandwidth backdoor or the generic "send 4 bytes at a time"
- * logic of the low-bandwidth backdoor
- * . The restore/resume detection logic
- * --hpreg
- */
-
-/*
- *-----------------------------------------------------------------------------
- *
- * GuestApp_GetHostSelectionLen --
- *
- * Retrieve the length of the clipboard (if any) to receive from the
- * VMX. --hpreg
- *
- * Results:
- * Length >= 0 if a clipboard must be retrieved from the host.
- * < 0 on error (VMWARE_DONT_EXCHANGE_SELECTIONS or
- * VMWARE_SELECTION_NOT_READY currently)
- *
- * Side effects:
- * None
- *
- *-----------------------------------------------------------------------------
- */
-
-int32
-GuestApp_GetHostSelectionLen(void)
-{
- Backdoor_proto bp;
-
- bp.in.cx.halfs.low = BDOOR_CMD_GETSELLENGTH;
- Backdoor(&bp);
- return bp.out.ax.word;
-}
-
-
-/*
- *-----------------------------------------------------------------------------
- *
- * GuestAppGetNextPiece --
- *
- * Retrieve the next 4 bytes of the host clipboard. --hpreg
- *
- * Results:
- * The next 4 bytes of the host clipboard.
- *
- * Side effects:
- * None
- *
- *-----------------------------------------------------------------------------
- */
-
-static uint32
-GuestAppGetNextPiece(void)
-{
- Backdoor_proto bp;
-
- bp.in.cx.halfs.low = BDOOR_CMD_GETNEXTPIECE;
- Backdoor(&bp);
- return bp.out.ax.word;
-}
-
-
-/*
- *-----------------------------------------------------------------------------
- *
- * GuestApp_GetHostSelection --
- *
- * Retrieve the host clipboard. 'data' must be a buffer whose size is at
- * least (('size' + 4 - 1) / 4) * 4 bytes. --hpreg
- *
- * Results:
- * The host clipboard in 'data'.
- *
- * Side effects:
- * None
- *
- *-----------------------------------------------------------------------------
- */
-
-void
-GuestApp_GetHostSelection(unsigned int size, // IN
- char *data) // OUT
-{
- uint32 *current;
- uint32 const *end;
-
- current = (uint32 *)data;
- end = current + (size + sizeof *current - 1) / sizeof *current;
- for (; current < end; current++) {
- *current = GuestAppGetNextPiece();
- }
-}
-
-
-/*
- *-----------------------------------------------------------------------------
- *
- * GuestApp_SetSelLength --
- *
- * Tell the VMX about the length of the clipboard we are about to send
- * to it. --hpreg
- *
- * Results:
- * None
- *
- * Side effects:
- * None
- *
- *-----------------------------------------------------------------------------
- */
-
-void
-GuestApp_SetSelLength(uint32 length) // IN
-{
- Backdoor_proto bp;
-
- bp.in.cx.halfs.low = BDOOR_CMD_SETSELLENGTH;
- bp.in.size = length;
- Backdoor(&bp);
-}
-
-
-/*
- *-----------------------------------------------------------------------------
- *
- * GuestApp_SetNextPiece --
- *
- * Send the next 4 bytes of the guest clipboard. --hpreg
- *
- * Results:
- * None
- *
- * Side effects:
- * None
- *
- *-----------------------------------------------------------------------------
- */
-
-void
-GuestApp_SetNextPiece(uint32 data) // IN
-{
- Backdoor_proto bp;
-
- bp.in.cx.halfs.low = BDOOR_CMD_SETNEXTPIECE;
- bp.in.size = data;
- Backdoor(&bp);
-}
-
char *
GuestApp_GetConfPath(void);
-void
-GuestApp_GetPos(int16 *x, // OUT
- int16 *y); // OUT
-
-void
-GuestApp_SetPos(uint16 x, // IN
- uint16 y); // IN
-
-int32
-GuestApp_GetHostSelectionLen(void);
-
-void
-GuestApp_GetHostSelection(unsigned int size, // IN
- char *data); // OUT
-
-void
-GuestApp_SetSelLength(uint32 length); // IN
-
-void
-GuestApp_SetNextPiece(uint32 data); // IN
-
-typedef enum {
- GUESTAPP_ABSMOUSE_UNAVAILABLE,
- GUESTAPP_ABSMOUSE_AVAILABLE,
- GUESTAPP_ABSMOUSE_UNKNOWN
-} GuestAppAbsoluteMouseState;
-
-GuestAppAbsoluteMouseState GuestApp_GetAbsoluteMouseState(void);
-
#ifdef __cplusplus
}
#endif
libdndcp_la_SOURCES += stringxx/string.cc
+libdndcp_la_SOURCES += copyPasteCompat.c
libdndcp_la_SOURCES += copyPasteCompatX11.c
libdndcp_la_SOURCES += copyPasteDnDWrapper.cpp
libdndcp_la_SOURCES += copyPasteDnDX11.cpp
--- /dev/null
+/*********************************************************
+ * Copyright (C) 2011 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
+ * by the Free Software Foundation version 2.1 and no later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the Lesser GNU General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ *********************************************************/
+
+/*
+ * copyPasteCompat.c --
+ *
+ * Legacy copy/paste functions.
+ */
+
+#include "backdoor.h"
+#include "backdoor_def.h"
+#include "copyPasteCompat.h"
+
+/*
+ *-----------------------------------------------------------------------------
+ *
+ * CopyPaste_GetHostSelectionLen --
+ *
+ * Retrieve the length of the clipboard (if any) to receive from the
+ * VMX.
+ *
+ * Results:
+ * Length >= 0 if a clipboard must be retrieved from the host.
+ * < 0 on error (VMWARE_DONT_EXCHANGE_SELECTIONS or
+ * VMWARE_SELECTION_NOT_READY currently)
+ *
+ * Side effects:
+ * None
+ *
+ *-----------------------------------------------------------------------------
+ */
+
+int32
+CopyPaste_GetHostSelectionLen(void)
+{
+ Backdoor_proto bp;
+
+ bp.in.cx.halfs.low = BDOOR_CMD_GETSELLENGTH;
+ Backdoor(&bp);
+ return bp.out.ax.word;
+}
+
+
+/*
+ *-----------------------------------------------------------------------------
+ *
+ * CopyPasteGetNextPiece --
+ *
+ * Retrieve the next 4 bytes of the host clipboard.
+ *
+ * Results:
+ * The next 4 bytes of the host clipboard.
+ *
+ * Side effects:
+ * None
+ *
+ *-----------------------------------------------------------------------------
+ */
+
+static uint32
+CopyPasteGetNextPiece(void)
+{
+ Backdoor_proto bp;
+
+ bp.in.cx.halfs.low = BDOOR_CMD_GETNEXTPIECE;
+ Backdoor(&bp);
+ return bp.out.ax.word;
+}
+
+
+/*
+ *-----------------------------------------------------------------------------
+ *
+ * CopyPaste_GetHostSelection --
+ *
+ * Retrieve the host clipboard. 'data' must be a buffer whose size is at
+ * least (('size' + 4 - 1) / 4) * 4 bytes.
+ *
+ * Results:
+ * The host clipboard in 'data'.
+ *
+ * Side effects:
+ * None
+ *
+ *-----------------------------------------------------------------------------
+ */
+
+void
+CopyPaste_GetHostSelection(unsigned int size, // IN
+ char *data) // OUT
+{
+ uint32 *current;
+ uint32 const *end;
+
+ current = (uint32 *)data;
+ end = current + (size + sizeof *current - 1) / sizeof *current;
+ for (; current < end; current++) {
+ *current = CopyPasteGetNextPiece();
+ }
+}
+
+
+/*
+ *-----------------------------------------------------------------------------
+ *
+ * CopyPaste_SetSelLength --
+ *
+ * Tell the VMX about the length of the clipboard we are about to send
+ * to it.
+ *
+ * Results:
+ * None
+ *
+ * Side effects:
+ * None
+ *
+ *-----------------------------------------------------------------------------
+ */
+
+void
+CopyPaste_SetSelLength(uint32 length) // IN
+{
+ Backdoor_proto bp;
+
+ bp.in.cx.halfs.low = BDOOR_CMD_SETSELLENGTH;
+ bp.in.size = length;
+ Backdoor(&bp);
+}
+
+
+/*
+ *-----------------------------------------------------------------------------
+ *
+ * CopyPaste_SetNextPiece --
+ *
+ * Send the next 4 bytes of the guest clipboard.
+ *
+ * Results:
+ * None
+ *
+ * Side effects:
+ * None
+ *
+ *-----------------------------------------------------------------------------
+ */
+
+void
+CopyPaste_SetNextPiece(uint32 data) // IN
+{
+ Backdoor_proto bp;
+
+ bp.in.cx.halfs.low = BDOOR_CMD_SETNEXTPIECE;
+ bp.in.size = data;
+ Backdoor(&bp);
+}
+
#if !defined _COPYPASTE_COMPAT_H
#define _COPYPASTE_COMPAT_H
+#include "vmware.h"
+
/* Functions to be compatible with old text copy/paste directly based on backdoor cmd. */
Bool CopyPaste_RequestSelection(void);
Bool CopyPaste_GetBackdoorSelections(void);
void CopyPaste_Init(void);
void CopyPaste_SetVersion(int version);
+int32
+CopyPaste_GetHostSelectionLen(void);
+
+void
+CopyPaste_GetHostSelection(unsigned int size, // IN
+ char *data); // OUT
+
+void
+CopyPaste_SetSelLength(uint32 length); // IN
+
+void
+CopyPaste_SetNextPiece(uint32 data); // IN
+
#endif
#include <errno.h>
#include "vm_assert.h"
+#include "copyPasteCompat.h"
#include "str.h"
#include "strutil.h"
-#include "guestApp.h"
#include "dnd.h"
#include "util.h"
#include "cpName.h"
* CopyPasteSetBackdoorSelections --
*
* Set the clipboard one of two ways, the old way or the new way.
- * The old way uses GuestApp_SetSel and there's only one selection.
+ * The old way uses CopyPaste_SetSelLength and there's only one selection.
* Set backdoor selection with either primary selection or clipboard.
* The primary selection is the first priority, then clipboard.
* If both unavailable, set backdoor selection length to be 0.
}
if (p == NULL) {
- GuestApp_SetSelLength(0);
+ CopyPaste_SetSelLength(0);
g_debug("CopyPasteSetBackdoorSelections Set empty text.\n");
} else {
len = strlen((char *)p);
/* Here long string should already be truncated. */
ASSERT(aligned_len <= MAX_SELECTION_BUFFER_LENGTH);
- GuestApp_SetSelLength(len);
+ CopyPaste_SetSelLength(len);
for (i = 0; i < len; i += 4, p++) {
- GuestApp_SetNextPiece(*p);
+ CopyPaste_SetNextPiece(*p);
}
}
}
* CopyPaste_GetBackdoorSelections --
*
* Get the clipboard "the old way".
- * The old way uses GuestApp_SetSel and there's only one selection.
- * We don't have to do anything for the "new way", since the host
- * will just push PRIMARY and/or CLIPBOARD when they are available
+ * The old way uses CopyPaste_GetHostSelectionLen and there's only one
+ * selection. We don't have to do anything for the "new way", since the
+ * host will just push PRIMARY and/or CLIPBOARD when they are available
* on the host.
*
* XXX: the "new way" isn't availble yet because the vmx doesn't
return TRUE;
}
- selLength = GuestApp_GetHostSelectionLen();
+ selLength = CopyPaste_GetHostSelectionLen();
if (selLength < 0 || selLength > MAX_SELECTION_BUFFER_LENGTH) {
return FALSE;
} else if (selLength > 0) {
- GuestApp_GetHostSelection(selLength, gHostClipboardBuf);
+ CopyPaste_GetHostSelection(selLength, gHostClipboardBuf);
gHostClipboardBuf[selLength] = 0;
g_debug("CopyPaste_GetBackdoorSelections Get text [%s].\n", gHostClipboardBuf);
gtk_selection_owner_set(gUserMainWidget,
#include "cpNameUtil.h"
#include "rpcout.h"
#include "vmware/guestrpc/tclodefs.h"
- #include "guestApp.h"
}
/*
#define __DNDPLUGIN_INT_H__
extern "C" {
- #include "guestApp.h"
#include "conf.h"
}
#include "vm_basic_types.h"
#include "dnd.h"
-#include "guestApp.h"
-
#define UNGRABBED_POS (-100)
extern Display *gXDisplay;
extern "C" {
#include "vm_assert.h"
- #include "guestApp.h"
#include "backdoor_def.h"
+ #include "backdoor.h"
#include "rpcvmx.h"
}
+
+typedef enum {
+ ABSMOUSE_UNAVAILABLE,
+ ABSMOUSE_AVAILABLE,
+ ABSMOUSE_UNKNOWN
+} AbsoluteMouseState;
+
+
static Bool mouseIsGrabbed;
-static GuestAppAbsoluteMouseState absoluteMouseState = GUESTAPP_ABSMOUSE_UNKNOWN;
+static AbsoluteMouseState absoluteMouseState = ABSMOUSE_UNKNOWN;
static uint8 gHostClipboardTries = 0;
#if defined(WIN32)
#define POINTER_UPDATE_TIMEOUT 100
+
+/*
+ *----------------------------------------------------------------------------
+ *
+ * PointerGetAbsoluteMouseState
+ *
+ * Are the host/guest capable of using absolute mouse mode?
+ *
+ * Results:
+ * TRUE if host is in absolute mouse mode, FALSE otherwise.
+ *
+ * Side effects:
+ * Issues Tools RPC.
+ *
+ *----------------------------------------------------------------------------
+ */
+
+static AbsoluteMouseState
+PointerGetAbsoluteMouseState(void)
+{
+ Backdoor_proto bp;
+ AbsoluteMouseState state = ABSMOUSE_UNKNOWN;
+
+ bp.in.cx.halfs.low = BDOOR_CMD_ISMOUSEABSOLUTE;
+ Backdoor(&bp);
+ if (bp.out.ax.word == 0) {
+ state = ABSMOUSE_UNAVAILABLE;
+ } else if (bp.out.ax.word == 1) {
+ state = ABSMOUSE_AVAILABLE;
+ }
+
+ return state;
+}
+
+
#if !defined(WIN32)
/*
*-----------------------------------------------------------------------------
#endif
+
+/*
+ *-----------------------------------------------------------------------------
+ *
+ * PointerGetPos --
+ *
+ * Retrieve the host notion of the guest pointer location.
+ *
+ * Results:
+ * '*x' and '*y' are the coordinates (top left corner is 0, 0) of the
+ * host notion of the guest pointer location. (-100, -100) means that the
+ * mouse is not grabbed on the host.
+ *
+ * Side effects:
+ * None
+ *
+ *-----------------------------------------------------------------------------
+ */
+
+static void
+PointerGetPos(int16 *x, // OUT
+ int16 *y) // OUT
+{
+ Backdoor_proto bp;
+
+ bp.in.cx.halfs.low = BDOOR_CMD_GETPTRLOCATION;
+ Backdoor(&bp);
+ *x = bp.out.ax.word >> 16;
+ *y = bp.out.ax.word;
+}
+
+
+/*
+ *-----------------------------------------------------------------------------
+ *
+ * PointerSetPos --
+ *
+ * Update the host notion of the guest pointer location. 'x' and 'y' are
+ * the coordinates (top left corner is 0, 0).
+ *
+ * Results:
+ * None
+ *
+ * Side effects:
+ * None
+ *
+ *-----------------------------------------------------------------------------
+ */
+
+static void
+PointerSetPos(uint16 x, // IN
+ uint16 y) // IN
+{
+ Backdoor_proto bp;
+
+ bp.in.cx.halfs.low = BDOOR_CMD_SETPTRLOCATION;
+ bp.in.size = (x << 16) | y;
+ Backdoor(&bp);
+}
+
+
/*
*-----------------------------------------------------------------------------
*
short hostPosX;
short hostPosY;
- GuestApp_GetPos(&hostPosX, &hostPosY);
+ PointerGetPos(&hostPosX, &hostPosY);
#if defined(WIN32)
SetCursorPos(hostPosX, hostPosY);
#else
int guestX, guestY;
#endif
- GuestApp_GetPos(&hostPosX, &hostPosY);
+ PointerGetPos(&hostPosX, &hostPosY);
if (mouseIsGrabbed) {
if (hostPosX == UNGRABBED_POS) {
/* We transitioned from grabbed to ungrabbed */
* where to position the outside pointer if the user releases the guest
* pointer via the key combination).
*/
- GuestApp_SetPos(guestPos.x, guestPos.y);
+ PointerSetPos(guestPos.x, guestPos.y);
}
}
#else
PointerGetXCursorPos(&guestX, &guestY);
if ( hostPosX != guestX || hostPosY != guestY) {
- GuestApp_SetPos(guestX, guestY);
+ PointerSetPos(guestX, guestY);
}
#endif
CopyPasteDnDWrapper *wrapper = CopyPasteDnDWrapper::GetInstance();
}
if (!CopyPaste_IsRpcCPSupported() ||
- (absoluteMouseState == GUESTAPP_ABSMOUSE_UNAVAILABLE)) {
+ (absoluteMouseState == ABSMOUSE_UNAVAILABLE)) {
GSource *src;
void
Pointer_Init(ToolsAppCtx *ctx)
{
- absoluteMouseState = GuestApp_GetAbsoluteMouseState();
+ absoluteMouseState = PointerGetAbsoluteMouseState();
PointerUpdatePointerLoop(NULL);
mouseIsGrabbed = FALSE;
}