Cocoa/MultiDisplay: fix the bug about GetCocoaWindowAtPos() in TCocoaWSPopupMenu.Popup()

This commit is contained in:
rich2014 2023-10-18 00:08:12 +08:00
parent afc2dae9d3
commit 98acb93c9a

View File

@ -967,7 +967,7 @@ begin
// in macOS it's possible to "rightclick" without focusing a window
// so let's try to find the window
if not Assigned(w) then
w := GetCocoaWindowAtPos( NSMakePoint(px, py) );
w := GetCocoaWindowAtPos( NSMakePoint(px, Round(NSGlobalScreenHeight) - py) );
if Assigned(w) then
begin
@ -975,17 +975,17 @@ begin
if Assigned(view) then
begin
// LCL Screen coordinate
menuY := round(NSGlobalScreenHeight - w.screen.visibleFrame.origin.y - menu.size.height) - 1;
menuY := Round(NSGlobalScreenHeight - w.screen.visibleFrame.origin.y - menu.size.height) - 1;
py := min(py, menuY);
view.lclScreenToLocal(px, py);
// have to flip again, because popUpMenuPositioningItem expects point
// to be in View coordinates and it does respect Flipped flag
if not view.isFlipped then
py := Round(view.frame.size.height - py);
py := Round(view.frame.size.height) - py;
end;
end
else
py := Round(NSGlobalScreenHeight - py);
py := Round(NSGlobalScreenHeight) - py;
menu.popUpMenuPositioningItem_atLocation_inView(nil, NSMakePoint(px, py), view);
APopupMenu.Close; // notify LCL popup menu