mirror of
https://invent.kde.org/plasma/layer-shell-qt.git
synced 2026-04-02 01:42:44 -04:00
Add support for fractional window sizes
This commit is contained in:
@ -133,6 +133,7 @@ void QWaylandLayerSurface::applyConfigure()
|
|||||||
window()->resizeFromApplyConfigure(m_pendingSize);
|
window()->resizeFromApplyConfigure(m_pendingSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if QT_VERSION < QT_VERSION_CHECK(6, 12, 0)
|
||||||
void QWaylandLayerSurface::setDesiredSize(const QSize &size)
|
void QWaylandLayerSurface::setDesiredSize(const QSize &size)
|
||||||
{
|
{
|
||||||
const bool horizontallyConstrained = m_interface->anchors().testFlags({Window::AnchorLeft, Window::AnchorRight});
|
const bool horizontallyConstrained = m_interface->anchors().testFlags({Window::AnchorLeft, Window::AnchorRight});
|
||||||
@ -147,6 +148,22 @@ void QWaylandLayerSurface::setDesiredSize(const QSize &size)
|
|||||||
}
|
}
|
||||||
set_size(effectiveSize.width(), effectiveSize.height());
|
set_size(effectiveSize.width(), effectiveSize.height());
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
void QWaylandLayerSurface::setDesiredSize(const QSizeF &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.toSize();
|
||||||
|
if (horizontallyConstrained) {
|
||||||
|
effectiveSize.setWidth(0);
|
||||||
|
}
|
||||||
|
if (verticallyConstrained) {
|
||||||
|
effectiveSize.setHeight(0);
|
||||||
|
}
|
||||||
|
set_size(effectiveSize.width(), effectiveSize.height());
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void QWaylandLayerSurface::setAnchor(uint anchor)
|
void QWaylandLayerSurface::setAnchor(uint anchor)
|
||||||
{
|
{
|
||||||
@ -181,7 +198,11 @@ void QWaylandLayerSurface::setLayer(uint32_t layer)
|
|||||||
set_layer(layer);
|
set_layer(layer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if QT_VERSION < QT_VERSION_CHECK(6, 12, 0)
|
||||||
void QWaylandLayerSurface::setWindowSize(const QSize &size)
|
void QWaylandLayerSurface::setWindowSize(const QSize &size)
|
||||||
|
#else
|
||||||
|
void QWaylandLayerSurface::setWindowSize(const QSizeF &size)
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
if (m_interface->desiredSize().isNull()) {
|
if (m_interface->desiredSize().isNull()) {
|
||||||
setDesiredSize(size);
|
setDesiredSize(size);
|
||||||
|
|||||||
@ -34,7 +34,11 @@ public:
|
|||||||
}
|
}
|
||||||
void attachPopup(QtWaylandClient::QWaylandShellSurface *popup) override;
|
void attachPopup(QtWaylandClient::QWaylandShellSurface *popup) override;
|
||||||
|
|
||||||
|
#if QT_VERSION < QT_VERSION_CHECK(6, 12, 0)
|
||||||
void setDesiredSize(const QSize &size);
|
void setDesiredSize(const QSize &size);
|
||||||
|
#else
|
||||||
|
void setDesiredSize(const QSizeF &size);
|
||||||
|
#endif
|
||||||
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);
|
||||||
@ -43,7 +47,11 @@ public:
|
|||||||
void setLayer(uint32_t layer);
|
void setLayer(uint32_t layer);
|
||||||
|
|
||||||
void applyConfigure() override;
|
void applyConfigure() override;
|
||||||
|
#if QT_VERSION < QT_VERSION_CHECK(6, 12, 0)
|
||||||
void setWindowSize(const QSize &size) override;
|
void setWindowSize(const QSize &size) override;
|
||||||
|
#else
|
||||||
|
void setWindowSize(const QSizeF &size) override;
|
||||||
|
#endif
|
||||||
|
|
||||||
bool requestActivate() override;
|
bool requestActivate() override;
|
||||||
bool requestActivateOnShow() override;
|
bool requestActivateOnShow() override;
|
||||||
|
|||||||
Reference in New Issue
Block a user