Make integration with KScreenLocker optional in WaylandServer

Summary:
In order to start the WaylandServer in kwin_x11 we need to make sure
that WaylandServer does not start the KScreenLocker integration. On
X11 the lock screen is provided by a different application (in Plasma
by ksmserver).

A new init flag is added to WaylandServer to not integrate with
KScreenLocker. Thus the default is still to integrate with KScreenLocker.

All direct usages of KScreenLocker are guarded to not be called if
the screenlocker integration is not present.

Reviewers: #plasma

Subscribers: plasma-devel

Projects: #plasma

Differential Revision: https://phabricator.kde.org/D1481
This commit is contained in:
Martin Gräßlin 2016-04-25 08:51:33 +02:00
parent 8e36d9c8e1
commit f8f8e61466
5 changed files with 51 additions and 28 deletions

View file

@ -374,7 +374,9 @@ void KeyboardInputRedirection::init()
connect(workspace(), &QObject::destroyed, this, [this] { m_inited = false; }); connect(workspace(), &QObject::destroyed, this, [this] { m_inited = false; });
connect(waylandServer(), &QObject::destroyed, this, [this] { m_inited = false; }); connect(waylandServer(), &QObject::destroyed, this, [this] { m_inited = false; });
connect(workspace(), &Workspace::clientActivated, this, &KeyboardInputRedirection::update); connect(workspace(), &Workspace::clientActivated, this, &KeyboardInputRedirection::update);
connect(ScreenLocker::KSldApp::self(), &ScreenLocker::KSldApp::lockStateChanged, this, &KeyboardInputRedirection::update); if (waylandServer()->hasScreenLockerIntegration()) {
connect(ScreenLocker::KSldApp::self(), &ScreenLocker::KSldApp::lockStateChanged, this, &KeyboardInputRedirection::update);
}
QAction *switchKeyboardAction = new QAction(this); QAction *switchKeyboardAction = new QAction(this);
switchKeyboardAction->setObjectName(QStringLiteral("Switch to Next Keyboard Layout")); switchKeyboardAction->setObjectName(QStringLiteral("Switch to Next Keyboard Layout"));

View file

@ -126,7 +126,9 @@ void PointerInputRedirection::init()
emit m_cursor->changed(); emit m_cursor->changed();
connect(workspace(), &Workspace::stackingOrderChanged, this, &PointerInputRedirection::update); connect(workspace(), &Workspace::stackingOrderChanged, this, &PointerInputRedirection::update);
connect(screens(), &Screens::changed, this, &PointerInputRedirection::updateAfterScreenChange); connect(screens(), &Screens::changed, this, &PointerInputRedirection::updateAfterScreenChange);
connect(ScreenLocker::KSldApp::self(), &ScreenLocker::KSldApp::lockStateChanged, this, &PointerInputRedirection::update); if (waylandServer()->hasScreenLockerIntegration()) {
connect(ScreenLocker::KSldApp::self(), &ScreenLocker::KSldApp::lockStateChanged, this, &PointerInputRedirection::update);
}
connect(workspace(), &QObject::destroyed, this, [this] { m_inited = false; }); connect(workspace(), &QObject::destroyed, this, [this] { m_inited = false; });
connect(waylandServer(), &QObject::destroyed, this, [this] { m_inited = false; }); connect(waylandServer(), &QObject::destroyed, this, [this] { m_inited = false; });
connect(waylandServer()->seat(), &KWayland::Server::SeatInterface::dragEnded, this, connect(waylandServer()->seat(), &KWayland::Server::SeatInterface::dragEnded, this,
@ -527,7 +529,9 @@ CursorImage::CursorImage(PointerInputRedirection *parent)
reevaluteSource(); reevaluteSource();
} }
); );
connect(ScreenLocker::KSldApp::self(), &ScreenLocker::KSldApp::lockStateChanged, this, &CursorImage::reevaluteSource); if (waylandServer()->hasScreenLockerIntegration()) {
connect(ScreenLocker::KSldApp::self(), &ScreenLocker::KSldApp::lockStateChanged, this, &CursorImage::reevaluteSource);
}
connect(m_pointer, &PointerInputRedirection::decorationChanged, this, &CursorImage::updateDecoration); connect(m_pointer, &PointerInputRedirection::decorationChanged, this, &CursorImage::updateDecoration);
// connect the move resize of all window // connect the move resize of all window
auto setupMoveResizeConnection = [this] (AbstractClient *c) { auto setupMoveResizeConnection = [this] (AbstractClient *c) {

View file

@ -43,13 +43,15 @@ void TouchInputRedirection::init()
Q_ASSERT(!m_inited); Q_ASSERT(!m_inited);
m_inited = true; m_inited = true;
connect(ScreenLocker::KSldApp::self(), &ScreenLocker::KSldApp::lockStateChanged, this, if (waylandServer()->hasScreenLockerIntegration()) {
[this] { connect(ScreenLocker::KSldApp::self(), &ScreenLocker::KSldApp::lockStateChanged, this,
cancel(); [this] {
// position doesn't matter cancel();
update(); // position doesn't matter
} update();
); }
);
}
connect(workspace(), &QObject::destroyed, this, [this] { m_inited = false; }); connect(workspace(), &QObject::destroyed, this, [this] { m_inited = false; });
connect(waylandServer(), &QObject::destroyed, this, [this] { m_inited = false; }); connect(waylandServer(), &QObject::destroyed, this, [this] { m_inited = false; });
} }

View file

@ -260,25 +260,27 @@ void WaylandServer::initWorkspace()
); );
} }
ScreenLocker::KSldApp::self(); if (hasScreenLockerIntegration()) {
ScreenLocker::KSldApp::self()->setWaylandDisplay(m_display); ScreenLocker::KSldApp::self();
ScreenLocker::KSldApp::self()->setGreeterEnvironment(kwinApp()->processStartupEnvironment()); ScreenLocker::KSldApp::self()->setWaylandDisplay(m_display);
ScreenLocker::KSldApp::self()->initialize(); ScreenLocker::KSldApp::self()->setGreeterEnvironment(kwinApp()->processStartupEnvironment());
ScreenLocker::KSldApp::self()->initialize();
connect(ScreenLocker::KSldApp::self(), &ScreenLocker::KSldApp::greeterClientConnectionChanged, this, connect(ScreenLocker::KSldApp::self(), &ScreenLocker::KSldApp::greeterClientConnectionChanged, this,
[this] () { [this] () {
m_screenLockerClientConnection = ScreenLocker::KSldApp::self()->greeterClientConnection(); m_screenLockerClientConnection = ScreenLocker::KSldApp::self()->greeterClientConnection();
}
);
connect(ScreenLocker::KSldApp::self(), &ScreenLocker::KSldApp::unlocked, this,
[this] () {
m_screenLockerClientConnection = nullptr;
}
);
if (m_initFlags.testFlag(InitalizationFlag::LockScreen)) {
ScreenLocker::KSldApp::self()->lock(ScreenLocker::EstablishLock::Immediate);
} }
);
connect(ScreenLocker::KSldApp::self(), &ScreenLocker::KSldApp::unlocked, this,
[this] () {
m_screenLockerClientConnection = nullptr;
}
);
if (m_initFlags.testFlag(InitalizationFlag::LockScreen)) {
ScreenLocker::KSldApp::self()->lock(ScreenLocker::EstablishLock::Immediate);
} }
} }
@ -511,8 +513,16 @@ quint16 WaylandServer::createClientId(ClientConnection *c)
bool WaylandServer::isScreenLocked() const bool WaylandServer::isScreenLocked() const
{ {
if (!hasScreenLockerIntegration()) {
return false;
}
return ScreenLocker::KSldApp::self()->lockState() == ScreenLocker::KSldApp::Locked || return ScreenLocker::KSldApp::self()->lockState() == ScreenLocker::KSldApp::Locked ||
ScreenLocker::KSldApp::self()->lockState() == ScreenLocker::KSldApp::AcquiringLock; ScreenLocker::KSldApp::self()->lockState() == ScreenLocker::KSldApp::AcquiringLock;
} }
bool WaylandServer::hasScreenLockerIntegration() const
{
return !m_initFlags.testFlag(InitalizationFlag::NoLockScreenIntegration);
}
} }

View file

@ -66,7 +66,8 @@ class KWIN_EXPORT WaylandServer : public QObject
public: public:
enum class InitalizationFlag { enum class InitalizationFlag {
NoOptions = 0x0, NoOptions = 0x0,
LockScreen = 0x1 LockScreen = 0x1,
NoLockScreenIntegration = 0x2
}; };
Q_DECLARE_FLAGS(InitalizationFlags, InitalizationFlag) Q_DECLARE_FLAGS(InitalizationFlags, InitalizationFlag)
@ -121,6 +122,10 @@ public:
* @returns true if screen is locked. * @returns true if screen is locked.
**/ **/
bool isScreenLocked() const; bool isScreenLocked() const;
/**
* @returns whether integration with KScreenLocker is available.
**/
bool hasScreenLockerIntegration() const;
void createInternalConnection(); void createInternalConnection();
void initWorkspace(); void initWorkspace();