mirror of
https://invent.kde.org/plasma/layer-shell-qt.git
synced 2025-05-25 09:30:22 -04:00
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
This commit is contained in:
parent
127d817aa1
commit
0a31923938
@ -41,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());
|
||||||
@ -64,17 +66,7 @@ QWaylandLayerSurface::QWaylandLayerSurface(QWaylandLayerShellIntegration *shell,
|
|||||||
setKeyboardInteractivity(m_interface->keyboardInteractivity());
|
setKeyboardInteractivity(m_interface->keyboardInteractivity());
|
||||||
});
|
});
|
||||||
|
|
||||||
QSize size = window->surfaceSize();
|
setDesiredSize(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());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QWaylandLayerSurface::~QWaylandLayerSurface()
|
QWaylandLayerSurface::~QWaylandLayerSurface()
|
||||||
@ -126,10 +118,24 @@ void QWaylandLayerSurface::applyConfigure()
|
|||||||
m_configuring = false;
|
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)
|
||||||
@ -166,17 +172,7 @@ void QWaylandLayerSurface::setWindowGeometry(const QRect &geometry)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const bool horizontallyConstrained = m_interface->anchors().testFlags({Window::AnchorLeft, Window::AnchorRight});
|
setDesiredSize(geometry.size());
|
||||||
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());
|
|
||||||
requestWaylandSync();
|
requestWaylandSync();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,6 +34,7 @@ public:
|
|||||||
}
|
}
|
||||||
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);
|
||||||
|
Loading…
Reference in New Issue
Block a user