From 9a86280a6378615c70f8463e649ab0b025c2018a Mon Sep 17 00:00:00 2001 From: spl3g Date: Fri, 10 Oct 2025 22:17:32 +0300 Subject: Fix clay pointer state update bug --- third-party/clay/clay.h | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/third-party/clay/clay.h b/third-party/clay/clay.h index 7adf9ea..58a6093 100644 --- a/third-party/clay/clay.h +++ b/third-party/clay/clay.h @@ -3964,8 +3964,24 @@ void Clay_SetPointerState(Clay_Vector2 position, bool isPointerDown) { if (context->booleanWarnings.maxElementsExceeded) { return; } + context->pointerInfo.position = position; context->pointerOverIds.length = 0; + + if (isPointerDown) { + if (context->pointerInfo.state == CLAY_POINTER_DATA_PRESSED_THIS_FRAME) { + context->pointerInfo.state = CLAY_POINTER_DATA_PRESSED; + } else if (context->pointerInfo.state != CLAY_POINTER_DATA_PRESSED) { + context->pointerInfo.state = CLAY_POINTER_DATA_PRESSED_THIS_FRAME; + } + } else { + if (context->pointerInfo.state == CLAY_POINTER_DATA_RELEASED_THIS_FRAME) { + context->pointerInfo.state = CLAY_POINTER_DATA_RELEASED; + } else if (context->pointerInfo.state != CLAY_POINTER_DATA_RELEASED) { + context->pointerInfo.state = CLAY_POINTER_DATA_RELEASED_THIS_FRAME; + } + } + Clay__int32_tArray dfsBuffer = context->layoutElementChildrenBuffer; for (int32_t rootIndex = context->layoutElementTreeRoots.length - 1; rootIndex >= 0; --rootIndex) { dfsBuffer.length = 0; @@ -4013,20 +4029,6 @@ void Clay_SetPointerState(Clay_Vector2 position, bool isPointerDown) { break; } } - - if (isPointerDown) { - if (context->pointerInfo.state == CLAY_POINTER_DATA_PRESSED_THIS_FRAME) { - context->pointerInfo.state = CLAY_POINTER_DATA_PRESSED; - } else if (context->pointerInfo.state != CLAY_POINTER_DATA_PRESSED) { - context->pointerInfo.state = CLAY_POINTER_DATA_PRESSED_THIS_FRAME; - } - } else { - if (context->pointerInfo.state == CLAY_POINTER_DATA_RELEASED_THIS_FRAME) { - context->pointerInfo.state = CLAY_POINTER_DATA_RELEASED; - } else if (context->pointerInfo.state != CLAY_POINTER_DATA_RELEASED) { - context->pointerInfo.state = CLAY_POINTER_DATA_RELEASED_THIS_FRAME; - } - } } CLAY_WASM_EXPORT("Clay_Initialize") -- cgit v1.2.3