Fix -center to center on the main screen if window is off screen

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/branches/gnustep_testplant_branch@35655 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Doug Simons 2012-10-08 21:47:53 +00:00
parent 2dd7f9fdcb
commit 0daa47b6fc
2 changed files with 10 additions and 1 deletions

View file

@ -1,3 +1,7 @@
2012-10-08 Doug Simons <doug.simons@testplant.com>
* NSWindow.m: Center on the main screen if window is off screen.
2012-09-04 Jonathan Gillaspie <jonathan.gillaspie@testplant.com>
* Source/NSWorkspace.m: Log if we have a distributed lock error instead of raise fatally.

View file

@ -2067,7 +2067,12 @@ many times.
- (void) center
{
NSSize screenSize = [[self screen] visibleFrame].size;
NSScreen *screen = [self screen];
// if not visible on any screen, center on the main screen
if (!screen) {
screen = [NSScreen mainScreen];
}
NSSize screenSize = [screen visibleFrame].size;
NSPoint origin = _frame.origin;
origin.x = (screenSize.width - _frame.size.width) / 2;