From a0b7b12ffc31352410eeb07d7121853a9091252a Mon Sep 17 00:00:00 2001 From: Geoffrey McRae Date: Thu, 6 Aug 2026 17:04:25 +1000 Subject: [PATCH] [client] tree: restore unrelated working changes Restore client and test files that were already staged when the OBS cadence commit was created. Keep that work out of the scheduler series while leaving its working-tree contents untouched. --- client/src/app.c | 5 +- client/src/core.c | 198 +++++------------------------------- client/src/main.c | 3 - client/src/main.h | 9 -- client/tests/CMakeLists.txt | 1 - client/tests/mouse_test.c | 73 +------------ 6 files changed, 31 insertions(+), 258 deletions(-) diff --git a/client/src/app.c b/client/src/app.c index 7024cbbd..cbc1e994 100644 --- a/client/src/app.c +++ b/client/src/app.c @@ -469,8 +469,7 @@ void app_handleButtonPress(int button) return; } - if (!core_inputEnabled() || g_cursor.exitWait || - !g_cursor.inView || !g_cursor.viewReq) + if (!core_inputEnabled() || !g_cursor.inView || !g_cursor.viewReq) return; if (!purespice_mousePress(button)) @@ -493,7 +492,7 @@ void app_handleButtonRelease(int button) return; } - if (!core_inputEnabled() || g_cursor.exitWait) + if (!core_inputEnabled()) return; if (!purespice_mouseRelease(button)) diff --git a/client/src/core.c b/client/src/core.c index d558656a..9365cfc3 100644 --- a/client/src/core.c +++ b/client/src/core.c @@ -62,21 +62,18 @@ static int exitPos(double pos, int edge) static void cancelExit(const char * why) { - if (!g_cursor.exit && !g_cursor.exitWait) + if (!g_cursor.exit) return; MTRACE("exit cancel=%s target=%.3f,%.3f", why, g_cursor.exitPos.x, g_cursor.exitPos.y); - g_cursor.exit = false; - g_cursor.exitWait = false; - g_cursor.exitRetry = false; - g_cursor.exitDelta = (struct DoublePoint) { 0 }; + g_cursor.exit = false; } -static bool finishExit(void) +static void finishExit(void) { if (!g_cursor.exit || g_cursor.viewReq) - return false; + return; const int x = exitPos(g_cursor.exitPos.x, g_state.dstRect.x); const int y = exitPos(g_cursor.exitPos.y, g_state.dstRect.y); @@ -85,27 +82,21 @@ static bool finishExit(void) MTRACE("exit warp target=%d,%d projected=%.3f,%.3f inWin=%d", x, y, g_cursor.exitPos.x, g_cursor.exitPos.y, g_cursor.inWindow); - if (g_cursor.exitWait) - g_cursor.viewReq = true; - else if (x < 0 || x >= g_state.windowW || - y < 0 || y >= g_state.windowH) + if (x < 0 || x >= g_state.windowW || + y < 0 || y >= g_state.windowH) g_cursor.inWindow = false; core_warpPointer(x, y, true); - return g_cursor.exitWait; } -static void startExit(double x, double y, bool wait) +static void startExit(double x, double y) { - g_cursor.exit = true; - g_cursor.exitWait = wait; - g_cursor.exitRetry = false; - g_cursor.exitPos = (struct DoublePoint) { x, y }; - g_cursor.exitDelta = (struct DoublePoint) { 0 }; + g_cursor.exit = true; + g_cursor.exitPos = (struct DoublePoint) { x, y }; core_setCursorInView(false); } -static struct DoublePoint exitMove(double ex, double ey) +static bool moveExit(double ex, double ey) { if (g_cursor.useScale && g_params.scaleMouseInput) { @@ -115,115 +106,18 @@ static struct DoublePoint exitMove(double ex, double ey) struct DoublePoint move = {.x = ex, .y = ey}; util_rotatePoint(&move); - return move; -} + g_cursor.exitPos.x += move.x; + g_cursor.exitPos.y += move.y; -static struct Point exitDir(void) -{ - return (struct Point) { - .x = g_cursor.exitPos.x < g_state.dstRect.x ? -1 : - g_cursor.exitPos.x >= g_state.dstRect.x + g_state.dstRect.w ? 1 : 0, - .y = g_cursor.exitPos.y < g_state.dstRect.y ? -1 : - g_cursor.exitPos.y >= g_state.dstRect.y + g_state.dstRect.h ? 1 : 0, - }; -} + const bool inside = + g_cursor.exitPos.x >= g_state.dstRect.x && + g_cursor.exitPos.x < g_state.dstRect.x + g_state.dstRect.w && + g_cursor.exitPos.y >= g_state.dstRect.y && + g_cursor.exitPos.y < g_state.dstRect.y + g_state.dstRect.h; -static bool exitInward(struct DoublePoint move) -{ - const struct Point dir = exitDir(); - return move.x * dir.x < 0 || move.y * dir.y < 0; -} - -static struct DoublePoint exitInput(struct DoublePoint move) -{ - double temp; - switch((g_state.rotate + g_params.winRotate) % LG_ROTATE_MAX) - { - case LG_ROTATE_0: - break; - - case LG_ROTATE_90: - temp = move.x; - move.x = -move.y; - move.y = temp; - break; - - case LG_ROTATE_180: - move.x = -move.x; - move.y = -move.y; - break; - - case LG_ROTATE_270: - temp = move.x; - move.x = move.y; - move.y = -temp; - break; - } - - if (g_cursor.useScale && g_params.scaleMouseInput) - { - move.x /= g_cursor.scale.x; - move.y /= g_cursor.scale.y; - } - - return move; -} - -static struct DoublePoint clampExit(double ex, double ey) -{ - struct DoublePoint move = exitMove(ex, ey); - const struct Point dir = exitDir(); - if (move.x * dir.x > 0) - move.x = 0; - if (move.y * dir.y > 0) - move.y = 0; - - const struct DoublePoint input = exitInput(move); - MTRACE("exit clamp input=%.3f,%.3f move=%.3f,%.3f dir=%d,%d", - input.x, input.y, move.x, move.y, dir.x, dir.y); - return input; -} - -static bool moveExit(double ex, double ey) -{ - const struct DoublePoint move = exitMove(ex, ey); - const bool inward = exitInward(move); - - if (!inward) - { - g_cursor.exitPos.x += move.x; - g_cursor.exitPos.y += move.y; - } - - MTRACE("exit move=%.3f,%.3f target=%.3f,%.3f inward=%d", - move.x, move.y, g_cursor.exitPos.x, g_cursor.exitPos.y, inward); - return inward; -} - -static void startRetry(void) -{ - if (!g_cursor.exitWait || g_cursor.exit || g_cursor.exitRetry) - return; - - MTRACE("exit retry target=%.3f,%.3f", g_cursor.exitPos.x, - g_cursor.exitPos.y); - g_cursor.pos.x = util_clamp(g_cursor.exitPos.x, 0, - g_state.windowW - 1); - g_cursor.pos.y = util_clamp(g_cursor.exitPos.y, 0, - g_state.windowH - 1); - g_cursor.exitRetry = true; - g_cursor.realign = true; - g_state.ds->grabPointer(); -} - -static void retryExit(double ex, double ey) -{ - const struct DoublePoint input = clampExit(ex, ey); - g_cursor.exitDelta.x += input.x; - g_cursor.exitDelta.y += input.y; - - if (input.x != 0 || input.y != 0) - startRetry(); + MTRACE("exit move=%.3f,%.3f target=%.3f,%.3f inside=%d", + move.x, move.y, g_cursor.exitPos.x, g_cursor.exitPos.y, inside); + return inside; } bool core_inputEnabled(void) @@ -299,17 +193,9 @@ void core_setCursorInView(bool enable) enable, g_cursor.viewReq, g_cursor.inView, g_state.focused, g_cursor.inWindow, g_cursor.grab); - if (enable && g_cursor.exitWait && !g_cursor.exit) - { - startRetry(); - return; - } - - if ((g_cursor.exit && enable) || - ((g_cursor.exit || g_cursor.exitWait) && - (!g_state.focused || !g_cursor.inWindow || g_state.ignoreInput || - !g_state.posInfoValid || app_isOverlayMode())) || - (g_cursor.exitWait && !g_cursor.exit && !enable)) + if (g_cursor.exit && + (enable || !g_state.focused || !g_cursor.inWindow || + g_state.ignoreInput || !g_state.posInfoValid || app_isOverlayMode())) cancelExit(enable ? "view" : "state"); if (enable && !g_state.focused) @@ -367,25 +253,10 @@ void core_handleGrabEvent(bool active) warpSupport == LG_DS_WARP_NONE) return; - struct DoublePoint replay = { 0 }; if (!active) - { - if (finishExit() || g_cursor.exitWait) - return; - } - else if (g_cursor.exitRetry) - { - replay = g_cursor.exitDelta; - g_cursor.exitWait = false; - g_cursor.exitRetry = false; - g_cursor.exitDelta = (struct DoublePoint) { 0 }; - g_cursor.warpState = WARP_STATE_ON; - } + finishExit(); applyView(active, false); - - if (replay.x != 0 || replay.y != 0) - core_handleMouseNormal(replay.x, replay.y); } void core_setGrab(bool enable) @@ -411,7 +282,6 @@ void core_setGrabQuiet(bool enable) if (g_cursor.grab == enable) return; - cancelExit("capture"); g_cursor.grab = enable; g_cursor.acc.x = 0.0; g_cursor.acc.y = 0.0; @@ -519,10 +389,7 @@ void core_onWindowSizeChanged(unsigned width, unsigned height) void core_updatePositionInfo(void) { - if (g_cursor.exitWait && !g_cursor.exit) - startRetry(); - else - cancelExit("geometry"); + cancelExit("geometry"); if (g_params.setGuestRes && g_state.transportFeatures & LG_TRANSPORT_FEATURE_WINDOW_SIZE) @@ -763,8 +630,7 @@ void core_handleGuestMouseUpdate(void) } const bool overlay = app_isOverlayMode(); - if (overlay || g_cursor.exitWait || - !g_cursor.inView || !g_cursor.viewReq) + if (overlay || !g_cursor.inView || !g_cursor.viewReq) { MTRACE("guest drop=%s guest=%d,%d local=%.3f,%.3f inWin=%d " "inView=%d req=%d", overlay ? "overlay" : "view", @@ -846,12 +712,6 @@ void core_handleMouseNormal(double ex, double ey) if (!core_inputEnabled()) return; - if (g_cursor.exitWait && !g_cursor.exit) - { - retryExit(ex, ey); - return; - } - if (g_cursor.viewReq != g_cursor.inView) { if (g_cursor.viewReq) @@ -1025,9 +885,7 @@ fallback: break; case LG_DS_WARP_SURFACE: - startExit(local.x, local.y, - tx < 0 || tx >= g_state.windowW || - ty < 0 || ty >= g_state.windowH); + startExit(local.x, local.y); return; case LG_DS_WARP_SCREEN: @@ -1035,7 +893,7 @@ fallback: g_state.windowPos.x + g_state.border.left + tx, g_state.windowPos.y + g_state.border.top + ty)) { - startExit(local.x, local.y, false); + startExit(local.x, local.y); return; } } diff --git a/client/src/main.c b/client/src/main.c index 4da40f9c..138ba42d 100644 --- a/client/src/main.c +++ b/client/src/main.c @@ -133,9 +133,6 @@ static void lgInit(void) g_cursor.inView = false; g_cursor.viewReq = false; g_cursor.exit = false; - g_cursor.exitWait = false; - g_cursor.exitRetry = false; - g_cursor.exitDelta = (struct DoublePoint) { 0 }; g_cursor.guest.valid = false; // if spice is not in use, hide the local cursor diff --git a/client/src/main.h b/client/src/main.h index 1bfd11a1..8aef380b 100644 --- a/client/src/main.h +++ b/client/src/main.h @@ -301,18 +301,9 @@ struct CursorState /* true if a pointer exit is waiting for confinement to release */ bool exit; - /* true if a surface exit is waiting for a pointer leave */ - bool exitWait; - - /* true if confinement is being restored after a failed exit */ - bool exitRetry; - /* the local pointer exit target */ struct DoublePoint exitPos; - /* input retained while confinement is restored */ - struct DoublePoint exitDelta; - /* true if the guest should be realigned to the host when next drawn */ bool realign; diff --git a/client/tests/CMakeLists.txt b/client/tests/CMakeLists.txt index 07f3c646..57e9e233 100644 --- a/client/tests/CMakeLists.txt +++ b/client/tests/CMakeLists.txt @@ -66,7 +66,6 @@ target_link_libraries(mouse-tests ) set(MOUSE_CASES inset-exit - surface-edge exit-delay exit-guest exit-cancel diff --git a/client/tests/mouse_test.c b/client/tests/mouse_test.c index 69300838..645c058e 100644 --- a/client/tests/mouse_test.c +++ b/client/tests/mouse_test.c @@ -329,76 +329,6 @@ static void setConf(bool active) core_handleGrabEvent(active); } -static void setEdge(enum LG_DSWarpSupport support) -{ - reset(); - m.support = support; - g_state.windowW = 100; - g_state.windowH = 80; - g_state.dstRect = (LG_RendererRect) { - .valid = true, - .x = 0, - .y = 0, - .w = 100, - .h = 80, - }; - setLocal(99, 40); -} - -static void testSurfaceEdge(void) -{ - setEdge(LG_DS_WARP_SURFACE); - - core_handleMouseNormal(1, 0); - - const int move = first(EV_WARP); - CHECK(move >= 0); - CHECK(m.ev[move].x == 100); - CHECK(m.ev[move].y == 40); - CHECK(g_cursor.inWindow); - CHECK(g_cursor.inView); - CHECK(g_cursor.viewReq); - CHECK(g_cursor.exitWait); - CHECK(!m.conf.req); - - core_handleGuestMouseUpdate(); - CHECK(count(EV_GUEST) == 0); - - core_handleMouseNormal(1, 0); - CHECK(!m.conf.req); - CHECK(!g_cursor.exitRetry); - - g_cursor.pos.x = 104; - core_handleMouseNormal(1, 2); - CHECK(m.conf.req); - CHECK(g_cursor.pos.x == 99); - CHECK(g_cursor.inView); - CHECK(g_cursor.exitWait); - CHECK(g_cursor.exitRetry); - CHECK(count(EV_MOTION) == 0); - - setConf(true); - CHECK(g_cursor.inView); - CHECK(!g_cursor.exitWait); - CHECK(!g_cursor.exitRetry); - CHECK(count(EV_MOTION) == 1); - CHECK(m.ev[first(EV_MOTION)].x == 0); - CHECK(m.ev[first(EV_MOTION)].y == 2); - - setEdge(LG_DS_WARP_SURFACE); - core_handleMouseNormal(1, 0); - g_cursor.inWindow = false; - core_setCursorInView(false); - CHECK(!g_cursor.inWindow); - CHECK(!g_cursor.inView); - CHECK(!g_cursor.viewReq); - CHECK(!g_cursor.exitWait); - - setEdge(LG_DS_WARP_SCREEN); - core_handleMouseNormal(1, 0); - CHECK(!g_cursor.inWindow); -} - static void startExit(void) { reset(); @@ -452,7 +382,7 @@ static void testExitCancel(void) CHECK(g_cursor.exit); CHECK(!g_cursor.viewReq); - core_handleMouseNormal(-0.25, 0); + core_handleMouseNormal(-3, 0); CHECK(!g_cursor.exit); CHECK(g_cursor.viewReq); CHECK(m.conf.req); @@ -812,7 +742,6 @@ struct Test static const struct Test tests[] = { { "inset-exit" , testInsetExit }, - { "surface-edge" , testSurfaceEdge }, { "exit-delay" , testExitWait }, { "exit-guest" , testExitGuest }, { "exit-cancel" , testExitCancel },