diff --git a/src/wayland/autotests/client/test_xdg_shell.cpp b/src/wayland/autotests/client/test_xdg_shell.cpp index 1c0a893d49..abb7164d7a 100644 --- a/src/wayland/autotests/client/test_xdg_shell.cpp +++ b/src/wayland/autotests/client/test_xdg_shell.cpp @@ -382,16 +382,17 @@ void XdgShellTest::testMove() void XdgShellTest::testResize_data() { QTest::addColumn("edges"); + QTest::addColumn("anchor"); - QTest::newRow("none") << Qt::Edges(); - QTest::newRow("top") << Qt::Edges(Qt::TopEdge); - QTest::newRow("bottom") << Qt::Edges(Qt::BottomEdge); - QTest::newRow("left") << Qt::Edges(Qt::LeftEdge); - QTest::newRow("top left") << Qt::Edges(Qt::TopEdge | Qt::LeftEdge); - QTest::newRow("bottom left") << Qt::Edges(Qt::BottomEdge | Qt::LeftEdge); - QTest::newRow("right") << Qt::Edges(Qt::RightEdge); - QTest::newRow("top right") << Qt::Edges(Qt::TopEdge | Qt::RightEdge); - QTest::newRow("bottom right") << Qt::Edges(Qt::BottomEdge | Qt::RightEdge); + QTest::newRow("none") << Qt::Edges() << XdgToplevelInterface::ResizeAnchor::None; + QTest::newRow("top") << Qt::Edges(Qt::TopEdge) << XdgToplevelInterface::ResizeAnchor::Top; + QTest::newRow("bottom") << Qt::Edges(Qt::BottomEdge) << XdgToplevelInterface::ResizeAnchor::Bottom; + QTest::newRow("left") << Qt::Edges(Qt::LeftEdge) << XdgToplevelInterface::ResizeAnchor::Left; + QTest::newRow("top left") << Qt::Edges(Qt::TopEdge | Qt::LeftEdge) << XdgToplevelInterface::ResizeAnchor::TopLeft; + QTest::newRow("bottom left") << Qt::Edges(Qt::BottomEdge | Qt::LeftEdge) << XdgToplevelInterface::ResizeAnchor::BottomLeft; + QTest::newRow("right") << Qt::Edges(Qt::RightEdge) << XdgToplevelInterface::ResizeAnchor::Right; + QTest::newRow("top right") << Qt::Edges(Qt::TopEdge | Qt::RightEdge) << XdgToplevelInterface::ResizeAnchor::TopRight; + QTest::newRow("bottom right") << Qt::Edges(Qt::BottomEdge | Qt::RightEdge) << XdgToplevelInterface::ResizeAnchor::BottomRight; } void XdgShellTest::testResize() @@ -412,7 +413,7 @@ void XdgShellTest::testResize() QVERIFY(resizeSpy.wait()); QCOMPARE(resizeSpy.count(), 1); QCOMPARE(resizeSpy.first().at(0).value(), m_seatInterface); - QCOMPARE(resizeSpy.first().at(1).value(), edges); + QTEST(resizeSpy.first().at(1).value(), "anchor"); QCOMPARE(resizeSpy.first().at(2).value(), 60u); } diff --git a/src/wayland/xdgshell_interface.cpp b/src/wayland/xdgshell_interface.cpp index 5bae580380..faf2bd2015 100644 --- a/src/wayland/xdgshell_interface.cpp +++ b/src/wayland/xdgshell_interface.cpp @@ -430,22 +430,7 @@ void XdgToplevelInterfacePrivate::xdg_toplevel_resize(Resource *resource, ::wl_r } SeatInterface *seat = SeatInterface::get(seatResource); - - Qt::Edges edges; - if (xdgEdges & XDG_TOPLEVEL_RESIZE_EDGE_TOP) { - edges |= Qt::TopEdge; - } - if (xdgEdges & XDG_TOPLEVEL_RESIZE_EDGE_RIGHT) { - edges |= Qt::RightEdge; - } - if (xdgEdges & XDG_TOPLEVEL_RESIZE_EDGE_BOTTOM) { - edges |= Qt::BottomEdge; - } - if (xdgEdges & XDG_TOPLEVEL_RESIZE_EDGE_LEFT) { - edges |= Qt::LeftEdge; - } - - Q_EMIT q->resizeRequested(seat, edges, serial); + Q_EMIT q->resizeRequested(seat, XdgToplevelInterface::ResizeAnchor(xdgEdges), serial); } void XdgToplevelInterfacePrivate::xdg_toplevel_set_max_size(Resource *resource, int32_t width, int32_t height) diff --git a/src/wayland/xdgshell_interface.h b/src/wayland/xdgshell_interface.h index f0b20f6097..deb4415dd1 100644 --- a/src/wayland/xdgshell_interface.h +++ b/src/wayland/xdgshell_interface.h @@ -210,6 +210,19 @@ public: }; Q_DECLARE_FLAGS(States, State) + enum class ResizeAnchor { + None = 0, + Top = 1, + Bottom = 2, + Left = 4, + TopLeft = 5, + BottomLeft = 6, + Right = 8, + TopRight = 9, + BottomRight = 10, + }; + Q_ENUM(ResizeAnchor) + /** * Constructs an XdgToplevelInterface for the given xdg-surface \a surface. */ @@ -332,11 +345,11 @@ Q_SIGNALS: void moveRequested(KWaylandServer::SeatInterface *seat, quint32 serial); /** - * This signal is emitted when the toplevel wants to be interactively resized along the - * specified window edges \a edges. The \a seat and the \a serial indicate the user action + * This signal is emitted when the toplevel wants to be interactively resized by dragging + * the specified \a anchor. The \a seat and the \a serial indicate the user action * in response to which this request has been issued. */ - void resizeRequested(KWaylandServer::SeatInterface *seat, Qt::Edges edges, quint32 serial); + void resizeRequested(KWaylandServer::SeatInterface *seat, KWaylandServer::XdgToplevelInterface::ResizeAnchor anchor, quint32 serial); /** * This signal is emitted when the toplevel surface wants to become maximized.