mirror of
https://github.com/moonlight-stream/moonlight-qt
synced 2024-12-14 05:12:27 +00:00
Clamp mouse motion to the video region rather than dropping it
This commit is contained in:
parent
8cb98b5365
commit
ab2bb51879
1 changed files with 6 additions and 10 deletions
|
@ -686,16 +686,12 @@ void SdlInputHandler::handleMouseMotionEvent(SDL_Window* window, SDL_MouseMotion
|
||||||
// Use the stream and window sizes to determine the video region
|
// Use the stream and window sizes to determine the video region
|
||||||
StreamUtils::scaleSourceToDestinationSurface(&src, &dst);
|
StreamUtils::scaleSourceToDestinationSurface(&src, &dst);
|
||||||
|
|
||||||
// Ignore motion outside the video region
|
// Clamp motion to the video region
|
||||||
if (event->x < dst.x || event->y < dst.y ||
|
short x = qMin(qMax(event->x - dst.x, 0), dst.w);
|
||||||
event->x > dst.x + dst.w || event->y > dst.y + dst.h) {
|
short y = qMin(qMax(event->y - dst.y, 0), dst.h);
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Send the mouse position update with coordinates relative to
|
// Send the mouse position update
|
||||||
// the video region.
|
LiSendMousePositionEvent(x, y, dst.w, dst.h);
|
||||||
LiSendMousePositionEvent(event->x - dst.x, event->y - dst.y,
|
|
||||||
dst.w, dst.h);
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// Batch until the next mouse polling window or we'll get awful
|
// Batch until the next mouse polling window or we'll get awful
|
||||||
|
@ -752,7 +748,7 @@ void SdlInputHandler::sendGamepadState(GamepadState* state)
|
||||||
state->rsY);
|
state->rsY);
|
||||||
}
|
}
|
||||||
|
|
||||||
Uint32 SdlInputHandler::longPressTimerCallback(Uint32, void *param)
|
Uint32 SdlInputHandler::longPressTimerCallback(Uint32, void*)
|
||||||
{
|
{
|
||||||
// Raise the left click and start a right click
|
// Raise the left click and start a right click
|
||||||
LiSendMouseButtonEvent(BUTTON_ACTION_RELEASE, BUTTON_LEFT);
|
LiSendMouseButtonEvent(BUTTON_ACTION_RELEASE, BUTTON_LEFT);
|
||||||
|
|
Loading…
Reference in a new issue