mirror of
https://github.com/moonlight-stream/moonlight-chrome.git
synced 2026-04-20 07:00:28 +00:00
Bugfix: window state not restored in normal mode after streaming.
Bugfix: window always run in fullscreen mode when app launched from chrome://apps or chrome://extensions
This commit is contained in:
@@ -1,8 +1,25 @@
|
||||
var windowState = 'normal';
|
||||
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 settings
|
||||
// load stored window state
|
||||
chrome.storage.sync.get('windowState', function(item) {
|
||||
windowState = (item && item.windowState)
|
||||
? item.windowState
|
||||
@@ -13,33 +30,3 @@ chrome.app.runtime.onLaunched.addListener(function() {
|
||||
createWindow(windowState);
|
||||
}
|
||||
});
|
||||
|
||||
function createWindow(state) {
|
||||
chrome.app.window.create('index.html', {
|
||||
state: state,
|
||||
bounds: {
|
||||
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);
|
||||
}
|
||||
Reference in New Issue
Block a user