mirror of
https://github.com/gnif/LookingGlass.git
synced 2025-04-28 09:36:28 +00:00
[client] util: move and rename clamp
to util_clamp
As this is a generic utility function it should live in `util.h` allowing it to be used elsewhere in the project.
This commit is contained in:
parent
a2d5c08460
commit
cd56321e65
@ -291,13 +291,6 @@ void app_handleMouseRelative(double normx, double normy,
|
|||||||
core_handleMouseNormal(normx, normy);
|
core_handleMouseNormal(normx, normy);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline double clamp(double x, double min, double max)
|
|
||||||
{
|
|
||||||
if (x < min) return min;
|
|
||||||
if (x > max) return max;
|
|
||||||
return x;
|
|
||||||
}
|
|
||||||
|
|
||||||
// On some display servers normal cursor logic does not work due to the lack of
|
// On some display servers normal cursor logic does not work due to the lack of
|
||||||
// cursor warp support. Instead, we attempt a best-effort emulation which works
|
// cursor warp support. Instead, we attempt a best-effort emulation which works
|
||||||
// with a 1:1 mouse movement patch applied in the guest. For anything fancy, use
|
// with a 1:1 mouse movement patch applied in the guest. For anything fancy, use
|
||||||
@ -323,8 +316,10 @@ void app_handleMouseBasic()
|
|||||||
struct DoublePoint guest;
|
struct DoublePoint guest;
|
||||||
util_localCurToGuest(&guest);
|
util_localCurToGuest(&guest);
|
||||||
|
|
||||||
int x = (int) round(clamp(guest.x, 0, g_state.srcSize.x) - g_cursor.projected.x);
|
int x = (int) round(util_clamp(guest.x, 0, g_state.srcSize.x) -
|
||||||
int y = (int) round(clamp(guest.y, 0, g_state.srcSize.y) - g_cursor.projected.y);
|
g_cursor.projected.x);
|
||||||
|
int y = (int) round(util_clamp(guest.y, 0, g_state.srcSize.y) -
|
||||||
|
g_cursor.projected.y);
|
||||||
|
|
||||||
if (!x && !y)
|
if (!x && !y)
|
||||||
return;
|
return;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user