mirror of
https://github.com/moonlight-stream/moonlight-qt.git
synced 2026-06-17 14:11:33 +00:00
Batch mouse move events for high DPI mice
This commit is contained in:
+22
-3
@@ -388,10 +388,29 @@ void SdlInputHandler::handleMouseMotionEvent(SDL_MouseMotionEvent* event)
|
|||||||
// Not capturing
|
// Not capturing
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
short xdelta = (short)event->xrel;
|
||||||
|
short ydelta = (short)event->yrel;
|
||||||
|
|
||||||
if (event->xrel != 0 || event->yrel != 0) {
|
// Delay for 1 ms to allow batching of mouse move
|
||||||
LiSendMouseMoveEvent((short)event->xrel,
|
// events from high DPI mice.
|
||||||
(short)event->yrel);
|
SDL_Delay(1);
|
||||||
|
SDL_PumpEvents();
|
||||||
|
|
||||||
|
SDL_Event nextEvent;
|
||||||
|
while (SDL_PeepEvents(&nextEvent,
|
||||||
|
1,
|
||||||
|
SDL_GETEVENT,
|
||||||
|
SDL_MOUSEMOTION,
|
||||||
|
SDL_MOUSEMOTION) == 1) {
|
||||||
|
// In theory, these can overflow but in practice
|
||||||
|
// it should be highly unlikely since it would require
|
||||||
|
// moving 64K pixels in 1 ms.
|
||||||
|
xdelta += nextEvent.motion.xrel;
|
||||||
|
ydelta += nextEvent.motion.yrel;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (xdelta != 0 || ydelta != 0) {
|
||||||
|
LiSendMouseMoveEvent(xdelta, ydelta);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user