[kdecoration] Decoration::client returns a QWeakPointer
In aurorae a wrapper property is added.
This commit is contained in:
parent
d1bf38e92c
commit
6bdd0e96f6
4 changed files with 20 additions and 11 deletions
|
@ -283,7 +283,7 @@ void Decoration::init()
|
||||||
visualParent.value<QQuickItem*>()->setProperty("drawBackground", false);
|
visualParent.value<QQuickItem*>()->setProperty("drawBackground", false);
|
||||||
} else {
|
} else {
|
||||||
// we need a QQuickWindow till we depend on Qt 5.4
|
// we need a QQuickWindow till we depend on Qt 5.4
|
||||||
m_decorationWindow.reset(QWindow::fromWinId(client()->decorationId()));
|
m_decorationWindow.reset(QWindow::fromWinId(client().data()->decorationId()));
|
||||||
m_view = new QQuickWindow(m_decorationWindow.data());
|
m_view = new QQuickWindow(m_decorationWindow.data());
|
||||||
m_view->setFlags(Qt::WindowDoesNotAcceptFocus | Qt::WindowTransparentForInput);
|
m_view->setFlags(Qt::WindowDoesNotAcceptFocus | Qt::WindowTransparentForInput);
|
||||||
m_view->setColor(Qt::transparent);
|
m_view->setColor(Qt::transparent);
|
||||||
|
@ -332,7 +332,7 @@ void Decoration::init()
|
||||||
m_view->setVisible(true);
|
m_view->setVisible(true);
|
||||||
auto resizeWindow = [this] {
|
auto resizeWindow = [this] {
|
||||||
QRect rect(QPoint(0, 0), size());
|
QRect rect(QPoint(0, 0), size());
|
||||||
if (m_padding && !client()->isMaximized()) {
|
if (m_padding && !client().data()->isMaximized()) {
|
||||||
rect = rect.adjusted(-m_padding->left(), -m_padding->top(), m_padding->right(), m_padding->bottom());
|
rect = rect.adjusted(-m_padding->left(), -m_padding->top(), m_padding->right(), m_padding->bottom());
|
||||||
}
|
}
|
||||||
m_view->setGeometry(rect);
|
m_view->setGeometry(rect);
|
||||||
|
@ -372,7 +372,7 @@ void Decoration::setupBorders(QQuickItem *item)
|
||||||
void Decoration::updateBorders()
|
void Decoration::updateBorders()
|
||||||
{
|
{
|
||||||
KWin::Borders *b = m_borders;
|
KWin::Borders *b = m_borders;
|
||||||
if (client()->isMaximized() && m_maximizedBorders) {
|
if (client().data()->isMaximized() && m_maximizedBorders) {
|
||||||
b = m_maximizedBorders;
|
b = m_maximizedBorders;
|
||||||
}
|
}
|
||||||
if (!b) {
|
if (!b) {
|
||||||
|
@ -392,7 +392,7 @@ void Decoration::paint(QPainter *painter, const QRect &repaintRegion)
|
||||||
QRectF r(QPointF(0, 0), m_buffer.size());
|
QRectF r(QPointF(0, 0), m_buffer.size());
|
||||||
if (m_padding &&
|
if (m_padding &&
|
||||||
(m_padding->left() > 0 || m_padding->top() > 0 || m_padding->right() > 0 || m_padding->bottom() > 0) &&
|
(m_padding->left() > 0 || m_padding->top() > 0 || m_padding->right() > 0 || m_padding->bottom() > 0) &&
|
||||||
!client()->isMaximized()) {
|
!client().data()->isMaximized()) {
|
||||||
r = r.adjusted(m_padding->left(), m_padding->top(), -m_padding->right(), -m_padding->bottom());
|
r = r.adjusted(m_padding->left(), m_padding->top(), -m_padding->right(), -m_padding->bottom());
|
||||||
KDecoration2::DecorationShadow *s = new KDecoration2::DecorationShadow(this);
|
KDecoration2::DecorationShadow *s = new KDecoration2::DecorationShadow(this);
|
||||||
s->setShadow(m_buffer);
|
s->setShadow(m_buffer);
|
||||||
|
@ -414,7 +414,7 @@ void Decoration::paint(QPainter *painter, const QRect &repaintRegion)
|
||||||
|
|
||||||
QMouseEvent Decoration::translatedMouseEvent(QMouseEvent *orig)
|
QMouseEvent Decoration::translatedMouseEvent(QMouseEvent *orig)
|
||||||
{
|
{
|
||||||
if (!m_padding || client()->isMaximized()) {
|
if (!m_padding || client().data()->isMaximized()) {
|
||||||
orig->setAccepted(false);
|
orig->setAccepted(false);
|
||||||
return *orig;
|
return *orig;
|
||||||
}
|
}
|
||||||
|
@ -498,6 +498,11 @@ void Decoration::installTitleItem(QQuickItem *item)
|
||||||
connect(item, &QQuickItem::yChanged, this, update);
|
connect(item, &QQuickItem::yChanged, this, update);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
KDecoration2::DecoratedClient *Decoration::clientPointer() const
|
||||||
|
{
|
||||||
|
return client().data();
|
||||||
|
}
|
||||||
|
|
||||||
ThemeFinder::ThemeFinder(QObject *parent, const QVariantList &args)
|
ThemeFinder::ThemeFinder(QObject *parent, const QVariantList &args)
|
||||||
: QObject(parent)
|
: QObject(parent)
|
||||||
{
|
{
|
||||||
|
|
|
@ -40,6 +40,7 @@ namespace Aurorae
|
||||||
class Decoration : public KDecoration2::Decoration
|
class Decoration : public KDecoration2::Decoration
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
Q_PROPERTY(KDecoration2::DecoratedClient* client READ clientPointer CONSTANT)
|
||||||
public:
|
public:
|
||||||
explicit Decoration(QObject *parent = nullptr, const QVariantList &args = QVariantList());
|
explicit Decoration(QObject *parent = nullptr, const QVariantList &args = QVariantList());
|
||||||
virtual ~Decoration();
|
virtual ~Decoration();
|
||||||
|
@ -48,6 +49,8 @@ public:
|
||||||
|
|
||||||
Q_INVOKABLE QVariant readConfig(const QString &key, const QVariant &defaultValue = QVariant());
|
Q_INVOKABLE QVariant readConfig(const QString &key, const QVariant &defaultValue = QVariant());
|
||||||
|
|
||||||
|
KDecoration2::DecoratedClient *clientPointer() const;
|
||||||
|
|
||||||
public Q_SLOTS:
|
public Q_SLOTS:
|
||||||
void init() override;
|
void init() override;
|
||||||
void installTitleItem(QQuickItem *item);
|
void installTitleItem(QQuickItem *item);
|
||||||
|
|
|
@ -185,10 +185,10 @@ void DecorationOptions::slotActiveChanged()
|
||||||
if (!m_decoration) {
|
if (!m_decoration) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (m_active == m_decoration->client()->isActive()) {
|
if (m_active == m_decoration->client().data()->isActive()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
m_active = m_decoration->client()->isActive();
|
m_active = m_decoration->client().data()->isActive();
|
||||||
emit colorsChanged();
|
emit colorsChanged();
|
||||||
emit fontChanged();
|
emit fontChanged();
|
||||||
}
|
}
|
||||||
|
|
|
@ -2213,15 +2213,16 @@ void Client::changeMaximize(bool vertical, bool horizontal, bool adjust)
|
||||||
}
|
}
|
||||||
|
|
||||||
// call into decoration update borders
|
// call into decoration update borders
|
||||||
if (m_decoration) {
|
if (m_decoration && m_decoration->client()) {
|
||||||
|
const auto c = m_decoration->client().data();
|
||||||
if ((max_mode & KDecorationDefines::MaximizeVertical) != (old_mode & KDecorationDefines::MaximizeVertical)) {
|
if ((max_mode & KDecorationDefines::MaximizeVertical) != (old_mode & KDecorationDefines::MaximizeVertical)) {
|
||||||
emit m_decoration->client()->maximizedVerticallyChanged(max_mode & KDecorationDefines::MaximizeVertical);
|
emit c->maximizedVerticallyChanged(max_mode & KDecorationDefines::MaximizeVertical);
|
||||||
}
|
}
|
||||||
if ((max_mode & KDecorationDefines::MaximizeHorizontal) != (old_mode & KDecorationDefines::MaximizeHorizontal)) {
|
if ((max_mode & KDecorationDefines::MaximizeHorizontal) != (old_mode & KDecorationDefines::MaximizeHorizontal)) {
|
||||||
emit m_decoration->client()->maximizedHorizontallyChanged(max_mode & KDecorationDefines::MaximizeHorizontal);
|
emit c->maximizedHorizontallyChanged(max_mode & KDecorationDefines::MaximizeHorizontal);
|
||||||
}
|
}
|
||||||
if ((max_mode == KDecorationDefines::MaximizeFull) != (old_mode == KDecorationDefines::MaximizeFull)) {
|
if ((max_mode == KDecorationDefines::MaximizeFull) != (old_mode == KDecorationDefines::MaximizeFull)) {
|
||||||
emit m_decoration->client()->maximizedChanged(max_mode & KDecorationDefines::MaximizeFull);
|
emit c->maximizedChanged(max_mode & KDecorationDefines::MaximizeFull);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue