[wayland] Better track if WaylandBackend is ready
The WaylandBackend emits a signal when the backend is ready. If a user connects to it after it became ready, it will never get notified. Therefore the WaylandBackend tracks also whether it is ready and implements connectNotify to emit the signal again if a user connects and the backend is already ready. Users of the signal need to disconnect if they cannot handle it being invoked multiple times. So far the only user does handle this properly.
This commit is contained in:
parent
7e0fcc5f1a
commit
40c52035a8
2 changed files with 16 additions and 0 deletions
|
@ -44,6 +44,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
#include <QAbstractEventDispatcher>
|
||||
#include <QCoreApplication>
|
||||
#include <QDebug>
|
||||
#include <QMetaMethod>
|
||||
#include <QThread>
|
||||
// xcb
|
||||
#include <xcb/xtest.h>
|
||||
|
@ -552,6 +553,7 @@ void WaylandBackend::initConnection()
|
|||
Qt::QueuedConnection);
|
||||
connect(m_connectionThreadObject, &ConnectionThread::connectionDied, this,
|
||||
[this]() {
|
||||
m_ready = false;
|
||||
emit systemCompositorDied();
|
||||
m_cursorTracker.reset();
|
||||
m_seat.reset();
|
||||
|
@ -652,9 +654,18 @@ 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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} // KWin
|
||||
|
|
|
@ -190,6 +190,10 @@ public:
|
|||
KWayland::Client::Surface *surface() const;
|
||||
QSize shellSurfaceSize() const;
|
||||
void installCursorImage(Qt::CursorShape shape);
|
||||
|
||||
protected:
|
||||
void connectNotify(const QMetaMethod &signal) override;
|
||||
|
||||
Q_SIGNALS:
|
||||
void shellSurfaceSizeChanged(const QSize &size);
|
||||
void systemCompositorDied();
|
||||
|
@ -217,6 +221,7 @@ private:
|
|||
KWayland::Client::FullscreenShell *m_fullscreenShell;
|
||||
KWayland::Client::SubCompositor *m_subCompositor;
|
||||
WaylandCursor *m_cursor;
|
||||
bool m_ready = false;
|
||||
|
||||
KWIN_SINGLETON(WaylandBackend)
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue