diff --git a/rpm/lipstick-qt5.spec b/rpm/lipstick-qt5.spec index a25eb03a..5b72ac02 100644 --- a/rpm/lipstick-qt5.spec +++ b/rpm/lipstick-qt5.spec @@ -26,7 +26,7 @@ BuildRequires: pkgconfig(Qt5Sensors) BuildRequires: pkgconfig(contentaction5) BuildRequires: pkgconfig(mlite5) >= 0.2.19 BuildRequires: pkgconfig(mce) >= 1.22.0 -BuildRequires: pkgconfig(mce-qt5) >= 1.2.0 +BuildRequires: pkgconfig(mce-qt5) >= 1.4.0 BuildRequires: pkgconfig(keepalive) BuildRequires: pkgconfig(dsme_dbus_if) >= 0.63.2 BuildRequires: pkgconfig(thermalmanager_dbus_if) diff --git a/src/compositor/lipstickcompositor.cpp b/src/compositor/lipstickcompositor.cpp index 9b275e8d..4114d892 100644 --- a/src/compositor/lipstickcompositor.cpp +++ b/src/compositor/lipstickcompositor.cpp @@ -1,7 +1,7 @@ /*************************************************************************** ** -** Copyright (C) 2013 Jolla Ltd. -** Contact: Aaron Kennedy +** Copyright (c) 2013-2019 Jolla Ltd. +** Copyright (c) 2019 Open Mobile Platform LLC. ** ** This file is part of lipstick. ** @@ -37,6 +37,8 @@ #include "hwcrenderstage.h" #include #include +#include +#include LipstickCompositor *LipstickCompositor::m_instance = 0; @@ -59,6 +61,8 @@ LipstickCompositor::LipstickCompositor() , m_onUpdatesDisabledUnfocusedWindowId(0) , m_keymap(0) , m_fakeRepaintTimerId(0) + , m_queuedSetUpdatesEnabledCalls() + , m_mceNameOwner(new QMceNameOwner(this)) { setColor(Qt::black); setRetainedSelectionEnabled(true); @@ -97,7 +101,12 @@ LipstickCompositor::LipstickCompositor() HwcRenderStage::initialize(this); - setUpdatesEnabled(false); + QObject::connect(m_mceNameOwner, &QMceNameOwner::validChanged, + this, &LipstickCompositor::processQueuedSetUpdatesEnabledCalls); + QObject::connect(m_mceNameOwner, &QMceNameOwner::nameOwnerChanged, + this, &LipstickCompositor::processQueuedSetUpdatesEnabledCalls); + + setUpdatesEnabledNow(false); QTimer::singleShot(0, this, SLOT(initialize())); setClientFullScreenHint(true); @@ -759,7 +768,7 @@ void LipstickCompositor::clipboardDataChanged() overrideSelection(const_cast(mimeData)); } -void LipstickCompositor::setUpdatesEnabled(bool enabled) +void LipstickCompositor::setUpdatesEnabledNow(bool enabled) { if (m_updatesEnabled != enabled) { m_updatesEnabled = enabled; @@ -801,6 +810,40 @@ void LipstickCompositor::setUpdatesEnabled(bool enabled) } } +void LipstickCompositor::setUpdatesEnabled(bool enabled) +{ + if (!calledFromDBus()) { + setUpdatesEnabledNow(enabled); + } else { + if (message().isReplyRequired()) + setDelayedReply(true); + m_queuedSetUpdatesEnabledCalls.append(QueuedSetUpdatesEnabledCall(connection(), message(), enabled)); + QMetaObject::invokeMethod(this, "processQueuedSetUpdatesEnabledCalls", Qt::QueuedConnection); + } +} + +void LipstickCompositor::processQueuedSetUpdatesEnabledCalls() +{ + if (m_mceNameOwner->valid()) { + while (!m_queuedSetUpdatesEnabledCalls.isEmpty()) { + QueuedSetUpdatesEnabledCall queued(m_queuedSetUpdatesEnabledCalls.takeFirst()); + if (queued.m_message.service() != m_mceNameOwner->nameOwner()) { + if (queued.m_message.isReplyRequired()) { + QDBusMessage reply(queued.m_message.createErrorReply(DBUS_ERROR_ACCESS_DENIED, + "Only mce is allowed to call this method")); + queued.m_connection.send(reply); + } + } else { + setUpdatesEnabledNow(queued.m_enable); + if (queued.m_message.isReplyRequired()) { + QDBusMessage reply(queued.m_message.createReply()); + queued.m_connection.send(reply); + } + } + } + } +} + void LipstickCompositor::readContent() { m_recorder->recordFrame(this); diff --git a/src/compositor/lipstickcompositor.h b/src/compositor/lipstickcompositor.h index 65612837..3b3a68c2 100644 --- a/src/compositor/lipstickcompositor.h +++ b/src/compositor/lipstickcompositor.h @@ -1,7 +1,7 @@ /*************************************************************************** ** -** Copyright (C) 2013 Jolla Ltd. -** Contact: Aaron Kennedy +** Copyright (c) 2013-2019 Jolla Ltd. +** Copyright (c) 2019 Open Mobile Platform LLC. ** ** This file is part of lipstick. ** @@ -25,6 +25,9 @@ #include #include #include +#include +#include +#include class WindowModel; class LipstickCompositorWindow; @@ -32,13 +35,31 @@ class LipstickCompositorProcWindow; class QOrientationSensor; class LipstickRecorderManager; class LipstickKeymap; +class QMceNameOwner; namespace ContentAction { class Action; } -class LIPSTICK_EXPORT LipstickCompositor : public QQuickWindow, public QWaylandQuickCompositor, - public QQmlParserStatus +struct QueuedSetUpdatesEnabledCall +{ + QueuedSetUpdatesEnabledCall(const QDBusConnection &connection, const QDBusMessage &message, bool enable) + : m_connection(connection) + , m_message(message) + , m_enable(enable) + { + } + + QDBusConnection m_connection; + QDBusMessage m_message; + bool m_enable; +}; + +class LIPSTICK_EXPORT LipstickCompositor + : public QQuickWindow + , public QWaylandQuickCompositor + , public QQmlParserStatus + , public QDBusContext { Q_OBJECT Q_INTERFACES(QQmlParserStatus) @@ -118,6 +139,7 @@ class LIPSTICK_EXPORT LipstickCompositor : public QQuickWindow, public QWaylandQ bool completed(); + void setUpdatesEnabledNow(bool enabled); void setUpdatesEnabled(bool enabled); QWaylandSurfaceView *createView(QWaylandSurface *surf) Q_DECL_OVERRIDE; @@ -183,6 +205,7 @@ private slots: void onSurfaceDying(); void updateKeymap(); void initialize(); + void processQueuedSetUpdatesEnabledCalls(); private: friend class LipstickCompositorWindow; @@ -234,6 +257,8 @@ private slots: LipstickKeymap *m_keymap; int m_fakeRepaintTimerId; + QList m_queuedSetUpdatesEnabledCalls; + QMceNameOwner *m_mceNameOwner; }; #endif // LIPSTICKCOMPOSITOR_H diff --git a/tests/stubs/lipstickcompositor_stub.h b/tests/stubs/lipstickcompositor_stub.h index b6ab0312..918a7db3 100644 --- a/tests/stubs/lipstickcompositor_stub.h +++ b/tests/stubs/lipstickcompositor_stub.h @@ -1,3 +1,18 @@ +/*************************************************************************** +** +** Copyright (c) 2013-2019 Jolla Ltd. +** Copyright (c) 2019 Open Mobile Platform LLC. +** +** This file is part of lipstick. +** +** This library is free software; you can redistribute it and/or +** modify it under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation +** and appearing in the file LICENSE.LGPL included in the packaging +** of this file. +** +****************************************************************************/ + #ifndef LIPSTICKCOMPOSITOR_STUB #define LIPSTICKCOMPOSITOR_STUB @@ -374,7 +389,6 @@ QWaylandSurfaceView *LipstickCompositorStub::createView(QWaylandSurface *surf) LipstickCompositorStub gDefaultLipstickCompositorStub; LipstickCompositorStub *gLipstickCompositorStub = &gDefaultLipstickCompositorStub; - // 4. CREATE A PROXY WHICH CALLS THE STUB LipstickCompositor::LipstickCompositor() { @@ -633,4 +647,8 @@ QWaylandQuickCompositor::QWaylandQuickCompositor(QQuickWindow *, const char *, Q { } +void LipstickCompositor::processQueuedSetUpdatesEnabledCalls() +{ +} + #endif