Cache the clientSize in DecoratedClientImpl
Summary: So far whenever the window geometry changed the widthChanged and heightChanged signals were emitted even if they did not change. E.g. while moving a window this resulted in the signal being emitted after every step, although from decoration point of view nothing changed. The decoration performed costly tasks like re-layout the window buttons. With this change the client size is cached and the widthChanged signal is only emitted if the width actually changed. Same for heightChanged. This results in the decoration only re-layouting the buttons if the window is resized horizontally. All other geometry changes no longer result in a re-layout. Reviewers: #kwin, #plasma Subscribers: kwin Tags: #kwin Differential Revision: https://phabricator.kde.org/D2389
This commit is contained in:
parent
089059aba3
commit
eed4bf32ae
2 changed files with 16 additions and 5 deletions
|
@ -41,6 +41,7 @@ DecoratedClientImpl::DecoratedClientImpl(AbstractClient *client, KDecoration2::D
|
|||
: QObject()
|
||||
, DecoratedClientPrivate(decoratedClient, decoration)
|
||||
, m_client(client)
|
||||
, m_clientSize(client->clientSize())
|
||||
, m_renderer(nullptr)
|
||||
{
|
||||
createRenderer();
|
||||
|
@ -51,9 +52,18 @@ DecoratedClientImpl::DecoratedClientImpl(AbstractClient *client, KDecoration2::D
|
|||
}
|
||||
);
|
||||
connect(client, &AbstractClient::geometryChanged, this,
|
||||
[decoratedClient, client]() {
|
||||
emit decoratedClient->widthChanged(client->clientSize().width());
|
||||
emit decoratedClient->heightChanged(client->clientSize().height());
|
||||
[decoratedClient, this]() {
|
||||
if (m_client->clientSize() == m_clientSize) {
|
||||
return;
|
||||
}
|
||||
const auto oldSize = m_clientSize;
|
||||
m_clientSize = m_client->clientSize();
|
||||
if (oldSize.width() != m_clientSize.width()) {
|
||||
emit decoratedClient->widthChanged(m_clientSize.width());
|
||||
}
|
||||
if (oldSize.height() != m_clientSize.height()) {
|
||||
emit decoratedClient->heightChanged(m_clientSize.height());
|
||||
}
|
||||
}
|
||||
);
|
||||
connect(client, &AbstractClient::desktopChanged, this,
|
||||
|
@ -205,12 +215,12 @@ void DecoratedClientImpl::delayedRequestToggleMaximization(Options::WindowOperat
|
|||
|
||||
int DecoratedClientImpl::width() const
|
||||
{
|
||||
return m_client->clientSize().width();
|
||||
return m_clientSize.width();
|
||||
}
|
||||
|
||||
int DecoratedClientImpl::height() const
|
||||
{
|
||||
return m_client->clientSize().height();
|
||||
return m_clientSize.height();
|
||||
}
|
||||
|
||||
bool DecoratedClientImpl::isMaximizedVertically() const
|
||||
|
|
|
@ -98,6 +98,7 @@ private Q_SLOTS:
|
|||
private:
|
||||
void createRenderer();
|
||||
AbstractClient *m_client;
|
||||
QSize m_clientSize;
|
||||
Renderer *m_renderer;
|
||||
QMetaObject::Connection m_compositorToggledConnection;
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue