Improve window restoring

Zoom or minimize windows before ordering them front, and for the latter, don’t actually order them front (as that magnifies them). Also order front windows without also setting the window as key window.
This commit is contained in:
Allan Odgaard
2014-10-21 09:28:52 +02:00
parent 73999c09ae
commit df1a29d7b0

View File

@@ -2458,27 +2458,43 @@ static NSUInteger DisableSessionSavingCount = 0;
BOOL res = NO;
++DisableSessionSavingCount;
NSWindow* keyWindow;
NSDictionary* session = [NSDictionary dictionaryWithContentsOfFile:[self sessionPath]];
for(NSDictionary* project in session[@"projects"])
{
DocumentController* controller = [DocumentController new];
[controller setupControllerForProject:project skipMissingFiles:NO];
if(controller.documents.empty())
continue;
if(NSString* windowFrame = project[@"windowFrame"])
{
if([windowFrame hasPrefix:@"{"]) // Legacy NSRect
[controller.window setFrame:NSRectFromString(windowFrame) display:NO];
else [controller.window setFrameFromString:windowFrame];
}
[controller showWindow:nil];
if([project[@"miniaturized"] boolValue])
{
[controller.window miniaturize:nil];
else if([project[@"fullScreen"] boolValue])
[controller.window toggleFullScreen:self];
else if([project[@"zoomed"] boolValue])
[controller.window zoom:self];
}
else
{
if([project[@"fullScreen"] boolValue])
[controller.window toggleFullScreen:self];
else if([project[@"zoomed"] boolValue])
[controller.window zoom:self];
[controller.window orderFront:self];
keyWindow = controller.window;
}
res = YES;
}
[keyWindow makeKeyWindow];
--DisableSessionSavingCount;
return res;
}