Skip to content

Fix pointer state update order in Clay_SetPointerState hover dispatch#587

Open
Harry-425 wants to merge 1 commit into
nicbarker:mainfrom
Harry-425:fix-pointer-state-before-hover-callback
Open

Fix pointer state update order in Clay_SetPointerState hover dispatch#587
Harry-425 wants to merge 1 commit into
nicbarker:mainfrom
Harry-425:fix-pointer-state-before-hover-callback

Conversation

@Harry-425
Copy link
Copy Markdown

Summary

This changes Clay_SetPointerState so context->pointerInfo.state is updated before ephemeral memory initialization and hover callback traversal.

Problem

Clay_OnHover callbacks can read pointerInfo.state to detect click/press events. Previously, callbacks were invoked while pointerInfo.state still held the previous frame state; the new state was written only after traversal. This caused handlers that check CLAY_POINTER_DATA_PRESSED_THIS_FRAME to miss a first click and react only on a follow-up frame.

Fix

  • Compute newState from current state + isPointerDown.
  • Assign context->pointerInfo.position and context->pointerInfo.state = newState before Clay__InitializeEphemeralMemory(context) and DFS traversal.
  • Keep traversal and hover logic unchanged.

Impact

  • Hover/click handlers receive the correct current-frame pointer state during callback execution.
  • No API changes.
  • No behavior changes outside pointer-state ordering during callback dispatch.

Notes

This was validated in a WASM app using Clay where button handlers inspect pointerInfo.state == CLAY_POINTER_DATA_PRESSED_THIS_FRAME.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants