[kwin_wayland] Create screens prior to Xwayland

Gives us the correct outputs in Xwayland direct from start.
icc-effect-5.14.5
Martin Gräßlin 2015-02-20 14:57:06 +01:00
parent dc0f040185
commit 7e0fcc5f1a
2 changed files with 36 additions and 24 deletions

View File

@ -79,24 +79,44 @@ ApplicationWayland::~ApplicationWayland()
void ApplicationWayland::performStartup()
{
if (m_startXWayland) {
setOperationMode(KWin::Application::OperationModeXwayland);
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;
}
setOperationMode(m_startXWayland ? OperationModeXwayland : OperationModeWaylandAndX11);
m_xcbConnectionFd = sx[0];
const int xDisplayPipe = startXServer(WaylandServer::self()->display()->socketName().toUtf8(), sx[1]);
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));
} else {
// try creating the Wayland Backend
createInput();
Wayland::WaylandBackend *backend = Wayland::WaylandBackend::create();
connect(backend, &Wayland::WaylandBackend::connectionFailed, this,
[] () {
fputs(i18n("kwin_wayland: could not connect to Wayland Server, ensure WAYLAND_DISPLAY is set.\n").toLocal8Bit().constData(), stderr);
::exit(1);
}
);
connect(backend, &Wayland::WaylandBackend::outputsChanged, this, &ApplicationWayland::continueStartupWithScreens);
}
void ApplicationWayland::continueStartupWithScreens()
{
disconnect(Wayland::WaylandBackend::self(), &Wayland::WaylandBackend::outputsChanged, this, &ApplicationWayland::continueStartupWithScreens);
createScreens();
waylandServer()->initOutputs();
if (!m_startXWayland) {
continueStartupWithX();
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;
}
m_xcbConnectionFd = sx[0];
const int xDisplayPipe = startXServer(WaylandServer::self()->display()->socketName().toUtf8(), sx[1]);
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));
}
void ApplicationWayland::continueStartupWithX()
@ -144,15 +164,6 @@ void ApplicationWayland::continueStartupWithX()
::exit(1);
}
// try creating the Wayland Backend
Wayland::WaylandBackend *backend = Wayland::WaylandBackend::create();
connect(backend, &Wayland::WaylandBackend::connectionFailed, this,
[] () {
fputs(i18n("kwin_wayland: could not connect to Wayland Server, ensure WAYLAND_DISPLAY is set.\n").toLocal8Bit().constData(), stderr);
::exit(1);
}
);
createWorkspace();
Xcb::sync(); // Trigger possible errors, there's still a chance to abort

View File

@ -40,6 +40,7 @@ protected:
private:
void createX11Connection();
void continueStartupWithScreens();
void continueStartupWithX();
bool m_startXWayland = false;