diff options
Diffstat (limited to 'src/client')
-rw-r--r-- | src/client/qwaylanddisplay.cpp | 24 | ||||
-rw-r--r-- | src/client/qwaylandeventthread.cpp | 27 | ||||
-rw-r--r-- | src/client/qwaylandeventthread_p.h | 2 |
3 files changed, 23 insertions, 30 deletions
diff --git a/src/client/qwaylanddisplay.cpp b/src/client/qwaylanddisplay.cpp index 74efbfda4..94bfa88bc 100644 --- a/src/client/qwaylanddisplay.cpp +++ b/src/client/qwaylanddisplay.cpp @@ -166,16 +166,8 @@ QWaylandDisplay::~QWaylandDisplay(void) void QWaylandDisplay::flushRequests() { - if (wl_display_dispatch_queue_pending(mDisplay, mEventQueue) < 0) { - int ecode = wl_display_get_error(mDisplay); - if ((ecode == EPIPE || ecode == ECONNRESET)) { - // special case this to provide a nicer error - qWarning("The Wayland connection broke. Did the Wayland compositor die?"); - } else { - qErrnoWarning(ecode, "The Wayland connection experienced a fatal error"); - } - ::exit(1); - } + if (wl_display_dispatch_queue_pending(mDisplay, mEventQueue) < 0) + mEventThreadObject->checkErrorAndExit(); wl_display_flush(mDisplay); } @@ -183,16 +175,8 @@ void QWaylandDisplay::flushRequests() void QWaylandDisplay::blockingReadEvents() { - if (wl_display_dispatch_queue(mDisplay, mEventQueue) < 0) { - int ecode = wl_display_get_error(mDisplay); - if ((ecode == EPIPE || ecode == ECONNRESET)) { - // special case this to provide a nicer error - qWarning("The Wayland connection broke. Did the Wayland compositor die?"); - } else { - qErrnoWarning(ecode, "The Wayland connection experienced a fatal error"); - } - ::exit(1); - } + if (wl_display_dispatch_queue(mDisplay, mEventQueue) < 0) + mEventThreadObject->checkErrorAndExit(); } QWaylandScreen *QWaylandDisplay::screenForOutput(struct wl_output *output) const diff --git a/src/client/qwaylandeventthread.cpp b/src/client/qwaylandeventthread.cpp index 979aa6e0e..b7266765e 100644 --- a/src/client/qwaylandeventthread.cpp +++ b/src/client/qwaylandeventthread.cpp @@ -71,18 +71,25 @@ void QWaylandEventThread::displayConnect() QMetaObject::invokeMethod(this, "waylandDisplayConnect", Qt::QueuedConnection); } -void QWaylandEventThread::readWaylandEvents() +// ### be careful what you do, this function may also be called from other +// threads to clean up & exit. +void QWaylandEventThread::checkErrorAndExit() { - if (wl_display_dispatch(m_display) < 0) { - int ecode = wl_display_get_error(m_display); - if ((ecode == EPIPE || ecode == ECONNRESET)) { - // special case this to provide a nicer error - qWarning("The Wayland connection broke. Did the Wayland compositor die?"); - } else { - qErrnoWarning(ecode, "The Wayland connection experienced a fatal error"); - } - ::exit(1); + int ecode = wl_display_get_error(m_display); + if ((ecode == EPIPE || ecode == ECONNRESET)) { + // special case this to provide a nicer error + qWarning("The Wayland connection broke. Did the Wayland compositor die?"); + } else { + qErrnoWarning(ecode, "The Wayland connection experienced a fatal error"); } + ::exit(1); +} + +void QWaylandEventThread::readWaylandEvents() +{ + if (wl_display_dispatch(m_display) < 0) + checkErrorAndExit(); + emit newEventsRead(); } diff --git a/src/client/qwaylandeventthread_p.h b/src/client/qwaylandeventthread_p.h index 0d2758c4c..d51d627b9 100644 --- a/src/client/qwaylandeventthread_p.h +++ b/src/client/qwaylandeventthread_p.h @@ -63,6 +63,8 @@ public: wl_display *display() const; + void checkErrorAndExit(); + private slots: void readWaylandEvents(); |