mirror of
https://github.com/moonlight-stream/moonlight-chrome.git
synced 2025-08-17 16:46:31 +00:00
Window state restored with previous saved window state (fullscreen or normal).
Window startup size changed to 16:9 aspect ratio = 960x540. After closing the game, window restored in previous state.
This commit is contained in:
parent
46a930ad11
commit
5ebcc58ae3
@ -1,8 +1,45 @@
|
|||||||
|
var windowState = 'normal';
|
||||||
|
|
||||||
chrome.app.runtime.onLaunched.addListener(function() {
|
chrome.app.runtime.onLaunched.addListener(function() {
|
||||||
|
if (chrome.storage) {
|
||||||
|
// load stored window settings
|
||||||
|
chrome.storage.sync.get('windowState', function(item) {
|
||||||
|
windowState = (item && item.windowState)
|
||||||
|
? item.windowState
|
||||||
|
: windowState;
|
||||||
|
createWindow(windowState);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
createWindow(windowState);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
function createWindow(state) {
|
||||||
chrome.app.window.create('index.html', {
|
chrome.app.window.create('index.html', {
|
||||||
state: "normal",
|
state: state,
|
||||||
bounds: {
|
bounds: {
|
||||||
width: 850, height: 500
|
width: 960,
|
||||||
}
|
height: 540
|
||||||
|
}
|
||||||
|
}, function(window) {
|
||||||
|
window.onFullscreened.addListener(onFullscreened);
|
||||||
|
window.onBoundsChanged.addListener(onBoundsChanged);
|
||||||
});
|
});
|
||||||
});
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function onFullscreened() {
|
||||||
|
// save windowState: 'fullscreen'
|
||||||
|
windowState != 'fullscreen' && saveItem('windowState', 'fullscreen', null);
|
||||||
|
}
|
||||||
|
|
||||||
|
function onBoundsChanged() {
|
||||||
|
// save windowState: 'normal'
|
||||||
|
windowState != 'normal' && saveItem('windowState', 'normal', null);
|
||||||
|
}
|
||||||
|
|
||||||
|
function saveItem(key, value, callback) {
|
||||||
|
var item = { };
|
||||||
|
item[key] = value;
|
||||||
|
chrome.storage && chrome.storage.sync.set(item, callback);
|
||||||
|
}
|
@ -30,7 +30,6 @@ function handleMessage(msg) {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
showApps(api);
|
showApps(api);
|
||||||
chrome.app.window.current().restore();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
} else if(msg.data === 'Connection Established') {
|
} else if(msg.data === 'Connection Established') {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user