Index: /trunk/include/VBox/VBoxGuestLib.h
===================================================================
--- /trunk/include/VBox/VBoxGuestLib.h	(revision 52955)
+++ /trunk/include/VBox/VBoxGuestLib.h	(revision 52956)
@@ -488,8 +488,17 @@
     "/VideoModeHint"
 
-VBGLR3DECL(int)     VbglR3GetDisplayChangeRequest(uint32_t *pcx, uint32_t *pcy, uint32_t *pcBits, uint32_t *piDisplay, bool fAck);
-VBGLR3DECL(int)     VbglR3GetDisplayChangeRequestEx(uint32_t *pcx, uint32_t *pcy, uint32_t *pcBits,
-                                                    uint32_t *piDisplay, uint32_t *pcOriginX, uint32_t *pcOriginY,
-                                                    bool *pfEnabled, bool fAck);
+/** The folder for saving video mode hints to between sessions. */
+#define VBGLR3HOSTDISPSAVEDMODEPATH "/var/lib/VBoxGuestAdditions"
+/** The path to the file for saving video mode hints to between sessions. */
+#define VBGLR3HOSTDISPSAVEDMODE     VBGLR3HOSTDISPSAVEDMODEPATH \
+    "/SavedVideoModes"
+
+VBGLR3DECL(int)     VbglR3GetDisplayChangeRequest(uint32_t *pcx, uint32_t *pcy,
+                                                  uint32_t *pcBits,
+                                                  uint32_t *piDisplay,
+                                                  uint32_t *pdx, uint32_t *pdy,
+                                                  bool *pfEnabled,
+                                                  bool *pfChangeOrigin,
+                                                  bool fAck);
 VBGLR3DECL(bool)    VbglR3HostLikesVideoMode(uint32_t cx, uint32_t cy, uint32_t cBits);
 VBGLR3DECL(int)     VbglR3VideoModeGetHighestSavedScreen(unsigned *pcScreen);
Index: /trunk/src/VBox/Additions/common/VBoxGuestLib/VBoxGuestR3LibVideo.cpp
===================================================================
--- /trunk/src/VBox/Additions/common/VBoxGuestLib/VBoxGuestR3LibVideo.cpp	(revision 52955)
+++ /trunk/src/VBox/Additions/common/VBoxGuestLib/VBoxGuestR3LibVideo.cpp	(revision 52956)
@@ -140,67 +140,4 @@
     if (RT_SUCCESS(rc))
         rc = pReq->header.rc;
-    return rc;
-}
-/**
- * Query the last display change request sent from the host to the guest.
- *
- * @returns iprt status value
- * @param   pcx         Where to store the horizontal pixel resolution
- *                      requested (a value of zero means do not change).
- * @param   pcy         Where to store the vertical pixel resolution
- *                      requested (a value of zero means do not change).
- * @param   pcBits      Where to store the bits per pixel requested (a value
- *                      of zero means do not change).
- * @param   iDisplay    Where to store the display number the request was for
- *                      - 0 for the primary display, 1 for the first
- *                      secondary display, etc.
- * @param   fAck        whether or not to acknowledge the newest request sent by
- *                      the host.  If this is set, the function will return the
- *                      most recent host request, otherwise it will return the
- *                      last request to be acknowledged.
- *
- * @param   pcOriginX   New horizontal position of the secondary monitor.
- * @param   pcOriginY   New vertical position of the secondary monitor.
- * param    pfEnabled   Secondary monitor is enabled or not.
- *
- */
-VBGLR3DECL(int) VbglR3GetDisplayChangeRequestEx(uint32_t *pcx, uint32_t *pcy, uint32_t *pcBits,
-                                                uint32_t *piDisplay, uint32_t *pcOriginX, uint32_t *pcOriginY,
-                                                bool *pfEnabled, bool fAck)
-{
-    VMMDevDisplayChangeRequestEx Req;
-    int rc = VINF_SUCCESS;
-    AssertPtrReturn(pcx, VERR_INVALID_PARAMETER);
-    AssertPtrReturn(pcy, VERR_INVALID_PARAMETER);
-    AssertPtrReturn(pcBits, VERR_INVALID_PARAMETER);
-    AssertPtrReturn(pcOriginX, VERR_INVALID_PARAMETER);
-    AssertPtrReturn(pcOriginY, VERR_INVALID_PARAMETER);
-    AssertPtrReturn(piDisplay, VERR_INVALID_PARAMETER);
-    AssertPtrReturn(pfEnabled, VERR_INVALID_PARAMETER);
-    RT_ZERO(Req);
-    rc = vmmdevInitRequest(&Req.header, VMMDevReq_GetDisplayChangeRequestEx);
-    if (RT_FAILURE(rc))
-    {
-        LogRelFlowFunc(("DisplayChangeRequest Extended not supported. Can't Init the Req.\n"));
-        return rc;
-    }
-
-    if (fAck)
-        Req.eventAck = VMMDEV_EVENT_DISPLAY_CHANGE_REQUEST;
-    rc = vbglR3GRPerform(&Req.header);
-    if (RT_SUCCESS(rc))
-        rc = Req.header.rc;
-    if (RT_SUCCESS(rc))
-    {
-        *pcx = Req.xres;
-        *pcy = Req.yres;
-        *pcBits = Req.bpp;
-        *piDisplay = Req.display;
-        *pcOriginX = Req.cxOrigin;
-        *pcOriginY = Req.cyOrigin;
-        *pfEnabled = Req.fEnabled;
-        LogRel(("VbglR3GetDisplayChangeRequestEx: pcx=%d pcy=%d display=%d orgX=%d orgY=%d and Enabled=%d\n",
-                 *pcx, *pcy, *piDisplay, *pcOriginX, *pcOriginY, *pfEnabled));
-    }
     return rc;
 }
@@ -225,5 +162,7 @@
  *
  */
-VBGLR3DECL(int) VbglR3GetDisplayChangeRequest(uint32_t *pcx, uint32_t *pcy, uint32_t *pcBits, uint32_t *piDisplay, bool fAck)
+static int getDisplayChangeRequest2(uint32_t *pcx, uint32_t *pcy,
+                                    uint32_t *pcBits, uint32_t *piDisplay,
+                                    bool fAck)
 {
     VMMDevDisplayChangeRequest2 Req;
@@ -246,4 +185,88 @@
         *pcBits = Req.bpp;
         *piDisplay = Req.display;
+    }
+    return rc;
+}
+
+
+/**
+ * Query the last display change request sent from the host to the guest.
+ *
+ * @returns iprt status value
+ * @param   pcx         Where to store the horizontal pixel resolution
+ *                      requested (a value of zero means do not change).
+ * @param   pcy         Where to store the vertical pixel resolution
+ *                      requested (a value of zero means do not change).
+ * @param   pcBits      Where to store the bits per pixel requested (a value
+ *                      of zero means do not change).
+ * @param   piDisplay   Where to store the display number the request was for
+ *                      - 0 for the primary display, 1 for the first
+ *                      secondary display, etc.
+ * @param   fAck        whether or not to acknowledge the newest request sent by
+ *                      the host.  If this is set, the function will return the
+ *                      most recent host request, otherwise it will return the
+ *                      last request to be acknowledged.
+ *
+ * @param   pdx         New horizontal position of the secondary monitor.
+ *                      Optional.
+ * @param   pdy         New vertical position of the secondary monitor.
+ *                      Optional.
+ * param    pfEnabled   Secondary monitor is enabled or not.
+ *                      Optional.
+ * param    pfChangeOrigin  Whether the mode hint retrieved included information
+ *                      about origin/display offset inside the frame-buffer.
+ *                      Optional.
+ *
+ */
+VBGLR3DECL(int) VbglR3GetDisplayChangeRequest(uint32_t *pcx, uint32_t *pcy,
+                                              uint32_t *pcBits,
+                                              uint32_t *piDisplay,
+                                              uint32_t *pdx, uint32_t *pdy,
+                                              bool *pfEnabled,
+                                              bool *pfChangeOrigin,
+                                              bool fAck)
+{
+    VMMDevDisplayChangeRequestEx Req;
+    int rc = VINF_SUCCESS;
+    AssertPtrReturn(pcx, VERR_INVALID_PARAMETER);
+    AssertPtrReturn(pcy, VERR_INVALID_PARAMETER);
+    AssertPtrReturn(pcBits, VERR_INVALID_PARAMETER);
+    AssertPtrNullReturn(pdx, VERR_INVALID_PARAMETER);
+    AssertPtrNullReturn(pdy, VERR_INVALID_PARAMETER);
+    AssertPtrReturn(piDisplay, VERR_INVALID_PARAMETER);
+    AssertPtrNullReturn(pfEnabled, VERR_INVALID_PARAMETER);
+    AssertPtrNullReturn(pfChangeOrigin, VERR_INVALID_PARAMETER);
+    RT_ZERO(Req);
+    rc = vmmdevInitRequest(&Req.header, VMMDevReq_GetDisplayChangeRequestEx);
+    AssertRCReturn(rc, rc);
+    if (fAck)
+        Req.eventAck = VMMDEV_EVENT_DISPLAY_CHANGE_REQUEST;
+    rc = vbglR3GRPerform(&Req.header);
+    if (RT_SUCCESS(rc))
+        rc = Req.header.rc;
+    if (RT_SUCCESS(rc))
+    {
+        *pcx = Req.xres;
+        *pcy = Req.yres;
+        *pcBits = Req.bpp;
+        *piDisplay = Req.display;
+        if (pdx)
+            *pdx = Req.cxOrigin;
+        if (pdy)
+            *pdy = Req.cyOrigin;
+        if (pfEnabled)
+            *pfEnabled = Req.fEnabled;
+        if (pfChangeOrigin)
+            *pfChangeOrigin = Req.fChangeOrigin;
+    }
+    /* NEEDS TESTING: test below with current Additions on VBox 4.1 or older. */
+    /** @todo Can we find some standard grep-able string for "NEEDS TESTING"? */
+    if (rc == VERR_NOT_IMPLEMENTED)  /* Fall back to the old API. */
+    {
+        if (pfEnabled)
+            *pfEnabled = true;
+        if (pfChangeOrigin)
+            *pfChangeOrigin = false;
+        return getDisplayChangeRequest2(pcx, pcy, pcBits, piDisplay, fAck);
     }
     return rc;
Index: /trunk/src/VBox/Additions/haiku/VBoxTray/VBoxDisplay.cpp
===================================================================
--- /trunk/src/VBox/Additions/haiku/VBoxTray/VBoxDisplay.cpp	(revision 52955)
+++ /trunk/src/VBox/Additions/haiku/VBoxTray/VBoxDisplay.cpp	(revision 52956)
@@ -130,5 +130,5 @@
         {
             uint32_t cx, cy, cBits, iDisplay;
-            int rc2 = VbglR3GetDisplayChangeRequest(&cx, &cy, &cBits, &iDisplay, true);
+            int rc2 = VbglR3GetDisplayChangeRequest(&cx, &cy, &cBits, &iDisplay, NULL, NULL, NULL, NULL, true);
             LogFlow(("rc2=%d screen %d size changed (%d, %d, %d)\n", rc2, iDisplay, cx, cy, cBits));
 
Index: /trunk/src/VBox/Additions/x11/VBoxClient/display.cpp
===================================================================
--- /trunk/src/VBox/Additions/x11/VBoxClient/display.cpp	(revision 52955)
+++ /trunk/src/VBox/Additions/x11/VBoxClient/display.cpp	(revision 52956)
@@ -118,5 +118,5 @@
 static void setModeX11(struct x11State *pState, unsigned cx, unsigned cy,
                        unsigned cBPP, unsigned iDisplay, unsigned x,
-                       unsigned y, bool fEnabled, bool fSetPosition)
+                       unsigned y, bool fEnabled, bool fChangeOrigin)
 {
     char szCommand[256];
@@ -135,5 +135,5 @@
         pState->cSizeHints = iDisplay + 1;
     }
-    if ((!fSetPosition || fEnabled) && cx != 0 && cy != 0)
+    if ((!fChangeOrigin || fEnabled) && cx != 0 && cy != 0)
     {
         pState->paSizeHints[iDisplay] = (cx & 0xffff) << 16 | (cy & 0xffff);
@@ -155,5 +155,5 @@
     else
     {
-        if (fSetPosition && fEnabled)
+        if (fChangeOrigin && fEnabled)
         {
             /* Extended Display support possible . Secondary monitor
@@ -166,5 +166,5 @@
                 VBClFatalError(("Failed to execute \\\"%s\\\".\n", szCommand));
         }
-        if ((!fSetPosition || fEnabled) && cx != 0 && cy != 0)
+        if ((!fChangeOrigin || fEnabled) && cx != 0 && cy != 0)
         {
             RTStrPrintf(szCommand, sizeof(szCommand),
@@ -252,23 +252,14 @@
         {
             uint32_t cx = 0, cy = 0, cBPP = 0, iDisplay = 0, x = 0, y = 0;
-            bool fEnabled = true, fSetPosition = true;
+            bool fEnabled = true, fChangeOrigin = true;
             VMMDevSeamlessMode Mode;
 
-            rc = VbglR3GetDisplayChangeRequestEx(&cx, &cy, &cBPP, &iDisplay,
-                                                 &x, &y, &fEnabled,
-                                                 true);
+            rc = VbglR3GetDisplayChangeRequest(&cx, &cy, &cBPP, &iDisplay,
+                                               &x, &y, &fEnabled,
+                                               &fChangeOrigin, true);
             /* Extended display version not supported on host */
             if (RT_FAILURE(rc))
-            {
-                if (rc != VERR_NOT_IMPLEMENTED)
-                    VBClFatalError(("Failed to get display change request, rc=%Rrc\n",
+                VBClFatalError(("Failed to get display change request, rc=%Rrc\n",
                                 rc));
-                fSetPosition = false;
-                rc = VbglR3GetDisplayChangeRequest(&cx, &cy, &cBPP,
-                                                   &iDisplay, true);
-                if (RT_SUCCESS(rc))
-                    LogRelFlowFunc(("Got size hint from host cx=%d, cy=%d, bpp=%d, iDisplay=%d\n",
-                                    cx, cy, cBPP, iDisplay));
-            }
             else
                 LogRelFlowFunc(("Got extended size hint from host cx=%d, cy=%d, bpp=%d, iDisplay=%d, x=%d, y=%d fEnabled=%d\n",
@@ -293,5 +284,5 @@
             }
             setModeX11(pState, cx, cy, cBPP, iDisplay, x, y, fEnabled,
-                       fSetPosition);
+                       fChangeOrigin);
         }
     }
