2014-08-12 07:08:48 +00:00
|
|
|
/********************************************************************
|
|
|
|
KWin - the KDE window manager
|
|
|
|
This file is part of the KDE project.
|
|
|
|
|
|
|
|
Copyright (C) 2014 Martin Gräßlin <mgraesslin@kde.org>
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*********************************************************************/
|
|
|
|
#include "main_wayland.h"
|
2016-04-14 06:51:16 +00:00
|
|
|
#include "composite.h"
|
2015-02-20 08:33:36 +00:00
|
|
|
#include "workspace.h"
|
2014-08-12 07:08:48 +00:00
|
|
|
#include <config-kwin.h>
|
|
|
|
// kwin
|
2015-05-05 15:58:09 +00:00
|
|
|
#include "abstract_backend.h"
|
2015-11-12 10:29:56 +00:00
|
|
|
#include "effects.h"
|
2015-02-09 12:28:37 +00:00
|
|
|
#include "wayland_server.h"
|
2014-08-12 07:08:48 +00:00
|
|
|
#include "xcbutils.h"
|
|
|
|
|
2015-02-09 12:28:37 +00:00
|
|
|
// KWayland
|
|
|
|
#include <KWayland/Server/display.h>
|
2015-03-19 07:29:34 +00:00
|
|
|
#include <KWayland/Server/seat_interface.h>
|
2014-08-12 07:08:48 +00:00
|
|
|
// KDE
|
|
|
|
#include <KLocalizedString>
|
2015-05-05 15:58:09 +00:00
|
|
|
#include <KPluginLoader>
|
|
|
|
#include <KPluginMetaData>
|
2014-08-12 07:08:48 +00:00
|
|
|
// Qt
|
|
|
|
#include <qplatformdefs.h>
|
2015-08-20 12:31:13 +00:00
|
|
|
#include <QAbstractEventDispatcher>
|
2014-08-12 07:08:48 +00:00
|
|
|
#include <QCommandLineParser>
|
2015-02-20 08:33:36 +00:00
|
|
|
#include <QtConcurrentRun>
|
2014-08-21 09:30:56 +00:00
|
|
|
#include <QFile>
|
2015-12-08 10:42:48 +00:00
|
|
|
#include <QFileInfo>
|
2015-02-20 08:33:36 +00:00
|
|
|
#include <QFutureWatcher>
|
2015-04-21 09:21:28 +00:00
|
|
|
#include <QProcess>
|
2015-02-20 08:33:36 +00:00
|
|
|
#include <QSocketNotifier>
|
|
|
|
#include <QThread>
|
|
|
|
#include <QDebug>
|
2015-02-25 10:42:56 +00:00
|
|
|
#include <QWindow>
|
2014-08-12 07:08:48 +00:00
|
|
|
|
|
|
|
// system
|
|
|
|
#ifdef HAVE_UNISTD_H
|
|
|
|
#include <unistd.h>
|
|
|
|
#endif // HAVE_UNISTD_H
|
|
|
|
|
2015-12-08 10:42:48 +00:00
|
|
|
#if HAVE_SYS_PRCTL_H
|
|
|
|
#include <sys/prctl.h>
|
|
|
|
#endif
|
|
|
|
|
2014-08-12 13:27:35 +00:00
|
|
|
#include <iostream>
|
2015-10-02 07:31:47 +00:00
|
|
|
#include <iomanip>
|
2014-08-12 13:27:35 +00:00
|
|
|
|
2014-08-12 07:08:48 +00:00
|
|
|
namespace KWin
|
|
|
|
{
|
|
|
|
|
2014-08-13 11:13:44 +00:00
|
|
|
static void sighandler(int)
|
|
|
|
{
|
|
|
|
QApplication::exit();
|
|
|
|
}
|
|
|
|
|
2015-02-20 10:53:25 +00:00
|
|
|
static void readDisplay(int pipe);
|
|
|
|
|
2014-08-12 07:08:48 +00:00
|
|
|
//************************************
|
|
|
|
// ApplicationWayland
|
|
|
|
//************************************
|
|
|
|
|
|
|
|
ApplicationWayland::ApplicationWayland(int &argc, char **argv)
|
|
|
|
: Application(OperationModeWaylandAndX11, argc, argv)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
ApplicationWayland::~ApplicationWayland()
|
|
|
|
{
|
2015-11-30 14:57:22 +00:00
|
|
|
if (!waylandServer()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-11-12 14:12:01 +00:00
|
|
|
waylandServer()->backend()->setOutputsEnabled(false);
|
2014-08-12 07:08:48 +00:00
|
|
|
destroyWorkspace();
|
2015-11-10 07:52:40 +00:00
|
|
|
waylandServer()->dispatch();
|
2015-11-12 10:29:56 +00:00
|
|
|
// need to unload all effects prior to destroying X connection as they might do X calls
|
|
|
|
if (effects) {
|
|
|
|
static_cast<EffectsHandlerImpl*>(effects)->unloadAllEffects();
|
|
|
|
}
|
2015-11-12 13:05:09 +00:00
|
|
|
disconnect(m_xwaylandFailConnection);
|
2015-02-20 08:33:36 +00:00
|
|
|
if (x11Connection()) {
|
|
|
|
Xcb::setInputFocus(XCB_INPUT_FOCUS_POINTER_ROOT);
|
2015-05-26 12:26:56 +00:00
|
|
|
destroyAtoms();
|
2015-11-12 14:13:42 +00:00
|
|
|
emit x11ConnectionAboutToBeDestroyed();
|
2015-02-20 08:33:36 +00:00
|
|
|
xcb_disconnect(x11Connection());
|
2015-11-10 12:54:26 +00:00
|
|
|
setX11Connection(nullptr);
|
2015-02-20 08:33:36 +00:00
|
|
|
}
|
2015-05-21 13:11:11 +00:00
|
|
|
if (m_xwaylandProcess) {
|
|
|
|
m_xwaylandProcess->terminate();
|
2015-11-12 14:15:44 +00:00
|
|
|
while (m_xwaylandProcess->state() != QProcess::NotRunning) {
|
|
|
|
processEvents(QEventLoop::WaitForMoreEvents);
|
|
|
|
}
|
2015-11-10 13:21:48 +00:00
|
|
|
waylandServer()->destroyXWaylandConnection();
|
2015-05-21 13:11:11 +00:00
|
|
|
}
|
2015-11-18 09:29:10 +00:00
|
|
|
waylandServer()->terminateClientConnections();
|
2015-11-10 07:52:40 +00:00
|
|
|
destroyCompositor();
|
2014-08-12 07:08:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ApplicationWayland::performStartup()
|
|
|
|
{
|
2015-02-20 13:57:06 +00:00
|
|
|
setOperationMode(m_startXWayland ? OperationModeXwayland : OperationModeWaylandAndX11);
|
2015-02-23 14:57:00 +00:00
|
|
|
// first load options - done internally by a different thread
|
|
|
|
createOptions();
|
2015-04-02 12:37:23 +00:00
|
|
|
waylandServer()->createInternalConnection();
|
2015-02-20 13:57:06 +00:00
|
|
|
|
|
|
|
// try creating the Wayland Backend
|
|
|
|
createInput();
|
2015-03-23 11:45:21 +00:00
|
|
|
createBackend();
|
2015-02-20 13:57:06 +00:00
|
|
|
}
|
2015-02-20 10:53:25 +00:00
|
|
|
|
2016-01-30 11:31:28 +00:00
|
|
|
void ApplicationWayland::setupCrashHandler()
|
|
|
|
{
|
|
|
|
// this disables auto-restart of kwin_wayland
|
|
|
|
// do nothing hence allowing OS to create dump and so on
|
|
|
|
}
|
|
|
|
|
2015-03-23 11:45:21 +00:00
|
|
|
void ApplicationWayland::createBackend()
|
|
|
|
{
|
2015-05-05 15:58:09 +00:00
|
|
|
AbstractBackend *backend = waylandServer()->backend();
|
|
|
|
connect(backend, &AbstractBackend::screensQueried, this, &ApplicationWayland::continueStartupWithScreens);
|
|
|
|
connect(backend, &AbstractBackend::initFailed, this,
|
|
|
|
[] () {
|
|
|
|
std::cerr << "FATAL ERROR: backend failed to initialize, exiting now" << std::endl;
|
|
|
|
::exit(1);
|
2015-03-23 11:45:21 +00:00
|
|
|
}
|
2015-05-05 15:58:09 +00:00
|
|
|
);
|
|
|
|
backend->init();
|
2015-03-23 11:45:21 +00:00
|
|
|
}
|
|
|
|
|
2015-02-20 13:57:06 +00:00
|
|
|
void ApplicationWayland::continueStartupWithScreens()
|
|
|
|
{
|
2015-05-06 07:03:54 +00:00
|
|
|
disconnect(waylandServer()->backend(), &AbstractBackend::screensQueried, this, &ApplicationWayland::continueStartupWithScreens);
|
2015-02-20 13:57:06 +00:00
|
|
|
createScreens();
|
|
|
|
waylandServer()->initOutputs();
|
|
|
|
|
|
|
|
if (!m_startXWayland) {
|
2015-02-20 10:53:25 +00:00
|
|
|
continueStartupWithX();
|
2015-02-20 13:57:06 +00:00
|
|
|
return;
|
2015-02-20 10:53:25 +00:00
|
|
|
}
|
2015-02-23 14:57:00 +00:00
|
|
|
createCompositor();
|
2016-04-14 06:51:16 +00:00
|
|
|
connect(Compositor::self(), &Compositor::sceneCreated, this, &ApplicationWayland::startXwaylandServer);
|
2015-02-20 10:53:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ApplicationWayland::continueStartupWithX()
|
|
|
|
{
|
|
|
|
createX11Connection();
|
2015-02-20 08:33:36 +00:00
|
|
|
xcb_connection_t *c = x11Connection();
|
2015-02-20 10:53:25 +00:00
|
|
|
if (!c) {
|
|
|
|
// about to quit
|
|
|
|
return;
|
|
|
|
}
|
2015-02-20 08:33:36 +00:00
|
|
|
QSocketNotifier *notifier = new QSocketNotifier(xcb_get_file_descriptor(c), QSocketNotifier::Read, this);
|
|
|
|
auto processXcbEvents = [this, c] {
|
|
|
|
while (auto event = xcb_poll_for_event(c)) {
|
|
|
|
updateX11Time(event);
|
2015-04-22 09:23:06 +00:00
|
|
|
long result = 0;
|
|
|
|
if (QThread::currentThread()->eventDispatcher()->filterNativeEvent(QByteArrayLiteral("xcb_generic_event_t"), event, &result)) {
|
|
|
|
free(event);
|
|
|
|
continue;
|
|
|
|
}
|
2015-02-20 08:33:36 +00:00
|
|
|
if (Workspace::self()) {
|
|
|
|
Workspace::self()->workspaceEvent(event);
|
|
|
|
}
|
|
|
|
free(event);
|
|
|
|
}
|
|
|
|
xcb_flush(c);
|
|
|
|
};
|
|
|
|
connect(notifier, &QSocketNotifier::activated, this, processXcbEvents);
|
|
|
|
connect(QThread::currentThread()->eventDispatcher(), &QAbstractEventDispatcher::aboutToBlock, this, processXcbEvents);
|
|
|
|
connect(QThread::currentThread()->eventDispatcher(), &QAbstractEventDispatcher::awake, this, processXcbEvents);
|
2014-08-12 07:08:48 +00:00
|
|
|
|
2015-02-20 10:53:25 +00:00
|
|
|
// create selection owner for WM_S0 - magic X display number expected by XWayland
|
|
|
|
KSelectionOwner owner("WM_S0", c, x11RootWindow());
|
|
|
|
owner.claim(true);
|
2014-08-12 07:08:48 +00:00
|
|
|
|
|
|
|
createAtoms();
|
|
|
|
|
|
|
|
setupEventFilters();
|
|
|
|
|
|
|
|
// Check whether another windowmanager is running
|
|
|
|
const uint32_t maskValues[] = {XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT};
|
|
|
|
ScopedCPointer<xcb_generic_error_t> redirectCheck(xcb_request_check(connection(),
|
|
|
|
xcb_change_window_attributes_checked(connection(),
|
|
|
|
rootWindow(),
|
|
|
|
XCB_CW_EVENT_MASK,
|
|
|
|
maskValues)));
|
|
|
|
if (!redirectCheck.isNull()) {
|
2014-08-12 07:45:43 +00:00
|
|
|
fputs(i18n("kwin_wayland: an X11 window manager is running on the X11 Display.\n").toLocal8Bit().constData(), stderr);
|
|
|
|
::exit(1);
|
|
|
|
}
|
|
|
|
|
2015-06-13 02:06:12 +00:00
|
|
|
if (!m_inputMethodServerToStart.isEmpty()) {
|
|
|
|
int socket = dup(waylandServer()->createInputMethodConnection());
|
|
|
|
if (socket >= 0) {
|
2015-06-29 08:51:37 +00:00
|
|
|
QProcessEnvironment environment = m_environment;
|
2015-06-13 02:06:12 +00:00
|
|
|
environment.insert(QStringLiteral("WAYLAND_SOCKET"), QByteArray::number(socket));
|
|
|
|
environment.insert(QStringLiteral("QT_QPA_PLATFORM"), QStringLiteral("wayland"));
|
|
|
|
environment.remove("DISPLAY");
|
|
|
|
environment.remove("WAYLAND_DISPLAY");
|
2015-12-15 09:22:03 +00:00
|
|
|
QProcess *p = new Process(this);
|
2015-12-15 09:08:36 +00:00
|
|
|
p->setProcessChannelMode(QProcess::ForwardedErrorChannel);
|
2015-11-10 13:38:45 +00:00
|
|
|
auto finishedSignal = static_cast<void (QProcess::*)(int, QProcess::ExitStatus)>(&QProcess::finished);
|
|
|
|
connect(p, finishedSignal, this,
|
|
|
|
[this, p] {
|
|
|
|
if (waylandServer()) {
|
|
|
|
waylandServer()->destroyInputMethodConnection();
|
|
|
|
}
|
|
|
|
p->deleteLater();
|
|
|
|
}
|
|
|
|
);
|
2015-06-13 02:06:12 +00:00
|
|
|
p->setProcessEnvironment(environment);
|
|
|
|
p->start(m_inputMethodServerToStart);
|
|
|
|
p->waitForStarted();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-07-07 15:35:57 +00:00
|
|
|
m_environment.insert(QStringLiteral("DISPLAY"), QString::fromUtf8(qgetenv("DISPLAY")));
|
2015-11-19 08:16:23 +00:00
|
|
|
// start session
|
|
|
|
if (!m_sessionArgument.isEmpty()) {
|
2015-12-15 09:22:03 +00:00
|
|
|
QProcess *p = new Process(this);
|
2015-12-15 09:08:36 +00:00
|
|
|
p->setProcessChannelMode(QProcess::ForwardedErrorChannel);
|
2015-11-19 08:16:23 +00:00
|
|
|
p->setProcessEnvironment(m_environment);
|
|
|
|
auto finishedSignal = static_cast<void (QProcess::*)(int, QProcess::ExitStatus)>(&QProcess::finished);
|
|
|
|
connect(p, finishedSignal, this, &ApplicationWayland::quit);
|
|
|
|
p->start(m_sessionArgument);
|
|
|
|
}
|
2015-04-21 09:21:28 +00:00
|
|
|
// start the applications passed to us as command line arguments
|
|
|
|
if (!m_applicationsToStart.isEmpty()) {
|
|
|
|
for (const QString &application: m_applicationsToStart) {
|
|
|
|
// note: this will kill the started process when we exit
|
|
|
|
// this is going to happen anyway as we are the wayland and X server the app connects to
|
2015-12-15 09:22:03 +00:00
|
|
|
QProcess *p = new Process(this);
|
2015-12-15 09:08:36 +00:00
|
|
|
p->setProcessChannelMode(QProcess::ForwardedErrorChannel);
|
2015-07-07 15:35:57 +00:00
|
|
|
p->setProcessEnvironment(m_environment);
|
2015-04-21 09:21:28 +00:00
|
|
|
p->start(application);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-08-18 06:21:23 +00:00
|
|
|
createWorkspace();
|
|
|
|
|
|
|
|
Xcb::sync(); // Trigger possible errors, there's still a chance to abort
|
|
|
|
|
|
|
|
notifyKSplash();
|
2014-08-12 07:08:48 +00:00
|
|
|
}
|
|
|
|
|
2015-02-20 10:53:25 +00:00
|
|
|
void ApplicationWayland::createX11Connection()
|
2015-02-20 08:33:36 +00:00
|
|
|
{
|
|
|
|
int screenNumber = 0;
|
|
|
|
xcb_connection_t *c = nullptr;
|
2015-02-20 10:53:25 +00:00
|
|
|
if (m_xcbConnectionFd == -1) {
|
2015-02-20 08:33:36 +00:00
|
|
|
c = xcb_connect(nullptr, &screenNumber);
|
|
|
|
} else {
|
2015-02-20 10:53:25 +00:00
|
|
|
c = xcb_connect_to_fd(m_xcbConnectionFd, nullptr);
|
2015-02-20 08:33:36 +00:00
|
|
|
}
|
2015-02-20 10:53:25 +00:00
|
|
|
if (int error = xcb_connection_has_error(c)) {
|
|
|
|
std::cerr << "FATAL ERROR: Creating connection to XServer failed: " << error << std::endl;
|
2015-02-20 08:33:36 +00:00
|
|
|
exit(1);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
setX11Connection(c);
|
|
|
|
// we don't support X11 multi-head in Wayland
|
|
|
|
setX11ScreenNumber(screenNumber);
|
|
|
|
setX11RootWindow(defaultScreen()->root);
|
|
|
|
}
|
|
|
|
|
2015-05-21 13:11:11 +00:00
|
|
|
void ApplicationWayland::startXwaylandServer()
|
2014-08-12 13:27:35 +00:00
|
|
|
{
|
2016-04-14 06:51:16 +00:00
|
|
|
disconnect(Compositor::self(), &Compositor::sceneCreated, this, &ApplicationWayland::startXwaylandServer);
|
2014-08-12 13:27:35 +00:00
|
|
|
int pipeFds[2];
|
|
|
|
if (pipe(pipeFds) != 0) {
|
2015-02-09 12:40:01 +00:00
|
|
|
std::cerr << "FATAL ERROR failed to create pipe to start Xwayland " << std::endl;
|
2014-08-12 13:27:35 +00:00
|
|
|
exit(1);
|
2015-05-21 13:11:11 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
int sx[2];
|
|
|
|
if (socketpair(AF_UNIX, SOCK_STREAM | SOCK_CLOEXEC, 0, sx) < 0) {
|
|
|
|
std::cerr << "FATAL ERROR: failed to open socket to open XCB connection" << std::endl;
|
|
|
|
exit(1);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
int fd = dup(sx[1]);
|
|
|
|
if (fd < 0) {
|
|
|
|
std::cerr << "FATAL ERROR: failed to open socket to open XCB connection" << std::endl;
|
|
|
|
exit(20);
|
|
|
|
return;
|
2014-08-12 13:27:35 +00:00
|
|
|
}
|
|
|
|
|
2015-05-21 13:11:11 +00:00
|
|
|
const int waylandSocket = waylandServer()->createXWaylandConnection();
|
|
|
|
if (waylandSocket == -1) {
|
|
|
|
std::cerr << "FATAL ERROR: failed to open socket for Xwayland" << std::endl;
|
|
|
|
exit(1);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
const int wlfd = dup(waylandSocket);
|
|
|
|
if (wlfd < 0) {
|
|
|
|
std::cerr << "FATAL ERROR: failed to open socket for Xwayland" << std::endl;
|
2014-08-12 13:27:35 +00:00
|
|
|
exit(20);
|
2015-05-21 13:11:11 +00:00
|
|
|
return;
|
2014-08-12 13:27:35 +00:00
|
|
|
}
|
2015-05-21 13:11:11 +00:00
|
|
|
|
|
|
|
m_xcbConnectionFd = sx[0];
|
|
|
|
|
2015-12-15 09:22:03 +00:00
|
|
|
m_xwaylandProcess = new Process(kwinApp());
|
2015-12-15 09:08:36 +00:00
|
|
|
m_xwaylandProcess->setProcessChannelMode(QProcess::ForwardedErrorChannel);
|
2015-05-21 13:11:11 +00:00
|
|
|
m_xwaylandProcess->setProgram(QStringLiteral("Xwayland"));
|
2015-06-29 08:51:37 +00:00
|
|
|
QProcessEnvironment env = m_environment;
|
2015-05-21 13:11:11 +00:00
|
|
|
env.insert("WAYLAND_SOCKET", QByteArray::number(wlfd));
|
|
|
|
m_xwaylandProcess->setProcessEnvironment(env);
|
|
|
|
m_xwaylandProcess->setArguments({QStringLiteral("-displayfd"),
|
|
|
|
QString::number(pipeFds[1]),
|
|
|
|
QStringLiteral("-rootless"),
|
|
|
|
QStringLiteral("-wm"),
|
|
|
|
QString::number(fd)});
|
2015-11-12 13:05:09 +00:00
|
|
|
m_xwaylandFailConnection = connect(m_xwaylandProcess, static_cast<void (QProcess::*)(QProcess::ProcessError)>(&QProcess::error), this,
|
2015-05-21 13:11:11 +00:00
|
|
|
[] (QProcess::ProcessError error) {
|
|
|
|
if (error == QProcess::FailedToStart) {
|
|
|
|
std::cerr << "FATAL ERROR: failed to start Xwayland" << std::endl;
|
|
|
|
} else {
|
|
|
|
std::cerr << "FATAL ERROR: Xwayland failed, going to exit now" << std::endl;
|
|
|
|
}
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
);
|
|
|
|
const int xDisplayPipe = pipeFds[0];
|
|
|
|
connect(m_xwaylandProcess, &QProcess::started, this,
|
|
|
|
[this, xDisplayPipe] {
|
|
|
|
QFutureWatcher<void> *watcher = new QFutureWatcher<void>(this);
|
|
|
|
QObject::connect(watcher, &QFutureWatcher<void>::finished, this, &ApplicationWayland::continueStartupWithX, Qt::QueuedConnection);
|
|
|
|
QObject::connect(watcher, &QFutureWatcher<void>::finished, watcher, &QFutureWatcher<void>::deleteLater, Qt::QueuedConnection);
|
|
|
|
watcher->setFuture(QtConcurrent::run(readDisplay, xDisplayPipe));
|
|
|
|
}
|
|
|
|
);
|
|
|
|
m_xwaylandProcess->start();
|
2014-08-12 13:27:35 +00:00
|
|
|
close(pipeFds[1]);
|
2015-02-09 12:28:37 +00:00
|
|
|
}
|
2014-08-12 13:27:35 +00:00
|
|
|
|
2015-02-09 12:28:37 +00:00
|
|
|
static void readDisplay(int pipe)
|
|
|
|
{
|
2014-08-12 13:27:35 +00:00
|
|
|
QFile readPipe;
|
2015-02-09 12:28:37 +00:00
|
|
|
if (!readPipe.open(pipe, QIODevice::ReadOnly)) {
|
|
|
|
std::cerr << "FATAL ERROR failed to open pipe to start X Server" << std::endl;
|
2014-08-12 13:27:35 +00:00
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
QByteArray displayNumber = readPipe.readLine();
|
|
|
|
|
|
|
|
displayNumber.prepend(QByteArray(":"));
|
|
|
|
displayNumber.remove(displayNumber.size() -1, 1);
|
2014-11-07 13:58:21 +00:00
|
|
|
std::cout << "X-Server started on display " << displayNumber.constData() << std::endl;
|
2014-08-12 13:27:35 +00:00
|
|
|
|
|
|
|
setenv("DISPLAY", displayNumber.constData(), true);
|
|
|
|
|
|
|
|
// close our pipe
|
2015-02-09 12:28:37 +00:00
|
|
|
close(pipe);
|
2014-08-12 13:27:35 +00:00
|
|
|
}
|
|
|
|
|
2015-06-29 09:59:27 +00:00
|
|
|
static const QString s_waylandPlugin = QStringLiteral("KWinWaylandWaylandBackend");
|
|
|
|
static const QString s_x11Plugin = QStringLiteral("KWinWaylandX11Backend");
|
|
|
|
static const QString s_fbdevPlugin = QStringLiteral("KWinWaylandFbdevBackend");
|
|
|
|
#if HAVE_DRM
|
|
|
|
static const QString s_drmPlugin = QStringLiteral("KWinWaylandDrmBackend");
|
|
|
|
#endif
|
|
|
|
#if HAVE_LIBHYBRIS
|
|
|
|
static const QString s_hwcomposerPlugin = QStringLiteral("KWinWaylandHwcomposerBackend");
|
|
|
|
#endif
|
2015-10-02 08:44:29 +00:00
|
|
|
static const QString s_virtualPlugin = QStringLiteral("KWinWaylandVirtualBackend");
|
2015-06-29 09:59:27 +00:00
|
|
|
|
|
|
|
static QString automaticBackendSelection()
|
|
|
|
{
|
|
|
|
if (qEnvironmentVariableIsSet("WAYLAND_DISPLAY")) {
|
|
|
|
return s_waylandPlugin;
|
|
|
|
}
|
|
|
|
if (qEnvironmentVariableIsSet("DISPLAY")) {
|
|
|
|
return s_x11Plugin;
|
|
|
|
}
|
|
|
|
#if HAVE_LIBHYBRIS
|
|
|
|
if (qEnvironmentVariableIsSet("ANDROID_ROOT")) {
|
|
|
|
return s_hwcomposerPlugin;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#if HAVE_DRM
|
|
|
|
return s_drmPlugin;
|
|
|
|
#endif
|
|
|
|
return s_fbdevPlugin;
|
|
|
|
}
|
|
|
|
|
2015-12-08 10:42:48 +00:00
|
|
|
static void disablePtrace()
|
|
|
|
{
|
|
|
|
#if HAVE_PR_SET_DUMPABLE
|
|
|
|
// check whether we are running under a debugger
|
|
|
|
const QFileInfo parent(QStringLiteral("/proc/%1/exe").arg(getppid()));
|
|
|
|
if (parent.isSymLink() && parent.symLinkTarget().endsWith(QLatin1String("/gdb"))) {
|
|
|
|
// debugger, don't adjust
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// disable ptrace in kwin_wayland
|
|
|
|
prctl(PR_SET_DUMPABLE, 0);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2014-08-12 07:08:48 +00:00
|
|
|
} // namespace
|
|
|
|
|
2015-07-06 07:57:30 +00:00
|
|
|
int main(int argc, char * argv[])
|
2014-08-12 07:08:48 +00:00
|
|
|
{
|
2015-12-08 10:42:48 +00:00
|
|
|
KWin::disablePtrace();
|
2014-08-12 07:08:48 +00:00
|
|
|
KWin::Application::setupMalloc();
|
|
|
|
KWin::Application::setupLocalizedString();
|
|
|
|
|
2014-08-13 11:13:44 +00:00
|
|
|
if (signal(SIGTERM, KWin::sighandler) == SIG_IGN)
|
|
|
|
signal(SIGTERM, SIG_IGN);
|
|
|
|
if (signal(SIGINT, KWin::sighandler) == SIG_IGN)
|
|
|
|
signal(SIGINT, SIG_IGN);
|
|
|
|
if (signal(SIGHUP, KWin::sighandler) == SIG_IGN)
|
|
|
|
signal(SIGHUP, SIG_IGN);
|
2015-03-31 07:30:19 +00:00
|
|
|
// ensure that no thread takes SIGUSR
|
2016-01-30 11:31:19 +00:00
|
|
|
sigset_t userSignals;
|
|
|
|
sigemptyset(&userSignals);
|
|
|
|
sigaddset(&userSignals, SIGUSR1);
|
|
|
|
sigaddset(&userSignals, SIGUSR2);
|
|
|
|
pthread_sigmask(SIG_BLOCK, &userSignals, nullptr);
|
2014-08-13 11:13:44 +00:00
|
|
|
|
2015-06-29 08:51:37 +00:00
|
|
|
QProcessEnvironment environment = QProcessEnvironment::systemEnvironment();
|
|
|
|
|
2015-08-18 06:05:08 +00:00
|
|
|
// enforce our internal qpa plugin, unfortunately command line switch has precedence
|
|
|
|
setenv("QT_QPA_PLATFORM", "wayland-org.kde.kwin.qpa", true);
|
2015-03-17 09:31:18 +00:00
|
|
|
|
2015-04-17 16:13:39 +00:00
|
|
|
qunsetenv("QT_DEVICE_PIXEL_RATIO");
|
2015-06-13 02:06:12 +00:00
|
|
|
qunsetenv("QT_IM_MODULE");
|
2015-07-10 06:57:56 +00:00
|
|
|
qputenv("QSG_RENDER_LOOP", "basic");
|
2015-10-29 09:08:23 +00:00
|
|
|
#if (QT_VERSION >= QT_VERSION_CHECK(5, 6, 0))
|
2015-11-09 17:21:50 +00:00
|
|
|
QCoreApplication::setAttribute(Qt::AA_DisableHighDpiScaling);
|
2015-10-29 09:08:23 +00:00
|
|
|
#endif
|
2014-08-12 07:08:48 +00:00
|
|
|
KWin::ApplicationWayland a(argc, argv);
|
|
|
|
a.setupTranslator();
|
2015-11-03 15:52:55 +00:00
|
|
|
// reset QT_QPA_PLATFORM to a sane value for any processes started from KWin
|
|
|
|
setenv("QT_QPA_PLATFORM", "wayland", true);
|
2015-02-09 12:28:37 +00:00
|
|
|
|
2014-08-12 07:08:48 +00:00
|
|
|
KWin::Application::createAboutData();
|
|
|
|
|
2015-10-02 07:31:47 +00:00
|
|
|
const auto availablePlugins = KPluginLoader::findPlugins(QStringLiteral("org.kde.kwin.waylandbackends"));
|
2015-10-02 07:47:27 +00:00
|
|
|
auto hasPlugin = [&availablePlugins] (const QString &name) {
|
|
|
|
return std::any_of(availablePlugins.begin(), availablePlugins.end(),
|
|
|
|
[name] (const KPluginMetaData &plugin) {
|
|
|
|
return plugin.pluginId() == name;
|
|
|
|
}
|
|
|
|
);
|
|
|
|
};
|
2015-10-03 18:14:16 +00:00
|
|
|
const bool hasWindowedOption = hasPlugin(KWin::s_x11Plugin) || hasPlugin(KWin::s_waylandPlugin);
|
|
|
|
const bool hasSizeOption = hasPlugin(KWin::s_x11Plugin) || hasPlugin(KWin::s_virtualPlugin);
|
2015-11-24 12:11:29 +00:00
|
|
|
const bool hasOutputCountOption = hasPlugin(KWin::s_x11Plugin);
|
2015-10-03 18:14:16 +00:00
|
|
|
const bool hasX11Option = hasPlugin(KWin::s_x11Plugin);
|
|
|
|
const bool hasVirtualOption = hasPlugin(KWin::s_virtualPlugin);
|
|
|
|
const bool hasWaylandOption = hasPlugin(KWin::s_waylandPlugin);
|
|
|
|
const bool hasFramebufferOption = hasPlugin(KWin::s_fbdevPlugin);
|
|
|
|
#if HAVE_DRM
|
|
|
|
const bool hasDrmOption = hasPlugin(KWin::s_drmPlugin);
|
|
|
|
#endif
|
|
|
|
#if HAVE_LIBHYBRIS
|
|
|
|
const bool hasHwcomposerOption = hasPlugin(KWin::s_hwcomposerPlugin);
|
|
|
|
#endif
|
2015-10-02 07:31:47 +00:00
|
|
|
|
2015-01-09 15:00:16 +00:00
|
|
|
QCommandLineOption xwaylandOption(QStringLiteral("xwayland"),
|
2015-02-09 12:40:01 +00:00
|
|
|
i18n("Start a rootless Xwayland server."));
|
2015-02-09 12:28:37 +00:00
|
|
|
QCommandLineOption waylandSocketOption(QStringList{QStringLiteral("s"), QStringLiteral("socket")},
|
|
|
|
i18n("Name of the Wayland socket to listen on. If not set \"wayland-0\" is used."),
|
|
|
|
QStringLiteral("socket"));
|
2015-03-19 07:29:34 +00:00
|
|
|
QCommandLineOption windowedOption(QStringLiteral("windowed"),
|
|
|
|
i18n("Use a nested compositor in windowed mode."));
|
2015-03-31 09:00:46 +00:00
|
|
|
QCommandLineOption framebufferOption(QStringLiteral("framebuffer"),
|
|
|
|
i18n("Render to framebuffer."));
|
|
|
|
QCommandLineOption framebufferDeviceOption(QStringLiteral("fb-device"),
|
|
|
|
i18n("The framebuffer device to render to."),
|
|
|
|
QStringLiteral("fbdev"));
|
|
|
|
framebufferDeviceOption.setDefaultValue(QStringLiteral("/dev/fb0"));
|
2015-03-19 07:29:34 +00:00
|
|
|
QCommandLineOption x11DisplayOption(QStringLiteral("x11-display"),
|
|
|
|
i18n("The X11 Display to use in windowed mode on platform X11."),
|
|
|
|
QStringLiteral("display"));
|
2015-03-23 11:45:21 +00:00
|
|
|
QCommandLineOption waylandDisplayOption(QStringLiteral("wayland-display"),
|
|
|
|
i18n("The Wayland Display to use in windowed mode on platform Wayland."),
|
|
|
|
QStringLiteral("display"));
|
2015-10-02 08:44:29 +00:00
|
|
|
QCommandLineOption virtualFbOption(QStringLiteral("virtual"), i18n("Render to a virtual framebuffer."));
|
2015-03-19 07:29:34 +00:00
|
|
|
QCommandLineOption widthOption(QStringLiteral("width"),
|
|
|
|
i18n("The width for windowed mode. Default width is 1024."),
|
|
|
|
QStringLiteral("width"));
|
|
|
|
widthOption.setDefaultValue(QString::number(1024));
|
|
|
|
QCommandLineOption heightOption(QStringLiteral("height"),
|
|
|
|
i18n("The height for windowed mode. Default height is 768."),
|
|
|
|
QStringLiteral("height"));
|
|
|
|
heightOption.setDefaultValue(QString::number(768));
|
2015-11-24 12:11:29 +00:00
|
|
|
QCommandLineOption outputCountOption(QStringLiteral("output-count"),
|
|
|
|
i18n("The number of windows to open as outputs in windowed mode. Default value is 1"),
|
|
|
|
QStringLiteral("height"));
|
|
|
|
outputCountOption.setDefaultValue(QString::number(1));
|
2014-08-12 13:27:35 +00:00
|
|
|
|
2014-08-12 07:08:48 +00:00
|
|
|
QCommandLineParser parser;
|
|
|
|
a.setupCommandLine(&parser);
|
2015-01-09 15:00:16 +00:00
|
|
|
parser.addOption(xwaylandOption);
|
2015-02-09 12:28:37 +00:00
|
|
|
parser.addOption(waylandSocketOption);
|
2015-10-03 18:14:16 +00:00
|
|
|
if (hasWindowedOption) {
|
2015-10-02 07:47:27 +00:00
|
|
|
parser.addOption(windowedOption);
|
|
|
|
}
|
2015-10-03 18:14:16 +00:00
|
|
|
if (hasX11Option) {
|
2015-10-02 07:47:27 +00:00
|
|
|
parser.addOption(x11DisplayOption);
|
|
|
|
}
|
2015-10-03 18:14:16 +00:00
|
|
|
if (hasWaylandOption) {
|
2015-10-02 07:47:27 +00:00
|
|
|
parser.addOption(waylandDisplayOption);
|
|
|
|
}
|
2015-10-03 18:14:16 +00:00
|
|
|
if (hasFramebufferOption) {
|
2015-10-02 07:47:27 +00:00
|
|
|
parser.addOption(framebufferOption);
|
|
|
|
parser.addOption(framebufferDeviceOption);
|
|
|
|
}
|
2015-10-03 18:14:16 +00:00
|
|
|
if (hasVirtualOption) {
|
2015-10-02 08:44:29 +00:00
|
|
|
parser.addOption(virtualFbOption);
|
|
|
|
}
|
2015-10-03 18:14:16 +00:00
|
|
|
if (hasSizeOption) {
|
2015-10-02 07:47:27 +00:00
|
|
|
parser.addOption(widthOption);
|
|
|
|
parser.addOption(heightOption);
|
|
|
|
}
|
2015-11-24 12:11:29 +00:00
|
|
|
if (hasOutputCountOption) {
|
|
|
|
parser.addOption(outputCountOption);
|
|
|
|
}
|
2015-05-06 15:47:07 +00:00
|
|
|
#if HAVE_LIBHYBRIS
|
|
|
|
QCommandLineOption hwcomposerOption(QStringLiteral("hwcomposer"), i18n("Use libhybris hwcomposer"));
|
2015-10-03 18:14:16 +00:00
|
|
|
if (hasHwcomposerOption) {
|
2015-10-02 07:47:27 +00:00
|
|
|
parser.addOption(hwcomposerOption);
|
|
|
|
}
|
2015-05-06 15:47:07 +00:00
|
|
|
#endif
|
2014-08-15 12:03:52 +00:00
|
|
|
#if HAVE_INPUT
|
|
|
|
QCommandLineOption libinputOption(QStringLiteral("libinput"),
|
|
|
|
i18n("Enable libinput support for input events processing. Note: never use in a nested session."));
|
|
|
|
parser.addOption(libinputOption);
|
2015-04-09 12:49:32 +00:00
|
|
|
#endif
|
|
|
|
#if HAVE_DRM
|
|
|
|
QCommandLineOption drmOption(QStringLiteral("drm"), i18n("Render through drm node."));
|
2015-10-03 18:14:16 +00:00
|
|
|
if (hasDrmOption) {
|
2015-10-02 07:47:27 +00:00
|
|
|
parser.addOption(drmOption);
|
|
|
|
}
|
2014-08-15 12:03:52 +00:00
|
|
|
#endif
|
2015-06-13 02:06:12 +00:00
|
|
|
|
|
|
|
QCommandLineOption inputMethodOption(QStringLiteral("inputmethod"),
|
|
|
|
i18n("Input method that KWin starts."),
|
|
|
|
QStringLiteral("path/to/imserver"));
|
|
|
|
parser.addOption(inputMethodOption);
|
|
|
|
|
2015-10-02 07:31:47 +00:00
|
|
|
QCommandLineOption listBackendsOption(QStringLiteral("list-backends"),
|
|
|
|
i18n("List all available backends and quit."));
|
|
|
|
parser.addOption(listBackendsOption);
|
|
|
|
|
2015-11-05 13:09:23 +00:00
|
|
|
QCommandLineOption screenLockerOption(QStringLiteral("lockscreen"),
|
|
|
|
i18n("Starts the session in locked mode."));
|
|
|
|
parser.addOption(screenLockerOption);
|
|
|
|
|
2015-11-19 08:16:23 +00:00
|
|
|
QCommandLineOption exitWithSessionOption(QStringLiteral("exit-with-session"),
|
|
|
|
i18n("Exit after the session application, which is started by KWin, closed."),
|
|
|
|
QStringLiteral("/path/to/session"));
|
|
|
|
parser.addOption(exitWithSessionOption);
|
|
|
|
|
2015-11-24 08:01:46 +00:00
|
|
|
#ifdef KWIN_BUILD_ACTIVITIES
|
|
|
|
QCommandLineOption noActivitiesOption(QStringLiteral("no-kactivities"),
|
|
|
|
i18n("Disable KActivities integration."));
|
|
|
|
parser.addOption(noActivitiesOption);
|
|
|
|
#endif
|
|
|
|
|
2015-04-21 09:21:28 +00:00
|
|
|
parser.addPositionalArgument(QStringLiteral("applications"),
|
|
|
|
i18n("Applications to start once Wayland and Xwayland server are started"),
|
|
|
|
QStringLiteral("[/path/to/application...]"));
|
2014-08-12 07:08:48 +00:00
|
|
|
|
|
|
|
parser.process(a);
|
|
|
|
a.processCommandLine(&parser);
|
|
|
|
|
2015-11-24 08:01:46 +00:00
|
|
|
#ifdef KWIN_BUILD_ACTIVITIES
|
|
|
|
if (parser.isSet(noActivitiesOption)) {
|
|
|
|
a.setUseKActivities(false);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2015-10-02 07:31:47 +00:00
|
|
|
if (parser.isSet(listBackendsOption)) {
|
|
|
|
for (const auto &plugin: availablePlugins) {
|
|
|
|
std::cout << std::setw(40) << std::left << qPrintable(plugin.name()) << qPrintable(plugin.description()) << std::endl;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2015-11-19 08:16:23 +00:00
|
|
|
if (parser.isSet(exitWithSessionOption)) {
|
|
|
|
a.setSessionArgument(parser.value(exitWithSessionOption));
|
|
|
|
}
|
|
|
|
|
2014-08-15 12:03:52 +00:00
|
|
|
#if HAVE_INPUT
|
|
|
|
KWin::Application::setUseLibinput(parser.isSet(libinputOption));
|
|
|
|
#endif
|
|
|
|
|
2015-05-05 15:58:09 +00:00
|
|
|
QString pluginName;
|
|
|
|
QSize initialWindowSize;
|
|
|
|
QByteArray deviceIdentifier;
|
2015-11-24 12:11:29 +00:00
|
|
|
int outputCount = 1;
|
2015-10-03 18:14:16 +00:00
|
|
|
|
2015-04-09 12:49:32 +00:00
|
|
|
#if HAVE_DRM
|
2015-10-03 18:14:16 +00:00
|
|
|
if (hasDrmOption && parser.isSet(drmOption)) {
|
2015-06-29 09:59:27 +00:00
|
|
|
pluginName = KWin::s_drmPlugin;
|
2015-05-05 15:58:09 +00:00
|
|
|
}
|
2015-04-09 12:49:32 +00:00
|
|
|
#endif
|
2015-03-31 09:00:46 +00:00
|
|
|
|
2015-10-03 18:14:16 +00:00
|
|
|
if (hasSizeOption) {
|
|
|
|
bool ok = false;
|
|
|
|
const int width = parser.value(widthOption).toInt(&ok);
|
|
|
|
if (!ok) {
|
|
|
|
std::cerr << "FATAL ERROR incorrect value for width" << std::endl;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
const int height = parser.value(heightOption).toInt(&ok);
|
|
|
|
if (!ok) {
|
|
|
|
std::cerr << "FATAL ERROR incorrect value for height" << std::endl;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
initialWindowSize = QSize(width, height);
|
2015-06-29 09:59:27 +00:00
|
|
|
}
|
|
|
|
|
2015-11-24 12:11:29 +00:00
|
|
|
if (hasOutputCountOption) {
|
|
|
|
bool ok = false;
|
|
|
|
const int count = parser.value(outputCountOption).toInt(&ok);
|
|
|
|
if (ok) {
|
|
|
|
outputCount = qMax(1, count);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-10-03 18:14:16 +00:00
|
|
|
if (hasWindowedOption && parser.isSet(windowedOption)) {
|
|
|
|
if (hasX11Option && parser.isSet(x11DisplayOption)) {
|
2015-05-05 15:58:09 +00:00
|
|
|
deviceIdentifier = parser.value(x11DisplayOption).toUtf8();
|
2015-10-03 18:14:16 +00:00
|
|
|
} else if (!(hasWaylandOption && parser.isSet(waylandDisplayOption))) {
|
2015-05-05 15:58:09 +00:00
|
|
|
deviceIdentifier = qgetenv("DISPLAY");
|
2015-03-23 11:45:21 +00:00
|
|
|
}
|
2015-05-05 15:58:09 +00:00
|
|
|
if (!deviceIdentifier.isEmpty()) {
|
2015-06-29 09:59:27 +00:00
|
|
|
pluginName = KWin::s_x11Plugin;
|
2015-10-03 18:14:16 +00:00
|
|
|
} else if (hasWaylandOption) {
|
2015-05-05 15:58:09 +00:00
|
|
|
if (parser.isSet(waylandDisplayOption)) {
|
|
|
|
deviceIdentifier = parser.value(waylandDisplayOption).toUtf8();
|
2015-10-03 18:14:16 +00:00
|
|
|
} else {
|
2015-05-05 15:58:09 +00:00
|
|
|
deviceIdentifier = qgetenv("WAYLAND_DISPLAY");
|
|
|
|
}
|
|
|
|
if (!deviceIdentifier.isEmpty()) {
|
2015-06-29 09:59:27 +00:00
|
|
|
pluginName = KWin::s_waylandPlugin;
|
2015-05-05 15:58:09 +00:00
|
|
|
}
|
2015-03-19 07:29:34 +00:00
|
|
|
}
|
|
|
|
}
|
2015-10-03 18:14:16 +00:00
|
|
|
if (hasFramebufferOption && parser.isSet(framebufferOption)) {
|
2015-06-29 09:59:27 +00:00
|
|
|
pluginName = KWin::s_fbdevPlugin;
|
2015-05-05 15:58:09 +00:00
|
|
|
deviceIdentifier = parser.value(framebufferDeviceOption).toUtf8();
|
|
|
|
}
|
2015-05-06 15:47:07 +00:00
|
|
|
#if HAVE_LIBHYBRIS
|
2015-10-03 18:14:16 +00:00
|
|
|
if (hasHwcomposerOption && parser.isSet(hwcomposerOption)) {
|
2015-06-29 09:59:27 +00:00
|
|
|
pluginName = KWin::s_hwcomposerPlugin;
|
2015-05-06 15:47:07 +00:00
|
|
|
}
|
|
|
|
#endif
|
2015-10-03 18:14:16 +00:00
|
|
|
if (hasVirtualOption && parser.isSet(virtualFbOption)) {
|
2015-10-02 08:44:29 +00:00
|
|
|
pluginName = KWin::s_virtualPlugin;
|
|
|
|
}
|
2015-05-05 15:58:09 +00:00
|
|
|
|
2015-06-29 09:59:27 +00:00
|
|
|
if (pluginName.isEmpty()) {
|
|
|
|
std::cerr << "No backend specified through command line argument, trying auto resolution" << std::endl;
|
|
|
|
pluginName = KWin::automaticBackendSelection();
|
|
|
|
}
|
|
|
|
|
2015-10-02 07:31:47 +00:00
|
|
|
auto pluginIt = std::find_if(availablePlugins.begin(), availablePlugins.end(),
|
2015-05-05 15:58:09 +00:00
|
|
|
[&pluginName] (const KPluginMetaData &plugin) {
|
|
|
|
return plugin.pluginId() == pluginName;
|
|
|
|
}
|
|
|
|
);
|
2015-10-02 07:31:47 +00:00
|
|
|
if (pluginIt == availablePlugins.end()) {
|
2015-05-05 15:58:09 +00:00
|
|
|
std::cerr << "FATAL ERROR: could not find a backend" << std::endl;
|
|
|
|
return 1;
|
|
|
|
}
|
2015-08-20 10:54:23 +00:00
|
|
|
|
|
|
|
// TODO: create backend without having the server running
|
|
|
|
KWin::WaylandServer *server = KWin::WaylandServer::create(&a);
|
2015-11-05 13:09:23 +00:00
|
|
|
|
|
|
|
KWin::WaylandServer::InitalizationFlags flags;
|
|
|
|
if (parser.isSet(screenLockerOption)) {
|
|
|
|
flags = KWin::WaylandServer::InitalizationFlag::LockScreen;
|
|
|
|
}
|
|
|
|
server->init(parser.value(waylandSocketOption).toUtf8(), flags);
|
2015-08-20 10:54:23 +00:00
|
|
|
|
2015-10-02 07:31:47 +00:00
|
|
|
if (qobject_cast<KWin::AbstractBackend*>((*pluginIt).instantiate())) {
|
2015-07-16 08:54:29 +00:00
|
|
|
#if HAVE_INPUT
|
2015-10-02 07:31:47 +00:00
|
|
|
// check whether it needs libinput
|
|
|
|
const QJsonObject &metaData = (*pluginIt).rawData();
|
|
|
|
auto it = metaData.find(QStringLiteral("input"));
|
2015-11-05 14:14:06 +00:00
|
|
|
if (it != metaData.end()) {
|
2015-10-02 07:31:47 +00:00
|
|
|
if ((*it).isBool()) {
|
|
|
|
if (!(*it).toBool()) {
|
|
|
|
std::cerr << "Backend does not support input, enforcing libinput support" << std::endl;
|
|
|
|
KWin::Application::setUseLibinput(true);
|
2015-07-16 08:54:29 +00:00
|
|
|
}
|
|
|
|
}
|
2015-05-05 15:58:09 +00:00
|
|
|
}
|
2015-10-02 07:31:47 +00:00
|
|
|
#endif
|
2015-05-05 15:58:09 +00:00
|
|
|
}
|
|
|
|
if (!server->backend()) {
|
|
|
|
std::cerr << "FATAL ERROR: could not instantiate a backend" << std::endl;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
server->backend()->setParent(server);
|
|
|
|
if (!deviceIdentifier.isEmpty()) {
|
|
|
|
server->backend()->setDeviceIdentifier(deviceIdentifier);
|
|
|
|
}
|
|
|
|
if (initialWindowSize.isValid()) {
|
|
|
|
server->backend()->setInitialWindowSize(initialWindowSize);
|
2015-03-31 09:00:46 +00:00
|
|
|
}
|
2015-11-24 12:11:29 +00:00
|
|
|
server->backend()->setInitialOutputCount(outputCount);
|
2015-03-19 07:29:34 +00:00
|
|
|
|
2015-06-12 23:48:11 +00:00
|
|
|
QObject::connect(&a, &KWin::Application::workspaceCreated, server, &KWin::WaylandServer::initWorkspace);
|
2015-08-20 10:54:23 +00:00
|
|
|
environment.insert(QStringLiteral("WAYLAND_DISPLAY"), server->display()->socketName());
|
|
|
|
a.setProcessStartupEnvironment(environment);
|
2015-02-20 10:53:25 +00:00
|
|
|
a.setStartXwayland(parser.isSet(xwaylandOption));
|
2015-04-21 09:21:28 +00:00
|
|
|
a.setApplicationsToStart(parser.positionalArguments());
|
2015-06-13 02:06:12 +00:00
|
|
|
a.setInputMethodServerToStart(parser.value(inputMethodOption));
|
2015-02-20 10:53:25 +00:00
|
|
|
a.start();
|
2014-08-12 07:08:48 +00:00
|
|
|
|
|
|
|
return a.exec();
|
|
|
|
}
|