prefersPointerLocked not worked properly if run on MacOS environment

Hi community.

I am trying to adopt my first person shooter iOS game for running on MacOS environment. I need to lock the pointer when I enter battle mode, and unlock in lobby. On iOS all works fine (with mouse and keyboard) - pointer locks and unlocks according to my commands.

However, on MacOS I faced the following behavior: after switching the pointer lock state and setNeedsUpdateOfPrefersPointerLocked invocation, the pointer does not locked immediately. To enable pointer lock, the user must click in the window.

I checked the criteria listed in documentation: I do have fullscreen mode, I monitor UISceneActivationState and can confirm it is UISceneActivationStateForegroundActive, I do not use MacCatalyst (it is disabled in app's capabilities). However pointer locks only after click on window, which is weird.

Can someone confirm that this is the exact behaviour as designed by Apple developers, or am I doing anything wrong. I have read the note: "Bringing an app built with Mac Catalyst to the foreground doesn’t immediately enable pointer lock. To enable pointer lock, the user must click in the window. To exit pointer lock, users can use Command-tab to switch to another app, or using Command-tilde.", but again, I don't use MacCatalyst.

Any hints are highly appreciated! Best regards.

refs: https://developer.apple.com/documentation/apple-silicon/running-your-ios-apps-in-macos https://developer.apple.com/documentation/uikit/uiviewcontroller/3601235-preferspointerlocked?language=objc

prefersPointerLocked not worked properly if run on MacOS environment
 
 
Q