diff --git a/hw/xwin/winmouse.c b/hw/xwin/winmouse.c index 9d896c90e..da067cde0 100644 --- a/hw/xwin/winmouse.c +++ b/hw/xwin/winmouse.c @@ -65,10 +65,10 @@ int winMouseProc(DeviceIntPtr pDeviceInt, int iState) { int lngMouseButtons, i; - int lngWheelEvents = 2; + int lngWheelEvents = 4; CARD8 *map; DevicePtr pDevice = (DevicePtr) pDeviceInt; - Atom *btn_labels; + Atom btn_labels[9]; Atom axes_labels[2]; switch (iState) { @@ -80,15 +80,23 @@ winMouseProc(DeviceIntPtr pDeviceInt, int iState) /* Mapping of windows events to X events: * LEFT:1 MIDDLE:2 RIGHT:3 * SCROLL_UP:4 SCROLL_DOWN:5 - * XBUTTON 1:6 XBUTTON 2:7 ... + * TILT_LEFT:6 TILT_RIGHT:7 + * XBUTTON 1:8 XBUTTON 2:9 (most commonly 'back' and 'forward') + * ... * + * The current Windows API only defines 2 extra buttons, so we don't + * expect more than 5 buttons to be reported, but more than that + * should be handled correctly + */ + + /* * To map scroll wheel correctly we need at least the 3 normal buttons */ if (lngMouseButtons < 3) lngMouseButtons = 3; - /* allocate memory: - * number of buttons + 2x mouse wheel event + 1 extra (offset for map) + /* allocate memory: + * number of buttons + 4 x mouse wheel event + 1 extra (offset for map) */ map = malloc(sizeof(CARD8) * (lngMouseButtons + lngWheelEvents + 1)); @@ -97,12 +105,15 @@ winMouseProc(DeviceIntPtr pDeviceInt, int iState) for (i = 1; i <= lngMouseButtons + lngWheelEvents; i++) map[i] = i; - btn_labels = calloc((lngMouseButtons + lngWheelEvents), sizeof(Atom)); btn_labels[0] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_LEFT); btn_labels[1] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_MIDDLE); btn_labels[2] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_RIGHT); btn_labels[3] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_WHEEL_UP); btn_labels[4] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_WHEEL_DOWN); + btn_labels[5] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_HWHEEL_LEFT); + btn_labels[6] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_HWHEEL_RIGHT); + btn_labels[7] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_BACK); + btn_labels[8] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_FORWARD); axes_labels[0] = XIGetKnownProperty(AXIS_LABEL_PROP_REL_X); axes_labels[1] = XIGetKnownProperty(AXIS_LABEL_PROP_REL_Y); @@ -114,7 +125,6 @@ winMouseProc(DeviceIntPtr pDeviceInt, int iState) winMouseCtrl, GetMotionHistorySize(), 2, axes_labels); free(map); - free(btn_labels); g_winMouseButtonMap = pDeviceInt->button->map; break; diff --git a/hw/xwin/winmultiwindowwndproc.c b/hw/xwin/winmultiwindowwndproc.c index 381818789..da7914ab7 100644 --- a/hw/xwin/winmultiwindowwndproc.c +++ b/hw/xwin/winmultiwindowwndproc.c @@ -661,7 +661,7 @@ winTopLevelWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) if (s_pScreenPriv == NULL || s_pScreenInfo->fIgnoreInput) break; SetCapture(hwnd); - return winMouseButtonsHandle(s_pScreen, ButtonPress, HIWORD(wParam) + 5, + return winMouseButtonsHandle(s_pScreen, ButtonPress, HIWORD(wParam) + 7, wParam); case WM_XBUTTONUP: @@ -670,7 +670,7 @@ winTopLevelWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) ReleaseCapture(); winStartMousePolling(s_pScreenPriv); return winMouseButtonsHandle(s_pScreen, ButtonRelease, - HIWORD(wParam) + 5, wParam); + HIWORD(wParam) + 7, wParam); case WM_MOUSEWHEEL: if (SendMessage diff --git a/hw/xwin/winwin32rootlesswndproc.c b/hw/xwin/winwin32rootlesswndproc.c index 13df18677..9c282ecb4 100644 --- a/hw/xwin/winwin32rootlesswndproc.c +++ b/hw/xwin/winwin32rootlesswndproc.c @@ -649,13 +649,13 @@ winMWExtWMWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) if (pScreenPriv == NULL || pScreenInfo->fIgnoreInput) break; SetCapture(hwnd); - return winMouseButtonsHandle(pScreen, ButtonPress, HIWORD(wParam) + 5, + return winMouseButtonsHandle(pScreen, ButtonPress, HIWORD(wParam) + 7, wParam); case WM_XBUTTONUP: if (pScreenPriv == NULL || pScreenInfo->fIgnoreInput) break; ReleaseCapture(); - return winMouseButtonsHandle(pScreen, ButtonRelease, HIWORD(wParam) + 5, + return winMouseButtonsHandle(pScreen, ButtonRelease, HIWORD(wParam) + 7, wParam); case WM_MOUSEWHEEL: diff --git a/hw/xwin/winwndproc.c b/hw/xwin/winwndproc.c index f99afb503..7af222ca5 100644 --- a/hw/xwin/winwndproc.c +++ b/hw/xwin/winwndproc.c @@ -894,7 +894,7 @@ winWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) #endif ) SetCapture(hwnd); - return winMouseButtonsHandle(s_pScreen, ButtonPress, HIWORD(wParam) + 5, + return winMouseButtonsHandle(s_pScreen, ButtonPress, HIWORD(wParam) + 7, wParam); case WM_XBUTTONUP: if (s_pScreenPriv == NULL || s_pScreenInfo->fIgnoreInput) @@ -906,7 +906,7 @@ winWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) ) ReleaseCapture(); return winMouseButtonsHandle(s_pScreen, ButtonRelease, - HIWORD(wParam) + 5, wParam); + HIWORD(wParam) + 7, wParam); case WM_TIMER: if (s_pScreenPriv == NULL || s_pScreenInfo->fIgnoreInput)