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(waylandServer(), &QObject::destroyed, this, [this] { m_inited = false; });
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);
switchKeyboardAction->setObjectName(QStringLiteral("Switch to Next Keyboard Layout"));

View file

@ -126,7 +126,9 @@ void PointerInputRedirection::init()
emit m_cursor->changed();
connect(workspace(), &Workspace::stackingOrderChanged, this, &PointerInputRedirection::update);
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(waylandServer(), &QObject::destroyed, this, [this] { m_inited = false; });
connect(waylandServer()->seat(), &KWayland::Server::SeatInterface::dragEnded, this,
@ -527,7 +529,9 @@ CursorImage::CursorImage(PointerInputRedirection *parent)
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 the move resize of all window
auto setupMoveResizeConnection = [this] (AbstractClient *c) {

View file

@ -43,13 +43,15 @@ void TouchInputRedirection::init()
Q_ASSERT(!m_inited);
m_inited = true;
connect(ScreenLocker::KSldApp::self(), &ScreenLocker::KSldApp::lockStateChanged, this,
[this] {
cancel();
// position doesn't matter
update();
}
);
if (waylandServer()->hasScreenLockerIntegration()) {
connect(ScreenLocker::KSldApp::self(), &ScreenLocker::KSldApp::lockStateChanged, this,
[this] {
cancel();
// position doesn't matter
update();
}
);
}
connect(workspace(), &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();
ScreenLocker::KSldApp::self()->setWaylandDisplay(m_display);
ScreenLocker::KSldApp::self()->setGreeterEnvironment(kwinApp()->processStartupEnvironment());
ScreenLocker::KSldApp::self()->initialize();
if (hasScreenLockerIntegration()) {
ScreenLocker::KSldApp::self();
ScreenLocker::KSldApp::self()->setWaylandDisplay(m_display);
ScreenLocker::KSldApp::self()->setGreeterEnvironment(kwinApp()->processStartupEnvironment());
ScreenLocker::KSldApp::self()->initialize();
connect(ScreenLocker::KSldApp::self(), &ScreenLocker::KSldApp::greeterClientConnectionChanged, this,
[this] () {
m_screenLockerClientConnection = ScreenLocker::KSldApp::self()->greeterClientConnection();
connect(ScreenLocker::KSldApp::self(), &ScreenLocker::KSldApp::greeterClientConnectionChanged, this,
[this] () {
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
{
if (!hasScreenLockerIntegration()) {
return false;
}
return ScreenLocker::KSldApp::self()->lockState() == ScreenLocker::KSldApp::Locked ||
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:
enum class InitalizationFlag {
NoOptions = 0x0,
LockScreen = 0x1
LockScreen = 0x1,
NoLockScreenIntegration = 0x2
};
Q_DECLARE_FLAGS(InitalizationFlags, InitalizationFlag)
@ -121,6 +122,10 @@ public:
* @returns true if screen is locked.
**/
bool isScreenLocked() const;
/**
* @returns whether integration with KScreenLocker is available.
**/
bool hasScreenLockerIntegration() const;
void createInternalConnection();
void initWorkspace();