[wayland] A backend can mark whether it is ready

Replaces the functionality of the WaylandBackend and makes it available
to all backends by providing the functionality directly in
AbstractBackend. By default a backend is not ready and the implementation
must call setReady(true) to indicate that setup has finished
successfully. The compositor won't start till the backend indicates that
it is ready.
This commit is contained in:
Martin Gräßlin 2015-05-05 19:02:52 +02:00
parent 8ff394a020
commit 2afaa60dc5
8 changed files with 31 additions and 21 deletions

View file

@ -298,4 +298,13 @@ void AbstractBackend::repaint(const QRect &rect)
Compositor::self()->addRepaint(rect);
}
void AbstractBackend::setReady(bool ready)
{
if (m_ready == ready) {
return;
}
m_ready = ready;
emit readyChanged(m_ready);
}
}

View file

@ -57,6 +57,9 @@ public:
bool handlesOutputs() const {
return m_handlesOutputs;
}
bool isReady() const {
return m_ready;
}
void pointerMotion(const QPointF &position, quint32 time);
void pointerButtonPressed(quint32 button, quint32 time);
@ -75,6 +78,7 @@ public:
Q_SIGNALS:
void cursorChanged();
void readyChanged(bool);
protected:
explicit AbstractBackend(QObject *parent = nullptr);
@ -85,6 +89,7 @@ protected:
m_handlesOutputs = true;
}
void repaint(const QRect &rect);
void setReady(bool ready);
private Q_SLOTS:
void installThemeCursor(quint32 id, const QPoint &hotspot);
@ -99,6 +104,7 @@ private:
} m_cursor;
WaylandCursorTheme *m_cursorTheme = nullptr;
bool m_handlesOutputs = false;
bool m_ready = false;
};
}

View file

@ -232,6 +232,7 @@ void DrmBackend::openDrm()
m_udevMonitor->enable();
}
}
setReady(true);
initCursor();
}

View file

@ -92,6 +92,7 @@ void FramebufferBackend::openFrameBuffer()
}
m_fd = fd;
queryScreenInfo();
setReady(true);
emit screensQueried();
}

View file

@ -458,7 +458,7 @@ void WaylandBackend::initConnection()
Qt::QueuedConnection);
connect(m_connectionThreadObject, &ConnectionThread::connectionDied, this,
[this]() {
m_ready = false;
setReady(false);
emit systemCompositorDied();
m_seat.reset();
m_shm->destroy();
@ -581,16 +581,7 @@ void WaylandBackend::checkBackendReady()
return;
}
disconnect(this, &WaylandBackend::shellSurfaceSizeChanged, this, &WaylandBackend::checkBackendReady);
m_ready = true;
emit backendReady();
}
void WaylandBackend::connectNotify(const QMetaMethod &signal)
{
if (m_ready && signal == QMetaMethod::fromSignal(&WaylandBackend::backendReady)) {
// backend is already ready, let's emit the signal
signal.invoke(this, Qt::QueuedConnection);
}
setReady(true);
}
Screens *WaylandBackend::createScreens(QObject *parent)

View file

@ -150,13 +150,9 @@ public:
OpenGLBackend *createOpenGLBackend() override;
QPainterBackend *createQPainterBackend() override;
protected:
void connectNotify(const QMetaMethod &signal) override;
Q_SIGNALS:
void shellSurfaceSizeChanged(const QSize &size);
void systemCompositorDied();
void backendReady();
void outputsChanged();
void connectionFailed();
private:
@ -179,7 +175,6 @@ private:
KWayland::Client::FullscreenShell *m_fullscreenShell;
KWayland::Client::SubCompositor *m_subCompositor;
WaylandCursor *m_cursor;
bool m_ready = false;
};
inline

View file

@ -77,6 +77,7 @@ X11WindowedBackend::X11WindowedBackend(const QByteArray &display, const QSize &s
XRenderUtils::init(m_connection, m_screen->root);
createWindow();
startEventReading();
setReady(true);
}
}

View file

@ -38,7 +38,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "compositingprefs.h"
#include "xcbutils.h"
#if HAVE_WAYLAND
#include "backends/wayland/wayland_backend.h"
#include "abstract_backend.h"
#include "wayland_server.h"
#endif
#include "decorations/decoratedclient.h"
@ -119,12 +119,18 @@ Compositor::Compositor(QObject* workspace)
connect(&m_unusedSupportPropertyTimer, SIGNAL(timeout()), SLOT(deleteUnusedSupportProperties()));
#if HAVE_WAYLAND
if (kwinApp()->operationMode() != Application::OperationModeX11) {
if (Wayland::WaylandBackend *w = dynamic_cast<Wayland::WaylandBackend *>(waylandServer()->backend())) {
connect(w, &Wayland::WaylandBackend::systemCompositorDied, this, &Compositor::finish);
connect(w, &Wayland::WaylandBackend::backendReady, this, &Compositor::setup);
} else {
if (waylandServer()->backend()->isReady()) {
QMetaObject::invokeMethod(this, "setup", Qt::QueuedConnection);
}
connect(waylandServer()->backend(), &AbstractBackend::readyChanged, this,
[this] (bool ready) {
if (ready) {
setup();
} else {
finish();
}
}, Qt::QueuedConnection
);
} else
#endif