Fix: [SDL] unify the way X11 and Wayland handle mouse events

Basically, we drop RelativeMode completely, and use the same trick
as used by the Windows driver: read all motion events till the last
one, and use that as value.
This commit is contained in:
Patric Stout
2023-06-03 23:08:37 +02:00
committed by Patric Stout
parent 8a2d550904
commit a969a78f81
2 changed files with 30 additions and 9 deletions

View File

@@ -478,12 +478,25 @@ bool VideoDriver_SDL::PollEvent()
if (!SDL_PollEvent(&ev)) return false;
switch (ev.type) {
case SDL_MOUSEMOTION:
if (_cursor.UpdateCursorPosition(ev.motion.x, ev.motion.y, true)) {
case SDL_MOUSEMOTION: {
int32_t x = ev.motion.x;
int32_t y = ev.motion.y;
if (_cursor.fix_at) {
/* Get all queued mouse events now in case we have to warp the cursor. In the
* end, we only care about the current mouse position and not bygone events. */
while (SDL_PeepEvents(&ev, 1, SDL_GETEVENT, SDL_MOUSEMOTION)) {
x = ev.motion.x;
y = ev.motion.y;
}
}
if (_cursor.UpdateCursorPosition(x, y, false)) {
SDL_WarpMouse(_cursor.pos.x, _cursor.pos.y);
}
HandleMouseEvents();
break;
}
case SDL_MOUSEBUTTONDOWN:
if (_rightclick_emulate && SDL_GetModState() & KMOD_CTRL) {