For testing purposes, I am using the sample app:
The background controller has this block of code:
overwolf.windows.onStateChanged.addListener(async () => {
const openWindows = await WindowsService.getOpenWindows();
if (Object.keys(openWindows).length <= 1) {
window.close();
}
});
In the manifest.json, the desktop window has the following attributes:
"native_window": true,
"desktop_only": true,
The app works fine as it is.
If you removed the mentioned attributes from the manfiest.json the app will close by itself. Why? commenting out the conditional block and adding console.log(openWindows)
shows:
The first time it’s triggered, the only open windows are background and so it will close the app.
If I put back the attributes in manifest.json, the result is similar to above without the first log that states that the background window is the sole window open.
I made another test where I commented out the overwolf.windows.restore()
block
within the restore function supplied by the windows-service.js
function restore(name) {
return new Promise(async (resolve, reject) => {
try {
await obtainWindow(name);
// overwolf.windows.restore(name, (result) => {
// if (result.status === 'success') {
// resolve();
// } else {
// reject(result);
// }
// });
} catch (e) {
reject(e)
}
});
}
The window is only obtained
, so the window doesn’t appear as predicted.
Going back to the backgorund controller. The overwolf.windows.onStateChanged
block mentioned earlier is triggered when the attributes are in the manifest.json showing that the open windows are background & main. On the other hand, when the attributes aren’t in the manifest.json, it’s not triggered at all.
I didn’t do any scaling or change for the window, but I believe that this might be related to the issue at hand.