Changing the mouse cursor over a frontmost view of a non-active application

Our application is a login item which runs inactive in background, and in some cases, it shows its popovers in NSModalPanelWindowLevel over a window of an (unrelated) active application. That works well and without a glitch for years.

Now we'd like to change the mouse cursor when the mouse is over some subviews of our popover. Is there a way to do that?

I've tried essentially all the cursor-related APIs I know of, from the most obvious cursorRects through trackingAreas up to the low-level explicit NSCursor.push/set, but whatever I do, looks like macOS simply ignores it and keeps showing the arrow default cursor, even though the mouse is over our window whose views have proper cursorRects or explicitly call NSCursor.push/set etc. Is there a trick to change the cursor in this case? Thanks!

NSTrackingArea should be the right API to do this, with the activeAlways option set so that your inactive app's tracking areas are respected. Note though that the documentation says that there are no cursorUpdate calls in this case:

https://developer.apple.com/documentation/appkit/nstrackingarea/options/

I would assume the correct approach would be to use the mouseEntered/mouseMoved calls instead, to adjust the cursor over your tracking area. In theory, that should work because — when the mouse pointer is over a visible portion of your window — it is by definition not inside any other app's tracking areas, but I haven't actually tried this, so there may be some edge cases here that don't work too well.

NSTrackingArea with cursorUpdate does not work (it is documented not to; I've tried it just out of desperation since no other way worked either).

NSTrackingArea with mouseEntered: and mouseExited: is not related to the mouse cursor shape at all, far as I understand properly. Do please correct me if I am wrong, but I understand that's just one possible way (there are others as well) to detect that the current mouse position is over my view. That's not the problem. The problem is changing the cursor. I presume I should call NSCursor.push (or set) when entered, pop (or a manual reset) when exited. Which, as mentioned above, does not work for me :(

Does it work for you (ie. does NSCursor.push or set work for you even when called from an inactive application), which would mean I am doing something wrong?

Changing the mouse cursor over a frontmost view of a non-active application
 
 
Q