Fix incorrect cursor motion coordinates for WIN32
Cursor motion events on windows read the position from GetCursorPos() which wasn't always the same location stored in `lParam`. In situations where events were handled immediately this wasn't often a problem, for heavier scenes or when updates between event handling was slow - many in-between cursor events would be incorrect. This behavior dates back to the initial commit, there doesn't seem to be a good reason not to use the cursor coordinates from the event. Noticed when investigating T102346.
This commit is contained in:
parent
d486f33d63
commit
979b295154
@ -1049,9 +1049,9 @@ void GHOST_SystemWin32::processPointerEvent(
|
||||
}
|
||||
}
|
||||
|
||||
GHOST_EventCursor *GHOST_SystemWin32::processCursorEvent(GHOST_WindowWin32 *window)
|
||||
GHOST_EventCursor *GHOST_SystemWin32::processCursorEvent(GHOST_WindowWin32 *window,
|
||||
const int32_t screen_co[2])
|
||||
{
|
||||
int32_t x_screen, y_screen;
|
||||
GHOST_SystemWin32 *system = (GHOST_SystemWin32 *)getSystem();
|
||||
|
||||
if (window->getTabletData().Active != GHOST_kTabletModeNone) {
|
||||
@ -1059,8 +1059,7 @@ GHOST_EventCursor *GHOST_SystemWin32::processCursorEvent(GHOST_WindowWin32 *wind
|
||||
return NULL;
|
||||
}
|
||||
|
||||
system->getCursorPosition(x_screen, y_screen);
|
||||
|
||||
int32_t x_screen = screen_co[0], y_screen = screen_co[1];
|
||||
if (window->getCursorGrabModeIsWarp()) {
|
||||
/* WORKAROUND:
|
||||
* Sometimes Windows ignores `SetCursorPos()` or `SendInput()` calls or the mouse event is
|
||||
@ -1834,7 +1833,10 @@ LRESULT WINAPI GHOST_SystemWin32::s_wndProc(HWND hwnd, uint msg, WPARAM wParam,
|
||||
}
|
||||
}
|
||||
|
||||
event = processCursorEvent(window);
|
||||
const int32_t window_co[2] = {GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)};
|
||||
int32_t screen_co[2];
|
||||
window->clientToScreen(UNPACK2(window_co), UNPACK2(screen_co));
|
||||
event = processCursorEvent(window, screen_co);
|
||||
|
||||
break;
|
||||
}
|
||||
@ -1876,7 +1878,10 @@ LRESULT WINAPI GHOST_SystemWin32::s_wndProc(HWND hwnd, uint msg, WPARAM wParam,
|
||||
WINTAB_PRINTF("HWND %p mouse leave\n", window->getHWND());
|
||||
window->m_mousePresent = false;
|
||||
if (window->getTabletData().Active == GHOST_kTabletModeNone) {
|
||||
event = processCursorEvent(window);
|
||||
/* FIXME: document why the cursor motion event on mouse leave is needed. */
|
||||
int32_t screen_co[2] = {0, 0};
|
||||
system->getCursorPosition(screen_co[0], screen_co[1]);
|
||||
event = processCursorEvent(window, screen_co);
|
||||
}
|
||||
GHOST_Wintab *wt = window->getWintab();
|
||||
if (wt) {
|
||||
|
@ -331,7 +331,8 @@ class GHOST_SystemWin32 : public GHOST_System {
|
||||
* \param window: The window receiving the event (the active window).
|
||||
* \return The event created.
|
||||
*/
|
||||
static GHOST_EventCursor *processCursorEvent(GHOST_WindowWin32 *window);
|
||||
static GHOST_EventCursor *processCursorEvent(GHOST_WindowWin32 *window,
|
||||
const int32_t screen_co[2]);
|
||||
|
||||
/**
|
||||
* Handles a mouse wheel event.
|
||||
|
Loading…
Reference in New Issue
Block a user