mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-25 19:01:05 +00:00
* Source/NSWindow.m (-constrainFrameRect:toScreen:) Handle
screen being nil and resize only if moving is not enough. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@39126 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
eec45ae8a9
commit
cd9a83f6ed
2 changed files with 79 additions and 32 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
2015-11-02 Fred Kiefer <FredKiefer@gmx.de>
|
||||||
|
|
||||||
|
* Source/NSWindow.m (-constrainFrameRect:toScreen:) Handle screen
|
||||||
|
being nil and resize only if moving is not enough.
|
||||||
|
|
||||||
2015-11-02 Richard Frith-Macdonald <rfm@gnu.org>
|
2015-11-02 Richard Frith-Macdonald <rfm@gnu.org>
|
||||||
|
|
||||||
* Source/NSOutlineView.m:
|
* Source/NSOutlineView.m:
|
||||||
|
|
|
@ -2096,47 +2096,89 @@ titleWithRepresentedFilename(NSString *representedFilename)
|
||||||
*/
|
*/
|
||||||
- (NSRect) constrainFrameRect: (NSRect)frameRect toScreen: (NSScreen*)screen
|
- (NSRect) constrainFrameRect: (NSRect)frameRect toScreen: (NSScreen*)screen
|
||||||
{
|
{
|
||||||
NSRect screenRect = [screen visibleFrame];
|
NSRect screenRect;
|
||||||
CGFloat difference;
|
CGFloat difference;
|
||||||
|
|
||||||
|
if (nil == screen)
|
||||||
|
{
|
||||||
|
return frameRect;
|
||||||
|
}
|
||||||
|
|
||||||
|
screenRect = [screen visibleFrame];
|
||||||
|
|
||||||
|
if (NSHeight(frameRect) < NSHeight(screenRect))
|
||||||
|
{
|
||||||
/* Move top edge of the window inside the screen */
|
/* Move top edge of the window inside the screen */
|
||||||
difference = NSMaxY (frameRect) - NSMaxY (screenRect);
|
difference = NSMaxY (frameRect) - NSMaxY (screenRect);
|
||||||
if (difference > 0)
|
if (difference > 0)
|
||||||
{
|
{
|
||||||
frameRect.origin.y -= difference;
|
frameRect.origin.y -= difference;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* Move bottom edge of the window inside the screen */
|
||||||
|
difference = screenRect.origin.y - frameRect.origin.y;
|
||||||
|
if (difference > 0)
|
||||||
|
{
|
||||||
|
frameRect.origin.y += difference;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* If the window is resizable, resize it so that
|
||||||
|
it fits on the screen. */
|
||||||
|
if (_styleMask & NSResizableWindowMask)
|
||||||
|
{
|
||||||
|
/* Ensure that resizing doesn't make window smaller than minimum */
|
||||||
|
if (_minimumSize.height < NSHeight(screenRect))
|
||||||
|
{
|
||||||
|
frameRect.origin.y = NSMinY(screenRect);
|
||||||
|
frameRect.size.height = NSHeight(screenRect);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
frameRect.origin.y = NSMaxY(screenRect) - _minimumSize.height;
|
||||||
|
frameRect.size.height = _minimumSize.height;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* Adjust X origin, if needed */
|
if (NSWidth(frameRect) < NSWidth(screenRect))
|
||||||
|
{
|
||||||
|
/* Move right edge of the window inside the screen */
|
||||||
difference = NSMaxX (frameRect) - NSMaxX (screenRect);
|
difference = NSMaxX (frameRect) - NSMaxX (screenRect);
|
||||||
if (difference > 0)
|
if (difference > 0)
|
||||||
{
|
{
|
||||||
frameRect.origin.x -= difference;
|
frameRect.origin.x -= difference;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
/* If the window is resizable, resize it (if needed) so that the
|
{
|
||||||
bottom edge is on the screen or can be on the screen when the user moves
|
/* Move left edge of the window inside the screen */
|
||||||
the window */
|
difference = screenRect.origin.x - frameRect.origin.x;
|
||||||
difference = NSMaxY (screenRect) - NSMaxY (frameRect);
|
if (difference > 0)
|
||||||
|
{
|
||||||
|
frameRect.origin.x += difference;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* If the window is resizable, resize it so that
|
||||||
|
it fits on the screen. */
|
||||||
if (_styleMask & NSResizableWindowMask)
|
if (_styleMask & NSResizableWindowMask)
|
||||||
{
|
{
|
||||||
CGFloat difference2;
|
/* Ensure that resizing doesn't make window smaller than minimum */
|
||||||
|
if (_minimumSize.width < NSWidth(screenRect))
|
||||||
difference2 = screenRect.origin.y - frameRect.origin.y;
|
|
||||||
difference2 -= difference;
|
|
||||||
// Take in account the space between the top of window and the top of the
|
|
||||||
// screen which can be used to move the bottom of the window on the screen
|
|
||||||
if (difference2 > 0)
|
|
||||||
{
|
{
|
||||||
frameRect.size.height -= difference2;
|
frameRect.origin.x = NSMinX(screenRect);
|
||||||
frameRect.origin.y += difference2;
|
frameRect.size.width = NSWidth(screenRect);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
/* Ensure that resizing doesn't makewindow smaller than minimum */
|
|
||||||
difference2 = _minimumSize.height - frameRect.size.height;
|
|
||||||
if (difference2 > 0)
|
|
||||||
{
|
{
|
||||||
frameRect.size.height += difference2;
|
frameRect.origin.x = NSMaxX(screenRect) - _minimumSize.width;
|
||||||
frameRect.origin.y -= difference2;
|
frameRect.size.width = _minimumSize.width;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue