mirror of
https://github.com/Ryujinx/SDL.git
synced 2024-12-23 12:55:37 +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);
|
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) */
|
/* Always translate the message in case it's a non-SDL window (e.g. with Qt integration) */
|
||||||
TranslateMessage(&msg);
|
TranslateMessage(&msg);
|
||||||
DispatchMessage(&msg);
|
DispatchMessage(&msg);
|
||||||
|
|
|
@ -27,6 +27,7 @@
|
||||||
#include "../../events/SDL_mouse_c.h"
|
#include "../../events/SDL_mouse_c.h"
|
||||||
|
|
||||||
|
|
||||||
|
DWORD SDL_last_warp_time = 0;
|
||||||
HCURSOR SDL_cursor = NULL;
|
HCURSOR SDL_cursor = NULL;
|
||||||
static SDL_Cursor *SDL_blank_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);
|
SetCursorPos(pt.x, pt.y);
|
||||||
|
|
||||||
/* Flush any pending mouse motion and simulate motion for this warp */
|
/* Flush any pending mouse motion and simulate motion for this warp */
|
||||||
{
|
SDL_last_warp_time = GetTickCount();
|
||||||
SDL_Mouse *mouse = SDL_GetMouse();
|
if (!SDL_last_warp_time) {
|
||||||
const SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
|
SDL_last_warp_time = 1;
|
||||||
MSG msg;
|
|
||||||
|
|
||||||
while (PeekMessage(&msg, data->hwnd, WM_MOUSEMOVE, WM_MOUSEMOVE, PM_REMOVE)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
SDL_SendMouseMotion(window, mouse->mouseID, 0, x, y);
|
|
||||||
}
|
}
|
||||||
|
SDL_SendMouseMotion(window, SDL_GetMouse()->mouseID, 0, x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
#ifndef SDL_windowsmouse_h_
|
#ifndef SDL_windowsmouse_h_
|
||||||
#define SDL_windowsmouse_h_
|
#define SDL_windowsmouse_h_
|
||||||
|
|
||||||
|
extern DWORD SDL_last_warp_time;
|
||||||
extern HCURSOR SDL_cursor;
|
extern HCURSOR SDL_cursor;
|
||||||
|
|
||||||
extern void WIN_InitMouse(_THIS);
|
extern void WIN_InitMouse(_THIS);
|
||||||
|
|
Loading…
Reference in a new issue