From cd56321e65db523aab4b2c1a2d775766a52fe732 Mon Sep 17 00:00:00 2001 From: Geoffrey McRae Date: Tue, 4 May 2021 05:14:33 +1000 Subject: [PATCH] [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. --- client/src/app.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/client/src/app.c b/client/src/app.c index 39c2e970..72929978 100644 --- a/client/src/app.c +++ b/client/src/app.c @@ -291,13 +291,6 @@ void app_handleMouseRelative(double normx, double 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 // 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 @@ -323,8 +316,10 @@ void app_handleMouseBasic() struct DoublePoint guest; util_localCurToGuest(&guest); - int x = (int) round(clamp(guest.x, 0, g_state.srcSize.x) - g_cursor.projected.x); - int y = (int) round(clamp(guest.y, 0, g_state.srcSize.y) - g_cursor.projected.y); + int x = (int) round(util_clamp(guest.x, 0, g_state.srcSize.x) - + g_cursor.projected.x); + int y = (int) round(util_clamp(guest.y, 0, g_state.srcSize.y) - + g_cursor.projected.y); if (!x && !y) return;