On Sun, 4 May 2025 20:52:47 GMT, Alisen Chung <ach...@openjdk.org> wrote:

> > > So this seems to be a bug in macOS, as the reported mouse location is 
> > > incorrect while it is actually positioned at the edge?
> > > Probably, there are other macOS APIs that could be used to implement 
> > > Java_sun_lwawt_macosx_CCursorManager_nativeGetCursorPosition. Or perhaps 
> > > the methods within it should be called on the appkit thread - I see a 
> > > potential race, since the mouse is moved asynchronously on appkit, but 
> > > the coordinates are fetched on the current thread.
> > 
> > 
> > Did you have a chance to check our implementation of setting and getting 
> > the cursor?
> 
> I took a look at the cocoa documentation and I wasn't able to find any APIs 
> that handle clamping. I also looked at our implementation: we create an empty 
> mouse event then grab the location of that event. Since macOS doesn't do 
> clamping, we would need to add clamping code to nativeGetCursorPosition after 
> we grab the location of that empty event. I think it's easier to just do the 
> clamping in CRobot on mouseMove instead since that would be the only way for 
> the mouse to initially reach out of bounds. What do you think?

I (we) looked at the code that was reporting the off-screen mouse position 
several weeks ago.
What we are doing seems to correspond to all the suggestions on the internet as 
to how to get mouse position on macOS.
I didn't spot any obvious alternative.

-------------

PR Comment: https://git.openjdk.org/jdk/pull/22781#issuecomment-2852102362

Reply via email to