mirror of
https://github.com/love2d/love.git
synced 2026-08-16 16:20:42 +02:00
Merge branch 'main' into 12.0-development
This commit is contained in:
@@ -54,6 +54,13 @@ static void windowToDPICoords(double *x, double *y)
|
||||
window->windowToDPICoords(x, y);
|
||||
}
|
||||
|
||||
static void clampToWindow(double *x, double *y)
|
||||
{
|
||||
auto window = Module::getInstance<window::Window>(Module::M_WINDOW);
|
||||
if (window)
|
||||
window->clampPositionInWindow(x, y);
|
||||
}
|
||||
|
||||
#ifndef LOVE_MACOS
|
||||
static void normalizedToDPICoords(double *x, double *y)
|
||||
{
|
||||
@@ -253,8 +260,16 @@ Message *Event::convert(const SDL_Event &e)
|
||||
double y = (double) e.motion.y;
|
||||
double xrel = (double) e.motion.xrel;
|
||||
double yrel = (double) e.motion.yrel;
|
||||
|
||||
// SDL reports mouse coordinates outside the window bounds when click-and-
|
||||
// dragging. For compatibility we clamp instead since user code may not be
|
||||
// able to handle out-of-bounds coordinates. SDL has a hint to turn off
|
||||
// auto capture, but it doesn't report the mouse's position at the edge of
|
||||
// the window if the mouse moves fast enough when it's off.
|
||||
clampToWindow(&x, &y);
|
||||
windowToDPICoords(&x, &y);
|
||||
windowToDPICoords(&xrel, &yrel);
|
||||
|
||||
vargs.emplace_back(x);
|
||||
vargs.emplace_back(y);
|
||||
vargs.emplace_back(xrel);
|
||||
@@ -280,7 +295,10 @@ Message *Event::convert(const SDL_Event &e)
|
||||
|
||||
double px = (double) e.button.x;
|
||||
double py = (double) e.button.y;
|
||||
|
||||
clampToWindow(&px, &py);
|
||||
windowToDPICoords(&px, &py);
|
||||
|
||||
vargs.emplace_back(px);
|
||||
vargs.emplace_back(py);
|
||||
vargs.emplace_back((double) button);
|
||||
|
||||
Reference in New Issue
Block a user