mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-05-31 10:50:47 +00:00
Fix cascadeTopLeftFromPoint to select main screen if window is off screen
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/branches/gnustep_testplant_branch@35769 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
71738e0dea
commit
17ebc6fcf0
1 changed files with 22 additions and 15 deletions
|
@ -1971,32 +1971,39 @@ titleWithRepresentedFilename(NSString *representedFilename)
|
|||
- (NSPoint) cascadeTopLeftFromPoint: (NSPoint)topLeftPoint
|
||||
{
|
||||
NSRect cRect;
|
||||
|
||||
if (NSEqualPoints(topLeftPoint, NSZeroPoint) == YES)
|
||||
|
||||
// Adjust top left point if not on a screen...
|
||||
CGFloat yValue = topLeftPoint.y - _frame.size.height;
|
||||
NSRect frame = NSMakeRect(topLeftPoint.x, yValue, _frame.size.width, _frame.size.height);
|
||||
if ([self _screenForFrame: frame] == nil)
|
||||
{
|
||||
NSScreen *screen = [NSScreen mainScreen];
|
||||
NSRect sFrame = [screen visibleFrame];
|
||||
topLeftPoint = sFrame.origin;
|
||||
}
|
||||
else if (NSEqualPoints(topLeftPoint, NSZeroPoint) == YES)
|
||||
{
|
||||
topLeftPoint.x = NSMinX(_frame);
|
||||
topLeftPoint.y = NSMaxY(_frame);
|
||||
}
|
||||
|
||||
|
||||
[self setFrameTopLeftPoint: topLeftPoint];
|
||||
cRect = [self contentRectForFrameRect: _frame];
|
||||
topLeftPoint.x = NSMinX(cRect);
|
||||
topLeftPoint.y = NSMaxY(cRect);
|
||||
|
||||
/* make sure the new point is inside the screen */
|
||||
if ([self screen])
|
||||
NSScreen *screen = [self screen];
|
||||
if (screen == nil)
|
||||
screen = [NSScreen mainScreen];
|
||||
NSRect screenRect = [screen visibleFrame];
|
||||
if (topLeftPoint.x >= NSMaxX(screenRect))
|
||||
{
|
||||
NSRect screenRect;
|
||||
|
||||
screenRect = [[self screen] visibleFrame];
|
||||
if (topLeftPoint.x >= NSMaxX(screenRect))
|
||||
{
|
||||
topLeftPoint.x = NSMinX(screenRect);
|
||||
}
|
||||
if (topLeftPoint.y <= NSMinY(screenRect))
|
||||
{
|
||||
topLeftPoint.y = NSMaxY(screenRect);
|
||||
}
|
||||
topLeftPoint.x = NSMinX(screenRect);
|
||||
}
|
||||
if (topLeftPoint.y <= NSMinY(screenRect))
|
||||
{
|
||||
topLeftPoint.y = NSMaxY(screenRect);
|
||||
}
|
||||
|
||||
return topLeftPoint;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue