x11: Fix shading with non-zero border

There was a geometry change that fixed mixing the next and current
geometries. While it did fix issues on wayland, it broke window shading
on x11 because of an obscure resize() call.

That obscure resize() had a side-effect that ensures m_clientGeometry
has the right value so the next time the window is unshaded,
implicitSize() will return a good value.

In order to make window size computation more robust, this change makes
X11Window compute the natural frame size based on cached size in
m_client, which shouldn't change when the window is shaded.

However, given how buggy window shading is and how difficult it is to
make it work right, I think that it's better to deprecate window shading
and remove it in some future release.

BUG: 450582
This commit is contained in:
Vlad Zahorodnii 2022-07-18 11:23:54 +03:00
parent 64c71a37a0
commit 4790916fb1
4 changed files with 12 additions and 12 deletions

View file

@ -4225,15 +4225,6 @@ void Window::checkOffscreenPosition(QRectF *geom, const QRectF &screenArea)
}
}
/**
* Returns the natural size of the window, if the window is not shaded it's the same
* as size().
*/
QSizeF Window::implicitSize() const
{
return clientSizeToFrameSize(clientSize());
}
/**
* Constrains the client size @p size according to a set of the window's size hints.
*

View file

@ -1147,7 +1147,6 @@ public:
virtual QSizeF constrainClientSize(const QSizeF &size, SizeMode mode = SizeModeAny) const;
QSizeF constrainFrameSize(const QSizeF &size, SizeMode mode = SizeModeAny) const;
QSizeF implicitSize() const;
/**
* Calculates the matching client position for the given frame position @p point.

View file

@ -1156,7 +1156,7 @@ void X11Window::createDecoration(const QRectF &oldgeom)
}
setDecoration(decoration);
moveResize(QRectF(calculateGravitation(false), implicitSize()));
moveResize(QRectF(calculateGravitation(false), clientSizeToFrameSize(clientSize())));
maybeCreateX11DecorationRenderer();
Q_EMIT geometryShapeChanged(this, oldgeom);
}
@ -1168,7 +1168,7 @@ void X11Window::destroyDecoration()
QPointF grav = calculateGravitation(true);
setDecoration(nullptr);
maybeDestroyX11DecorationRenderer();
moveResize(QRectF(grav, implicitSize()));
moveResize(QRectF(grav, clientSizeToFrameSize(clientSize())));
if (!isZombie()) {
Q_EMIT geometryShapeChanged(this, oldgeom);
}
@ -2697,6 +2697,15 @@ QRectF X11Window::frameRectToBufferRect(const QRectF &rect) const
return frameRectToClientRect(rect);
}
/**
* Returns the natural size of the window, if the window is not shaded it's the same
* as size().
*/
QSizeF X11Window::implicitSize() const
{
return clientSizeToFrameSize(m_client.geometry().size());
}
QMatrix4x4 X11Window::inputTransformation() const
{
QMatrix4x4 matrix;

View file

@ -110,6 +110,7 @@ public:
QSizeF frameSizeToClientSize(const QSizeF &size) const override;
QSizeF clientSizeToFrameSize(const QSizeF &size) const override;
QRectF frameRectToBufferRect(const QRectF &rect) const;
QSizeF implicitSize() const;
QMatrix4x4 inputTransformation() const override;