[kwin_wayland] Flush display connection before going to block

Integrate with QAbstractEventDispatcher::aboutToBlock and because of that
we can drop all direct calls to flush from the Scenes.
icc-effect-5.14.5
Martin Gräßlin 2014-08-20 12:00:26 +02:00
parent 8c4bc3ba45
commit bd8ed3cd70
5 changed files with 11 additions and 14 deletions

View File

@ -250,9 +250,6 @@ bool EglWaylandBackend::initBufferConfigs()
void EglWaylandBackend::present()
{
// need to dispatch pending events as eglSwapBuffers can block
m_wayland->dispatchEvents();
m_lastFrameRendered = false;
wl_callback *callback = wl_surface_frame(m_wayland->surface());
wl_callback_add_listener(callback, &s_surfaceFrameListener, this);

View File

@ -140,7 +140,6 @@ void WaylandQPainterBackend::present(int mask, const QRegion &damage)
wl_surface_damage(surface, rect.x(), rect.y(), rect.width(), rect.height());
}
wl_surface_commit(surface);
wl->dispatchEvents();
}
void WaylandQPainterBackend::lastFrameRendered()

View File

@ -349,7 +349,6 @@ void WaylandXRenderBackend::present(int mask, const QRegion &damage)
wl_surface_damage(surface, rect.x(), rect.y(), rect.width(), rect.height());
}
wl_surface_commit(surface);
wl->dispatchEvents();
}
bool WaylandXRenderBackend::isLastFrameRendered() const

View File

@ -28,6 +28,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "wayland_client/registry.h"
#include "wayland_client/shell.h"
// Qt
#include <QAbstractEventDispatcher>
#include <QCoreApplication>
#include <QDebug>
#include <QImage>
#include <QTemporaryFile>
@ -571,6 +573,15 @@ WaylandBackend::WaylandBackend(QObject *parent)
, m_connectionThread(nullptr)
, m_fullscreenShell(new FullscreenShell(this))
{
QAbstractEventDispatcher *dispatcher = QCoreApplication::instance()->eventDispatcher();
connect(dispatcher, &QAbstractEventDispatcher::aboutToBlock, this,
[this]() {
if (!m_display) {
return;
}
wl_display_flush(m_display);
}
);
connect(this, &WaylandBackend::shellSurfaceSizeChanged, this, &WaylandBackend::checkBackendReady);
connect(m_registry, &Registry::compositorAnnounced, this,
[this](quint32 name) {
@ -643,7 +654,6 @@ void WaylandBackend::initConnection()
m_registry->create(m_display);
wl_proxy_set_queue((wl_proxy*)m_registry->registry(), m_eventQueue);
m_registry->setup();
wl_display_flush(m_display);
},
Qt::QueuedConnection);
connect(m_connectionThreadObject, &ConnectionThread::eventsRead, this,
@ -757,12 +767,6 @@ void WaylandBackend::addOutput(wl_output *o)
connect(output, &Output::changed, this, &WaylandBackend::outputsChanged);
}
void WaylandBackend::dispatchEvents()
{
// TODO: integrate into event loop to flush before going to block
wl_display_flush(m_display);
}
wl_registry *WaylandBackend::registry()
{
return m_registry->registry();

View File

@ -190,8 +190,6 @@ public:
wl_surface *surface() const;
QSize shellSurfaceSize() const;
void installCursorImage(Qt::CursorShape shape);
void dispatchEvents();
Q_SIGNALS:
void shellSurfaceSizeChanged(const QSize &size);
void systemCompositorDied();