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 | |||||
| int acc = system->m_wheelDeltaAccum; | |||||
| int delta = GET_WHEEL_DELTA_WPARAM(wParam); | |||||
brecht: Same here, better use `int`. | |||||
| // 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. | ||||
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… | |||||
| 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 = acc * direction; | |||||
Not Done Inline ActionsAnd here as well. brecht: And here as well. | |||||
| } | } | ||||
| 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 310 Lines • ▼ Show 20 Lines | #endif /* WITH_INPUT_IME */ | ||||
| case WM_SYSDEADCHAR: | case WM_SYSDEADCHAR: | ||||
| /* The WM_SYSDEADCHAR message is sent to the window with the keyboard focus when | /* The WM_SYSDEADCHAR message is sent to the window with the keyboard focus when | ||||
| * a WM_SYSKEYDOWN message is translated by the TranslateMessage function. | * a WM_SYSKEYDOWN message is translated by the TranslateMessage function. | ||||
| * WM_SYSDEADCHAR specifies the character code of a system dead key - that is, | * WM_SYSDEADCHAR specifies the character code of a system dead key - that is, | ||||
| * a dead key that is pressed while holding down the alt key. | * a dead key that is pressed while holding down the alt key. | ||||
| */ | */ | ||||
| case WM_SYSCHAR: | case WM_SYSCHAR: | ||||
| /* The WM_SYSCHAR message is sent to the window with the keyboard focus when | /* The WM_SYSCHAR message is sent to the window with the keyboard focus when | ||||
| * a WM_SYSCHAR message is translated by the TranslateMessage function. | * a WM_SYSCHAR message is translated by the TranslateMessage function. | ||||
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. | |||||
| * WM_SYSCHAR specifies the character code of a dead key - that is, | * WM_SYSCHAR specifies the character code of a dead key - that is, | ||||
| * a dead key that is pressed while holding down the alt key. | * a dead key that is pressed while holding down the alt key. | ||||
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… | |||||
| * To prevent the sound, DefWindowProc must be avoided by return | * To prevent the sound, DefWindowProc must be avoided by return | ||||
| */ | */ | ||||
| break; | break; | ||||
| case WM_SYSCOMMAND: | case WM_SYSCOMMAND: | ||||
| /* The WM_SYSCHAR message is sent to the window when system commands such as | /* The WM_SYSCHAR message is sent to the window when system commands such as | ||||
| * maximize, minimize or close the window are triggered. Also it is sent when ALT | * maximize, minimize or close the window are triggered. Also it is sent when ALT | ||||
| * button is press for menu. To prevent this we must return preventing DefWindowProc. | * button is press for menu. To prevent this we must return preventing DefWindowProc. | ||||
| */ | */ | ||||
| if (wParam == SC_KEYMENU) { | if (wParam == SC_KEYMENU) { | ||||
| eventHandled = true; | eventHandled = true; | ||||
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… | |||||
| } | } | ||||
| break; | break; | ||||
| //////////////////////////////////////////////////////////////////////// | //////////////////////////////////////////////////////////////////////// | ||||
| // Tablet events, processed | // Tablet events, processed | ||||
| //////////////////////////////////////////////////////////////////////// | //////////////////////////////////////////////////////////////////////// | ||||
| case WT_PACKET: | case WT_PACKET: | ||||
| window->processWin32TabletEvent(wParam, lParam); | window->processWin32TabletEvent(wParam, lParam); | ||||
| break; | break; | ||||
| ▲ Show 20 Lines • Show All 58 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 | |||||
Same here, better use int.