Adjust to KDecoration API changes

This commit is contained in:
Vlad Zahorodnii 2023-03-11 14:35:02 +02:00
parent c2b4526791
commit 18a9b3b25a
10 changed files with 24 additions and 29 deletions

View file

@ -114,7 +114,7 @@ void TestMaximized::testMaximizedPassedToDeco()
// now maximize
QSignalSpy bordersChangedSpy(decoration, &KDecoration2::Decoration::bordersChanged);
QSignalSpy maximizedChangedSpy(decoration->client().toStrongRef().get(), &KDecoration2::DecoratedClient::maximizedChanged);
QSignalSpy maximizedChangedSpy(decoration->client(), &KDecoration2::DecoratedClient::maximizedChanged);
QSignalSpy frameGeometryChangedSpy(window, &Window::frameGeometryChanged);
workspace()->slotWindowMaximize();

View file

@ -31,7 +31,7 @@ DecoratedClientImpl::DecoratedClientImpl(Window *window, KDecoration2::Decorated
, m_window(window)
, m_clientSize(window->clientSize().toSize())
{
window->setDecoratedClient(QPointer<DecoratedClientImpl>(this));
window->setDecoratedClient(this);
connect(window, &Window::activeChanged, this, [decoratedClient, window]() {
Q_EMIT decoratedClient->activeChanged(window->isActive());
});

View file

@ -9,6 +9,7 @@
#include <KDecoration2/Private/DecorationSettingsPrivate>
#include <QAbstractListModel>
#include <QObject>
#include <QPointer>
namespace KDecoration2
{

View file

@ -348,14 +348,14 @@ void Decoration::init()
connect(m_extendedBorders, &KWin::Borders::bottomChanged, this, &Decoration::updateExtendedBorders);
}
auto decorationClient = clientPointer();
auto decorationClient = client();
connect(decorationClient, &KDecoration2::DecoratedClient::maximizedChanged, this, &Decoration::updateBorders);
connect(decorationClient, &KDecoration2::DecoratedClient::shadedChanged, this, &Decoration::updateBorders);
updateBorders();
if (m_view) {
auto resizeWindow = [this] {
QRect rect(QPoint(0, 0), size());
if (m_padding && !clientPointer()->isMaximized()) {
if (m_padding && !client()->isMaximized()) {
rect = rect.adjusted(-m_padding->left(), -m_padding->top(), m_padding->right(), m_padding->bottom());
}
m_view->setGeometry(rect);
@ -396,7 +396,7 @@ void Decoration::setupBorders(QQuickItem *item)
void Decoration::updateBorders()
{
KWin::Borders *b = m_borders;
if (clientPointer()->isMaximized() && m_maximizedBorders) {
if (client()->isMaximized() && m_maximizedBorders) {
b = m_maximizedBorders;
}
if (!b) {
@ -429,7 +429,7 @@ void Decoration::updateShadow()
}
bool updateShadow = false;
const auto oldShadow = shadow();
if (m_padding && (m_padding->left() > 0 || m_padding->top() > 0 || m_padding->right() > 0 || m_padding->bottom() > 0) && !clientPointer()->isMaximized()) {
if (m_padding && (m_padding->left() > 0 || m_padding->top() > 0 || m_padding->right() > 0 || m_padding->bottom() > 0) && !client()->isMaximized()) {
if (oldShadow.isNull()) {
updateShadow = true;
} else {
@ -555,15 +555,15 @@ void Decoration::updateExtendedBorders()
int extBottom = m_extendedBorders->bottom();
if (settings()->borderSize() == KDecoration2::BorderSize::None) {
if (!clientPointer()->isMaximizedHorizontally()) {
if (!client()->isMaximizedHorizontally()) {
extLeft = std::max(m_extendedBorders->left(), extSize);
extRight = std::max(m_extendedBorders->right(), extSize);
}
if (!clientPointer()->isMaximizedVertically()) {
if (!client()->isMaximizedVertically()) {
extBottom = std::max(m_extendedBorders->bottom(), extSize);
}
} else if (settings()->borderSize() == KDecoration2::BorderSize::NoSides && !clientPointer()->isMaximizedHorizontally()) {
} else if (settings()->borderSize() == KDecoration2::BorderSize::NoSides && !client()->isMaximizedHorizontally()) {
extLeft = std::max(m_extendedBorders->left(), extSize);
extRight = std::max(m_extendedBorders->right(), extSize);
}
@ -579,7 +579,7 @@ void Decoration::updateBlur()
QRegion mask;
if (clientPointer() && clientPointer()->isMaximized()) {
if (client() && client()->isMaximized()) {
mask = QRect(0, 0, m_item->width(), m_item->height());
} else {
const QVariant maskProperty = m_item->property("decorationMask");
@ -606,7 +606,7 @@ void Decoration::updateBuffer()
return;
}
m_contentRect = QRect(QPoint(0, 0), m_view->contentItem()->size().toSize());
if (m_padding && (m_padding->left() > 0 || m_padding->top() > 0 || m_padding->right() > 0 || m_padding->bottom() > 0) && !clientPointer()->isMaximized()) {
if (m_padding && (m_padding->left() > 0 || m_padding->top() > 0 || m_padding->right() > 0 || m_padding->bottom() > 0) && !client()->isMaximized()) {
m_contentRect = m_contentRect.adjusted(m_padding->left(), m_padding->top(), -m_padding->right(), -m_padding->bottom());
}
updateShadow();
@ -614,11 +614,6 @@ void Decoration::updateBuffer()
update();
}
KDecoration2::DecoratedClient *Decoration::clientPointer() const
{
return client().toStrongRef().data();
}
QQuickItem *Decoration::item() const
{
return m_item.get();

View file

@ -32,7 +32,7 @@ namespace Aurorae
class Decoration : public KDecoration2::Decoration
{
Q_OBJECT
Q_PROPERTY(KDecoration2::DecoratedClient *client READ clientPointer CONSTANT)
Q_PROPERTY(KDecoration2::DecoratedClient *client READ client CONSTANT)
Q_PROPERTY(QQuickItem *item READ item)
public:
explicit Decoration(QObject *parent = nullptr, const QVariantList &args = QVariantList());
@ -42,7 +42,6 @@ public:
Q_INVOKABLE QVariant readConfig(const QString &key, const QVariant &defaultValue = QVariant());
KDecoration2::DecoratedClient *clientPointer() const;
QQuickItem *item() const;
public Q_SLOTS:

View file

@ -155,7 +155,7 @@ void DecorationOptions::setDecoration(KDecoration2::Decoration *decoration)
}
if (m_decoration) {
// disconnect from existing decoration
disconnect(m_decoration->client().toStrongRef().data(), &KDecoration2::DecoratedClient::activeChanged, this, &DecorationOptions::slotActiveChanged);
disconnect(m_decoration->client(), &KDecoration2::DecoratedClient::activeChanged, this, &DecorationOptions::slotActiveChanged);
auto s = m_decoration->settings();
disconnect(s.data(), &KDecoration2::DecorationSettings::fontChanged, this, &DecorationOptions::fontChanged);
disconnect(s.data(), &KDecoration2::DecorationSettings::decorationButtonsLeftChanged, this, &DecorationOptions::titleButtonsChanged);
@ -163,8 +163,8 @@ void DecorationOptions::setDecoration(KDecoration2::Decoration *decoration)
disconnect(m_paletteConnection);
}
m_decoration = decoration;
connect(m_decoration->client().toStrongRef().data(), &KDecoration2::DecoratedClient::activeChanged, this, &DecorationOptions::slotActiveChanged);
m_paletteConnection = connect(m_decoration->client().toStrongRef().data(), &KDecoration2::DecoratedClient::paletteChanged, this, [this](const QPalette &pal) {
connect(m_decoration->client(), &KDecoration2::DecoratedClient::activeChanged, this, &DecorationOptions::slotActiveChanged);
m_paletteConnection = connect(m_decoration->client(), &KDecoration2::DecoratedClient::paletteChanged, this, [this](const QPalette &pal) {
m_colors.update(pal);
Q_EMIT colorsChanged();
});
@ -180,10 +180,10 @@ void DecorationOptions::slotActiveChanged()
if (!m_decoration) {
return;
}
if (m_active == m_decoration->client().toStrongRef().data()->isActive()) {
if (m_active == m_decoration->client()->isActive()) {
return;
}
m_active = m_decoration->client().toStrongRef().data()->isActive();
m_active = m_decoration->client()->isActive();
Q_EMIT colorsChanged();
Q_EMIT fontChanged();
}

View file

@ -3099,12 +3099,12 @@ void Window::showContextHelp()
{
}
QPointer<Decoration::DecoratedClientImpl> Window::decoratedClient() const
Decoration::DecoratedClientImpl *Window::decoratedClient() const
{
return m_decoration.client;
}
void Window::setDecoratedClient(QPointer<Decoration::DecoratedClientImpl> client)
void Window::setDecoratedClient(Decoration::DecoratedClientImpl *client)
{
m_decoration.client = client;
}

View file

@ -1231,8 +1231,8 @@ public:
{
return m_decoration.decoration != nullptr;
}
QPointer<Decoration::DecoratedClientImpl> decoratedClient() const;
void setDecoratedClient(QPointer<Decoration::DecoratedClientImpl> client);
Decoration::DecoratedClientImpl *decoratedClient() const;
void setDecoratedClient(Decoration::DecoratedClientImpl *client);
bool decorationHasAlpha() const;
void triggerDecorationRepaint();
virtual void layoutDecorationRects(QRectF &left, QRectF &top, QRectF &right, QRectF &bottom) const;

View file

@ -4379,7 +4379,7 @@ void X11Window::maximize(MaximizeMode mode)
// call into decoration update borders
if (isDecorated() && decoration()->client() && !(options->borderlessMaximizedWindows() && max_mode == KWin::MaximizeFull)) {
changeMaximizeRecursion = true;
const auto c = decoration()->client().toStrongRef();
const auto c = decoration()->client();
if ((max_mode & MaximizeVertical) != (old_mode & MaximizeVertical)) {
Q_EMIT c->maximizedVerticallyChanged(max_mode & MaximizeVertical);
}

View file

@ -1618,7 +1618,7 @@ void XdgToplevelWindow::maximize(MaximizeMode mode)
// call into decoration update borders
if (m_nextDecoration && !(options->borderlessMaximizedWindows() && m_requestedMaximizeMode == KWin::MaximizeFull)) {
changeMaximizeRecursion = true;
const auto c = m_nextDecoration->client().toStrongRef();
const auto c = m_nextDecoration->client();
if ((m_requestedMaximizeMode & MaximizeVertical) != (oldMode & MaximizeVertical)) {
Q_EMIT c->maximizedVerticallyChanged(m_requestedMaximizeMode & MaximizeVertical);
}