window: add keepInArea variant that doesn't modify any window state
This commit is contained in:
parent
3fff256b88
commit
2b2d382ed1
2 changed files with 10 additions and 9 deletions
|
@ -1505,7 +1505,7 @@ void Window::handlePaletteChange()
|
||||||
Q_EMIT paletteChanged(palette());
|
Q_EMIT paletteChanged(palette());
|
||||||
}
|
}
|
||||||
|
|
||||||
void Window::keepInArea(QRectF area, bool partial)
|
QRectF Window::keepInArea(QRectF geometry, QRectF area, bool partial)
|
||||||
{
|
{
|
||||||
if (partial) {
|
if (partial) {
|
||||||
// increase the area so that can have only 100 pixels in the area
|
// increase the area so that can have only 100 pixels in the area
|
||||||
|
@ -1517,13 +1517,11 @@ void Window::keepInArea(QRectF area, bool partial)
|
||||||
}
|
}
|
||||||
if (!partial) {
|
if (!partial) {
|
||||||
// resize to fit into area
|
// resize to fit into area
|
||||||
const QRectF geometry = moveResizeGeometry();
|
|
||||||
if (area.width() < geometry.width() || area.height() < geometry.height()) {
|
if (area.width() < geometry.width() || area.height() < geometry.height()) {
|
||||||
moveResize(resizeWithChecks(geometry, geometry.size().boundedTo(area.size())));
|
geometry = resizeWithChecks(geometry, geometry.size().boundedTo(area.size()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QRectF geometry = moveResizeGeometry();
|
|
||||||
if (geometry.right() > area.right() && geometry.width() <= area.width()) {
|
if (geometry.right() > area.right() && geometry.width() <= area.width()) {
|
||||||
geometry.moveRight(area.right());
|
geometry.moveRight(area.right());
|
||||||
}
|
}
|
||||||
|
@ -1537,10 +1535,12 @@ void Window::keepInArea(QRectF area, bool partial)
|
||||||
if (geometry.top() < area.top()) {
|
if (geometry.top() < area.top()) {
|
||||||
geometry.moveTop(area.top());
|
geometry.moveTop(area.top());
|
||||||
}
|
}
|
||||||
|
return geometry;
|
||||||
|
}
|
||||||
|
|
||||||
if (moveResizeGeometry().topLeft() != geometry.topLeft()) {
|
void Window::keepInArea(QRectF area, bool partial)
|
||||||
move(geometry.topLeft());
|
{
|
||||||
}
|
moveResize(keepInArea(moveResizeGeometry(), area, partial));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -3930,15 +3930,15 @@ void Window::sendToOutput(Output *newOutput)
|
||||||
center.setY(center.y() * screenArea.height() / oldScreenArea.height());
|
center.setY(center.y() * screenArea.height() / oldScreenArea.height());
|
||||||
center += screenArea.center();
|
center += screenArea.center();
|
||||||
newGeom.moveCenter(center);
|
newGeom.moveCenter(center);
|
||||||
moveResize(newGeom);
|
|
||||||
|
|
||||||
// If the window was inside the old screen area, explicitly make sure its inside also the new screen area.
|
// If the window was inside the old screen area, explicitly make sure its inside also the new screen area.
|
||||||
// Calling checkWorkspacePosition() should ensure that, but when moving to a small screen the window could
|
// Calling checkWorkspacePosition() should ensure that, but when moving to a small screen the window could
|
||||||
// be big enough to overlap outside of the new screen area, making struts from other screens come into effect,
|
// be big enough to overlap outside of the new screen area, making struts from other screens come into effect,
|
||||||
// which could alter the resulting geometry.
|
// which could alter the resulting geometry.
|
||||||
if (oldScreenArea.contains(oldGeom)) {
|
if (oldScreenArea.contains(oldGeom)) {
|
||||||
keepInArea(screenArea);
|
newGeom = keepInArea(newGeom, screenArea);
|
||||||
}
|
}
|
||||||
|
moveResize(newGeom);
|
||||||
|
|
||||||
if (isFullScreen()) {
|
if (isFullScreen()) {
|
||||||
updateGeometryRestoresForFullscreen(newOutput);
|
updateGeometryRestoresForFullscreen(newOutput);
|
||||||
|
|
|
@ -1142,6 +1142,7 @@ public:
|
||||||
|
|
||||||
virtual QRectF resizeWithChecks(const QRectF &geometry, const QSizeF &s) = 0;
|
virtual QRectF resizeWithChecks(const QRectF &geometry, const QSizeF &s) = 0;
|
||||||
void keepInArea(QRectF area, bool partial = false);
|
void keepInArea(QRectF area, bool partial = false);
|
||||||
|
QRectF keepInArea(QRectF geometry, QRectF area, bool partial = false);
|
||||||
virtual QSizeF minSize() const;
|
virtual QSizeF minSize() const;
|
||||||
virtual QSizeF maxSize() const;
|
virtual QSizeF maxSize() const;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue