There is a bug on desktop where if you're trying t...
# compose-desktop
a
There is a bug on desktop where if you're trying to switch from one custom pointer icon (mouse cursor) to another, it doesn't work because AWT cursor class treats all custom cursors as equal, so we don't update the cursor properly. It used to work in Compose 1.5.10, but it stopped working in 1.6, iirc. Here's a workaround that I'm using, switch to a standard cursor every time the cursor updates:
Copy code
var pointerIcon by remember { mutableStateOf(state.mouseCursor.pointerIcon) }
// There is a bug with updating the cursor when going from one custom cursor to another.
// This is due to AWT Cursor equals() implementation that makes all custom cursors equal, so
// Compose skips the update.
// The trick is to set the default cursor momentarily before the new custom cursor, to force the
// change to be detected.
val mouseCursor = state.mouseCursor
LaunchedEffect(mouseCursor) {
    pointerIcon = PointerIcon.Default
    delay(16) // delay by a frame
    pointerIcon = mouseCursor.pointerIcon
}
I also had to write a MouseCursor class that implements equality properly (it uses the resource path of the cursor image for custom cursors).
e
what about
Copy code
var pointerIcon by remember { mutableStateOf(pointerIcon, referentialEqualityPolicy() }
or
neverEqualPolicy()
a
Thanks for the suggestion! I tried and it doesn't work. I think there's an equality check that's happening inside of the modifier, so it doesn't make a difference if we can make
pointerIcon
fire a new state unfortunately
j
To wait a frame call
withFrameNanos { }
a
Thx for the suggestion! It does not seem to work though..