mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
bug 864107 - constrain restored window dimensions to available screen area. r=ttaubert
This commit is contained in:
parent
659b807986
commit
adb8ad49b0
@ -83,6 +83,8 @@ Cu.import("resource://gre/modules/commonjs/sdk/core/promise.js", this);
|
||||
|
||||
XPCOMUtils.defineLazyServiceGetter(this, "gSessionStartup",
|
||||
"@mozilla.org/browser/sessionstartup;1", "nsISessionStartup");
|
||||
XPCOMUtils.defineLazyServiceGetter(this, "gScreenManager",
|
||||
"@mozilla.org/gfx/screenmanager;1", "nsIScreenManager");
|
||||
|
||||
// List of docShell capabilities to (re)store. These are automatically
|
||||
// retrieved from a given docShell if not already collected before.
|
||||
@ -3579,6 +3581,31 @@ let SessionStoreInternal = {
|
||||
var _this = this;
|
||||
function win_(aName) { return _this._getWindowDimension(win, aName); }
|
||||
|
||||
// find available space on the screen where this window is being placed
|
||||
let screen = gScreenManager.screenForRect(aLeft, aTop, aWidth, aHeight);
|
||||
if (screen) {
|
||||
let screenLeft = {}, screenTop = {}, screenWidth = {}, screenHeight = {};
|
||||
screen.GetAvailRectDisplayPix(screenLeft, screenTop, screenWidth, screenHeight);
|
||||
// constrain the dimensions to the actual space available
|
||||
if (aWidth > screenWidth.value) {
|
||||
aWidth = screenWidth.value;
|
||||
}
|
||||
if (aHeight > screenHeight.value) {
|
||||
aHeight = screenHeight.value;
|
||||
}
|
||||
// and then pull the window within the screen's bounds
|
||||
if (aLeft < screenLeft.value) {
|
||||
aLeft = screenLeft.value;
|
||||
} else if (aLeft + aWidth > screenLeft.value + screenWidth.value) {
|
||||
aLeft = screenLeft.value + screenWidth.value - aWidth;
|
||||
}
|
||||
if (aTop < screenTop.value) {
|
||||
aTop = screenTop.value;
|
||||
} else if (aTop + aHeight > screenTop.value + screenHeight.value) {
|
||||
aTop = screenTop.value + screenHeight.value - aHeight;
|
||||
}
|
||||
}
|
||||
|
||||
// only modify those aspects which aren't correct yet
|
||||
if (aWidth && aHeight && (aWidth != win_("width") || aHeight != win_("height"))) {
|
||||
aWindow.resizeTo(aWidth, aHeight);
|
||||
|
Loading…
Reference in New Issue
Block a user