Carbon ClientToScreen does not agree with GetCursorPos
Original Reporter info from Mantis: jcjr
-
Reporter name: James Chandler Jr.
Original Reporter info from Mantis: jcjr
- Reporter name: James Chandler Jr.
Description:
On PC Lazarus (and Delphi), ClientToScreen gives global mouse coordinates which agree perfectly with GetCursorPos. They also both agree with what you get with SetCursorPos.
On Mac Lazarus (at least Intel Mac 10.4), the Y returned by ClientToScreen is bigger than the Y returned by GetCursorPos.
On Mac Lazarus, the Y returned by ClientToScreen is measured from the top of the screen, but the Y returned by GetCursorPos is measured from the bottom of the Menu Bar.
On my Mac, this causes the ClientToScreen Y to be 22 pixels larger than the GetCursorPos Y.
These numbers should agree, because custom controls such as sliders can use ClientToScreen to determine a screen location reference, and then calculate the slider value by comparing that with GetCursorPos.
Also, I wrote a Carbon SetCursorPos function (which carbon Lazarus did not have). I will submit the SetCursorPos in another report.
But I need to know whether my SetCursorPos should use the Y returned from ClientToScreen (measured from screen top), or whether my SetCursorPos should use the Y you get from GetCursorPos (measured from MenuBar bottom).
I can get my new carbon SetCursorPos to agree with ClientToScreen by subtracting the Y by FPCMacOSAll.GetMBarHeight before warping the cursor. But if I do that, it will not agree with GetCursorPos.
One solution: Add GetMBarHeight to GetCursorPos Y. That would make GetCursorPos agree with ClientToScreen. And then if my new SetCursorPos subtracts its Y by GetMBarHeight, all three metrics would match and be usable by controls.
Maybe there is a more elegant solution.
Additional information:
Attached is a PC Lazarus simple example program which demonstrates that ClientToScreen agrees with GetCursorPos on the PC.
I have run this same code on Mac Lazarus, and on Mac the two coordinates do not match.
Mantis conversion info:
- Mantis ID: 9921
- Version: 0.9.23 (SVN)
- Fixed in version: 0.9.25 (SVN)
- Fixed in revision: 13091 (#5f40a1f3)
- Target version: 1.2