Add support for xx-fractional-scale-v2

This commit is contained in:
Vlad Zahorodnii
2026-04-02 09:17:07 +03:00
parent 7da48d8af4
commit 4e4f3c48ac
2 changed files with 21 additions and 6 deletions

View File

@@ -104,7 +104,11 @@ void QWaylandLayerSurface::zwlr_layer_surface_v1_closed()
void QWaylandLayerSurface::zwlr_layer_surface_v1_configure(uint32_t serial, uint32_t width, uint32_t height) void QWaylandLayerSurface::zwlr_layer_surface_v1_configure(uint32_t serial, uint32_t width, uint32_t height)
{ {
ack_configure(serial); ack_configure(serial);
#if QT_VERSION < QT_VERSION_CHECK(6, 13, 0)
m_pendingSize = QSize(width, height); m_pendingSize = QSize(width, height);
#else
m_pendingSize = QSizeF(width, height) / compositorToClientScale();
#endif
if (!m_configured) { if (!m_configured) {
m_configured = true; m_configured = true;
@@ -133,7 +137,7 @@ void QWaylandLayerSurface::applyConfigure()
window()->resizeFromApplyConfigure(m_pendingSize); window()->resizeFromApplyConfigure(m_pendingSize);
} }
#if QT_VERSION < QT_VERSION_CHECK(6, 12, 0) #if QT_VERSION < QT_VERSION_CHECK(6, 13, 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});
@@ -154,7 +158,7 @@ void QWaylandLayerSurface::setDesiredSize(const QSizeF &size)
const bool horizontallyConstrained = m_interface->anchors().testFlags({Window::AnchorLeft, Window::AnchorRight}); const bool horizontallyConstrained = m_interface->anchors().testFlags({Window::AnchorLeft, Window::AnchorRight});
const bool verticallyConstrained = m_interface->anchors().testFlags({Window::AnchorTop, Window::AnchorBottom}); const bool verticallyConstrained = m_interface->anchors().testFlags({Window::AnchorTop, Window::AnchorBottom});
QSize effectiveSize = size.toSize(); QSize effectiveSize = (size * clientToCompositorScale()).toSize();
if (horizontallyConstrained) { if (horizontallyConstrained) {
effectiveSize.setWidth(0); effectiveSize.setWidth(0);
} }
@@ -172,7 +176,7 @@ void QWaylandLayerSurface::setAnchor(uint anchor)
void QWaylandLayerSurface::setExclusiveZone(int32_t zone) void QWaylandLayerSurface::setExclusiveZone(int32_t zone)
{ {
set_exclusive_zone(zone); set_exclusive_zone(std::round(zone * clientToCompositorScale()));
} }
void QWaylandLayerSurface::setExclusiveEdge(uint32_t edge) void QWaylandLayerSurface::setExclusiveEdge(uint32_t edge)
@@ -184,7 +188,14 @@ void QWaylandLayerSurface::setExclusiveEdge(uint32_t edge)
void QWaylandLayerSurface::setMargins(const QMargins &margins) void QWaylandLayerSurface::setMargins(const QMargins &margins)
{ {
#if QT_VERSION < QT_VERSION_CHECK(6, 13, 0)
set_margin(margins.top(), margins.right(), margins.bottom(), margins.left()); set_margin(margins.top(), margins.right(), margins.bottom(), margins.left());
#else
set_margin(std::round(margins.top() * clientToCompositorScale()),
std::round(margins.right() * clientToCompositorScale()),
std::round(margins.bottom() * clientToCompositorScale()),
std::round(margins.left() * clientToCompositorScale()));
#endif
} }
void QWaylandLayerSurface::setKeyboardInteractivity(uint32_t interactivity) void QWaylandLayerSurface::setKeyboardInteractivity(uint32_t interactivity)
@@ -198,7 +209,7 @@ void QWaylandLayerSurface::setLayer(uint32_t layer)
set_layer(layer); set_layer(layer);
} }
#if QT_VERSION < QT_VERSION_CHECK(6, 12, 0) #if QT_VERSION < QT_VERSION_CHECK(6, 13, 0)
void QWaylandLayerSurface::setWindowSize(const QSize &size) void QWaylandLayerSurface::setWindowSize(const QSize &size)
#else #else
void QWaylandLayerSurface::setWindowSize(const QSizeF &size) void QWaylandLayerSurface::setWindowSize(const QSizeF &size)

View File

@@ -34,7 +34,7 @@ public:
} }
void attachPopup(QtWaylandClient::QWaylandShellSurface *popup) override; void attachPopup(QtWaylandClient::QWaylandShellSurface *popup) override;
#if QT_VERSION < QT_VERSION_CHECK(6, 12, 0) #if QT_VERSION < QT_VERSION_CHECK(6, 13, 0)
void setDesiredSize(const QSize &size); void setDesiredSize(const QSize &size);
#else #else
void setDesiredSize(const QSizeF &size); void setDesiredSize(const QSizeF &size);
@@ -47,7 +47,7 @@ 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) #if QT_VERSION < QT_VERSION_CHECK(6, 13, 0)
void setWindowSize(const QSize &size) override; void setWindowSize(const QSize &size) override;
#else #else
void setWindowSize(const QSizeF &size) override; void setWindowSize(const QSizeF &size) override;
@@ -66,7 +66,11 @@ private:
QWaylandLayerShellIntegration *m_shell; QWaylandLayerShellIntegration *m_shell;
LayerShellQt::Window *m_interface; LayerShellQt::Window *m_interface;
QtWaylandClient::QWaylandWindow *m_window; QtWaylandClient::QWaylandWindow *m_window;
#if QT_VERSION < QT_VERSION_CHECK(6, 13, 0)
QSize m_pendingSize; QSize m_pendingSize;
#else
QSizeF m_pendingSize;
#endif
QString m_activationToken; QString m_activationToken;
bool m_configured = false; bool m_configured = false;