Implement it the way @fredkiefer suggested. Check which side has more room.

This commit is contained in:
Gregory John Casamento 2023-01-06 03:11:52 -05:00
parent d649b99418
commit b12d151163

View file

@ -601,32 +601,38 @@ static NSNotificationCenter *nc = nil;
NSRectEdge result = _preferredEdge;
NSRect windowFrame = [[self parentWindow] frame];
NSRect screenRect = [[NSScreen mainScreen] frame];
// Diffs,,,
CGFloat top = screenRect.size.height - (windowFrame.origin.y + windowFrame.size.height);
CGFloat bottom = windowFrame.origin.y;
CGFloat right = screenRect.size.width - (windowFrame.origin.x + windowFrame.size.width);
CGFloat left = windowFrame.origin.x;
switch (_preferredEdge)
{
case NSMinXEdge:
if (windowFrame.origin.x < _maxContentSize.width)
if (right > left)
{
result = NSMaxXEdge;
}
break;
case NSMinYEdge:
if (windowFrame.origin.y < _maxContentSize.height)
if (top > bottom)
{
result = NSMaxYEdge;
}
break;
case NSMaxXEdge:
if (windowFrame.origin.x + windowFrame.size.width > screenRect.size.width)
if (left > right)
{
result = NSMinXEdge;
}
break;
case NSMaxYEdge:
if (windowFrame.origin.y + windowFrame.size.height > screenRect.size.height)
if (bottom > top)
{
result = NSMinYEdge;
}