diff --git a/src/VBox/Additions/x11/vboxmouse/vboxmouse_15.c b/src/VBox/Additions/x11/vboxmouse/vboxmouse_15.c
index 3c9b0e9..f2c4340 100644
--- a/src/VBox/Additions/x11/vboxmouse/vboxmouse_15.c
+++ b/src/VBox/Additions/x11/vboxmouse/vboxmouse_15.c
@@ -59,6 +59,43 @@
 #include <errno.h>
 #include <fcntl.h>
 
+/* replacement for Xorg's xf86ScaleAxis which used to be broken and got the clamp on the
+   result backwards so all users of this function had to reverse minimum and maximum values.
+   It was only fixed before Xorg Server 1.6 but was also backported to 1.4 at least by
+   Debian so there is no safe way to know if the fixed version is in use or not. */
+static int
+VBoxScale(InputInfoPtr pInfo, int scaleval, int oMin, int oMax, int iMin, int iMax)
+{
+    int iDiff = iMax - iMin;
+    int oDiff = oMax - oMin;
+    
+    /* try to clamp on input already to avoid
+       incorrect results due to overflow */
+    if(scaleval > iMax)
+        return oMax;
+    
+    if(scaleval < iMin)
+        return oMin;
+
+    
+    if(iDiff) {
+        scaleval = (((scaleval - iMin) * oDiff) / iDiff) + oMin;
+    } else {
+        if (pInfo) {
+            xf86Msg(X_ERROR, "%s:division by zero scaling %d: %d %d on %d %d\n", pInfo->name, scaleval, iMin, iMax, oMin, oMax);
+        }
+        scaleval = 0;
+    }
+    
+    if(scaleval > oMax)
+        scaleval = oMax;
+    
+    if(scaleval < oMin)
+        scaleval = oMin;
+    
+    return scaleval;
+}
+
 static void
 VBoxReadInput(InputInfoPtr pInfo)
 {
@@ -72,15 +109,16 @@ VBoxReadInput(InputInfoPtr pInfo)
            miPointerGetScreen(pInfo->dev) != NULL
 #endif
         &&  RT_SUCCESS(VbglR3GetMouseStatus(&fFeatures, &cx, &cy))
-        && (fFeatures & VMMDEV_MOUSE_HOST_CAN_ABSOLUTE))
+        && (fFeatures & VMMDEV_MOUSE_HOST_CAN_ABSOLUTE)) {
 #if ABI_XINPUT_VERSION == SET_ABI_VERSION(2, 0)
-        /* Bug in the 1.4 X server series - conversion_proc was no longer
-         * called, but the server didn't yet do the conversion itself. */
-        cx = xf86ScaleAxis(cx, 0, screenInfo.screens[0]->width, 0, 65536);
-        cy = xf86ScaleAxis(cy, 0, screenInfo.screens[0]->height, 0, 65536);
+            /* Bug in the 1.4 X server series - conversion_proc was no longer
+             * called, but the server didn't yet do the conversion itself. */
+            cx = VBoxScale(pInfo, cx, 0, screenInfo.screens[0]->width, 0, 65536);
+            cy = VBoxScale(pInfo, cy, 0, screenInfo.screens[0]->height, 0, 65536);
 #endif
-        /* send absolute movement */
-        xf86PostMotionEvent(pInfo->dev, 1, 0, 2, cx, cy);
+            /* send absolute movement */
+            xf86PostMotionEvent(pInfo->dev, 1, 0, 2, cx, cy);
+        }
 }
 
 static void
@@ -229,8 +267,8 @@ VBoxConvert(InputInfoPtr pInfo, int first, int num, int v0, int v1, int v2,
             int v3, int v4, int v5, int *x, int *y)
 {
     if (first == 0) {
-        *x = xf86ScaleAxis(v0, 0, screenInfo.screens[0]->width, 0, 65536);
-        *y = xf86ScaleAxis(v1, 0, screenInfo.screens[0]->height, 0, 65536);
+        *x = VBoxScale(pInfo, v0, 0, screenInfo.screens[0]->width, 0, 65536);
+        *y = VBoxScale(pInfo, v1, 0, screenInfo.screens[0]->height, 0, 65536);
         return TRUE;
     } else
         return FALSE;
