i am writing a text editor, i need the app window be always on top when switching to browser or e-book reader software. as i know ,for windows users, chrome doesn't provide any solution. is there any parameter to send when creating window to make window always on top?
or can i provide any button in app to turn this feature on or off?
Code i use to create window in bg.js:
var launch = function () {
chrome.app.window.create('index.html', {
type: 'shell',
width: 440,
height: 680,
minWidth: 440,
maxHeight: 680,
id: 'paat-start'
});
};
chrome.app.runtime.onLaunched.addListener(launch);
chrome.commands.onCommand.addListener(launch);
thank for any suggestion.
As Ben Wells mentioned above, this feature is now available in the stable release (either v33 or v34) via the alwaysOnTop
option in chrome.app.windows.create
. Note that special permissions are required in the manifest.json
file. Example:
chrome.app.window.create('window.html', {
alwaysOnTop: true,
}, function (appWindow) {
// Window created and will remain on top of others.
// Change the property programmatically via:
//appWindow.setAlwaysOnTop();
});
manifest.json
"permissions": [
"alwaysOnTopWindows"
]
This seems to have been added in issue 26427002, gone stable in issue 159523002 and issue 48113024 thanks to the community!
I had looked into this a while back and wanted to catalog my findings since historically there were some discrepancies in the documentation which previously stated the name of the required permission was alwaysOnTop
, but using this caused a "permission is unknown" error.
Reading through the original proposal for this feature lead me to issue 326361 which mentions the permission setting is actually called alwaysOnTopWindows
. Using this one back then, however, yielded a "requires Google Chrome dev channel or newer" error (probably since the feature wasn't yet stable).
I did find it peculiar from browsing the source code, these two permissions might be aliases of each other, but that might be because I don't fully understand the Chromium codebase.
chrome.app.window.create
does support a boolean alwaysOnTop
option in more recent versions of Chrome. The feature is currently in beta channel on most platforms and at least dev channel on the rest.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With