Changeset View
Changeset View
Standalone View
Standalone View
intern/ghost/intern/GHOST_SystemWin32.cpp
| Context not available. | |||||
| } | } | ||||
| GHOST_EventWheel *GHOST_SystemWin32::processWheelEvent(GHOST_WindowWin32 *window, WPARAM wParam, LPARAM lParam) | void GHOST_SystemWin32::processWheelEvent(GHOST_WindowWin32 *window, WPARAM wParam, LPARAM lParam) | ||||
| { | { | ||||
| // short fwKeys = LOWORD(wParam); // key flags | GHOST_SystemWin32 *system = (GHOST_SystemWin32 *)getSystem(); | ||||
| int zDelta = (short) HIWORD(wParam); // wheel rotation | |||||
| // zDelta /= WHEEL_DELTA; | |||||
| // temporary fix below: microsoft now has added more precision, making the above division not work | |||||
| zDelta = (zDelta <= 0) ? -1 : 1; | |||||
| // short xPos = (short) LOWORD(lParam); // horizontal position of pointer | short acc = system->m_wheelDeltaAccum; | ||||
| // short yPos = (short) HIWORD(lParam); // vertical position of pointer | short delta = GET_WHEEL_DELTA_WPARAM(wParam); | ||||
brecht: Same here, better use `int`. | |||||
| return new GHOST_EventWheel(getSystem()->getMilliSeconds(), window, zDelta); | |||||
| if (acc * delta < 0) { | |||||
| // scroll direction reversed. | |||||
Not Done Inline ActionsSee below, since always 0 is returned, you can get rid of the return value for this method alltogether elubie: See below, since always 0 is returned, you can get rid of the return value for this method… | |||||
| acc = 0; | |||||
| } | |||||
| acc += delta; | |||||
| int direction = (acc >= 0) ? 1 : -1; | |||||
| acc = abs(acc); | |||||
| while (acc >= WHEEL_DELTA) { | |||||
| system->pushEvent(new GHOST_EventWheel(system->getMilliSeconds(), window, direction)); | |||||
| acc -= WHEEL_DELTA; | |||||
| } | |||||
| system->m_wheelDeltaAccum = (signed char)(acc * direction); | |||||
brechtUnsubmitted Not Done Inline ActionsAnd here as well. brecht: And here as well. | |||||
| } | } | ||||
Not Done Inline ActionsThis could be a member variable of GHOST_SystemWin32 I think. brecht: This could be a member variable of GHOST_SystemWin32 I think. | |||||
Not Done Inline ActionsWhy is there a maximum here, to avoid a very high number of mouse wheel events? 5 seems a bit low. brecht: Why is there a maximum here, to avoid a very high number of mouse wheel events? 5 seems a bit… | |||||
Not Done Inline ActionsWith the new behavior only, this check is not necessary since all events are now handled in processWheelEvent. In this case you can probably also get rid of the return value alltogether elubie: With the new behavior only, this check is not necessary since all events are now handled in… | |||||
| Context not available. | |||||
| POINT mouse_pos = {GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)}; | POINT mouse_pos = {GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)}; | ||||
| HWND mouse_hwnd = ChildWindowFromPoint(HWND_DESKTOP, mouse_pos); | HWND mouse_hwnd = ChildWindowFromPoint(HWND_DESKTOP, mouse_pos); | ||||
| GHOST_WindowWin32 *mouse_window = (GHOST_WindowWin32 *)::GetWindowLongPtr(mouse_hwnd, GWLP_USERDATA); | GHOST_WindowWin32 *mouse_window = (GHOST_WindowWin32 *)::GetWindowLongPtr(mouse_hwnd, GWLP_USERDATA); | ||||
| if (mouse_window != NULL) { | |||||
| event = processWheelEvent(mouse_window, wParam, lParam); | processWheelEvent(mouse_window ? mouse_window : window , wParam, lParam); | ||||
| } | eventHandled = true; | ||||
| else { | |||||
| /* Happens when mouse is not over any of blender's windows. */ | |||||
| event = processWheelEvent(window, wParam, lParam); | |||||
| } | |||||
| #ifdef BROKEN_PEEK_TOUCHPAD | #ifdef BROKEN_PEEK_TOUCHPAD | ||||
| PostMessage(hwnd, WM_USER, 0, 0); | PostMessage(hwnd, WM_USER, 0, 0); | ||||
| #endif | #endif | ||||
| Context not available. | |||||
| GHOST_ModifierKeys modifiers; | GHOST_ModifierKeys modifiers; | ||||
| modifiers.clear(); | modifiers.clear(); | ||||
| system->storeModifierKeys(modifiers); | system->storeModifierKeys(modifiers); | ||||
| system->m_wheelDeltaAccum = 0; | |||||
| event = processWindowEvent(LOWORD(wParam) ? GHOST_kEventWindowActivate : GHOST_kEventWindowDeactivate, window); | event = processWindowEvent(LOWORD(wParam) ? GHOST_kEventWindowActivate : GHOST_kEventWindowDeactivate, window); | ||||
| /* WARNING: Let DefWindowProc handle WM_ACTIVATE, otherwise WM_MOUSEWHEEL | /* WARNING: Let DefWindowProc handle WM_ACTIVATE, otherwise WM_MOUSEWHEEL | ||||
| * will not be dispatched to OUR active window if we minimize one of OUR windows. */ | * will not be dispatched to OUR active window if we minimize one of OUR windows. */ | ||||
| Context not available. | |||||
Same here, better use int.