Compare commits

...

12 Commits

Author SHA1 Message Date
797c8b26ca Use QWaylandWindow::windowContentGeometry() to set the initial preferred size
This matches the geometry used in the setWindowGeometry() function.

(cherry picked from commit e8594be884)
2024-04-05 10:30:03 +03:00
32afbcf68a Update the desired size when the anchors change
When the anchor changes, the desired size should be updated to avoid
the compositor posting a protocol error.

BUG: 484990
(cherry picked from commit 0a31923938)
2024-04-05 10:29:55 +03:00
81782b38e4 Guard against calling set_size while applying a configure event more explicitly
Depending on code path taken, geometry.size() == m_pendingSize can
produce incorrect results.

If a configure event is applied, it's fine.

If the window is resized by user, m_pendingSize will have outdated value,
and setWindowGeometry() can ignore future size updates that are valid.

In hindsight, we need special hooks in the QWaylandWindow to request and
apply new geometry. Rather than have one function that deals with all cases.


(cherry picked from commit 127d817aa1)
2024-04-03 12:25:03 +00:00
4dfa7b53f1 update version for new release 2024-03-28 14:31:54 +00:00
aeb8d198ce update version for new release 2024-03-26 14:23:48 +00:00
f32b64244f update version for new release 2024-03-05 23:23:45 +00:00
9fb17e63b2 update version for new release 2024-03-05 22:17:10 +00:00
ec1a2d02fb Update Frameworks version requirement to 6.0.0
GIT_SILENT
2024-02-21 14:43:27 +00:00
c902d638ec Port to asynchronous roundtrip
When a resize is driven client side we wait for the compositor to have a
chance to reconfigure us before submitting the next frame.

Using a blocking round trip caused an issue. Instead block isExposed and
trigger an expose event whilst a sync is in progress.
2024-02-16 17:15:50 +00:00
176b7648d4 Synchronise client driven resizing
Qt's resizing is inherently synchronous. When an application calls
QWindow::setGeometry with a new size, we expect it to make that resize.
An expose event of the requested size will be generated.

Wayland is by default async, a client requests a size, and then will be
configured to that size, or potentially another size.

The simplest way to map the two APIs is to roundtrip when the client
wants to resize. This way we can guarantee that a call to
`setGeometry();  update()` will have the server configured size before
the paint.

In practice it's still not perfect due to other issues, but at least
will sort itself out within a frame.


(cherry picked from commit 697c747c58)
2024-02-14 12:10:19 +00:00
cce9896e42 Fix build with Qt 6.7
This also fixes a hypothetical case of a layer shell with subsurfaces
and matches the call made by xdgshell after the first configure.


(cherry picked from commit 6427176da4)
2024-02-08 10:19:13 +00:00
f7fee6e7f6 update version for new release 2024-02-01 09:46:00 +00:00
3 changed files with 82 additions and 29 deletions

View File

@ -4,13 +4,13 @@
cmake_minimum_required(VERSION 3.16) cmake_minimum_required(VERSION 3.16)
project(layershellqt) project(layershellqt)
set(PROJECT_VERSION "5.93.0") set(PROJECT_VERSION "6.0.4")
set(PROJECT_VERSION_MAJOR 6) set(PROJECT_VERSION_MAJOR 6)
set(CMAKE_C_STANDARD 99) set(CMAKE_C_STANDARD 99)
set(QT_MIN_VERSION "6.6.0") set(QT_MIN_VERSION "6.6.0")
set(KF6_MIN_VERSION "5.240.0") set(KF6_MIN_VERSION "6.0.0")
set(KDE_COMPILERSETTINGS_LEVEL "5.82") set(KDE_COMPILERSETTINGS_LEVEL "5.82")
set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD 20)

View File

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

View File

@ -30,10 +30,11 @@ public:
bool isExposed() const override bool isExposed() const override
{ {
return m_configured; return m_configured && !m_waitForSyncCallback;
} }
void attachPopup(QtWaylandClient::QWaylandShellSurface *popup) override; void attachPopup(QtWaylandClient::QWaylandShellSurface *popup) override;
void setDesiredSize(const QSize &size);
void setAnchor(uint32_t anchor); void setAnchor(uint32_t anchor);
void setExclusiveZone(int32_t zone); void setExclusiveZone(int32_t zone);
void setExclusiveEdge(uint32_t edge); void setExclusiveEdge(uint32_t edge);
@ -49,14 +50,23 @@ public:
void requestXdgActivationToken(quint32 serial) override; void requestXdgActivationToken(quint32 serial) override;
private: private:
void requestWaylandSync();
void handleWaylandSyncDone();
void sendExpose();
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;
QWaylandLayerShellIntegration *m_shell; QWaylandLayerShellIntegration *m_shell;
LayerShellQt::Window *m_interface; LayerShellQt::Window *m_interface;
QtWaylandClient::QWaylandWindow *m_window;
QSize m_pendingSize; QSize m_pendingSize;
QString m_activationToken; QString m_activationToken;
bool m_configured = false; bool m_configured = false;
bool m_configuring = false;
static const wl_callback_listener syncCallbackListener;
struct wl_callback *m_waitForSyncCallback = nullptr;
}; };
} }