Compare commits

...

7 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
3 changed files with 28 additions and 29 deletions

View File

@ -4,7 +4,7 @@
cmake_minimum_required(VERSION 3.16)
project(layershellqt)
set(PROJECT_VERSION "6.0.0")
set(PROJECT_VERSION "6.0.4")
set(PROJECT_VERSION_MAJOR 6)
set(CMAKE_C_STANDARD 99)

View File

@ -41,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());
@ -64,17 +66,7 @@ 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()
@ -99,7 +91,7 @@ void QWaylandLayerSurface::zwlr_layer_surface_v1_configure(uint32_t serial, uint
if (!m_configured) {
m_configured = true;
window()->resizeFromApplyConfigure(m_pendingSize);
applyConfigure();
sendExpose();
} else {
// Later configures are resizes, so we have to queue them up for a time when we
@ -121,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)
@ -160,22 +168,11 @@ void QWaylandLayerSurface::setLayer(uint32_t layer)
void QWaylandLayerSurface::setWindowGeometry(const QRect &geometry)
{
// if we are setting it to the last size we were configured at, we don't need to do anything
if (geometry.size() == m_pendingSize && !m_waitForSyncCallback) {
if (m_configuring) {
return;
}
const bool horizontallyConstrained = m_interface->anchors().testFlags({Window::AnchorLeft, Window::AnchorRight});
const bool verticallyConstrained = m_interface->anchors().testFlags({Window::AnchorTop, Window::AnchorBottom});
QSize size = geometry.size();
if (horizontallyConstrained) {
size.setWidth(0);
}
if (verticallyConstrained) {
size.setHeight(0);
}
set_size(size.width(), size.height());
setDesiredSize(geometry.size());
requestWaylandSync();
}

View File

@ -34,6 +34,7 @@ public:
}
void attachPopup(QtWaylandClient::QWaylandShellSurface *popup) override;
void setDesiredSize(const QSize &size);
void setAnchor(uint32_t anchor);
void setExclusiveZone(int32_t zone);
void setExclusiveEdge(uint32_t edge);
@ -62,6 +63,7 @@ private:
QString m_activationToken;
bool m_configured = false;
bool m_configuring = false;
static const wl_callback_listener syncCallbackListener;
struct wl_callback *m_waitForSyncCallback = nullptr;