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
|
b
|
|
| 59 | 59 | #include <errno.h> |
| 60 | 60 | #include <fcntl.h> |
| 61 | 61 | |
| | 62 | /* replacement for Xorg's xf86ScaleAxis which used to be broken and got the clamp on the |
| | 63 | result backwards so all users of this function had to reverse minimum and maximum values. |
| | 64 | It was only fixed before Xorg Server 1.6 but was also backported to 1.4 at least by |
| | 65 | Debian so there is no safe way to know if the fixed version is in use or not. */ |
| | 66 | static int |
| | 67 | VBoxScale(InputInfoPtr pInfo, int scaleval, int oMin, int oMax, int iMin, int iMax) |
| | 68 | { |
| | 69 | int iDiff = iMax - iMin; |
| | 70 | int oDiff = oMax - oMin; |
| | 71 | |
| | 72 | /* try to clamp on input already to avoid |
| | 73 | incorrect results due to overflow */ |
| | 74 | if(scaleval > iMax) |
| | 75 | return oMax; |
| | 76 | |
| | 77 | if(scaleval < iMin) |
| | 78 | return oMin; |
| | 79 | |
| | 80 | |
| | 81 | if(iDiff) { |
| | 82 | scaleval = (((scaleval - iMin) * oDiff) / iDiff) + oMin; |
| | 83 | } else { |
| | 84 | if (pInfo) { |
| | 85 | xf86Msg(X_ERROR, "%s:division by zero scaling %d: %d %d on %d %d\n", pInfo->name, scaleval, iMin, iMax, oMin, oMax); |
| | 86 | } |
| | 87 | scaleval = 0; |
| | 88 | } |
| | 89 | |
| | 90 | if(scaleval > oMax) |
| | 91 | scaleval = oMax; |
| | 92 | |
| | 93 | if(scaleval < oMin) |
| | 94 | scaleval = oMin; |
| | 95 | |
| | 96 | return scaleval; |
| | 97 | } |
| | 98 | |
| 62 | 99 | static void |
| 63 | 100 | VBoxReadInput(InputInfoPtr pInfo) |
| 64 | 101 | { |
| … |
… |
VBoxReadInput(InputInfoPtr pInfo)
|
| 72 | 109 | miPointerGetScreen(pInfo->dev) != NULL |
| 73 | 110 | #endif |
| 74 | 111 | && RT_SUCCESS(VbglR3GetMouseStatus(&fFeatures, &cx, &cy)) |
| 75 | | && (fFeatures & VMMDEV_MOUSE_HOST_CAN_ABSOLUTE)) |
| | 112 | && (fFeatures & VMMDEV_MOUSE_HOST_CAN_ABSOLUTE)) { |
| 76 | 113 | #if ABI_XINPUT_VERSION == SET_ABI_VERSION(2, 0) |
| 77 | | /* Bug in the 1.4 X server series - conversion_proc was no longer |
| 78 | | * called, but the server didn't yet do the conversion itself. */ |
| 79 | | cx = xf86ScaleAxis(cx, 0, screenInfo.screens[0]->width, 0, 65536); |
| 80 | | cy = xf86ScaleAxis(cy, 0, screenInfo.screens[0]->height, 0, 65536); |
| | 114 | /* Bug in the 1.4 X server series - conversion_proc was no longer |
| | 115 | * called, but the server didn't yet do the conversion itself. */ |
| | 116 | cx = VBoxScale(pInfo, cx, 0, screenInfo.screens[0]->width, 0, 65536); |
| | 117 | cy = VBoxScale(pInfo, cy, 0, screenInfo.screens[0]->height, 0, 65536); |
| 81 | 118 | #endif |
| 82 | | /* send absolute movement */ |
| 83 | | xf86PostMotionEvent(pInfo->dev, 1, 0, 2, cx, cy); |
| | 119 | /* send absolute movement */ |
| | 120 | xf86PostMotionEvent(pInfo->dev, 1, 0, 2, cx, cy); |
| | 121 | } |
| 84 | 122 | } |
| 85 | 123 | |
| 86 | 124 | static void |
| … |
… |
VBoxConvert(InputInfoPtr pInfo, int first, int num, int v0, int v1, int v2,
|
| 229 | 267 | int v3, int v4, int v5, int *x, int *y) |
| 230 | 268 | { |
| 231 | 269 | if (first == 0) { |
| 232 | | *x = xf86ScaleAxis(v0, 0, screenInfo.screens[0]->width, 0, 65536); |
| 233 | | *y = xf86ScaleAxis(v1, 0, screenInfo.screens[0]->height, 0, 65536); |
| | 270 | *x = VBoxScale(pInfo, v0, 0, screenInfo.screens[0]->width, 0, 65536); |
| | 271 | *y = VBoxScale(pInfo, v1, 0, screenInfo.screens[0]->height, 0, 65536); |
| 234 | 272 | return TRUE; |
| 235 | 273 | } else |
| 236 | 274 | return FALSE; |