BACKENDS: Fix missing mouse events when system cursor cannot be moved
Normally with SDL, a mouse motion event will be sent after the system mouse cursor has been moved by a call to SDL_WarpMouseInWindow, but if the system cursor cannot be moved (e.g. because the window does not have mouse focus), games still need to receive these mouse events so they can successfully update the mouse position internally. Otherwise, games continue to think the mouse is still in the original position and will continue to try to perform whatever action is associated with that mouse position. Refs Trac#9689.
This commit is contained in:
parent
cd538ffffa
commit
d1b77d4b68
10 changed files with 80 additions and 7 deletions
|
@ -75,7 +75,7 @@ static uint32 convUTF8ToUTF32(const char *src) {
|
|||
#endif
|
||||
|
||||
SdlEventSource::SdlEventSource()
|
||||
: EventSource(), _scrollLock(false), _joystick(0), _lastScreenID(0), _graphicsManager(0)
|
||||
: EventSource(), _scrollLock(false), _joystick(0), _lastScreenID(0), _graphicsManager(0), _queuedFakeMouseMove(false)
|
||||
#if SDL_VERSION_ATLEAST(2, 0, 0)
|
||||
, _queuedFakeKeyUp(false), _fakeKeyUp()
|
||||
#endif
|
||||
|
@ -508,6 +508,12 @@ bool SdlEventSource::pollEvent(Common::Event &event) {
|
|||
return true;
|
||||
}
|
||||
|
||||
if (_queuedFakeMouseMove) {
|
||||
event = _fakeMouseMove;
|
||||
_queuedFakeMouseMove = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
SDL_Event ev;
|
||||
while (SDL_PollEvent(&ev)) {
|
||||
preprocessEvents(&ev);
|
||||
|
@ -1003,6 +1009,12 @@ void SdlEventSource::resetKeyboardEmulation(int16 x_max, int16 y_max) {
|
|||
_km.joy_y = 0;
|
||||
}
|
||||
|
||||
void SdlEventSource::fakeWarpMouse(const int x, const int y) {
|
||||
_queuedFakeMouseMove = true;
|
||||
_fakeMouseMove.type = Common::EVENT_MOUSEMOVE;
|
||||
_fakeMouseMove.mouse = Common::Point(x, y);
|
||||
}
|
||||
|
||||
bool SdlEventSource::handleResizeEvent(Common::Event &event, int w, int h) {
|
||||
if (_graphicsManager) {
|
||||
_graphicsManager->notifyResize(w, h);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue