]> git.ipfire.org Git - thirdparty/open-vm-tools.git/commitdiff
Internal branch sync. Included in this change:
authorVMware, Inc <>
Mon, 22 Mar 2010 22:11:21 +0000 (15:11 -0700)
committerMarcelo Vanzin <mvanzin@vmware.com>
Mon, 22 Mar 2010 22:11:21 +0000 (15:11 -0700)
. Allow the host to configure unity behaviour in the guest.

. Avoid warnings when compiling with gcc 4.2.

Signed-off-by: Marcelo Vanzin <mvanzin@vmware.com>
open-vm-tools/lib/guestRpc/unity.x
open-vm-tools/lib/include/unityCommon.h
open-vm-tools/lib/unity/unity.c
open-vm-tools/services/plugins/guestInfo/guestInfoServer.c

index 95ee19c298b1b6cbfe4c0a09257f4ac4f190e361..5d35e63023c7060300888cc1c018beb730356d47 100644 (file)
@@ -29,8 +29,8 @@
 /*
  * Enumerates the different versions of the messages.
  */
-enum UnityEnterVersion {
-  UNITY_ENTER_V1 = 1
+enum UnityOptionsVersion {
+  UNITY_OPTIONS_V1 = 1
 };
 
 /*
@@ -38,18 +38,20 @@ enum UnityEnterVersion {
  * Unity mode. By default all these features are disabled.
  */
 enum UnityFeatures {
-   UNITY_ADD_HIDDEN_WINDOWS_TO_TRACKER = 1
+   UNITY_ADD_HIDDEN_WINDOWS_TO_TRACKER = 1,
+   UNITY_INTERLOCK_MINIMIZE_OPERATION = 2,
+   UNITY_SEND_WINDOW_CONTENTS = 4
 };
 
 /*
  * The structure used for version 1 of the message.
  */
-struct UnityEnterV1 {
+struct UnityOptionsV1 {
   int featureMask;
 };
 
 /*
- * This defines the protocol for a 'unityEnter' message.
+ * This defines the protocol for a 'unityOptions' message.
  *
  * The union allows us to introduce new versions of the protocol later by
  * creating new values in the enumeration, without having to change much of
@@ -58,9 +60,9 @@ struct UnityEnterV1 {
  * Since the union doesn't have a default case, de-serialization will fail if
  * an unknown version is provided on the wire.
  */
-union UnityEnter switch (UnityEnterVersion ver) {
-case UNITY_ENTER_V1:
-   struct UnityEnterV1 *unityEnterV1;
+union UnityOptions switch (UnityOptionsVersion ver) {
+case UNITY_OPTIONS_V1:
+   struct UnityOptionsV1 *unityOptionsV1;
 };
 
 
index 49117fe7bbd43beca83bf9768847a72973935017..a3084855063cc02f7fea3a92c4af78404a4e8f41 100644 (file)
 #define UNITY_RPC_DESKTOP_CONFIG_SET      "unity.desktop.config.set"
 #define UNITY_RPC_DESKTOP_ACTIVE_SET      "unity.desktop.active.set"
 #define UNITY_RPC_WINDOW_DESKTOP_SET      "unity.window.desktop.set"
+#define UNITY_RPC_SET_OPTIONS             "unity.set.options"
 #define UNITY_RPC_WINDOW_STICK            "unity.window.stick"
 #define UNITY_RPC_WINDOW_UNSTICK          "unity.window.unstick"
 #define UNITY_RPC_WINDOW_CONTENTS_REQUEST "unity.window.contents.request"
@@ -756,6 +757,14 @@ desktop where the upper right <tt>{1,2}</tt> is the currently active desktop.
    @param[in] offset Offset into desktop configuration, as defined by
                      @ref UNITY_RPC_DESKTOP_CONFIG_SET, 0 or greater.
 
+   @def         UNITY_RPC_SET_OPTIONS
+   @brief       Set optional behaviour for unity mode in the guest.
+   @code
+   UNITY_RPC_SET_OPTIONS
+   @endcode
+   @param[in]   XDR encoded options mask.
+   @note        This must be called before entering Unity mode - setting the options
+                after Unity mode has begun will result in undefined behaviour.
 
    @def         UNITY_RPC_WINDOW_STICK
    @brief       "Stick" a window to the screen.
index 15fe3835c7703474295f6adca68c2b48418f0540..21192b7ed21930abe62a6462e8afad02a72d5df8 100644 (file)
@@ -52,6 +52,7 @@
 #include "dynxdr.h"
 #include "guestrpc/unity.h"
 #include "guestrpc/unityActive.h"
+#include "guestrpc/unity.h"
 #include "appUtil.h"
 #include "xdrutil.h"
 #include <stdio.h>
@@ -64,6 +65,7 @@ typedef struct UnityState {
    UnityWindowTracker tracker;
    Bool forceEnable;
    Bool isEnabled;
+   uint32 currentOptions;                       // Last feature mask received via 'set.options'
    UnityVirtualDesktopArray virtDesktopArray;   // Virtual desktop configuration
    UnityUpdateChannel updateChannel;            // Unity update transmission channel.
    UnityPlatform *up; // Platform-specific state
@@ -152,6 +154,15 @@ static Bool UnityTcloSetWindowDesktop(char const **result,
                                       size_t argsSize,
                                       void *clientData);
 
+static void UnitySetAddHiddenWindows(Bool enabled);
+static void UnitySetInterlockMinimizeOperation(Bool enabled);
+static void UnitySetSendWindowContents(Bool enabled);
+
+/*
+ * Wrapper function for the "unity.set.options" RPC.
+ */
+static Bool UnityTcloSetUnityOptions(RpcInData *data);
+
 /*
  * Wrapper function for the "unity.window.contents.request" RPC.
  */
@@ -209,6 +220,23 @@ static UnityCommandElem unityCommandTable[] = {
    { NULL, NULL }
 };
 
+typedef struct {
+   uint32 featureBit;
+   void (*setter)(Bool enabled);
+} UnityFeatureSetter;
+
+/*
+ * Dispatch table for each unity option and a specific function to handle enabling
+ * or disabling the option. The function is called with an enable (TRUE) bool value.
+ */
+static UnityFeatureSetter unityFeatureTable[] = {
+   { UNITY_ADD_HIDDEN_WINDOWS_TO_TRACKER, UnitySetAddHiddenWindows },
+   { UNITY_INTERLOCK_MINIMIZE_OPERATION, UnitySetInterlockMinimizeOperation },
+   { UNITY_SEND_WINDOW_CONTENTS, UnitySetSendWindowContents },
+   /* Add more Unity Feature Setters above this. */
+   {0, NULL}
+};
+
 /*
  * XXX:
  * According to Adar:
@@ -455,6 +483,9 @@ Unity_InitBackdoor(struct RpcIn *rpcIn)   // IN
       RpcIn_RegisterCallback(rpcIn, UNITY_RPC_WINDOW_DESKTOP_SET,
                              UnityTcloSetWindowDesktop, NULL);
 
+      RpcIn_RegisterCallbackEx(rpcIn, UNITY_RPC_SET_OPTIONS,
+                               UnityTcloSetUnityOptions, NULL);
+
       RpcIn_RegisterCallbackEx(rpcIn, UNITY_RPC_WINDOW_CONTENTS_REQUEST,
                                UnityTcloRequestWindowContents, NULL);
 
@@ -2018,6 +2049,84 @@ error:
 }
 
 
+/*
+ *----------------------------------------------------------------------------
+ *
+ * UnityTcloSetUnityOptions --
+ *
+ *     Set the Unity options - must be be called before entering Unity mode.
+ *
+ * Results:
+ *     TRUE if RPC was succesfully handled.
+ *     FALSE otherwise.
+ *
+ * Side effects:
+ *     None.
+ *
+ *----------------------------------------------------------------------------
+ */
+
+Bool
+UnityTcloSetUnityOptions(RpcInData *data)
+{
+   Bool ret = TRUE;
+   UnityOptions optionsMsg;
+   int featureIndex = 0;
+   uint32 featuresChanged;
+
+   memset(&optionsMsg, 0, sizeof optionsMsg);
+
+   /* Check our arguments. */
+   ASSERT(data);
+   ASSERT(data->name);
+   ASSERT(data->args);
+
+   if (!(data && data->name && data->args)) {
+      Debug("%s: Invalid arguments.\n", __FUNCTION__);
+      ret = RPCIN_SETRETVALS(data, "Invalid arguments.", FALSE);
+      goto exit;
+   }
+
+   Debug("%s: Got RPC, name: \"%s\", argument length: %"FMTSZ"u.\n",
+         __FUNCTION__, data->name, data->argsSize);
+
+   /*
+    * Deserialize the XDR data. Note that the data begins with args + 1 since
+    * there is a space between the RPC name and the XDR serialization.
+    */
+   if (!XdrUtil_Deserialize((char *)data->args + 1, data->argsSize - 1,
+                            xdr_UnityOptions, &optionsMsg)) {
+      Debug("%s: Failed to deserialize data\n", __FUNCTION__);
+      ret = RPCIN_SETRETVALS(data, "Failed to deserialize data.", FALSE);
+      goto exit;
+   }
+
+   /*
+    * For each potential feature bit XOR the current mask with the newly
+    * specified set, then if the bit has changed call the specific setter
+    * function with TRUE/FALSE according to the new state of the bit.
+    */
+   featuresChanged = optionsMsg.UnityOptions_u.unityOptionsV1->featureMask ^
+                     unity.currentOptions;
+   while (unityFeatureTable[featureIndex].featureBit != 0) {
+      if (featuresChanged & unityFeatureTable[featureIndex].featureBit) {
+         unityFeatureTable[featureIndex].setter(
+            optionsMsg.UnityOptions_u.unityOptionsV1->featureMask &
+            unityFeatureTable[featureIndex].featureBit);
+      }
+      featureIndex++;
+   }
+
+   ret = RPCIN_SETRETVALS(data,
+                          "",
+                          TRUE);
+exit:
+   VMX_XDR_FREE(xdr_UnityOptions, &optionsMsg);
+
+   return ret;
+}
+
+
 /*
  *----------------------------------------------------------------------------
  *
@@ -2094,6 +2203,7 @@ exit:
    return ret;
 }
 
+
 /*
  *----------------------------------------------------------------------------
  *
@@ -2152,7 +2262,7 @@ out:
 
 
 /*
- *------------------------------------------------------------------------------
+ *----------------------------------------------------------------------------
  *
  * UnitySendWindowContents --
  *
@@ -2233,6 +2343,109 @@ exit:
 }
 
 
+/*
+ *----------------------------------------------------------------------------
+ *
+ * UnitySetAddHiddenWindows --
+ *
+ *     Set (or unset) whether hidden windows should be added to the tracker.
+ *
+ * Results:
+ *     None.
+ *
+ * Side effects:
+ *     None.
+ *
+ *----------------------------------------------------------------------------
+ */
+
+void
+UnitySetAddHiddenWindows(Bool enabled)
+{
+   /*
+    * Should we add hidden windows to the tracker (the host will use the trackers
+    * attribute field to display hidden windows in the appropriate manner.)
+    */
+   if (enabled) {
+      Debug("%s: Adding hidden windows to tracker\n", __FUNCTION__);
+   } else {
+      Debug("%s: Do not add hidden windows to tracker\n", __FUNCTION__);
+   }
+}
+
+
+/*
+ *----------------------------------------------------------------------------
+ *
+ * UnitySetInterlockMinimizeOperation --
+ *
+ *     Set (or unset) whether window operations should be denied/delayed and
+ *     relayed to the host for later confirmation.
+ *
+ * Results:
+ *     None.
+ *
+ * Side effects:
+ *     None.
+ *
+ *----------------------------------------------------------------------------
+ */
+
+void
+UnitySetInterlockMinimizeOperation(Bool enabled)
+{
+   /*
+    * Should we interlock operations through the host. For example: instead of
+    * allowing minimize to occur immediately in the guest should we prevent the
+    * minimize of a window in the guest, then relay the minimize to the host and wait
+    * for the hosts confirmation before actually minimizing the window in the guest.
+    */
+   if (enabled) {
+      Debug("%s: Interlocking minimize operations through the host\n",
+            __FUNCTION__);
+   } else {
+      Debug("%s: Do not interlock minimize operations through the host\n",
+            __FUNCTION__);
+   }
+}
+
+
+/*
+ *----------------------------------------------------------------------------
+ *
+ * UnitySetSendWindowContents --
+ *
+ *     Set (or unset) whether window contents should be sent to the host.
+ *
+ * Results:
+ *     None.
+ *
+ * Side effects:
+ *     None.
+ *
+ *----------------------------------------------------------------------------
+ */
+
+void
+UnitySetSendWindowContents(Bool enabled)
+{
+   /*
+    * Is the host prepared to receive scraped window contents at any time - even though
+    * it may not have previously requested the window contents. Explicit requests from
+    * the host will always be honored - this flag determines whether the guest will send
+    * the window contents directly after a qualifying operation (like changes in the
+    * z-order of a window).
+    */
+   if (enabled) {
+      Debug("%s: Sending window contents to the host on appropriate events\n",
+            __FUNCTION__);
+   } else {
+      Debug("%s: Do not send window contents to the host on appropriate events\n",
+            __FUNCTION__);
+   }
+}
+
+
 /*
  *------------------------------------------------------------------------------
  *
index 2bfa8a18dc180c06152afe3a3e3ae553c93a1920..e402b1dd5c2489464a41c06aa8c24ee65212374c 100644 (file)
@@ -1045,14 +1045,14 @@ NicInfoV3ToV2(const NicInfoV3 *infoV3)
 
    nicList = Util_SafeCalloc(sizeof *nicList, 1);
 
-   XDRUTIL_ARRAYAPPEND(nicList, nics, infoV3->nics.nics_len);
+   (void)XDRUTIL_ARRAYAPPEND(nicList, nics, infoV3->nics.nics_len);
    XDRUTIL_FOREACH(i, infoV3, nics) {
       GuestNicV3 *nic = XDRUTIL_GETITEM(infoV3, nics, i);
       GuestNic *oldNic = XDRUTIL_GETITEM(nicList, nics, i);
 
       Str_Strcpy(oldNic->macAddress, nic->macAddress, sizeof oldNic->macAddress);
 
-      XDRUTIL_ARRAYAPPEND(oldNic, ips, nic->ips.ips_len);
+      (void)XDRUTIL_ARRAYAPPEND(oldNic, ips, nic->ips.ips_len);
 
       XDRUTIL_FOREACH(j, nic, ips) {
          IpAddressEntry *ipEntry = XDRUTIL_GETITEM(nic, ips, j);