Partially unrevert 05e82c24 for macOS which still needs it

This commit is contained in:
Cameron Gutman
2020-05-06 21:18:23 -07:00
parent 8cc61ca8b8
commit 080421f2fb
4 changed files with 57 additions and 1 deletions

View File

@@ -122,5 +122,29 @@ Uint32 SdlInputHandler::mouseMoveTimerCallback(Uint32 interval, void *param)
LiSendMouseMoveEvent(deltaX, deltaY);
}
if (me->m_AbsoluteMouseMode && me->m_PendingFocusGain) {
int mouseX, mouseY;
int windowX, windowY;
SDL_Event event;
Uint32 buttonState = SDL_GetGlobalMouseState(&mouseX, &mouseY);
SDL_GetWindowPosition(me->m_Window, &windowX, &windowY);
// Send synthetic mouse move events until the button is released
event.motion.type = SDL_MOUSEMOTION;
event.motion.timestamp = SDL_GetTicks();
event.motion.windowID = SDL_GetWindowID(me->m_Window);
event.motion.which = 0;
event.motion.state = buttonState;
event.motion.x = mouseX - windowX;
event.motion.y = mouseY - windowY;
event.motion.xrel = 0;
event.motion.yrel = 0;
SDL_PushEvent(&event);
if ((buttonState & SDL_BUTTON_LMASK) == 0) {
me->m_PendingFocusGain = false;
}
}
return interval;
}