mirror of
https://github.com/Ryujinx/SDL.git
synced 2024-12-23 08:25:31 +00:00
Guarantee that we don't dispatch any mouse motion from before or including the last mouse warp
This commit is contained in:
parent
649466f491
commit
16aeb8d0f5
|
@ -1550,6 +1550,16 @@ WIN_PumpEvents(_THIS)
|
|||
g_WindowsMessageHook(g_WindowsMessageHookData, msg.hwnd, msg.message, msg.wParam, msg.lParam);
|
||||
}
|
||||
|
||||
/* Don't dispatch any mouse motion queued prior to or including the last mouse warp */
|
||||
if (msg.message == WM_MOUSEMOVE && SDL_last_warp_time) {
|
||||
if (!SDL_TICKS_PASSED(msg.time, (SDL_last_warp_time + 1))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
/* This mouse message happened after the warp */
|
||||
SDL_last_warp_time = 0;
|
||||
}
|
||||
|
||||
/* Always translate the message in case it's a non-SDL window (e.g. with Qt integration) */
|
||||
TranslateMessage(&msg);
|
||||
DispatchMessage(&msg);
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
#include "../../events/SDL_mouse_c.h"
|
||||
|
||||
|
||||
DWORD SDL_last_warp_time = 0;
|
||||
HCURSOR SDL_cursor = NULL;
|
||||
static SDL_Cursor *SDL_blank_cursor = NULL;
|
||||
|
||||
|
@ -253,16 +254,11 @@ WIN_WarpMouse(SDL_Window * window, int x, int y)
|
|||
SetCursorPos(pt.x, pt.y);
|
||||
|
||||
/* Flush any pending mouse motion and simulate motion for this warp */
|
||||
{
|
||||
SDL_Mouse *mouse = SDL_GetMouse();
|
||||
const SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
|
||||
MSG msg;
|
||||
|
||||
while (PeekMessage(&msg, data->hwnd, WM_MOUSEMOVE, WM_MOUSEMOVE, PM_REMOVE)) {
|
||||
continue;
|
||||
}
|
||||
SDL_SendMouseMotion(window, mouse->mouseID, 0, x, y);
|
||||
SDL_last_warp_time = GetTickCount();
|
||||
if (!SDL_last_warp_time) {
|
||||
SDL_last_warp_time = 1;
|
||||
}
|
||||
SDL_SendMouseMotion(window, SDL_GetMouse()->mouseID, 0, x, y);
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
#ifndef SDL_windowsmouse_h_
|
||||
#define SDL_windowsmouse_h_
|
||||
|
||||
extern DWORD SDL_last_warp_time;
|
||||
extern HCURSOR SDL_cursor;
|
||||
|
||||
extern void WIN_InitMouse(_THIS);
|
||||
|
|
Loading…
Reference in a new issue