Changeset View
Changeset View
Standalone View
Standalone View
intern/ghost/intern/GHOST_SystemWin32.cpp
| Show First 20 Lines • Show All 706 Lines • ▼ Show 20 Lines | return new GHOST_EventCursor(system->getMilliSeconds(), | ||||
| x_screen, | x_screen, | ||||
| y_screen | y_screen | ||||
| ); | ); | ||||
| } | } | ||||
| return NULL; | return NULL; | ||||
| } | } | ||||
| 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 | |||||
| short acc = system->m_wheelDeltaAccum; | |||||
| short delta = GET_WHEEL_DELTA_WPARAM(wParam); | |||||
| // zDelta /= WHEEL_DELTA; | if (acc * delta < 0) { | ||||
| // temporary fix below: microsoft now has added more precision, making the above division not work | // scroll direction reversed. | ||||
| zDelta = (zDelta <= 0) ? -1 : 1; | acc = 0; | ||||
| } | |||||
| // short xPos = (short) LOWORD(lParam); // horizontal position of pointer | acc += delta; | ||||
| // short yPos = (short) HIWORD(lParam); // vertical position of pointer | int direction = (acc >= 0) ? 1 : -1; | ||||
| return new GHOST_EventWheel(getSystem()->getMilliSeconds(), window, zDelta); | 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); | |||||
| } | } | ||||
| GHOST_EventKey *GHOST_SystemWin32::processKeyEvent(GHOST_WindowWin32 *window, RAWINPUT const &raw) | GHOST_EventKey *GHOST_SystemWin32::processKeyEvent(GHOST_WindowWin32 *window, RAWINPUT const &raw) | ||||
| { | { | ||||
| int keyDown = 0; | int keyDown = 0; | ||||
| char vk; | char vk; | ||||
| GHOST_SystemWin32 *system = (GHOST_SystemWin32 *)getSystem(); | GHOST_SystemWin32 *system = (GHOST_SystemWin32 *)getSystem(); | ||||
| ▲ Show 20 Lines • Show All 397 Lines • ▼ Show 20 Lines | #endif /* WITH_INPUT_IME */ | ||||
| * 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. | ||||
| */ | */ | ||||
| /* Get the window under the mouse and send event to its queue. */ | /* Get the window under the mouse and send event to its queue. */ | ||||
| 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); | |||||
| } | |||||
| else { | |||||
| /* Happens when mouse is not over any of blender's windows. */ | |||||
| event = processWheelEvent(window, wParam, lParam); | |||||
| } | |||||
| processWheelEvent(mouse_window ? mouse_window : window , wParam, lParam); | |||||
| eventHandled = true; | |||||
| #ifdef BROKEN_PEEK_TOUCHPAD | #ifdef BROKEN_PEEK_TOUCHPAD | ||||
| PostMessage(hwnd, WM_USER, 0, 0); | PostMessage(hwnd, WM_USER, 0, 0); | ||||
| #endif | #endif | ||||
| 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. | ||||
| ▲ Show 20 Lines • Show All 42 Lines • ▼ Show 20 Lines | #endif | ||||
| * first to the window procedure of the top-level window being deactivated, then to the window | * first to the window procedure of the top-level window being deactivated, then to the window | ||||
| * procedure of the top-level window being activated. If the windows use different input queues, | * procedure of the top-level window being activated. If the windows use different input queues, | ||||
| * the message is sent asynchronously, so the window is activated immediately. | * the message is sent asynchronously, so the window is activated immediately. | ||||
| */ | */ | ||||
| { | { | ||||
| 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. */ | ||||
| if (LOWORD(wParam) == WA_INACTIVE) | if (LOWORD(wParam) == WA_INACTIVE) | ||||
| window->lostMouseCapture(); | window->lostMouseCapture(); | ||||
| lResult = ::DefWindowProc(hwnd, msg, wParam, lParam); | lResult = ::DefWindowProc(hwnd, msg, wParam, lParam); | ||||
| break; | break; | ||||
| ▲ Show 20 Lines • Show All 366 Lines • Show Last 20 Lines | |||||