Changeset View
Changeset View
Standalone View
Standalone View
intern/ghost/intern/GHOST_SystemWin32.cpp
| Context not available. | |||||
| return NULL; | return NULL; | ||||
| } | } | ||||
| void GHOST_SystemWin32::processWheelEvent(GHOST_IWindow *window, WPARAM wParam, LPARAM lParam) | |||||
| GHOST_EventWheel *GHOST_SystemWin32::processWheelEvent(GHOST_IWindow *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 | |||||
| if (zDelta <= 0) zDelta = -1; else zDelta = 1; | |||||
| // short xPos = (short) LOWORD(lParam); // horizontal position of pointer | |||||
| // short yPos = (short) HIWORD(lParam); // vertical position of pointer | |||||
| return new GHOST_EventWheel(getSystem()->getMilliSeconds(), window, zDelta); | |||||
| } | |||||
| short acc = system->m_wheelDeltaAccum; | |||||
| short delta = GET_WHEEL_DELTA_WPARAM(wParam); | |||||
| if (acc * delta < 0) { | |||||
| // scroll direction reversed. | |||||
| acc = 0; | |||||
| } | |||||
| acc += delta; | |||||
| int direction = (acc >= 0) ? 1 : -1; | |||||
| acc = abs(acc); | |||||
brecht: Same here, better use `int`. | |||||
| while (acc >= WHEEL_DELTA) { | |||||
| system->pushEvent(new GHOST_EventWheel(system->getMilliSeconds(), window, direction)); | |||||
| acc -= WHEEL_DELTA; | |||||
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… | |||||
| } | |||||
| system->m_wheelDeltaAccum = (signed char)(acc * direction); | |||||
| } | |||||
| GHOST_EventKey *GHOST_SystemWin32::processKeyEvent(GHOST_IWindow *window, RAWINPUT const& raw) | GHOST_EventKey *GHOST_SystemWin32::processKeyEvent(GHOST_IWindow *window, RAWINPUT const& raw) | ||||
| { | { | ||||
Not Done Inline ActionsAnd here as well. brecht: And here as well. | |||||
| Context not available. | |||||
| * since DefWindowProc propagates it up the parent chain | * since DefWindowProc propagates it up the parent chain | ||||
| * until it finds a window that processes it. | * until it finds a window that processes it. | ||||
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. | |||||
| */ | */ | ||||
| event = processWheelEvent(window, wParam, lParam); | processWheelEvent(window, wParam, lParam); | ||||
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… | |||||
| // already handled inside the method | |||||
| eventHandled = true; | |||||
| break; | break; | ||||
| case WM_SETCURSOR: | case WM_SETCURSOR: | ||||
| /* The WM_SETCURSOR message is sent to a window if the mouse causes the cursor | /* The WM_SETCURSOR message is sent to a window if the mouse causes the cursor | ||||
| * to move within a window and mouse input is not captured. | * to move within a window and mouse input is not captured. | ||||
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… | |||||
| 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.