mirror of
https://github.com/overte-org/overte.git
synced 2025-04-26 06:16:24 +02:00
Center new windows without a defined position
This commit is contained in:
parent
fee920723a
commit
9a8d56da77
1 changed files with 4 additions and 3 deletions
|
@ -211,15 +211,16 @@ FocusScope {
|
||||||
var windowRect = targetWindow.framedRect();
|
var windowRect = targetWindow.framedRect();
|
||||||
var minPosition = Qt.vector2d(-windowRect.x, -windowRect.y);
|
var minPosition = Qt.vector2d(-windowRect.x, -windowRect.y);
|
||||||
var maxPosition = Qt.vector2d(desktop.width - windowRect.width, desktop.height - windowRect.height);
|
var maxPosition = Qt.vector2d(desktop.width - windowRect.width, desktop.height - windowRect.height);
|
||||||
var newPosition;
|
var newPosition = Qt.vector2d(targetWindow.x, targetWindow.y);
|
||||||
if (targetWindow.x === -1 && targetWindow.y === -1) {
|
if (newPosition.x === -1 && newPosition.y === -1) {
|
||||||
// Set initial window position
|
// Set initial window position
|
||||||
// newPosition = Utils.randomPosition(minPosition, maxPosition);
|
// newPosition = Utils.randomPosition(minPosition, maxPosition);
|
||||||
|
console.log("Target has no defined position, putting in center of the screen")
|
||||||
newPosition = Qt.vector2d(desktop.width / 2 - windowRect.width / 2,
|
newPosition = Qt.vector2d(desktop.width / 2 - windowRect.width / 2,
|
||||||
desktop.height / 2 - windowRect.height / 2);
|
desktop.height / 2 - windowRect.height / 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
newPosition = Utils.clampVector(Qt.vector2d(targetWindow.x, targetWindow.y), minPosition, maxPosition);
|
newPosition = Utils.clampVector(newPosition, minPosition, maxPosition);
|
||||||
targetWindow.x = newPosition.x;
|
targetWindow.x = newPosition.x;
|
||||||
targetWindow.y = newPosition.y;
|
targetWindow.y = newPosition.y;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue