|
|
|
@ -23,6 +23,7 @@ QWaylandLayerSurface::QWaylandLayerSurface(QWaylandLayerShellIntegration *shell,
|
|
|
|
|
, QtWayland::zwlr_layer_surface_v1()
|
|
|
|
|
, m_shell(shell)
|
|
|
|
|
, m_interface(Window::get(window->window()))
|
|
|
|
|
, m_window(window)
|
|
|
|
|
{
|
|
|
|
|
wl_output *output = nullptr;
|
|
|
|
|
if (m_interface->screenConfiguration() == Window::ScreenFromQWindow) {
|
|
|
|
@ -40,10 +41,12 @@ QWaylandLayerSurface::QWaylandLayerSurface(QWaylandLayerShellIntegration *shell,
|
|
|
|
|
setLayer(m_interface->layer());
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
set_anchor(m_interface->anchors());
|
|
|
|
|
setAnchor(m_interface->anchors());
|
|
|
|
|
connect(m_interface, &Window::anchorsChanged, this, [this]() {
|
|
|
|
|
set_anchor(m_interface->anchors());
|
|
|
|
|
setAnchor(m_interface->anchors());
|
|
|
|
|
setDesiredSize(m_window->windowContentGeometry().size());
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
setExclusiveZone(m_interface->exclusionZone());
|
|
|
|
|
connect(m_interface, &Window::exclusionZoneChanged, this, [this]() {
|
|
|
|
|
setExclusiveZone(m_interface->exclusionZone());
|
|
|
|
@ -63,21 +66,14 @@ QWaylandLayerSurface::QWaylandLayerSurface(QWaylandLayerShellIntegration *shell,
|
|
|
|
|
setKeyboardInteractivity(m_interface->keyboardInteractivity());
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
QSize size = window->surfaceSize();
|
|
|
|
|
const Window::Anchors anchors = m_interface->anchors();
|
|
|
|
|
if ((anchors & Window::AnchorLeft) && (anchors & Window::AnchorRight)) {
|
|
|
|
|
size.setWidth(0);
|
|
|
|
|
}
|
|
|
|
|
if ((anchors & Window::AnchorTop) && (anchors & Window::AnchorBottom)) {
|
|
|
|
|
size.setHeight(0);
|
|
|
|
|
}
|
|
|
|
|
if (size.isValid() && size != QSize(0, 0)) {
|
|
|
|
|
set_size(size.width(), size.height());
|
|
|
|
|
}
|
|
|
|
|
setDesiredSize(window->windowContentGeometry().size());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QWaylandLayerSurface::~QWaylandLayerSurface()
|
|
|
|
|
{
|
|
|
|
|
if (m_waitForSyncCallback) {
|
|
|
|
|
wl_callback_destroy(m_waitForSyncCallback);
|
|
|
|
|
}
|
|
|
|
|
destroy();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -95,8 +91,8 @@ void QWaylandLayerSurface::zwlr_layer_surface_v1_configure(uint32_t serial, uint
|
|
|
|
|
|
|
|
|
|
if (!m_configured) {
|
|
|
|
|
m_configured = true;
|
|
|
|
|
window()->resizeFromApplyConfigure(m_pendingSize);
|
|
|
|
|
window()->handleExpose(QRect(QPoint(), m_pendingSize));
|
|
|
|
|
applyConfigure();
|
|
|
|
|
sendExpose();
|
|
|
|
|
} else {
|
|
|
|
|
// Later configures are resizes, so we have to queue them up for a time when we
|
|
|
|
|
// are not painting to the window.
|
|
|
|
@ -117,13 +113,29 @@ void QWaylandLayerSurface::attachPopup(QtWaylandClient::QWaylandShellSurface *po
|
|
|
|
|
|
|
|
|
|
void QWaylandLayerSurface::applyConfigure()
|
|
|
|
|
{
|
|
|
|
|
m_configuring = true;
|
|
|
|
|
window()->resizeFromApplyConfigure(m_pendingSize);
|
|
|
|
|
m_configuring = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QWaylandLayerSurface::setDesiredSize(const QSize &size)
|
|
|
|
|
{
|
|
|
|
|
const bool horizontallyConstrained = m_interface->anchors().testFlags({Window::AnchorLeft, Window::AnchorRight});
|
|
|
|
|
const bool verticallyConstrained = m_interface->anchors().testFlags({Window::AnchorTop, Window::AnchorBottom});
|
|
|
|
|
|
|
|
|
|
QSize effectiveSize = size;
|
|
|
|
|
if (horizontallyConstrained) {
|
|
|
|
|
effectiveSize.setWidth(0);
|
|
|
|
|
}
|
|
|
|
|
if (verticallyConstrained) {
|
|
|
|
|
effectiveSize.setHeight(0);
|
|
|
|
|
}
|
|
|
|
|
set_size(effectiveSize.width(), effectiveSize.height());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QWaylandLayerSurface::setAnchor(uint anchor)
|
|
|
|
|
{
|
|
|
|
|
set_anchor(anchor);
|
|
|
|
|
setWindowGeometry(window()->windowContentGeometry());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QWaylandLayerSurface::setExclusiveZone(int32_t zone)
|
|
|
|
@ -156,17 +168,12 @@ void QWaylandLayerSurface::setLayer(uint32_t layer)
|
|
|
|
|
|
|
|
|
|
void QWaylandLayerSurface::setWindowGeometry(const QRect &geometry)
|
|
|
|
|
{
|
|
|
|
|
const bool horizontallyConstrained = m_interface->anchors().testFlags({Window::AnchorLeft, Window::AnchorRight});
|
|
|
|
|
const bool verticallyConstrained = m_interface->anchors().testFlags({Window::AnchorTop, Window::AnchorBottom});
|
|
|
|
|
if (m_configuring) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QSize size = geometry.size();
|
|
|
|
|
if (horizontallyConstrained) {
|
|
|
|
|
size.setWidth(0);
|
|
|
|
|
}
|
|
|
|
|
if (verticallyConstrained) {
|
|
|
|
|
size.setHeight(0);
|
|
|
|
|
}
|
|
|
|
|
set_size(size.width(), size.height());
|
|
|
|
|
setDesiredSize(geometry.size());
|
|
|
|
|
requestWaylandSync();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool QWaylandLayerSurface::requestActivate()
|
|
|
|
@ -215,7 +222,43 @@ void QWaylandLayerSurface::requestXdgActivationToken(quint32 serial)
|
|
|
|
|
Q_EMIT window()->xdgActivationTokenCreated(token);
|
|
|
|
|
});
|
|
|
|
|
connect(tokenProvider, &QWaylandXdgActivationTokenV1::done, tokenProvider, &QObject::deleteLater);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const wl_callback_listener QWaylandLayerSurface::syncCallbackListener = {
|
|
|
|
|
.done = [](void *data, struct wl_callback *callback, uint32_t time){
|
|
|
|
|
Q_UNUSED(time);
|
|
|
|
|
wl_callback_destroy(callback);
|
|
|
|
|
QWaylandLayerSurface *layerSurface = static_cast<QWaylandLayerSurface *>(data);
|
|
|
|
|
layerSurface->m_waitForSyncCallback = nullptr;
|
|
|
|
|
layerSurface->sendExpose();
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
void QWaylandLayerSurface::requestWaylandSync()
|
|
|
|
|
{
|
|
|
|
|
if (m_waitForSyncCallback) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
m_waitForSyncCallback = wl_display_sync(m_window->display()->wl_display());
|
|
|
|
|
wl_callback_add_listener(m_waitForSyncCallback, &syncCallbackListener, this);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QWaylandLayerSurface::handleWaylandSyncDone()
|
|
|
|
|
{
|
|
|
|
|
if (!window()->isExposed()) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
sendExpose();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QWaylandLayerSurface::sendExpose()
|
|
|
|
|
{
|
|
|
|
|
#if QT_VERSION < QT_VERSION_CHECK(6, 7, 0)
|
|
|
|
|
window()->handleExpose(QRect(QPoint(), m_pendingSize));
|
|
|
|
|
#else
|
|
|
|
|
window()->sendRecursiveExposeEvent();
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|