[wayland] Start ksldapp from the WaylandServer

This introduces --lockscreen option in kwin_wayland which when used will
lock screen immediately. Also dependency to newly created kscreenlocker
repo is introduced.

REVIEW: 125954
icc-effect-5.14.5
Bhushan Shah 2015-11-05 18:39:23 +05:30
parent 1f9fa64a49
commit bacfd876fe
4 changed files with 34 additions and 3 deletions

View File

@ -116,6 +116,11 @@ set_package_properties(KF5Wayland PROPERTIES
TYPE REQUIRED
)
find_package(KScreenLocker CONFIG REQUIRED)
set_package_properties(KScreenLocker PROPERTIES
TYPE REQUIRED
PURPOSE "For screenlocker integration in kwin_wayland")
find_package(EGL)
set_package_properties(EGL PROPERTIES
TYPE RUNTIME
@ -462,6 +467,7 @@ set(kwin_KDE_LIBS
KF5::WindowSystem
KDecoration2::KDecoration
KDecoration2::KDecoration2Private
PW::KScreenLocker
)
set(kwin_XLIB_LIBS

View File

@ -486,6 +486,10 @@ int main(int argc, char * argv[])
i18n("List all available backends and quit."));
parser.addOption(listBackendsOption);
QCommandLineOption screenLockerOption(QStringLiteral("lockscreen"),
i18n("Starts the session in locked mode."));
parser.addOption(screenLockerOption);
parser.addPositionalArgument(QStringLiteral("applications"),
i18n("Applications to start once Wayland and Xwayland server are started"),
QStringLiteral("[/path/to/application...]"));
@ -578,7 +582,12 @@ int main(int argc, char * argv[])
// TODO: create backend without having the server running
KWin::WaylandServer *server = KWin::WaylandServer::create(&a);
server->init(parser.value(waylandSocketOption).toUtf8());
KWin::WaylandServer::InitalizationFlags flags;
if (parser.isSet(screenLockerOption)) {
flags = KWin::WaylandServer::InitalizationFlag::LockScreen;
}
server->init(parser.value(waylandSocketOption).toUtf8(), flags);
if (qobject_cast<KWin::AbstractBackend*>((*pluginIt).instantiate())) {
#if HAVE_INPUT

View File

@ -53,6 +53,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <sys/types.h>
#include <sys/socket.h>
//screenlocker
#include <KScreenLocker/KsldApp>
using namespace KWayland::Server;
namespace KWin
@ -77,8 +80,9 @@ WaylandServer::~WaylandServer()
}
}
void WaylandServer::init(const QByteArray &socketName)
void WaylandServer::init(const QByteArray &socketName, InitalizationFlags flags)
{
m_initFlags = flags;
m_display = new KWayland::Server::Display(this);
if (!socketName.isNull() && !socketName.isEmpty()) {
m_display->setSocketName(QString::fromUtf8(socketName));
@ -206,6 +210,10 @@ void WaylandServer::initWorkspace()
}
);
}
ScreenLocker::KSldApp::self();
if (m_initFlags.testFlag(InitalizationFlag::LockScreen)) {
ScreenLocker::KSldApp::self()->lock(ScreenLocker::EstablishLock::Immediate);
}
}
void WaylandServer::initOutputs()

View File

@ -62,8 +62,15 @@ class KWIN_EXPORT WaylandServer : public QObject
{
Q_OBJECT
public:
enum class InitalizationFlag {
NoOptions = 0x0,
LockScreen = 0x1
};
Q_DECLARE_FLAGS(InitalizationFlags, InitalizationFlag)
virtual ~WaylandServer();
void init(const QByteArray &socketName = QByteArray());
void init(const QByteArray &socketName = QByteArray(), InitalizationFlags flags = InitalizationFlag::NoOptions);
void initOutputs();
KWayland::Server::Display *display() {
@ -159,6 +166,7 @@ private:
QList<ShellClient*> m_clients;
QList<ShellClient*> m_internalClients;
QHash<KWayland::Server::ClientConnection*, quint16> m_clientIds;
InitalizationFlags m_initFlags;
KWIN_SINGLETON(WaylandServer)
};