mirror of
https://invent.kde.org/plasma/layer-shell-qt.git
synced 2025-05-28 02:50:21 -04:00
make roundtrip async
This commit is contained in:
parent
697c747c58
commit
6be66ae20e
@ -18,6 +18,17 @@
|
|||||||
|
|
||||||
namespace LayerShellQt
|
namespace LayerShellQt
|
||||||
{
|
{
|
||||||
|
|
||||||
|
const wl_callback_listener QWaylandLayerSurface::syncCallbackListener = {
|
||||||
|
[](void *data, struct wl_callback *callback, uint32_t time){
|
||||||
|
Q_UNUSED(time);
|
||||||
|
wl_callback_destroy(callback);
|
||||||
|
QWaylandLayerSurface *display = static_cast<QWaylandLayerSurface *>(data);
|
||||||
|
display->mSyncCallback = nullptr;
|
||||||
|
display->handleWaylandSync();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
QWaylandLayerSurface::QWaylandLayerSurface(QWaylandLayerShellIntegration *shell, QtWaylandClient::QWaylandWindow *window)
|
QWaylandLayerSurface::QWaylandLayerSurface(QWaylandLayerShellIntegration *shell, QtWaylandClient::QWaylandWindow *window)
|
||||||
: QtWaylandClient::QWaylandShellSurface(window)
|
: QtWaylandClient::QWaylandShellSurface(window)
|
||||||
, QtWayland::zwlr_layer_surface_v1()
|
, QtWayland::zwlr_layer_surface_v1()
|
||||||
@ -77,6 +88,26 @@ QWaylandLayerSurface::QWaylandLayerSurface(QWaylandLayerShellIntegration *shell,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void QWaylandLayerSurface::requestWaylandSync()
|
||||||
|
{
|
||||||
|
if (mSyncCallback)
|
||||||
|
return;
|
||||||
|
|
||||||
|
mSyncCallback = wl_display_sync(m_window->display()->wl_display());
|
||||||
|
wl_callback_add_listener(mSyncCallback, &syncCallbackListener, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
void QWaylandLayerSurface::handleWaylandSync()
|
||||||
|
{
|
||||||
|
if (!window()->isExposed())
|
||||||
|
return;
|
||||||
|
#if QT_VERSION < QT_VERSION_CHECK(6, 7, 0)
|
||||||
|
window()->handleExpose(QRect(QPoint(), m_pendingSize));
|
||||||
|
#else
|
||||||
|
window()->sendRecursiveExposeEvent();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
QWaylandLayerSurface::~QWaylandLayerSurface()
|
QWaylandLayerSurface::~QWaylandLayerSurface()
|
||||||
{
|
{
|
||||||
destroy();
|
destroy();
|
||||||
@ -172,7 +203,7 @@ void QWaylandLayerSurface::setWindowGeometry(const QRect &geometry)
|
|||||||
size.setHeight(0);
|
size.setHeight(0);
|
||||||
}
|
}
|
||||||
set_size(size.width(), size.height());
|
set_size(size.width(), size.height());
|
||||||
wl_display_roundtrip(m_window->display()->wl_display());
|
requestWaylandSync();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool QWaylandLayerSurface::requestActivate()
|
bool QWaylandLayerSurface::requestActivate()
|
||||||
|
@ -30,7 +30,7 @@ public:
|
|||||||
|
|
||||||
bool isExposed() const override
|
bool isExposed() const override
|
||||||
{
|
{
|
||||||
return m_configured;
|
return m_configured && !mSyncCallback;
|
||||||
}
|
}
|
||||||
void attachPopup(QtWaylandClient::QWaylandShellSurface *popup) override;
|
void attachPopup(QtWaylandClient::QWaylandShellSurface *popup) override;
|
||||||
|
|
||||||
@ -48,6 +48,8 @@ public:
|
|||||||
void setXdgActivationToken(const QString &token) override;
|
void setXdgActivationToken(const QString &token) override;
|
||||||
void requestXdgActivationToken(quint32 serial) override;
|
void requestXdgActivationToken(quint32 serial) override;
|
||||||
|
|
||||||
|
void requestWaylandSync();
|
||||||
|
void handleWaylandSync();
|
||||||
private:
|
private:
|
||||||
void zwlr_layer_surface_v1_configure(uint32_t serial, uint32_t width, uint32_t height) override;
|
void zwlr_layer_surface_v1_configure(uint32_t serial, uint32_t width, uint32_t height) override;
|
||||||
void zwlr_layer_surface_v1_closed() override;
|
void zwlr_layer_surface_v1_closed() override;
|
||||||
@ -57,7 +59,10 @@ private:
|
|||||||
QtWaylandClient::QWaylandWindow *m_window;
|
QtWaylandClient::QWaylandWindow *m_window;
|
||||||
QSize m_pendingSize;
|
QSize m_pendingSize;
|
||||||
QString m_activationToken;
|
QString m_activationToken;
|
||||||
|
|
||||||
|
static const wl_callback_listener syncCallbackListener;
|
||||||
bool m_configured = false;
|
bool m_configured = false;
|
||||||
|
struct wl_callback *mSyncCallback = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user