Replace AbstractClient::adjustedSize() with a simpler alternative
Currently, adjustedSize() does two things - it computes and constrains the natural size of the window. In many places where adjustedSize() is used, the natural size doesn't need to be constrained and in some it's actually undesired because AbstractClient::constrainClientSize() doesn't allow the client size to be 0x0, which can happen when dealing with a client that has no buffer committed yet. This change replaces adjustedSize() with implicitSize(), which simply calculates the natural frame size based on the current client size. If the frame size needs to be constrained, for example during interactive move-resize, use constrainFrameSize() or if you need to constrain the client size - constrainClientSize().
This commit is contained in:
parent
a195290600
commit
b90975b7a2
4 changed files with 14 additions and 20 deletions
|
@ -906,7 +906,7 @@ void AbstractClient::blockGeometryUpdates(bool block)
|
|||
if (--m_blockGeometryUpdates == 0) {
|
||||
if (m_pendingMoveResizeMode != MoveResizeMode::None) {
|
||||
if (isShade())
|
||||
moveResizeInternal(QRect(pos(), adjustedSize()), m_pendingMoveResizeMode);
|
||||
moveResizeInternal(QRect(pos(), implicitSize()), m_pendingMoveResizeMode);
|
||||
else
|
||||
moveResizeInternal(moveResizeGeometry(), m_pendingMoveResizeMode);
|
||||
m_pendingMoveResizeMode = MoveResizeMode::None;
|
||||
|
@ -3594,18 +3594,12 @@ void AbstractClient::checkOffscreenPosition(QRect* geom, const QRect& screenArea
|
|||
}
|
||||
|
||||
/**
|
||||
* Returns the appropriate frame size for the current client size.
|
||||
*
|
||||
* This is equivalent to clientSizeToFrameSize(constrainClientSize(clientSize())).
|
||||
* Returns the natural size of the window, if the window is not shaded it's the same
|
||||
* as size().
|
||||
*/
|
||||
QSize AbstractClient::adjustedSize() const
|
||||
QSize AbstractClient::implicitSize() const
|
||||
{
|
||||
QSize size = clientSize();
|
||||
// The client size is unknown until the window is mapped, don't constrain it.
|
||||
if (!size.isEmpty()) {
|
||||
size = constrainClientSize(size);
|
||||
}
|
||||
return clientSizeToFrameSize(size);
|
||||
return clientSizeToFrameSize(clientSize());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -654,7 +654,7 @@ public:
|
|||
|
||||
virtual QSize constrainClientSize(const QSize &size, SizeMode mode = SizeModeAny) const;
|
||||
QSize constrainFrameSize(const QSize &size, SizeMode mode = SizeModeAny) const;
|
||||
QSize adjustedSize() const;
|
||||
QSize implicitSize() const;
|
||||
|
||||
/**
|
||||
* Calculates the matching client position for the given frame position @p point.
|
||||
|
|
|
@ -862,7 +862,7 @@ void AbstractClient::applyWindowRules()
|
|||
// Placement - does need explicit update, just like some others below
|
||||
// Geometry : setGeometry() doesn't check rules
|
||||
auto client_rules = rules();
|
||||
QRect orig_geom = QRect(pos(), adjustedSize()); // handle shading
|
||||
QRect orig_geom = QRect(pos(), implicitSize()); // handle shading
|
||||
QRect geom = client_rules->checkGeometry(orig_geom);
|
||||
if (geom != orig_geom)
|
||||
moveResize(geom);
|
||||
|
|
|
@ -1133,7 +1133,7 @@ void X11Client::createDecoration(const QRect& oldgeom)
|
|||
// move(calculateGravitation(true));
|
||||
// move(calculateGravitation(false));
|
||||
QRect oldgeom = frameGeometry();
|
||||
resize(adjustedSize());
|
||||
resize(implicitSize());
|
||||
if (!isShade())
|
||||
checkWorkspacePosition(oldgeom);
|
||||
Q_EMIT geometryShapeChanged(this, oldgeom);
|
||||
|
@ -1147,7 +1147,7 @@ void X11Client::createDecoration(const QRect& oldgeom)
|
|||
setDecoration(decoration);
|
||||
|
||||
move(calculateGravitation(false));
|
||||
resize(adjustedSize());
|
||||
resize(implicitSize());
|
||||
updateDecorationInputShape();
|
||||
maybeCreateX11DecorationRenderer();
|
||||
Q_EMIT geometryShapeChanged(this, oldgeom);
|
||||
|
@ -1160,7 +1160,7 @@ void X11Client::destroyDecoration()
|
|||
QPoint grav = calculateGravitation(true);
|
||||
AbstractClient::destroyDecoration();
|
||||
maybeDestroyX11DecorationRenderer();
|
||||
resize(adjustedSize());
|
||||
resize(implicitSize());
|
||||
move(grav);
|
||||
if (!isZombie()) {
|
||||
Q_EMIT geometryShapeChanged(this, oldgeom);
|
||||
|
@ -1505,7 +1505,7 @@ void X11Client::doSetShade(ShadeMode previousShadeMode)
|
|||
addWorkspaceRepaint(visibleGeometry());
|
||||
// Shade
|
||||
shade_geometry_change = true;
|
||||
QSize s(adjustedSize());
|
||||
QSize s(implicitSize());
|
||||
s.setHeight(borderTop() + borderBottom());
|
||||
m_wrapper.selectInput(ClientWinMask); // Avoid getting UnmapNotify
|
||||
m_wrapper.unmap();
|
||||
|
@ -1526,7 +1526,7 @@ void X11Client::doSetShade(ShadeMode previousShadeMode)
|
|||
shade_geometry_change = true;
|
||||
if (decoratedClient())
|
||||
decoratedClient()->signalShadeChange();
|
||||
QSize s(adjustedSize());
|
||||
QSize s(implicitSize());
|
||||
shade_geometry_change = false;
|
||||
resize(s);
|
||||
setGeometryRestore(frameGeometry());
|
||||
|
@ -3609,7 +3609,7 @@ void X11Client::getWmNormalHints()
|
|||
}
|
||||
if (isManaged()) {
|
||||
// update to match restrictions
|
||||
QSize new_size = adjustedSize();
|
||||
QSize new_size = clientSizeToFrameSize(constrainClientSize(clientSize()));
|
||||
if (new_size != size() && !isFullScreen()) {
|
||||
QRect origClientGeometry = m_clientGeometry;
|
||||
resizeWithChecks(new_size);
|
||||
|
@ -4201,7 +4201,7 @@ void X11Client::changeMaximize(bool horizontal, bool vertical, bool adjust)
|
|||
// save sizes for restoring, if maximalizing
|
||||
QSize sz;
|
||||
if (isShade())
|
||||
sz = adjustedSize();
|
||||
sz = implicitSize();
|
||||
else
|
||||
sz = size();
|
||||
|
||||
|
|
Loading…
Reference in a new issue