mirror of
https://github.com/moonlight-stream/moonlight-chrome.git
synced 2025-08-17 08:36:42 +00:00
Bugfix: window always run in fullscreen mode when app launched from chrome://apps or chrome://extensions
33 lines
986 B
JavaScript
33 lines
986 B
JavaScript
function createWindow(state) {
|
|
chrome.app.window.create('index.html', {
|
|
state: state,
|
|
bounds: {
|
|
width: 960,
|
|
height: 540
|
|
}
|
|
}, function(window) {
|
|
// workaround:
|
|
// state = 'normal' in some cases not work (e.g. starting app from 'chrome://extensions' always open window in fullscreen mode)
|
|
// it requires manually restoring window state to 'normal'
|
|
if (state == 'normal') {
|
|
setTimeout(function() { window.restore(); }, 1000);
|
|
}
|
|
});
|
|
}
|
|
|
|
chrome.app.runtime.onLaunched.addListener(function() {
|
|
var windowState = 'normal';
|
|
|
|
if (chrome.storage) {
|
|
// load stored window state
|
|
chrome.storage.sync.get('windowState', function(item) {
|
|
windowState = (item && item.windowState)
|
|
? item.windowState
|
|
: windowState;
|
|
createWindow(windowState);
|
|
});
|
|
} else {
|
|
createWindow(windowState);
|
|
}
|
|
});
|