Introduce a RequestGeometryBlocker in ShellClient
Summary: The idea is to not send multiple resize requests to a client when we know that we might have multiple geometry changes. E.g. when going from maximized to restored the borders change and trigger a resize in addition to the resize from switching to restored. The implementation is inspired by the GeometryUpdateBlocker. Reviewers: #kwin, #plasma_on_wayland Subscribers: plasma-devel, kwin Tags: #plasma_on_wayland, #kwin Differential Revision: https://phabricator.kde.org/D1808
This commit is contained in:
parent
53a3740082
commit
39e7b26243
3 changed files with 39 additions and 0 deletions
|
@ -214,6 +214,15 @@ void TestMaximized::testMaximizedPassedToDeco()
|
|||
QCOMPARE(client->maximizeMode(), MaximizeMode::MaximizeRestore);
|
||||
QCOMPARE(maximizedChangedSpy.count(), 2);
|
||||
QCOMPARE(maximizedChangedSpy.last().first().toBool(), false);
|
||||
QCOMPARE(bordersChangedSpy.count(), 2);
|
||||
QVERIFY(decoration->borderTop() != 0);
|
||||
QVERIFY(decoration->borderLeft() != 0);
|
||||
QVERIFY(decoration->borderRight() != 0);
|
||||
QVERIFY(decoration->borderBottom() != 0);
|
||||
|
||||
QVERIFY(sizeChangedSpy.wait());
|
||||
QCOMPARE(sizeChangedSpy.count(), 2);
|
||||
QCOMPARE(sizeChangedSpy.last().first().toSize(), QSize(100, 50));
|
||||
}
|
||||
|
||||
void TestMaximized::testInitiallyMaximized()
|
||||
|
|
|
@ -348,6 +348,7 @@ void ShellClient::createDecoration(const QRect &oldGeom)
|
|||
connect(decoration, &KDecoration2::Decoration::bordersChanged, this,
|
||||
[this]() {
|
||||
GeometryUpdatesBlocker blocker(this);
|
||||
RequestGeometryBlocker requestBlocker(this);
|
||||
QRect oldgeom = geometry();
|
||||
if (!isShade())
|
||||
checkWorkspacePosition(oldgeom);
|
||||
|
@ -565,6 +566,7 @@ void ShellClient::changeMaximize(bool horizontal, bool vertical, bool adjust)
|
|||
}
|
||||
MaximizeMode oldMode = m_maximizeMode;
|
||||
StackingUpdatesBlocker blocker(workspace());
|
||||
RequestGeometryBlocker geometryBlocker(this);
|
||||
// 'adjust == true' means to update the size only, e.g. after changing workspace size
|
||||
if (!adjust) {
|
||||
if (vertical)
|
||||
|
@ -801,10 +803,15 @@ bool ShellClient::isInputMethod() const
|
|||
|
||||
void ShellClient::requestGeometry(const QRect &rect)
|
||||
{
|
||||
if (m_requestGeometryBlockCounter != 0) {
|
||||
m_blockedRequestGeometry = rect;
|
||||
return;
|
||||
}
|
||||
m_positionAfterResize.setPoint(rect.topLeft());
|
||||
if (m_shellSurface) {
|
||||
m_shellSurface->requestSize(rect.size() - QSize(borderLeft() + borderRight(), borderTop() + borderBottom()));
|
||||
}
|
||||
m_blockedRequestGeometry = QRect();
|
||||
}
|
||||
|
||||
void ShellClient::clientFullScreenChanged(bool fullScreen)
|
||||
|
|
|
@ -172,6 +172,29 @@ private:
|
|||
bool m_transient = false;
|
||||
bool m_internal;
|
||||
qreal m_opacity = 1.0;
|
||||
|
||||
class RequestGeometryBlocker {
|
||||
public:
|
||||
RequestGeometryBlocker(ShellClient *client)
|
||||
: m_client(client)
|
||||
{
|
||||
m_client->m_requestGeometryBlockCounter++;
|
||||
}
|
||||
~RequestGeometryBlocker()
|
||||
{
|
||||
m_client->m_requestGeometryBlockCounter--;
|
||||
if (m_client->m_requestGeometryBlockCounter == 0) {
|
||||
if (m_client->m_blockedRequestGeometry.isValid()) {
|
||||
m_client->requestGeometry(m_client->m_blockedRequestGeometry);
|
||||
}
|
||||
}
|
||||
}
|
||||
private:
|
||||
ShellClient *m_client;
|
||||
};
|
||||
friend class RequestGeometryBlocker;
|
||||
int m_requestGeometryBlockCounter = 0;
|
||||
QRect m_blockedRequestGeometry;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue