Save window size and position. Fixes #45

This commit is contained in:
Corey Johnson
2011-11-07 15:52:52 -08:00
parent 8243046a73
commit 3df83d10d8
3 changed files with 33 additions and 7 deletions

View File

@@ -23,7 +23,9 @@
AtomController *controller = [[AtomController alloc] initWithPath:path];
[controllers addObject:controller];
[[controller window] makeKeyWindow];
// window.coffee will set the window size
[[controller window] setFrame:NSMakeRect(0, 0, 0, 0) display:YES animate:NO];
return controller;
}
@@ -81,6 +83,14 @@
}
}
- (void)terminate:(id)sender {
for (AtomController *controller in controllers) {
[controller.jscocoa callJSFunctionNamed:@"shutdown" withArguments:nil];
}
[super terminate:sender];
}
// AppDelegate
- (void)applicationWillFinishLaunching:(NSNotification *)aNotification {
self.controllers = [NSMutableArray array];

View File

@@ -73,5 +73,5 @@
[(AtomApp *)NSApp removeController:self];
return YES;
}
@end

View File

@@ -28,6 +28,12 @@ windowAdditions =
@path = $atomController.path
@setTitle _.last @path.split '/'
# Remember sizing!
defaultFrame = x: 0, y: 0, width: 600, height: 800
frame = Storage.get "window.frame.#{@path}", defaultFrame
rect = OSX.CGRectMake(frame.x, frame.y, frame.width, frame.height)
$atomController.window.setFrame_display rect, true
@editor = new Editor
@browser = new Browser
@@ -37,8 +43,18 @@ windowAdditions =
@editor.restoreOpenBuffers()
storageKey: ->
"window:" + @path
$atomController.window.makeKeyWindow
shutdown: ->
extension.shutdown() for name, extension of @extensions
frame = $atomController.window.frame
x = frame.origin.x
y = frame.origin.y
width = frame.size.width
height = frame.size.height
Storage.set "window.frame.#{@path}", {x:x, y:y, width:width, height:height}
loadExtensions: ->
extension.shutdown() for name, extension of @extensions
@@ -79,19 +95,19 @@ windowAdditions =
$atomController.window.title = title
reload: ->
@shutdown()
$atomController.close
OSX.NSApp.createController @path
open: (path) ->
$atomController.window.makeKeyAndOrderFront atomController
$atomController.window.makeKeyAndOrderFront $atomController
Event.trigger 'window:open', path
close: (path) ->
extension.shutdown() for name, extension of @extensions
@shutdown()
$atomController.close
Event.trigger 'window:close', path
# Global methods that are used by the cocoa side of things
handleKeyEvent: ->
KeyBinder.handleEvent.apply KeyBinder, arguments