问题
I am making a canvas game in a chrome app with it's own window. I made my game resize with the window's size using window.onResize
. Since my game is made with an 8-bit style, I don't want the default window size to have blurry pixels because it is partially resized.
I am aware that you can specify the window's size in the background.js
file, but when the window opens, the size of the window includes the title bar.
Basically, I want the game height to be 400px, but I can only set the window height. The title bar is included in the window height, so different operating systems with different title bar heights will affect the size of the game height. I need a way to detect the height of the operating systems title bar height in background.js
.
回答1:
To fully control window size of the app create a frameless window that won't have any built-in decorations, draw everything yourself.
chrome.app.runtime.onLaunched.addListener(function() {
chrome.app.window.create("window.html", {
frame: "none",
.............
});
});
chrome.app.window API documentation provides a sample app, here's a screenshot:
来源:https://stackoverflow.com/questions/33740780/detect-the-the-title-bar-height-for-a-window-for-different-operating-systems-wit