Use Chrome's window position memory instead of manually restoring position.

This commit is contained in:
Thomas Wilburn 2013-11-24 21:08:18 -05:00
parent 3117a046c2
commit fa0ab6112e
2 changed files with 16 additions and 29 deletions

View file

@ -18,30 +18,23 @@ var openWindow = function() {
}
//otherwise, open a new window
chrome.storage.local.get("bounds", function(data) {
var defaults = {
width: 800,
height: 600,
left: 50,
top: 50
};
var bounds = data.bounds || defaults;
//sanity check the bounds information -- also need to add maximums
if (bounds.left < 0 || bounds.top < 0 || bounds.width < 0 || bounds.height < 0) {
bounds = defaults;
}
chrome.app.window.create("main.html", {
bounds: bounds
}, function(win) {
mainWindow = win;
win.contentWindow.launchData = files;
mainWindow.onClosed.addListener(function() {
mainWindow = null;
});
files = [];
timeout = null;
var defaults = {
width: 800,
height: 600,
left: 50,
top: 50
};
chrome.app.window.create("main.html", {
bounds: defaults,
id: "caret:main"
}, function(win) {
mainWindow = win;
win.contentWindow.launchData = files;
mainWindow.onClosed.addListener(function() {
mainWindow = null;
});
files = [];
timeout = null;
});
}

View file

@ -12,12 +12,6 @@ require([
var frame = chrome.app.window.current();
//store window dimensions on resize
frame.onBoundsChanged.addListener(function() {
var bounds = frame.getBounds();
chrome.storage.local.set({bounds: bounds});
});
command.on("app:exit", function() {
frame.close();
});