diff --git a/autotests/client/test_xdg_shell_stable.cpp b/autotests/client/test_xdg_shell_stable.cpp index e3f0617..7a13677 100644 --- a/autotests/client/test_xdg_shell_stable.cpp +++ b/autotests/client/test_xdg_shell_stable.cpp @@ -1,224 +1,251 @@ /******************************************************************** Copyright 2016 Martin Gräßlin Copyright 2017 David Edmundson This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) version 3, or any later version accepted by the membership of KDE e.V. (or its successor approved by the membership of KDE e.V.), which shall act as a proxy defined in Section 6 of version 3 of the license. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library. If not, see . *********************************************************************/ #include "test_xdg_shell.h" #include class XdgShellTestStable : public XdgShellTest { Q_OBJECT public: XdgShellTestStable() : XdgShellTest(KWayland::Server::XdgShellInterfaceVersion::Stable) {} private Q_SLOTS: void testMaxSize(); void testMinSize(); void testPopup_data(); void testPopup(); void testMultipleRoles1(); void testMultipleRoles2(); + + void testWindowGeometry(); }; void XdgShellTestStable::testMaxSize() { qRegisterMetaType(); // this test verifies changing the window maxSize QSignalSpy xdgSurfaceCreatedSpy(m_xdgShellInterface, &XdgShellInterface::surfaceCreated); QVERIFY(xdgSurfaceCreatedSpy.isValid()); QScopedPointer surface(m_compositor->createSurface()); QScopedPointer xdgSurface(m_xdgShell->createSurface(surface.data())); QVERIFY(xdgSurfaceCreatedSpy.wait()); auto serverXdgSurface = xdgSurfaceCreatedSpy.first().first().value(); QVERIFY(serverXdgSurface); QSignalSpy maxSizeSpy(serverXdgSurface, &XdgShellSurfaceInterface::maxSizeChanged); QVERIFY(maxSizeSpy.isValid()); xdgSurface->setMaxSize(QSize(100, 100)); QVERIFY(maxSizeSpy.wait()); QCOMPARE(maxSizeSpy.count(), 1); QCOMPARE(maxSizeSpy.last().at(0).value(), QSize(100,100)); xdgSurface->setMaxSize(QSize(200, 200)); QVERIFY(maxSizeSpy.wait()); QCOMPARE(maxSizeSpy.count(), 2); QCOMPARE(maxSizeSpy.last().at(0).value(), QSize(200,200)); } void XdgShellTestStable::testPopup_data() { QTest::addColumn("positioner"); XdgPositioner positioner(QSize(10,10), QRect(100,100,50,50)); QTest::newRow("default") << positioner; XdgPositioner positioner2(QSize(20,20), QRect(101,102,51,52)); QTest::newRow("sizeAndAnchorRect") << positioner2; positioner.setAnchorEdge(Qt::TopEdge | Qt::RightEdge); QTest::newRow("anchorEdge") << positioner; positioner.setGravity(Qt::BottomEdge); QTest::newRow("gravity") << positioner; positioner.setGravity(Qt::TopEdge | Qt::RightEdge); QTest::newRow("gravity2") << positioner; positioner.setConstraints(XdgPositioner::Constraint::SlideX | XdgPositioner::Constraint::FlipY); QTest::newRow("constraints") << positioner; positioner.setConstraints(XdgPositioner::Constraint::SlideX | XdgPositioner::Constraint::SlideY | XdgPositioner::Constraint::FlipX | XdgPositioner::Constraint::FlipY | XdgPositioner::Constraint::ResizeX | XdgPositioner::Constraint::ResizeY); QTest::newRow("constraints2") << positioner; positioner.setAnchorOffset(QPoint(4,5)); QTest::newRow("offset") << positioner; } void XdgShellTestStable::testPopup() { QSignalSpy xdgTopLevelCreatedSpy(m_xdgShellInterface, &XdgShellInterface::surfaceCreated); QSignalSpy xdgPopupCreatedSpy(m_xdgShellInterface, &XdgShellInterface::xdgPopupCreated); QScopedPointer parentSurface(m_compositor->createSurface()); QScopedPointer xdgParentSurface(m_xdgShell->createSurface(parentSurface.data())); QVERIFY(xdgTopLevelCreatedSpy.wait()); auto serverXdgTopLevel = xdgTopLevelCreatedSpy.first().first().value(); QFETCH(XdgPositioner, positioner); QScopedPointer surface(m_compositor->createSurface()); QScopedPointer xdgSurface(m_xdgShell->createPopup(surface.data(), xdgParentSurface.data(), positioner)); QVERIFY(xdgPopupCreatedSpy.wait()); auto serverXdgPopup = xdgPopupCreatedSpy.first().first().value(); QVERIFY(serverXdgPopup); QCOMPARE(serverXdgPopup->initialSize(), positioner.initialSize()); QCOMPARE(serverXdgPopup->anchorRect(), positioner.anchorRect()); QCOMPARE(serverXdgPopup->anchorEdge(), positioner.anchorEdge()); QCOMPARE(serverXdgPopup->gravity(), positioner.gravity()); QCOMPARE(serverXdgPopup->anchorOffset(), positioner.anchorOffset()); //we have different enums for client server, but they share the same values QCOMPARE((int)serverXdgPopup->constraintAdjustments(), (int)positioner.constraints()); QCOMPARE(serverXdgPopup->transientFor().data(), serverXdgTopLevel->surface()); } void XdgShellTestStable::testMinSize() { qRegisterMetaType(); // this test verifies changing the window minSize QSignalSpy xdgSurfaceCreatedSpy(m_xdgShellInterface, &XdgShellInterface::surfaceCreated); QVERIFY(xdgSurfaceCreatedSpy.isValid()); QScopedPointer surface(m_compositor->createSurface()); QScopedPointer xdgSurface(m_xdgShell->createSurface(surface.data())); QVERIFY(xdgSurfaceCreatedSpy.wait()); auto serverXdgSurface = xdgSurfaceCreatedSpy.first().first().value(); QVERIFY(serverXdgSurface); QSignalSpy minSizeSpy(serverXdgSurface, &XdgShellSurfaceInterface::minSizeChanged); QVERIFY(minSizeSpy.isValid()); xdgSurface->setMinSize(QSize(200, 200)); QVERIFY(minSizeSpy.wait()); QCOMPARE(minSizeSpy.count(), 1); QCOMPARE(minSizeSpy.last().at(0).value(), QSize(200,200)); xdgSurface->setMinSize(QSize(100, 100)); QVERIFY(minSizeSpy.wait()); QCOMPARE(minSizeSpy.count(), 2); QCOMPARE(minSizeSpy.last().at(0).value(), QSize(100,100)); } //top level then toplevel void XdgShellTestStable::testMultipleRoles1() { //setting multiple roles on an xdg surface should fail QSignalSpy xdgSurfaceCreatedSpy(m_xdgShellInterface, &XdgShellInterface::surfaceCreated); QSignalSpy xdgPopupCreatedSpy(m_xdgShellInterface, &XdgShellInterface::xdgPopupCreated); QVERIFY(xdgSurfaceCreatedSpy.isValid()); QVERIFY(xdgPopupCreatedSpy.isValid()); QScopedPointer surface(m_compositor->createSurface()); //This is testing we work when a client does something stupid //we can't use KWayland API here because by design that stops you from doing anything stupid qDebug() << (xdg_wm_base*)*m_xdgShell; auto xdgSurface = xdg_wm_base_get_xdg_surface(*m_xdgShell, *surface.data()); //create a top level auto xdgTopLevel1 = xdg_surface_get_toplevel(xdgSurface); QVERIFY(xdgSurfaceCreatedSpy.wait()); //now try to create another top level for the same xdg surface. It should fail auto xdgTopLevel2 = xdg_surface_get_toplevel(xdgSurface); QVERIFY(!xdgSurfaceCreatedSpy.wait(10)); xdg_toplevel_destroy(xdgTopLevel1); xdg_toplevel_destroy(xdgTopLevel2); xdg_surface_destroy(xdgSurface); } //toplevel then popup void XdgShellTestStable::testMultipleRoles2() { QSignalSpy xdgSurfaceCreatedSpy(m_xdgShellInterface, &XdgShellInterface::surfaceCreated); QSignalSpy xdgPopupCreatedSpy(m_xdgShellInterface, &XdgShellInterface::xdgPopupCreated); QVERIFY(xdgSurfaceCreatedSpy.isValid()); QVERIFY(xdgPopupCreatedSpy.isValid()); QScopedPointer surface(m_compositor->createSurface()); QScopedPointer parentSurface(m_compositor->createSurface()); auto parentXdgSurface = xdg_wm_base_get_xdg_surface(*m_xdgShell, *parentSurface.data()); auto xdgTopLevelParent = xdg_surface_get_toplevel(parentXdgSurface); QVERIFY(xdgSurfaceCreatedSpy.wait()); auto xdgSurface = xdg_wm_base_get_xdg_surface(*m_xdgShell, *surface.data()); //create a top level auto xdgTopLevel1 = xdg_surface_get_toplevel(xdgSurface); QVERIFY(xdgSurfaceCreatedSpy.wait()); //now try to create a popup on the same xdg surface. It should fail auto positioner = xdg_wm_base_create_positioner(*m_xdgShell); xdg_positioner_set_anchor_rect(positioner,10, 10, 10, 10); xdg_positioner_set_size(positioner,10, 100); auto xdgPopup2 = xdg_surface_get_popup(xdgSurface, parentXdgSurface, positioner); QVERIFY(!xdgPopupCreatedSpy.wait(10)); xdg_positioner_destroy(positioner); xdg_toplevel_destroy(xdgTopLevel1); xdg_toplevel_destroy(xdgTopLevelParent); xdg_popup_destroy(xdgPopup2); xdg_surface_destroy(xdgSurface); } +void XdgShellTestStable::testWindowGeometry() +{ + SURFACE + QSignalSpy windowGeometryChangedSpy(serverXdgSurface, &XdgShellSurfaceInterface::windowGeometryChanged); + xdgSurface->setWindowGeometry(QRect(50, 50, 400, 400)); + + windowGeometryChangedSpy.wait(); + QCOMPARE(serverXdgSurface->windowGeometry(), QRect(50, 50, 400, 400)); + + + //add a popup to this surface + XdgPositioner positioner(QSize(10,10), QRect(100,100,50,50)); + QSignalSpy xdgPopupCreatedSpy(m_xdgShellInterface, &XdgShellInterface::xdgPopupCreated); + QScopedPointer popupSurface(m_compositor->createSurface()); + QScopedPointer xdgPopupSurface(m_xdgShell->createPopup(popupSurface.data(), xdgSurface.data(), positioner)); + QVERIFY(xdgPopupCreatedSpy.wait()); + auto serverXdgPopup = xdgPopupCreatedSpy.first().first().value(); + QVERIFY(serverXdgPopup); + + QSignalSpy popupWindowGeometryChangedSpy(serverXdgPopup, &XdgShellPopupInterface::windowGeometryChanged); + xdgPopupSurface->setWindowGeometry(QRect(60, 60, 300, 300)); + popupWindowGeometryChangedSpy.wait(); + QCOMPARE(serverXdgPopup->windowGeometry(), QRect(60, 60, 300, 300)); +} + QTEST_GUILESS_MAIN(XdgShellTestStable) #include "test_xdg_shell_stable.moc" diff --git a/src/client/xdgshell.cpp b/src/client/xdgshell.cpp index 6acf2a4..ea62dc6 100644 --- a/src/client/xdgshell.cpp +++ b/src/client/xdgshell.cpp @@ -1,486 +1,496 @@ /**************************************************************************** Copyright 2016 Martin Gräßlin This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) version 3, or any later version accepted by the membership of KDE e.V. (or its successor approved by the membership of KDE e.V.), which shall act as a proxy defined in Section 6 of version 3 of the license. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library. If not, see . ****************************************************************************/ #include "xdgshell_p.h" #include "event_queue.h" #include "wayland_pointer_p.h" #include "seat.h" #include "surface.h" #include "output.h" #include "../compat/wayland-xdg-shell-v5-client-protocol.h" namespace KWayland { namespace Client { XdgShell::Private::~Private() = default; XdgShell::XdgShell(Private *p, QObject *parent) : QObject(parent) , d(p) { } XdgShell::~XdgShell() { release(); } void XdgShell::setup(xdg_shell *xdgshellv5) { d->setupV5(xdgshellv5); } void XdgShell::setup(zxdg_shell_v6 *xdgshellv6) { d->setupV6(xdgshellv6); } void XdgShell::setup(xdg_wm_base *xdg_wm_base) { d->setup(xdg_wm_base); } void XdgShell::release() { d->release(); } void XdgShell::destroy() { d->destroy(); } void XdgShell::setEventQueue(EventQueue *queue) { d->queue = queue; } EventQueue *XdgShell::eventQueue() { return d->queue; } XdgShell::operator xdg_shell*() { return *(d.data()); } XdgShell::operator xdg_shell*() const { return *(d.data()); } XdgShell::operator zxdg_shell_v6*() { return *(d.data()); } XdgShell::operator zxdg_shell_v6*() const { return *(d.data()); } XdgShell::operator xdg_wm_base*() { return *(d.data()); } XdgShell::operator xdg_wm_base*() const { return *(d.data()); } bool XdgShell::isValid() const { return d->isValid(); } XdgShellSurface *XdgShell::createSurface(Surface *surface, QObject *parent) { return d->getXdgSurface(surface, parent); } XdgShellPopup *XdgShell::createPopup(Surface *surface, Surface *parentSurface, Seat *seat, quint32 serial, const QPoint &parentPos, QObject *parent) { return d->getXdgPopup(surface, parentSurface, seat, serial, parentPos, parent); } XdgShellPopup *XdgShell::createPopup(Surface *surface, XdgShellSurface *parentSurface, const XdgPositioner &positioner, QObject *parent) { return d->getXdgPopup(surface, parentSurface, positioner, parent); } XdgShellPopup *XdgShell::createPopup(Surface *surface, XdgShellPopup *parentSurface, const XdgPositioner &positioner, QObject *parent) { return d->getXdgPopup(surface, parentSurface, positioner, parent); } XdgShellSurface::Private::Private(XdgShellSurface *q) : q(q) { } XdgShellSurface::Private::~Private() = default; XdgShellSurface::XdgShellSurface(Private *p, QObject *parent) : QObject(parent) , d(p) { } XdgShellSurface::~XdgShellSurface() { release(); } void XdgShellSurface::setup(xdg_surface *xdgsurfacev5) { d->setupV5(xdgsurfacev5); } void XdgShellSurface::setup(zxdg_surface_v6 *xdgsurfacev6, zxdg_toplevel_v6 *xdgtoplevelv6) { d->setupV6(xdgsurfacev6, xdgtoplevelv6); } void XdgShellSurface::setup(xdg_surface *xdgsurface, xdg_toplevel *xdgtoplevel) { d->setup(xdgsurface, xdgtoplevel); } void XdgShellSurface::release() { d->release(); } void XdgShellSurface::destroy() { d->destroy(); } void XdgShellSurface::setEventQueue(EventQueue *queue) { d->queue = queue; } EventQueue *XdgShellSurface::eventQueue() { return d->queue; } XdgShellSurface::operator xdg_surface*() { return *(d.data()); } XdgShellSurface::operator xdg_surface*() const { return *(d.data()); } XdgShellSurface::operator xdg_toplevel*() { return *(d.data()); } XdgShellSurface::operator xdg_toplevel*() const { return *(d.data()); } XdgShellSurface::operator zxdg_surface_v6*() { return *(d.data()); } XdgShellSurface::operator zxdg_surface_v6*() const { return *(d.data()); } XdgShellSurface::operator zxdg_toplevel_v6*() { return *(d.data()); } XdgShellSurface::operator zxdg_toplevel_v6*() const { return *(d.data()); } bool XdgShellSurface::isValid() const { return d->isValid(); } void XdgShellSurface::setTransientFor(XdgShellSurface *parent) { d->setTransientFor(parent); } void XdgShellSurface::setTitle(const QString &title) { d->setTitle(title); } void XdgShellSurface::setAppId(const QByteArray &appId) { d->setAppId(appId); } void XdgShellSurface::requestShowWindowMenu(Seat *seat, quint32 serial, const QPoint &pos) { d->showWindowMenu(seat, serial, pos.x(), pos.y()); } void XdgShellSurface::requestMove(Seat *seat, quint32 serial) { d->move(seat, serial); } void XdgShellSurface::requestResize(Seat *seat, quint32 serial, Qt::Edges edges) { d->resize(seat, serial, edges); } void XdgShellSurface::ackConfigure(quint32 serial) { d->ackConfigure(serial); } void XdgShellSurface::setMaximized(bool set) { if (set) { d->setMaximized(); } else { d->unsetMaximized(); } } void XdgShellSurface::setFullscreen(bool set, Output *output) { if (set) { d->setFullscreen(output); } else { d->unsetFullscreen(); } } void XdgShellSurface::setMaxSize(const QSize &size) { d->setMaxSize(size); } void XdgShellSurface::setMinSize(const QSize &size) { d->setMinSize(size); } +void XdgShellSurface::setWindowGeometry(const QRect &windowGeometry) +{ + d->setWindowGeometry(windowGeometry); +} + void XdgShellSurface::requestMinimize() { d->setMinimized(); } void XdgShellSurface::setSize(const QSize &size) { if (d->size == size) { return; } d->size = size; emit sizeChanged(size); } QSize XdgShellSurface::size() const { return d->size; } XdgShellPopup::Private::~Private() = default; XdgShellPopup::Private::Private(XdgShellPopup *q) : q(q) { } XdgShellPopup::XdgShellPopup(Private *p, QObject *parent) : QObject(parent) , d(p) { } XdgShellPopup::~XdgShellPopup() { release(); } void XdgShellPopup::setup(xdg_popup *xdgpopupv5) { d->setupV5(xdgpopupv5); } void XdgShellPopup::setup(zxdg_surface_v6 *xdgsurfacev6, zxdg_popup_v6 *xdgpopupv6) { d->setupV6(xdgsurfacev6, xdgpopupv6); } void XdgShellPopup::setup(xdg_surface *surface, xdg_popup *popup) { d->setup(surface, popup); } void XdgShellPopup::release() { d->release(); } void XdgShellPopup::destroy() { d->destroy(); } void XdgShellPopup::setEventQueue(EventQueue *queue) { d->queue = queue; } EventQueue *XdgShellPopup::eventQueue() { return d->queue; } void XdgShellPopup::requestGrab(KWayland::Client::Seat* seat, quint32 serial) { d->requestGrab(seat, serial); } void XdgShellPopup::ackConfigure(quint32 serial) { d->ackConfigure(serial); } +void XdgShellPopup::setWindowGeometry(const QRect &windowGeometry) +{ + d->setWindowGeometry(windowGeometry); +} + XdgShellPopup::operator xdg_surface*() { return *(d.data()); } XdgShellPopup::operator xdg_surface*() const { return *(d.data()); } XdgShellPopup::operator xdg_popup*() { return *(d.data()); } XdgShellPopup::operator xdg_popup*() const { return *(d.data()); } XdgShellPopup::operator zxdg_surface_v6*() { return *(d.data()); } XdgShellPopup::operator zxdg_surface_v6*() const { return *(d.data()); } XdgShellPopup::operator zxdg_popup_v6*() { return *(d.data()); } XdgShellPopup::operator zxdg_popup_v6*() const { return *(d.data()); } bool XdgShellPopup::isValid() const { return d->isValid(); } XdgPositioner::XdgPositioner(const QSize& initialSize, const QRect& anchor) :d (new Private) { d->initialSize = initialSize; d->anchorRect = anchor; } XdgPositioner::XdgPositioner(const XdgPositioner &other) :d (new Private) { *d = *other.d; } XdgPositioner::~XdgPositioner() { } void XdgPositioner::setInitialSize(const QSize& size) { d->initialSize = size; } QSize XdgPositioner::initialSize() const { return d->initialSize; } void XdgPositioner::setAnchorRect(const QRect& anchor) { d->anchorRect = anchor; } QRect XdgPositioner::anchorRect() const { return d->anchorRect; } void XdgPositioner::setAnchorEdge(Qt::Edges edge) { d->anchorEdge = edge; } Qt::Edges XdgPositioner::anchorEdge() const { return d->anchorEdge; } void XdgPositioner::setAnchorOffset(const QPoint& offset) { d->anchorOffset = offset; } QPoint XdgPositioner::anchorOffset() const { return d->anchorOffset; } void XdgPositioner::setGravity(Qt::Edges edge) { d->gravity = edge; } Qt::Edges XdgPositioner::gravity() const { return d->gravity; } void XdgPositioner::setConstraints(Constraints constraints) { d->constraints = constraints; } XdgPositioner::Constraints XdgPositioner::constraints() const { return d->constraints; } } } diff --git a/src/client/xdgshell.h b/src/client/xdgshell.h index a888db1..5a43b44 100644 --- a/src/client/xdgshell.h +++ b/src/client/xdgshell.h @@ -1,645 +1,657 @@ /**************************************************************************** Copyright 2016 Martin Gräßlin This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) version 3, or any later version accepted by the membership of KDE e.V. (or its successor approved by the membership of KDE e.V.), which shall act as a proxy defined in Section 6 of version 3 of the license. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library. If not, see . ****************************************************************************/ #ifndef KWAYLAND_CLIENT_XDG_SHELL_H #define KWAYLAND_CLIENT_XDG_SHELL_H #include #include #include #include //This is a mix of structs for both xdgshell unstable v5 AND xdg wm base stable struct xdg_wm_base; struct xdg_shell; struct xdg_surface; struct xdg_popup; struct xdg_toplevel; struct zxdg_shell_v6; struct zxdg_toplevel_v6; struct zxdg_surface_v6; struct zxdg_popup_v6; struct zxdg_position_v6; namespace KWayland { namespace Client { class EventQueue; class Output; class Surface; class Seat; class XdgShellPopup; class XdgShellSurface; /** * Builder class describing how a popup should be positioned * when created * * @since 5.39 */ class KWAYLANDCLIENT_EXPORT XdgPositioner { public: /* * Flags describing how a popup should be reposition if constrained */ enum class Constraint { /* * Slide the popup on the X axis until there is room */ SlideX = 1 << 0, /* * Slide the popup on the Y axis until there is room */ SlideY = 1 << 1, /* * Invert the anchor and gravity on the X axis */ FlipX = 1 << 2, /* * Invert the anchor and gravity on the Y axis */ FlipY = 1 << 3, /* * Resize the popup in the X axis */ ResizeX = 1 << 4, /* * Resize the popup in the Y axis */ ResizeY = 1 << 5 }; Q_DECLARE_FLAGS(Constraints, Constraint) XdgPositioner(const QSize &initialSize = QSize(), const QRect &anchor = QRect()); XdgPositioner(const XdgPositioner &other); ~XdgPositioner(); /** * Which edge of the anchor should the popup be positioned around */ //KF6 TODO use a better data type (enum of 8 options) rather than flags which allow invalid values Qt::Edges anchorEdge() const; void setAnchorEdge(Qt::Edges edge); /** * Specifies in what direction the popup should be positioned around the anchor * i.e if the gravity is "bottom", then then the top of top of the popup will be at the anchor edge * if the gravity is top, then the bottom of the popup will be at the anchor edge * */ //KF6 TODO use a better data type (enum of 8 options) rather than flags which allow invalid values Qt::Edges gravity() const; void setGravity(Qt::Edges edge); /** * The area this popup should be positioned around */ QRect anchorRect() const; void setAnchorRect(const QRect &anchor); /** * The size of the surface that is to be positioned. */ QSize initialSize() const; void setInitialSize(const QSize &size); /** * Specifies how the compositor should position the popup if it does not fit in the requested position */ Constraints constraints() const; void setConstraints(Constraints constraints); /** * An additional offset that should be applied from the anchor. */ QPoint anchorOffset() const; void setAnchorOffset(const QPoint &offset); private: class Private; QScopedPointer d; }; /** * @short Wrapper for the xdg_shell interface. * * This class provides a convenient wrapper for the xdg_shell interface. * * To use this class one needs to interact with the Registry. There are two * possible ways to create the XdgShell interface: * @code * XdgShell *c = registry->createXdgShell(name, version); * @endcode * * This creates the XdgShell and sets it up directly. As an alternative this * can also be done in a more low level way: * @code * XdgShell *c = new XdgShell; * c->setup(registry->bindXdgShell(name, version)); * @endcode * * The XdgShell can be used as a drop-in replacement for any xdg_shell * pointer as it provides matching cast operators. * * @see Registry * @since 5.25 **/ class KWAYLANDCLIENT_EXPORT XdgShell : public QObject { Q_OBJECT public: virtual ~XdgShell(); /** * Setup this XdgShell to manage the @p xdgshellv5. * When using Registry::createXdgShell there is no need to call this * method. **/ void setup(xdg_shell *xdgshellv5); /** * Setup this XdgShell to manage the @p xdgshellv6. * When using Registry::createXdgShell there is no need to call this * method. **/ void setup(zxdg_shell_v6 *xdgshellv6); /** * Setup this XdgShell to manage the @p xdg_wm_base. * When using Registry::createXdgShell there is no need to call this * method. **/ void setup(xdg_wm_base *xdg_wm_base); /** * @returns @c true if managing a xdg_shell. **/ bool isValid() const; /** * Releases the xdg_shell interface. * After the interface has been released the XdgShell instance is no * longer valid and can be setup with another xdg_shell interface. **/ void release(); /** * Destroys the data held by this XdgShell. * This method is supposed to be used when the connection to the Wayland * server goes away. If the connection is not valid anymore, it's not * possible to call release anymore as that calls into the Wayland * connection and the call would fail. This method cleans up the data, so * that the instance can be deleted or set up to a new xdg_shell interface * once there is a new connection available. * * This method is automatically invoked when the Registry which created this * XdgShell gets destroyed. * * @see release **/ void destroy(); /** * Sets the @p queue to use for creating objects with this XdgShell. **/ void setEventQueue(EventQueue *queue); /** * @returns The event queue to use for creating objects with this XdgShell. **/ EventQueue *eventQueue(); /** * Creates a new XdgShellSurface for the given @p surface. **/ XdgShellSurface *createSurface(Surface *surface, QObject *parent = nullptr); /** * Creates a new XdgShellPopup for the given @p surface on top of @p parentSurface. * This method is only valid for Xdgv5 **/ XdgShellPopup *createPopup(Surface *surface, Surface *parentSurface, Seat *seat, quint32 serial, const QPoint &parentPos, QObject *parent = nullptr); /** * Creates a new XdgShellPopup for the given @p surface on top of @p parentSurface with the given @p positioner. * This method is only valid for Xdgv6 onwards. * @since 5.39 **/ XdgShellPopup *createPopup(Surface *surface, XdgShellSurface *parentSurface, const XdgPositioner &positioner, QObject *parent = nullptr); /** * Creates a new XdgShellPopup for the given @p surface on top of @p parentSurface with the given @p positioner. * @since 5.39 **/ XdgShellPopup *createPopup(Surface *surface, XdgShellPopup *parentSurface, const XdgPositioner &positioner, QObject *parent = nullptr); operator xdg_wm_base*(); operator xdg_wm_base*() const; operator xdg_shell*(); operator xdg_shell*() const; operator zxdg_shell_v6*(); operator zxdg_shell_v6*() const; Q_SIGNALS: /** * The corresponding global for this interface on the Registry got removed. * * This signal gets only emitted if the XdgShell got created by * Registry::createXdgShell **/ void removed(); protected: /** * Creates a new XdgShell. * Note: after constructing the XdgShell it is not yet valid and one needs * to call setup. In order to get a ready to use XdgShell prefer using * Registry::createXdgShell. **/ class Private; explicit XdgShell(Private *p, QObject *parent = nullptr); private: QScopedPointer d; }; /** * * @since 5.25 **/ class KWAYLANDCLIENT_EXPORT XdgShellSurface : public QObject { Q_OBJECT public: virtual ~XdgShellSurface(); /** * States the Surface can be in **/ enum class State { /** * The Surface is maximized. **/ Maximized = 1 << 0, /** * The Surface is fullscreen. **/ Fullscreen = 1 << 1, /** * The Surface is currently being resized by the Compositor. **/ Resizing = 1 << 2, /** * The Surface is considered active. Does not imply keyboard focus. **/ Activated = 1 << 3 }; Q_DECLARE_FLAGS(States, State) /** * Setup this XdgShellSurface to manage the @p xdgsurfacev5. * When using XdgShell::createXdgShellSurface there is no need to call this * method. **/ void setup(xdg_surface *xdgsurfacev5); /** * Setup this XdgShellSurface to manage the @p toplevel on the relevant @p xdgsurfacev6 * When using XdgShell::createXdgShellSurface there is no need to call this * method. **/ void setup(zxdg_surface_v6 *xdgsurfacev6, zxdg_toplevel_v6 *toplevel); /** * Setup this XdgShellSurface to manage the @p toplevel on the relevant @p xdgsurface * When using XdgShell::createXdgShellSurface there is no need to call this * method. **/ void setup(xdg_surface *xdgsurface, xdg_toplevel *toplevel); /** * @returns @c true if managing a xdg_surface. **/ bool isValid() const; /** * Releases the xdg_surface interface. * After the interface has been released the XdgShellSurface instance is no * longer valid and can be setup with another xdg_surface interface. **/ void release(); /** * Destroys the data held by this XdgShellSurface. * This method is supposed to be used when the connection to the Wayland * server goes away. If the connection is not valid anymore, it's not * possible to call release anymore as that calls into the Wayland * connection and the call would fail. This method cleans up the data, so * that the instance can be deleted or set up to a new xdg_surface interface * once there is a new connection available. * * It is suggested to connect this method to ConnectionThread::connectionDied: * @code * connect(connection, &ConnectionThread::connectionDied, xdgsurfacev5, &XdgShellSurface::destroy); * @endcode * * @see release **/ void destroy(); /** * Sets the @p queue to use for bound proxies. **/ void setEventQueue(EventQueue *queue); /** * @returns The event queue to use for bound proxies. **/ EventQueue *eventQueue(); /** * The currently configured size. * @see sizeChanged * @see setSize **/ QSize size() const; /** * Sets the size for the XdgShellSurface to @p size. * This is mostly an internal information. The actual size of the XdgShellSurface is * determined by the size of the Buffer attached to the XdgShellSurface's Surface. * * @param size The new size to be used for the XdgShellSurface * @see size * @see sizeChanged **/ void setSize(const QSize &size); /** * Set this XdgShellSurface as transient for @p parent. **/ void setTransientFor(XdgShellSurface *parent); /** * Sets the window title of this XdgShellSurface to @p title. **/ void setTitle(const QString &title); /** * Set an application identifier for the surface. **/ void setAppId(const QByteArray &appId); /** * Requests to show the window menu at @p pos in surface coordinates. **/ void requestShowWindowMenu(Seat *seat, quint32 serial, const QPoint &pos); /** * Requests a move on the given @p seat after the pointer button press with the given @p serial. * * @param seat The seat on which to move the window * @param serial The serial of the pointer button press which should trigger the move **/ void requestMove(Seat *seat, quint32 serial); /** * Requests a resize on the given @p seat after the pointer button press with the given @p serial. * * @param seat The seat on which to resize the window * @param serial The serial of the pointer button press which should trigger the resize * @param edges A hint for the compositor to set e.g. an appropriate cursor image **/ void requestResize(Seat *seat, quint32 serial, Qt::Edges edges); /** * When a configure event is received, if a client commits the * Surface in response to the configure event, then the client * must make an ackConfigure request sometime before the commit * request, passing along the @p serial of the configure event. * @see configureRequested **/ void ackConfigure(quint32 serial); /** * Request to set this XdgShellSurface to be maximized if @p set is @c true. * If @p set is @c false it requests to unset the maximized state - if set. * * @param set Whether the XdgShellSurface should be maximized **/ void setMaximized(bool set); /** * Request to set this XdgShellSurface as fullscreen on @p output. * If @p set is @c true the Surface should be set to fullscreen, otherwise restore * from fullscreen state. * * @param set Whether the Surface should be fullscreen or not * @param output Optional output as hint to the compositor where the Surface should be put **/ void setFullscreen(bool set, Output *output = nullptr); /** * Request to the compositor to minimize this XdgShellSurface. **/ void requestMinimize(); /** * Set this surface to have a given maximum size * @since 5.39 */ void setMaxSize(const QSize &size); /** * Set this surface to have a given minimum size * @since 5.39 */ void setMinSize(const QSize &size); + /** + * Sets the position of the window contents within the buffer + * @since 5.59 + */ + void setWindowGeometry(const QRect &windowGeometry); + operator xdg_surface*(); operator xdg_surface*() const; operator xdg_toplevel*(); operator xdg_toplevel*() const; operator zxdg_surface_v6*(); operator zxdg_surface_v6*() const; operator zxdg_toplevel_v6*(); operator zxdg_toplevel_v6*() const; Q_SIGNALS: /** * The compositor requested to close this window. **/ void closeRequested(); /** * The compositor sent a configure with the new @p size and the @p states. * Before the next commit of the surface the @p serial needs to be passed to ackConfigure. **/ void configureRequested(const QSize &size, KWayland::Client::XdgShellSurface::States states, quint32 serial); /** * Emitted whenever the size of the XdgShellSurface changes by e.g. receiving a configure request. * * @see configureRequested * @see size * @see setSize **/ void sizeChanged(const QSize &); protected: class Private; explicit XdgShellSurface(Private *p, QObject *parent = nullptr); private: QScopedPointer d; }; /** * A XdgShellPopup is a short-lived, temporary surface that can be * used to implement menus. It takes an explicit grab on the surface * that will be dismissed when the user dismisses the popup. This can * be done by the user clicking outside the surface, using the keyboard, * or even locking the screen through closing the lid or a timeout. * @since 5.25 **/ class KWAYLANDCLIENT_EXPORT XdgShellPopup : public QObject { Q_OBJECT public: virtual ~XdgShellPopup(); /** * Setup this XdgShellPopup to manage the @p xdgpopupv5. * When using XdgShell::createXdgShellPopup there is no need to call this * method. * * This was for XDGShellV5, this is now deprecated **/ void setup(xdg_popup *xdgpopupv5); /** * Setup this XdgShellPopup to manage the @p xdgpopupv6 on associated @p xdgsurfacev6 * When using XdgShell::createXdgShellPopup there is no need to call this * method. * @since 5.39 **/ void setup(zxdg_surface_v6 *xdgsurfacev6, zxdg_popup_v6 *xdgpopup6); /** * Setup this XdgShellPopup to manage the @p xdgpopupv on associated @p xdgsurface * When using XdgShell::createXdgShellPopup there is no need to call this * method. * @since 5.XDGSTABLE **/ void setup(xdg_surface *xdgsurface, xdg_popup *xdgpopup); /** * @returns @c true if managing an xdg_popup. **/ bool isValid() const; /** * Releases the xdg_popup interface. * After the interface has been released the XdgShellPopup instance is no * longer valid and can be setup with another xdg_popup interface. **/ void release(); /** * Destroys the data held by this XdgShellPopup. * This method is supposed to be used when the connection to the Wayland * server goes away. If the connection is not valid anymore, it's not * possible to call release anymore as that calls into the Wayland * connection and the call would fail. This method cleans up the data, so * that the instance can be deleted or set up to a new xdg_popup interface * once there is a new connection available. * * It is suggested to connect this method to ConnectionThread::connectionDied: * @code * connect(connection, &ConnectionThread::connectionDied, xdgpopupv5, &XdgShellPopup::destroy); * @endcode * * @see release **/ void destroy(); /** * Sets the @p queue to use for bound proxies. **/ void setEventQueue(EventQueue *queue); /** * @returns The event queue to use for bound proxies. **/ EventQueue *eventQueue(); /** * Requests a grab on this popup * @since 5.39 */ void requestGrab(Seat *seat, quint32 serial); /** * When a configure event is received, if a client commits the * Surface in response to the configure event, then the client * must make an ackConfigure request sometime before the commit * request, passing along the @p serial of the configure event. * @see configureRequested * @since 5.56 **/ void ackConfigure(quint32 serial); + /** + * Sets the position of the window contents within the buffer + * @since 5.59 + */ + void setWindowGeometry(const QRect &windowGeometry); + operator xdg_surface*(); operator xdg_surface*() const; operator xdg_popup*(); operator xdg_popup*() const; operator zxdg_surface_v6*(); operator zxdg_surface_v6*() const; operator zxdg_popup_v6*(); operator zxdg_popup_v6*() const; Q_SIGNALS: /** * This signal is emitted when a XdgShellPopup is dismissed by the * compositor. The user should delete this instance at this point. **/ void popupDone(); /** * Emitted when the server has configured the popup with the final location of @p relativePosition * This is emitted for V6 surfaces only * @since 5.39 **/ void configureRequested(const QRect &relativePosition, quint32 serial); protected: class Private; explicit XdgShellPopup(Private *p, QObject *parent = nullptr); private: QScopedPointer d; }; } } Q_DECLARE_OPERATORS_FOR_FLAGS(KWayland::Client::XdgShellSurface::States) Q_DECLARE_OPERATORS_FOR_FLAGS(KWayland::Client::XdgPositioner::Constraints) Q_DECLARE_METATYPE(KWayland::Client::XdgPositioner) Q_DECLARE_METATYPE(KWayland::Client::XdgShellSurface::State) Q_DECLARE_METATYPE(KWayland::Client::XdgShellSurface::States) Q_DECLARE_METATYPE(KWayland::Client::XdgPositioner::Constraint) Q_DECLARE_METATYPE(KWayland::Client::XdgPositioner::Constraints) #endif diff --git a/src/client/xdgshell_p.h b/src/client/xdgshell_p.h index f1366fc..90a305e 100644 --- a/src/client/xdgshell_p.h +++ b/src/client/xdgshell_p.h @@ -1,354 +1,361 @@ /**************************************************************************** Copyright 2016 Martin Gräßlin This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) version 3, or any later version accepted by the membership of KDE e.V. (or its successor approved by the membership of KDE e.V.), which shall act as a proxy defined in Section 6 of version 3 of the license. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library. If not, see . ****************************************************************************/ #ifndef KWAYLAND_CLIENT_XDGSHELL_P_H #define KWAYLAND_CLIENT_XDGSHELL_P_H #include "xdgshell.h" #include #include #include namespace KWayland { namespace Client { class Q_DECL_HIDDEN XdgShell::Private { public: virtual ~Private(); virtual void setupV5(xdg_shell *xdgshellv5) { Q_UNUSED(xdgshellv5) } virtual void setupV6(zxdg_shell_v6 *xdgshellv6) { Q_UNUSED(xdgshellv6) } virtual void setup(xdg_wm_base *xdgshell) { Q_UNUSED(xdgshell); } virtual void release() = 0; virtual void destroy() = 0; virtual bool isValid() const = 0; virtual operator xdg_shell*() { return nullptr; } virtual operator xdg_shell*() const { return nullptr; } virtual operator zxdg_shell_v6*() { return nullptr; } virtual operator zxdg_shell_v6*() const { return nullptr; } virtual operator xdg_wm_base*() { return nullptr; } virtual operator xdg_wm_base*() const { return nullptr; } virtual XdgShellSurface *getXdgSurface(Surface *surface, QObject *parent) = 0; virtual XdgShellPopup *getXdgPopup(Surface *surface, Surface *parentSurface, Seat *seat, quint32 serial, const QPoint &parentPos, QObject *parent) { Q_UNUSED(surface) Q_UNUSED(parentSurface) Q_UNUSED(seat) Q_UNUSED(serial) Q_UNUSED(parentPos) Q_UNUSED(parent) Q_ASSERT(false); return nullptr; }; virtual XdgShellPopup *getXdgPopup(Surface *surface, XdgShellSurface *parentSurface, const XdgPositioner &positioner, QObject *parent) { Q_UNUSED(surface) Q_UNUSED(parentSurface) Q_UNUSED(positioner) Q_UNUSED(parent) Q_ASSERT(false); return nullptr; } virtual XdgShellPopup *getXdgPopup(Surface *surface, XdgShellPopup *parentSurface, const XdgPositioner &positioner, QObject *parent) { Q_UNUSED(surface) Q_UNUSED(parentSurface) Q_UNUSED(positioner) Q_UNUSED(parent) Q_ASSERT(false); return nullptr; } EventQueue *queue = nullptr; protected: Private() = default; }; class XdgShellUnstableV5 : public XdgShell { Q_OBJECT public: explicit XdgShellUnstableV5(QObject *parent = nullptr); virtual ~XdgShellUnstableV5(); private: class Private; }; class XdgShellUnstableV6 : public XdgShell { Q_OBJECT public: explicit XdgShellUnstableV6(QObject *parent = nullptr); virtual ~XdgShellUnstableV6(); private: class Private; }; class XdgShellStable : public XdgShell { Q_OBJECT public: explicit XdgShellStable(QObject *parent = nullptr); virtual ~XdgShellStable(); private: class Private; }; class XdgShellSurfaceUnstableV5 : public XdgShellSurface { Q_OBJECT public: virtual ~XdgShellSurfaceUnstableV5(); private: explicit XdgShellSurfaceUnstableV5(QObject *parent = nullptr); friend class XdgShellUnstableV5; class Private; }; class XdgTopLevelUnstableV6 : public XdgShellSurface { Q_OBJECT public: virtual ~XdgTopLevelUnstableV6(); private: explicit XdgTopLevelUnstableV6(QObject *parent = nullptr); friend class XdgShellUnstableV6; class Private; }; class XdgTopLevelStable : public XdgShellSurface { Q_OBJECT public: virtual ~XdgTopLevelStable(); private: explicit XdgTopLevelStable(QObject *parent = nullptr); friend class XdgShellStable; class Private; }; class Q_DECL_HIDDEN XdgShellSurface::Private { public: virtual ~Private(); EventQueue *queue = nullptr; QSize size; virtual void setupV5(xdg_surface *surface) { Q_UNUSED(surface) } virtual void setupV6(zxdg_surface_v6 *surface, zxdg_toplevel_v6 *toplevel) { Q_UNUSED(toplevel) Q_UNUSED(surface) } virtual void setup(xdg_surface *surface, xdg_toplevel *toplevel) { Q_UNUSED(surface) Q_UNUSED(toplevel) } virtual void release() = 0; virtual void destroy() = 0; virtual bool isValid() const = 0; virtual operator xdg_surface*() { return nullptr; } virtual operator xdg_surface*() const { return nullptr; } virtual operator xdg_toplevel*() { return nullptr; } virtual operator xdg_toplevel*() const { return nullptr; } virtual operator zxdg_surface_v6*() { return nullptr; } virtual operator zxdg_surface_v6*() const { return nullptr; } virtual operator zxdg_toplevel_v6*() { return nullptr; } virtual operator zxdg_toplevel_v6*() const { return nullptr; } virtual void setTransientFor(XdgShellSurface *parent) = 0; virtual void setTitle(const QString &title) = 0; virtual void setAppId(const QByteArray &appId) = 0; virtual void showWindowMenu(Seat *seat, quint32 serial, qint32 x, qint32 y) = 0; virtual void move(Seat *seat, quint32 serial) = 0; virtual void resize(Seat *seat, quint32 serial, Qt::Edges edges) = 0; virtual void ackConfigure(quint32 serial) = 0; virtual void setMaximized() = 0; virtual void unsetMaximized() = 0; virtual void setFullscreen(Output *output) = 0; virtual void unsetFullscreen() = 0; virtual void setMinimized() = 0; virtual void setMaxSize(const QSize &size) = 0; virtual void setMinSize(const QSize &size) = 0; + virtual void setWindowGeometry(const QRect &windowGeometry) { + Q_UNUSED(windowGeometry); + } protected: Private(XdgShellSurface *q); XdgShellSurface *q; }; class Q_DECL_HIDDEN XdgShellPopup::Private { public: Private(XdgShellPopup *q); virtual ~Private(); EventQueue *queue = nullptr; virtual void setupV5(xdg_popup *p) { Q_UNUSED(p) } virtual void setupV6(zxdg_surface_v6 *s, zxdg_popup_v6 *p) { Q_UNUSED(s) Q_UNUSED(p) } virtual void setup(xdg_surface *s, xdg_popup *p) { Q_UNUSED(s) Q_UNUSED(p) } virtual void release() = 0; virtual void destroy() = 0; virtual bool isValid() const = 0; virtual void requestGrab(Seat *seat, quint32 serial) { Q_UNUSED(seat); Q_UNUSED(serial); }; virtual void ackConfigure(quint32 serial) { Q_UNUSED(serial); } + virtual void setWindowGeometry(const QRect &windowGeometry) { + Q_UNUSED(windowGeometry); + } + virtual operator xdg_surface*() { return nullptr; } virtual operator xdg_surface*() const { return nullptr; } virtual operator xdg_popup*() { return nullptr; } virtual operator xdg_popup*() const { return nullptr; } virtual operator zxdg_surface_v6*() { return nullptr; } virtual operator zxdg_surface_v6*() const { return nullptr; } virtual operator zxdg_popup_v6*() { return nullptr; } virtual operator zxdg_popup_v6*() const { return nullptr; } protected: XdgShellPopup *q; private: }; class XdgPositioner::Private { public: QSize initialSize; QRect anchorRect; Qt::Edges gravity; Qt::Edges anchorEdge; XdgPositioner::Constraints constraints; QPoint anchorOffset; }; class XdgShellPopupUnstableV5 : public XdgShellPopup { public: virtual ~XdgShellPopupUnstableV5(); private: explicit XdgShellPopupUnstableV5(QObject *parent = nullptr); friend class XdgShellUnstableV5; class Private; }; class XdgShellPopupUnstableV6 : public XdgShellPopup { public: virtual ~XdgShellPopupUnstableV6(); private: explicit XdgShellPopupUnstableV6(QObject *parent = nullptr); friend class XdgShellUnstableV6; class Private; }; class XdgShellPopupStable : public XdgShellPopup { public: virtual ~XdgShellPopupStable(); private: explicit XdgShellPopupStable(QObject *parent = nullptr); friend class XdgShellStable; class Private; }; } } #endif diff --git a/src/client/xdgshell_stable.cpp b/src/client/xdgshell_stable.cpp index 49d4b6e..0c37c84 100644 --- a/src/client/xdgshell_stable.cpp +++ b/src/client/xdgshell_stable.cpp @@ -1,612 +1,624 @@ /**************************************************************************** Copyright 2017 David Edmundson This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) version 3, or any later version accepted by the membership of KDE e.V. (or its successor approved by the membership of KDE e.V.), which shall act as a proxy defined in Section 6 of version 3 of the license. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library. If not, see . ****************************************************************************/ #include "xdgshell_p.h" #include "event_queue.h" #include "output.h" #include "seat.h" #include "surface.h" #include "wayland_pointer_p.h" #include namespace KWayland { namespace Client { class XdgShellStable::Private : public XdgShell::Private { public: void setup(xdg_wm_base *shell) override; void release() override; void destroy() override; bool isValid() const override; XdgShellSurface *getXdgSurface(Surface *surface, QObject *parent) override; XdgShellPopup *getXdgPopup(Surface *surface, XdgShellSurface *parentSurface, const XdgPositioner &positioner, QObject *parent) override; XdgShellPopup *getXdgPopup(Surface *surface, XdgShellPopup *parentSurface, const XdgPositioner &positioner, QObject *parent) override; using XdgShell::Private::operator xdg_shell*; using XdgShell::Private::operator zxdg_shell_v6*; operator xdg_wm_base*() override { return xdg_shell_base; } operator xdg_wm_base*() const override { return xdg_shell_base; } private: XdgShellPopup *internalGetXdgPopup(Surface *surface, xdg_surface *parentSurface, const XdgPositioner &positioner, QObject *parent); static void pingCallback(void *data, struct xdg_wm_base *shell, uint32_t serial); WaylandPointer xdg_shell_base; static const struct xdg_wm_base_listener s_shellListener; }; const struct xdg_wm_base_listener XdgShellStable::Private::s_shellListener = { pingCallback, }; void XdgShellStable::Private::pingCallback(void *data, struct xdg_wm_base *shell, uint32_t serial) { Q_UNUSED(data) xdg_wm_base_pong(shell, serial); } void XdgShellStable::Private::setup(xdg_wm_base *shell) { Q_ASSERT(shell); Q_ASSERT(!xdg_shell_base); xdg_shell_base.setup(shell); xdg_wm_base_add_listener(shell, &s_shellListener, this); } void XdgShellStable::Private::release() { xdg_shell_base.release(); } void XdgShellStable::Private::destroy() { xdg_shell_base.destroy(); } bool XdgShellStable::Private::isValid() const { return xdg_shell_base.isValid(); } XdgShellSurface *XdgShellStable::Private::getXdgSurface(Surface *surface, QObject *parent) { Q_ASSERT(isValid()); auto ss = xdg_wm_base_get_xdg_surface(xdg_shell_base, *surface); if (!ss) { return nullptr; } auto s = new XdgTopLevelStable(parent); auto toplevel = xdg_surface_get_toplevel(ss); if (queue) { queue->addProxy(ss); queue->addProxy(toplevel); } s->setup(ss, toplevel); return s; } XdgShellPopup *XdgShellStable::Private::getXdgPopup(Surface *surface, XdgShellSurface *parentSurface, const XdgPositioner &positioner, QObject *parent) { return internalGetXdgPopup(surface, *parentSurface, positioner, parent); } XdgShellPopup *XdgShellStable::Private::getXdgPopup(Surface *surface, XdgShellPopup *parentSurface, const XdgPositioner &positioner, QObject *parent) { return internalGetXdgPopup(surface, *parentSurface, positioner, parent); } XdgShellPopup *XdgShellStable::Private::internalGetXdgPopup(Surface *surface, xdg_surface *parentSurface, const XdgPositioner &positioner, QObject *parent) { Q_ASSERT(isValid()); auto ss = xdg_wm_base_get_xdg_surface(xdg_shell_base, *surface); if (!ss) { return nullptr; } auto p = xdg_wm_base_create_positioner(xdg_shell_base); auto anchorRect = positioner.anchorRect(); xdg_positioner_set_anchor_rect(p, anchorRect.x(), anchorRect.y(), anchorRect.width(), anchorRect.height()); QSize initialSize = positioner.initialSize(); xdg_positioner_set_size(p, initialSize.width(), initialSize.height()); QPoint anchorOffset = positioner.anchorOffset(); if (!anchorOffset.isNull()) { xdg_positioner_set_offset(p, anchorOffset.x(), anchorOffset.y()); } uint32_t anchor = XDG_POSITIONER_ANCHOR_NONE; if (positioner.anchorEdge().testFlag(Qt::TopEdge)) { if (positioner.anchorEdge().testFlag(Qt::LeftEdge) && ((positioner.anchorEdge() & ~Qt::LeftEdge) == Qt::TopEdge)) { anchor = XDG_POSITIONER_ANCHOR_TOP_LEFT; } else if (positioner.anchorEdge().testFlag(Qt::RightEdge) && ((positioner.anchorEdge() & ~Qt::RightEdge) == Qt::TopEdge)) { anchor = XDG_POSITIONER_ANCHOR_TOP_RIGHT; } else if ((positioner.anchorEdge() & ~Qt::TopEdge) == Qt::Edges()) { anchor = XDG_POSITIONER_ANCHOR_TOP; } } else if (positioner.anchorEdge().testFlag(Qt::BottomEdge)) { if (positioner.anchorEdge().testFlag(Qt::LeftEdge) && ((positioner.anchorEdge() & ~Qt::LeftEdge) == Qt::BottomEdge)) { anchor = XDG_POSITIONER_ANCHOR_BOTTOM_LEFT; } else if (positioner.anchorEdge().testFlag(Qt::RightEdge) && ((positioner.anchorEdge() & ~Qt::RightEdge) == Qt::BottomEdge)) { anchor = XDG_POSITIONER_ANCHOR_BOTTOM_RIGHT; } else if ((positioner.anchorEdge() & ~Qt::BottomEdge) == Qt::Edges()) { anchor = XDG_POSITIONER_ANCHOR_BOTTOM; } } else if (positioner.anchorEdge().testFlag(Qt::RightEdge) && ((positioner.anchorEdge() & ~Qt::RightEdge) == Qt::Edges())) { anchor = XDG_POSITIONER_ANCHOR_RIGHT; } else if (positioner.anchorEdge().testFlag(Qt::LeftEdge) && ((positioner.anchorEdge() & ~Qt::LeftEdge) == Qt::Edges())) { anchor = XDG_POSITIONER_ANCHOR_LEFT; } if (anchor != 0) { xdg_positioner_set_anchor(p, anchor); } uint32_t gravity = XDG_POSITIONER_GRAVITY_NONE; if (positioner.gravity().testFlag(Qt::TopEdge)) { if (positioner.gravity().testFlag(Qt::LeftEdge) && ((positioner.gravity() & ~Qt::LeftEdge) == Qt::TopEdge)) { gravity = XDG_POSITIONER_GRAVITY_TOP_LEFT; } else if (positioner.gravity().testFlag(Qt::RightEdge) && ((positioner.gravity() & ~Qt::RightEdge) == Qt::TopEdge)) { gravity = XDG_POSITIONER_GRAVITY_TOP_RIGHT; } else if ((positioner.gravity() & ~Qt::TopEdge) == Qt::Edges()) { gravity = XDG_POSITIONER_GRAVITY_TOP; } } else if (positioner.gravity().testFlag(Qt::BottomEdge)) { if (positioner.gravity().testFlag(Qt::LeftEdge) && ((positioner.gravity() & ~Qt::LeftEdge) == Qt::BottomEdge)) { gravity = XDG_POSITIONER_GRAVITY_BOTTOM_LEFT; } else if (positioner.gravity().testFlag(Qt::RightEdge) && ((positioner.gravity() & ~Qt::RightEdge) == Qt::BottomEdge)) { gravity = XDG_POSITIONER_GRAVITY_BOTTOM_RIGHT; } else if ((positioner.gravity() & ~Qt::BottomEdge) == Qt::Edges()) { gravity = XDG_POSITIONER_GRAVITY_BOTTOM; } } else if (positioner.gravity().testFlag(Qt::RightEdge) && ((positioner.gravity() & ~Qt::RightEdge) == Qt::Edges())) { gravity = XDG_POSITIONER_GRAVITY_RIGHT; } else if (positioner.gravity().testFlag(Qt::LeftEdge) && ((positioner.gravity() & ~Qt::LeftEdge) == Qt::Edges())) { gravity = XDG_POSITIONER_GRAVITY_LEFT; } if (gravity != 0) { xdg_positioner_set_gravity(p, gravity); } uint32_t constraint = XDG_POSITIONER_CONSTRAINT_ADJUSTMENT_NONE; if (positioner.constraints().testFlag(XdgPositioner::Constraint::SlideX)) { constraint |= XDG_POSITIONER_CONSTRAINT_ADJUSTMENT_SLIDE_X; } if (positioner.constraints().testFlag(XdgPositioner::Constraint::SlideY)) { constraint |= XDG_POSITIONER_CONSTRAINT_ADJUSTMENT_SLIDE_Y; } if (positioner.constraints().testFlag(XdgPositioner::Constraint::FlipX)) { constraint |= XDG_POSITIONER_CONSTRAINT_ADJUSTMENT_FLIP_X; } if (positioner.constraints().testFlag(XdgPositioner::Constraint::FlipY)) { constraint |= XDG_POSITIONER_CONSTRAINT_ADJUSTMENT_FLIP_Y; } if (positioner.constraints().testFlag(XdgPositioner::Constraint::ResizeX)) { constraint |= XDG_POSITIONER_CONSTRAINT_ADJUSTMENT_RESIZE_X; } if (positioner.constraints().testFlag(XdgPositioner::Constraint::ResizeY)) { constraint |= XDG_POSITIONER_CONSTRAINT_ADJUSTMENT_RESIZE_Y; } if (constraint != 0) { xdg_positioner_set_constraint_adjustment(p, constraint); } XdgShellPopup *s = new XdgShellPopupStable(parent); auto popup = xdg_surface_get_popup(ss, parentSurface, p); if (queue) { //deliberately not adding the positioner because the positioner has no events sent to it queue->addProxy(ss); queue->addProxy(popup); } s->setup(ss, popup); xdg_positioner_destroy(p); return s; } XdgShellStable::XdgShellStable(QObject *parent) : XdgShell(new Private, parent) { } XdgShellStable::~XdgShellStable() = default; //A top level wraps both xdg_surface and xdg_top_level into the public API XdgShelllSurface class XdgTopLevelStable::Private : public XdgShellSurface::Private { public: Private(XdgShellSurface *q); WaylandPointer xdgtoplevel; WaylandPointer xdgsurface; void setup(xdg_surface *surface, xdg_toplevel *toplevel) override; void release() override; void destroy() override; bool isValid() const override; using XdgShellSurface::Private::operator zxdg_toplevel_v6*; using XdgShellSurface::Private::operator zxdg_surface_v6*; operator xdg_surface*() override { return xdgsurface; } operator xdg_surface*() const override { return xdgsurface; } operator xdg_toplevel*() override { return xdgtoplevel; } operator xdg_toplevel*() const override { return xdgtoplevel; } void setTransientFor(XdgShellSurface *parent) override; void setTitle(const QString &title) override; void setAppId(const QByteArray &appId) override; void showWindowMenu(Seat *seat, quint32 serial, qint32 x, qint32 y) override; void move(Seat *seat, quint32 serial) override; void resize(Seat *seat, quint32 serial, Qt::Edges edges) override; void ackConfigure(quint32 serial) override; void setMaximized() override; void unsetMaximized() override; void setFullscreen(Output *output) override; void unsetFullscreen() override; void setMinimized() override; void setMaxSize(const QSize &size) override; void setMinSize(const QSize &size) override; + void setWindowGeometry(const QRect &windowGeometry) override; private: QSize pendingSize; States pendingState; static void configureCallback(void *data, struct xdg_toplevel *xdg_toplevel, int32_t width, int32_t height, struct wl_array *state); static void closeCallback(void *data, xdg_toplevel *xdg_toplevel); static void surfaceConfigureCallback(void *data, xdg_surface *xdg_surface, uint32_t serial); static const struct xdg_toplevel_listener s_toplevelListener; static const struct xdg_surface_listener s_surfaceListener; }; const struct xdg_toplevel_listener XdgTopLevelStable::Private::s_toplevelListener = { configureCallback, closeCallback }; const struct xdg_surface_listener XdgTopLevelStable::Private::s_surfaceListener = { surfaceConfigureCallback }; void XdgTopLevelStable::Private::surfaceConfigureCallback(void *data, struct xdg_surface *surface, uint32_t serial) { Q_UNUSED(surface) auto s = static_cast(data); s->q->configureRequested(s->pendingSize, s->pendingState, serial); if (!s->pendingSize.isNull()) { s->q->setSize(s->pendingSize); s->pendingSize = QSize(); } s->pendingState = nullptr; } void XdgTopLevelStable::Private::configureCallback(void *data, struct xdg_toplevel *xdg_toplevel, int32_t width, int32_t height, struct wl_array *state) { Q_UNUSED(xdg_toplevel) auto s = static_cast(data); States states; uint32_t *statePtr = static_cast(state->data); for (size_t i = 0; i < state->size / sizeof(uint32_t); i++) { switch (statePtr[i]) { case XDG_TOPLEVEL_STATE_MAXIMIZED: states = states | XdgShellSurface::State::Maximized; break; case XDG_TOPLEVEL_STATE_FULLSCREEN: states = states | XdgShellSurface::State::Fullscreen; break; case XDG_TOPLEVEL_STATE_RESIZING: states = states | XdgShellSurface::State::Resizing; break; case XDG_TOPLEVEL_STATE_ACTIVATED: states = states | XdgShellSurface::State::Activated; break; } } s->pendingSize = QSize(width, height); s->pendingState = states; } void XdgTopLevelStable::Private::closeCallback(void *data, xdg_toplevel *xdg_toplevel) { auto s = static_cast(data); Q_ASSERT(s->xdgtoplevel == xdg_toplevel); emit s->q->closeRequested(); } XdgTopLevelStable::Private::Private(XdgShellSurface *q) : XdgShellSurface::Private(q) { } void XdgTopLevelStable::Private::setup(xdg_surface *surface, xdg_toplevel *topLevel) { Q_ASSERT(surface); Q_ASSERT(!xdgtoplevel); xdgsurface.setup(surface); xdgtoplevel.setup(topLevel); xdg_surface_add_listener(xdgsurface, &s_surfaceListener, this); xdg_toplevel_add_listener(xdgtoplevel, &s_toplevelListener, this); } void XdgTopLevelStable::Private::release() { xdgtoplevel.release(); xdgsurface.release(); } void XdgTopLevelStable::Private::destroy() { xdgtoplevel.destroy(); xdgsurface.destroy(); } bool XdgTopLevelStable::Private::isValid() const { return xdgtoplevel.isValid() && xdgsurface.isValid(); } void XdgTopLevelStable::Private::setTransientFor(XdgShellSurface *parent) { xdg_toplevel *parentSurface = nullptr; if (parent) { parentSurface = *parent; } xdg_toplevel_set_parent(xdgtoplevel, parentSurface); } void XdgTopLevelStable::Private::setTitle(const QString & title) { xdg_toplevel_set_title(xdgtoplevel, title.toUtf8().constData()); } void XdgTopLevelStable::Private::setAppId(const QByteArray & appId) { xdg_toplevel_set_app_id(xdgtoplevel, appId.constData()); } void XdgTopLevelStable::Private::showWindowMenu(Seat *seat, quint32 serial, qint32 x, qint32 y) { xdg_toplevel_show_window_menu(xdgtoplevel, *seat, serial, x, y); } void XdgTopLevelStable::Private::move(Seat *seat, quint32 serial) { xdg_toplevel_move(xdgtoplevel, *seat, serial); } void XdgTopLevelStable::Private::resize(Seat *seat, quint32 serial, Qt::Edges edges) { uint wlEdge = XDG_TOPLEVEL_RESIZE_EDGE_NONE; if (edges.testFlag(Qt::TopEdge)) { if (edges.testFlag(Qt::LeftEdge) && ((edges & ~Qt::LeftEdge) == Qt::TopEdge)) { wlEdge = XDG_TOPLEVEL_RESIZE_EDGE_TOP_LEFT; } else if (edges.testFlag(Qt::RightEdge) && ((edges & ~Qt::RightEdge) == Qt::TopEdge)) { wlEdge = XDG_TOPLEVEL_RESIZE_EDGE_TOP_RIGHT; } else if ((edges & ~Qt::TopEdge) == Qt::Edges()) { wlEdge = XDG_TOPLEVEL_RESIZE_EDGE_TOP; } } else if (edges.testFlag(Qt::BottomEdge)) { if (edges.testFlag(Qt::LeftEdge) && ((edges & ~Qt::LeftEdge) == Qt::BottomEdge)) { wlEdge = XDG_TOPLEVEL_RESIZE_EDGE_BOTTOM_LEFT; } else if (edges.testFlag(Qt::RightEdge) && ((edges & ~Qt::RightEdge) == Qt::BottomEdge)) { wlEdge = XDG_TOPLEVEL_RESIZE_EDGE_BOTTOM_RIGHT; } else if ((edges & ~Qt::BottomEdge) == Qt::Edges()) { wlEdge = XDG_TOPLEVEL_RESIZE_EDGE_BOTTOM; } } else if (edges.testFlag(Qt::RightEdge) && ((edges & ~Qt::RightEdge) == Qt::Edges())) { wlEdge = XDG_TOPLEVEL_RESIZE_EDGE_RIGHT; } else if (edges.testFlag(Qt::LeftEdge) && ((edges & ~Qt::LeftEdge) == Qt::Edges())) { wlEdge = XDG_TOPLEVEL_RESIZE_EDGE_LEFT; } xdg_toplevel_resize(xdgtoplevel, *seat, serial, wlEdge); } void XdgTopLevelStable::Private::ackConfigure(quint32 serial) { xdg_surface_ack_configure(xdgsurface, serial); } void XdgTopLevelStable::Private::setMaximized() { xdg_toplevel_set_maximized(xdgtoplevel); } void XdgTopLevelStable::Private::unsetMaximized() { xdg_toplevel_unset_maximized(xdgtoplevel); } void XdgTopLevelStable::Private::setFullscreen(Output *output) { wl_output *o = nullptr; if (output) { o = *output; } xdg_toplevel_set_fullscreen(xdgtoplevel, o); } void XdgTopLevelStable::Private::unsetFullscreen() { xdg_toplevel_unset_fullscreen(xdgtoplevel); } void XdgTopLevelStable::Private::setMinimized() { xdg_toplevel_set_minimized(xdgtoplevel); } void XdgTopLevelStable::Private::setMaxSize(const QSize &size) { xdg_toplevel_set_max_size(xdgtoplevel, size.width(), size.height()); } void XdgTopLevelStable::Private::setMinSize(const QSize &size) { xdg_toplevel_set_min_size(xdgtoplevel, size.width(), size.height()); } +void XdgTopLevelStable::Private::setWindowGeometry(const QRect &windowGeometry) +{ + xdg_surface_set_window_geometry(xdgsurface, windowGeometry.x(), windowGeometry.y(), windowGeometry.width(), windowGeometry.height()); +} + XdgTopLevelStable::XdgTopLevelStable(QObject *parent) : XdgShellSurface(new Private(this), parent) { } XdgTopLevelStable::~XdgTopLevelStable() = default; class XdgShellPopupStable::Private : public XdgShellPopup::Private { public: Private(XdgShellPopup *q); void setup(xdg_surface *s, xdg_popup *p) override; void release() override; void destroy() override; bool isValid() const override; void requestGrab(Seat *seat, quint32 serial) override; void ackConfigure(quint32 serial) override; + void setWindowGeometry(const QRect &windowGeometry) override; using XdgShellPopup::Private::operator zxdg_popup_v6*; using XdgShellPopup::Private::operator zxdg_surface_v6*; operator xdg_surface*() override { return xdgsurface; } operator xdg_surface*() const override { return xdgsurface; } operator xdg_popup*() override { return xdgpopup; } operator xdg_popup*() const override { return xdgpopup; } WaylandPointer xdgsurface; WaylandPointer xdgpopup; QRect pendingRect; private: static void configureCallback(void *data, xdg_popup *xdg_popup, int32_t x, int32_t y, int32_t width, int32_t height); static void popupDoneCallback(void *data, xdg_popup *xdg_popup); static void surfaceConfigureCallback(void *data, xdg_surface *xdg_surface, uint32_t serial); static const struct xdg_popup_listener s_popupListener; static const struct xdg_surface_listener s_surfaceListener; }; const struct xdg_popup_listener XdgShellPopupStable::Private::s_popupListener = { configureCallback, popupDoneCallback }; const struct xdg_surface_listener XdgShellPopupStable::Private::s_surfaceListener = { surfaceConfigureCallback, }; void XdgShellPopupStable::Private::configureCallback(void *data, xdg_popup *xdg_popup, int32_t x, int32_t y, int32_t width, int32_t height) { Q_UNUSED(xdg_popup) auto s = static_cast(data); s->pendingRect = QRect(x, y, width, height); } void XdgShellPopupStable::Private::surfaceConfigureCallback(void *data, struct xdg_surface *surface, uint32_t serial) { Q_UNUSED(surface) auto s = static_cast(data); s->q->configureRequested(s->pendingRect, serial); s->pendingRect = QRect(); } void XdgShellPopupStable::Private::popupDoneCallback(void *data, xdg_popup *xdg_popup) { auto s = static_cast(data); Q_ASSERT(s->xdgpopup == xdg_popup); emit s->q->popupDone(); } XdgShellPopupStable::Private::Private(XdgShellPopup *q) : XdgShellPopup::Private(q) { } void XdgShellPopupStable::Private::setup(xdg_surface *s, xdg_popup *p) { Q_ASSERT(p); Q_ASSERT(!xdgsurface); Q_ASSERT(!xdgpopup); xdgsurface.setup(s); xdgpopup.setup(p); xdg_surface_add_listener(xdgsurface, &s_surfaceListener, this); xdg_popup_add_listener(xdgpopup, &s_popupListener, this); } void XdgShellPopupStable::Private::release() { xdgpopup.release(); } void XdgShellPopupStable::Private::destroy() { xdgpopup.destroy(); } bool XdgShellPopupStable::Private::isValid() const { return xdgpopup.isValid(); } void XdgShellPopupStable::Private::requestGrab(Seat *seat, quint32 serial) { xdg_popup_grab(xdgpopup, *seat, serial); } void XdgShellPopupStable::Private::ackConfigure(quint32 serial) { xdg_surface_ack_configure(xdgsurface, serial); } +void XdgShellPopupStable::Private::setWindowGeometry(const QRect &windowGeometry) +{ + xdg_surface_set_window_geometry(xdgsurface, windowGeometry.x(), windowGeometry.y(), windowGeometry.width(), windowGeometry.height()); +} + XdgShellPopupStable::XdgShellPopupStable(QObject *parent) : XdgShellPopup(new Private(this), parent) { } XdgShellPopupStable::~XdgShellPopupStable() = default; } } diff --git a/src/server/xdgshell_interface.cpp b/src/server/xdgshell_interface.cpp index 134ce20..ac09118 100644 --- a/src/server/xdgshell_interface.cpp +++ b/src/server/xdgshell_interface.cpp @@ -1,273 +1,285 @@ /**************************************************************************** Copyright 2016 Martin Gräßlin This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) version 3, or any later version accepted by the membership of KDE e.V. (or its successor approved by the membership of KDE e.V.), which shall act as a proxy defined in Section 6 of version 3 of the license. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library. If not, see . ****************************************************************************/ #include "xdgshell_interface_p.h" namespace KWayland { namespace Server { XdgShellInterface::Private::Private(XdgShellInterfaceVersion interfaceVersion, XdgShellInterface *q, Display *d, const wl_interface *interface, quint32 version) : Global::Private(d, interface, version) , interfaceVersion(interfaceVersion) , q(q) { } void XdgShellInterface::Private::setupTimer(quint32 serial) { QTimer *pingTimer = new QTimer(); pingTimer->setSingleShot(false); pingTimer->setInterval(1000); int attempt = 0; connect(pingTimer, &QTimer::timeout, q, [this, serial, attempt]() mutable { ++attempt; if (attempt == 1) { emit q->pingDelayed(serial); } else { emit q->pingTimeout(serial); auto timerIt = pingTimers.find(serial); if (timerIt != pingTimers.end()) { delete timerIt.value(); pingTimers.erase(timerIt); } } }); pingTimers.insert(serial, pingTimer); pingTimer->start(); } XdgShellInterface::XdgShellInterface(Private *d, QObject *parent) : Global(d, parent) { } XdgShellInterface::~XdgShellInterface() = default; XdgShellSurfaceInterface *XdgShellInterface::getSurface(wl_resource *native) { Q_UNUSED(native) return nullptr; } XdgShellInterfaceVersion XdgShellInterface::interfaceVersion() const { Q_D(); return d->interfaceVersion; } quint32 XdgShellInterface::ping(XdgShellSurfaceInterface * surface) { return d_func()->ping(surface); } XdgShellInterface::Private *XdgShellInterface::d_func() const { return reinterpret_cast(d.data()); } XdgShellSurfaceInterface::Private::Private(XdgShellInterfaceVersion interfaceVersion, XdgShellSurfaceInterface *q, Global *c, SurfaceInterface *surface, wl_resource *parentResource, const wl_interface *interface, const void *implementation) : Resource::Private(q, c, parentResource, interface, implementation) , GenericShellSurface(q, surface) , interfaceVersion(interfaceVersion) { } XdgShellSurfaceInterface::Private::~Private() = default; XdgShellSurfaceInterface::XdgShellSurfaceInterface(Private *p) : Resource(p) { } XdgShellSurfaceInterface::~XdgShellSurfaceInterface() = default; XdgShellInterfaceVersion XdgShellSurfaceInterface::interfaceVersion() const { Q_D(); return d->interfaceVersion; } quint32 XdgShellSurfaceInterface::configure(States states, const QSize &size) { Q_D(); return d->configure(states, size); } bool XdgShellSurfaceInterface::isConfigurePending() const { Q_D(); return !d->configureSerials.isEmpty(); } SurfaceInterface *XdgShellSurfaceInterface::surface() const { Q_D(); return d->surface; } QString XdgShellSurfaceInterface::title() const { Q_D(); return d->title; } QByteArray XdgShellSurfaceInterface::windowClass() const { Q_D(); return d->windowClass; } bool XdgShellSurfaceInterface::isTransient() const { Q_D(); return !d->parent.isNull(); } QPointer XdgShellSurfaceInterface::transientFor() const { Q_D(); return d->parent; } void XdgShellSurfaceInterface::close() { Q_D(); d->close(); } +QRect XdgShellSurfaceInterface::windowGeometry() const +{ + Q_D(); + return d->windowGeometry; +} + XdgShellSurfaceInterface::Private *XdgShellSurfaceInterface::d_func() const { return reinterpret_cast(d.data()); } XdgShellPopupInterface::Private::Private(XdgShellInterfaceVersion interfaceVersion, XdgShellPopupInterface *q, XdgShellInterface *c, SurfaceInterface *surface, wl_resource *parentResource, const wl_interface *interface, const void *implementation) : Resource::Private(q, c, parentResource, interface, implementation) , GenericShellSurface(q, surface) , interfaceVersion(interfaceVersion) { } XdgShellPopupInterface::Private::~Private() = default; XdgShellPopupInterface::XdgShellPopupInterface(Private *p) : Resource(p) { } XdgShellPopupInterface::~XdgShellPopupInterface() = default; SurfaceInterface *XdgShellPopupInterface::surface() const { Q_D(); return d->surface; } QPointer XdgShellPopupInterface::transientFor() const { Q_D(); return d->parent; } QSize XdgShellPopupInterface::initialSize() const { Q_D(); return d->initialSize; } QPoint XdgShellPopupInterface::transientOffset() const { QRect rect = anchorRect(); const QPoint center = rect.isEmpty() ? rect.topLeft() : rect.center(); rect = rect.adjusted(0,0,1,1); //compensate for the stupid QRect::right +1 fiasco switch(anchorEdge()) { case Qt::TopEdge | Qt::LeftEdge: return rect.topLeft(); case Qt::TopEdge: return QPoint(center.x(), rect.y()); case Qt::TopEdge | Qt::RightEdge: return rect.topRight(); case Qt::RightEdge: return QPoint(rect.right(), center.y()); case Qt::BottomEdge | Qt::RightEdge: return rect.bottomRight(); case Qt::BottomEdge: return QPoint(center.x(), rect.bottom()); case Qt::BottomEdge | Qt::LeftEdge: return rect.bottomLeft(); case Qt::LeftEdge: return QPoint(rect.left(), center.y()); default: return center; } Q_UNREACHABLE(); } QRect XdgShellPopupInterface::anchorRect() const { Q_D(); return d->anchorRect; } Qt::Edges XdgShellPopupInterface::anchorEdge() const { Q_D(); return d->anchorEdge; } Qt::Edges XdgShellPopupInterface::gravity() const { Q_D(); return d->gravity; } QPoint XdgShellPopupInterface::anchorOffset() const { Q_D(); return d->anchorOffset; } PositionerConstraints XdgShellPopupInterface::constraintAdjustments() const { Q_D(); return d->constraintAdjustments; } +QRect XdgShellPopupInterface::windowGeometry() const +{ + Q_D(); + return d->windowGeometry; +} + void XdgShellPopupInterface::popupDone() { Q_D(); return d->popupDone(); } quint32 XdgShellPopupInterface::configure(const QRect &rect) { Q_D(); return d->configure(rect); } XdgShellPopupInterface::Private *XdgShellPopupInterface::d_func() const { return reinterpret_cast(d.data()); } } } diff --git a/src/server/xdgshell_interface.h b/src/server/xdgshell_interface.h index 2ba719e..6e59469 100644 --- a/src/server/xdgshell_interface.h +++ b/src/server/xdgshell_interface.h @@ -1,484 +1,514 @@ /**************************************************************************** Copyright 2016 Martin Gräßlin This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) version 3, or any later version accepted by the membership of KDE e.V. (or its successor approved by the membership of KDE e.V.), which shall act as a proxy defined in Section 6 of version 3 of the license. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library. If not, see . ****************************************************************************/ #ifndef KWAYLAND_SERVER_XDGSHELL_INTERFACE_H #define KWAYLAND_SERVER_XDGSHELL_INTERFACE_H #include "global.h" #include "resource.h" #include #include namespace KWayland { namespace Server { class OutputInterface; class SeatInterface; class SurfaceInterface; class XdgShellPopupInterface; class XdgShellSurfaceInterface; template class GenericShellSurface; /** * Enum describing the different InterfaceVersion encapsulated in this implementation. * * @since 5.25 **/ enum class XdgShellInterfaceVersion { /** * xdg_shell (unstable v5) **/ UnstableV5, /** * zxdg_shell_v6 (unstable v6) * @since 5.39 **/ UnstableV6, /** xdg_wm_base (stable) @since 5.48 */ Stable }; /** * Flags describing how a popup should be reposition if constrained * @since 5.39 */ enum class PositionerConstraint { /** * Slide the popup on the X axis until there is room */ SlideX = 1 << 0, /** * Slide the popup on the Y axis until there is room */ SlideY = 1 << 1, /** * Invert the anchor and gravity on the X axis */ FlipX = 1 << 2, /** * Invert the anchor and gravity on the Y axis */ FlipY = 1 << 3, /** * Resize the popup in the X axis */ ResizeX = 1 << 4, /** * Resize the popup in the Y axis */ ResizeY = 1 << 5 }; Q_DECLARE_FLAGS(PositionerConstraints, PositionerConstraint) /** * * @since 5.25 **/ class KWAYLANDSERVER_EXPORT XdgShellInterface : public Global { Q_OBJECT public: virtual ~XdgShellInterface(); /** * @returns The interface version used by this XdgShellInterface **/ XdgShellInterfaceVersion interfaceVersion() const; /** * @returns The XdgShellSurfaceInterface for the @p native resource. **/ //TODO KF6 make virtual XdgShellSurfaceInterface *getSurface(wl_resource *native); /** * Confirm the client is still alive and responding * * Will result in pong being emitted * * @returns unique identifier for this request * @since 5.39 */ quint32 ping(XdgShellSurfaceInterface * surface); Q_SIGNALS: void surfaceCreated(KWayland::Server::XdgShellSurfaceInterface *surface); /** * Emitted whenever a new popup got created. * * A popup only gets created in response to an action on the @p seat. * * * @param surface The popup xdg shell surface which got created * @param seat The seat on which an action triggered the popup * @param serial The serial of the action on the seat * * XDGV5 only * Use both xdgPopupCreated and XdgShellPopupInterface::grabbed to cover both XDGV5 and XDGV6 **/ void popupCreated(KWayland::Server::XdgShellPopupInterface *surface, KWayland::Server::SeatInterface *seat, quint32 serial); /* * Emitted whenever a new popup gets created. * * @param surface The popup xdg shell surface which got created * @since 5.39 */ void xdgPopupCreated(KWayland::Server::XdgShellPopupInterface *surface); /* * Emitted in response to a ping request * * @param serial unique identifier for the request * @since 5.39 */ void pongReceived(quint32 serial); /* * Emitted when the application takes more than expected * to answer to a ping, this will always be emitted before * eventuallt pingTimeout gets emitted * * @param serial unique identifier for the request * @since 5.39 */ void pingDelayed(quint32 serial); /* * Emitted when the application doesn't answer to a ping * and the serve gave up on it * * @param serial unique identifier for the request * @since 5.39 */ void pingTimeout(quint32 serial); protected: class Private; explicit XdgShellInterface(Private *d, QObject *parent = nullptr); private: Private *d_func() const; }; /** * * @since 5.25 **/ class KWAYLANDSERVER_EXPORT XdgShellSurfaceInterface : public Resource { Q_OBJECT public: virtual ~XdgShellSurfaceInterface(); /** * @returns The interface version used by this XdgShellSurfaceInterface **/ XdgShellInterfaceVersion interfaceVersion() const; /** * States the Surface can be in **/ enum class State { /** * The Surface is maximized. **/ Maximized = 1 << 0, /** * The Surface is fullscreen. **/ Fullscreen = 1 << 1, /** * The Surface is currently being resized by the Compositor. **/ Resizing = 1 << 2, /** * The Surface is considered active. Does not imply keyboard focus. **/ Activated = 1 << 3 }; Q_DECLARE_FLAGS(States, State) /** * Sends a configure event to the Surface. * This tells the Surface the current @p states it is in and the @p size it should have. * If @p size has width and height at @c 0, the Surface can choose the size. * * The Surface acknowledges the configure event with {@link configureAcknowledged}. * * @param states The states the surface is in * @param size The requested size * @returns The serial of the configure event * @see configureAcknowledged * @see isConfigurePending **/ quint32 configure(States states, const QSize &size = QSize(0, 0)); /** * @returns @c true if there is a not yet acknowledged configure event. * @see configure * @see configureAcknowledged **/ bool isConfigurePending() const; /** * @return The SurfaceInterface this XdgSurfaceV5Interface got created for. **/ SurfaceInterface *surface() const; /** * @returns The title of this surface. * @see titleChanged **/ QString title() const; QByteArray windowClass() const; /** * @returns Whether this Surface is a transient for another Surface, that is it has a parent. * @see transientFor **/ bool isTransient() const; /** * @returns the parent surface if the surface is a transient for another surface * @see isTransient **/ QPointer transientFor() const; /** * Request the client to close the window. **/ void close(); + /** + * @brief windowGeometry + * The geometry of the window within the buffer + * + * If invalid, the geometry of the bufer should be used instead + * @since 5.59 + */ + QRect windowGeometry() const; + Q_SIGNALS: /** * Emitted whenever the title changes. * * @see title **/ void titleChanged(const QString&); /** * Emitted whenever the window class changes. * * @see windowClass **/ void windowClassChanged(const QByteArray&); /** * The surface requested a window move. * * @param seat The SeatInterface on which the surface requested the move * @param serial The serial of the implicit mouse grab which triggered the move **/ void moveRequested(KWayland::Server::SeatInterface *seat, quint32 serial); /** * The surface requested a window resize. * * @param seat The SeatInterface on which the surface requested the resize * @param serial The serial of the implicit mouse grab which triggered the resize * @param edges A hint which edges are involved in the resize **/ void resizeRequested(KWayland::Server::SeatInterface *seat, quint32 serial, Qt::Edges edges); void windowMenuRequested(KWayland::Server::SeatInterface *seat, quint32 serial, const QPoint &surfacePos); /** * The surface requested a change of maximized state. * @param maximized Whether the window wants to be maximized **/ void maximizedChanged(bool maximized); /** * The surface requested a change of fullscreen state * @param fullscreen Whether the window wants to be fullscreen * @param output An optional output hint on which the window wants to be fullscreen **/ void fullscreenChanged(bool fullscreen, KWayland::Server::OutputInterface *output); /** * The surface requested to be minimized. **/ void minimizeRequested(); /** * A configure event with @p serial got acknowledged. * @see configure **/ void configureAcknowledged(quint32 serial); /** * Emitted whenever the parent surface changes. * @see isTransient * @see transientFor **/ void transientForChanged(); /** * Emitted whenever the maximum size hint changes * @since 5.39 */ void maxSizeChanged(const QSize &size); /** * Emitted whenever the minimum size hint changes * @since 5.39 */ void minSizeChanged(const QSize &size); + /** + * @brief windowGeometryChanged + * @param windowGeometry the newly changed windowGeometry + * @since 5.59 + */ + void windowGeometryChanged(const QRect &windowGeometry); + protected: class Private; explicit XdgShellSurfaceInterface(Private *p); private: Private *d_func() const; friend class GenericShellSurface; }; /** * * @since 5.25 **/ class KWAYLANDSERVER_EXPORT XdgShellPopupInterface : public Resource { Q_OBJECT public: virtual ~XdgShellPopupInterface(); /** * @return The SurfaceInterface this XdgShellPopupInterface got created for. **/ SurfaceInterface *surface() const; /* * Ask the popup surface to configure itself for the given configuration. * * @arg rect. The position of the surface relative to the transient parent * @since 5.39 */ quint32 configure(const QRect &rect); /** * @returns the parent surface. * @see transientOffset **/ QPointer transientFor() const; /** * The offset of the Surface in the coordinate system of the SurfaceInterface this surface is a transient for. * * For XDG V6 this returns the point on the anchorRect defined by the anchor edge. * * @returns offset in parent coordinate system. * @see transientFor **/ QPoint transientOffset() const; /** * The size of the surface that is to be positioned. * * @since 5.39 */ QSize initialSize() const; /** * The area this popup should be positioned around * @since 5.39 */ QRect anchorRect() const; /** * Which edge of the anchor should the popup be positioned around * @since 5.39 */ Qt::Edges anchorEdge() const; /** * An additional offset that should be applied to the popup from the anchor rect * * @since 5.39 */ QPoint anchorOffset() const; /** * Specifies in what direction the popup should be positioned around the anchor * i.e if the gravity is "bottom", then then the top of top of the popup will be at the anchor edge * if the gravity is top, then the bottom of the popup will be at the anchor edge * * @since 5.39 */ //DAVE left + right is illegal, so this is possible a useless return value? Maybe an enum with 9 entries left, topleft, top, .. Qt::Edges gravity() const; /** * Specifies how the compositor should position the popup if it does not fit in the requested position * @since 5.39 */ PositionerConstraints constraintAdjustments() const; /** * Dismiss this popup. This indicates to the client that it should destroy this popup. * The Compositor can invoke this method when e.g. the user clicked outside the popup * to dismiss it. **/ void popupDone(); + /** + * @brief windowGeometryChanged + * @param windowGeometry the newly changed geometry of the window contents within the buffer + * @since 5.59 + */ + QRect windowGeometry()const; + Q_SIGNALS: /** * A configure event with @p serial got acknowledged. * Note: XdgV6 only * @see configure * @since 5.39 **/ void configureAcknowledged(quint32 serial); /** * The client requested that this popup takes an explicit grab * * @param seat The seat on which an action triggered the popup * @param serial The serial of the action on the seat * @since 5.39 */ void grabRequested(KWayland::Server::SeatInterface *seat, quint32 serial); + /** + * @brief windowGeometryChanged + * @param windowGeometry the newly changed windowGeometry + * @since 5.59 + */ + void windowGeometryChanged(const QRect &windowGeometry); + protected: class Private; explicit XdgShellPopupInterface(Private *p); private: friend class GenericShellSurface; Private *d_func() const; }; } } Q_DECLARE_METATYPE(KWayland::Server::XdgShellSurfaceInterface *) Q_DECLARE_METATYPE(KWayland::Server::XdgShellPopupInterface *) Q_DECLARE_METATYPE(KWayland::Server::XdgShellSurfaceInterface::State) Q_DECLARE_METATYPE(KWayland::Server::XdgShellSurfaceInterface::States) Q_DECLARE_OPERATORS_FOR_FLAGS(KWayland::Server::PositionerConstraints) #endif diff --git a/src/server/xdgshell_interface_p.h b/src/server/xdgshell_interface_p.h index 43c5881..1f9dc17 100644 --- a/src/server/xdgshell_interface_p.h +++ b/src/server/xdgshell_interface_p.h @@ -1,107 +1,109 @@ /**************************************************************************** Copyright 2016 Martin Gräßlin This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) version 3, or any later version accepted by the membership of KDE e.V. (or its successor approved by the membership of KDE e.V.), which shall act as a proxy defined in Section 6 of version 3 of the license. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library. If not, see . ****************************************************************************/ #ifndef KWAYLAND_SERVER_XDGSHELL_INTERFACE_P_H #define KWAYLAND_SERVER_XDGSHELL_INTERFACE_P_H #include "xdgshell_interface.h" #include "global_p.h" #include "generic_shell_surface_p.h" #include "resource_p.h" #include namespace KWayland { namespace Server { class XdgShellInterface::Private : public Global::Private { public: XdgShellInterfaceVersion interfaceVersion; virtual quint32 ping(XdgShellSurfaceInterface * surface) = 0; void setupTimer(quint32 serial); //pingserial/timer correspondence QHash pingTimers; protected: Private(XdgShellInterfaceVersion interfaceVersion, XdgShellInterface *q, Display *d, const wl_interface *interface, quint32 version); XdgShellInterface *q; }; class XdgShellSurfaceInterface::Private : public Resource::Private, public GenericShellSurface { public: virtual ~Private(); virtual void close() = 0; virtual quint32 configure(States states, const QSize &size) = 0; XdgShellSurfaceInterface *q_func() { return reinterpret_cast(q); } QVector configureSerials; QPointer parent; + QRect windowGeometry; XdgShellInterfaceVersion interfaceVersion; protected: Private(XdgShellInterfaceVersion interfaceVersion, XdgShellSurfaceInterface *q, Global *c, SurfaceInterface *surface, wl_resource *parentResource, const wl_interface *interface, const void *implementation); }; class XdgShellPopupInterface::Private : public Resource::Private, public GenericShellSurface { public: virtual ~Private(); virtual void popupDone() = 0; XdgShellPopupInterface *q_func() { return reinterpret_cast(q); } virtual quint32 configure(const QRect &rect) { Q_UNUSED(rect) return 0; }; QVector configureSerials; QPointer parent; QSize initialSize; /* * */ QRect anchorRect; Qt::Edges anchorEdge; Qt::Edges gravity; PositionerConstraints constraintAdjustments; QPoint anchorOffset; + QRect windowGeometry; XdgShellInterfaceVersion interfaceVersion; protected: Private(XdgShellInterfaceVersion interfaceVersion, XdgShellPopupInterface *q, XdgShellInterface *c, SurfaceInterface *surface, wl_resource *parentResource, const wl_interface *interface, const void *implementation); }; } } #endif diff --git a/src/server/xdgshell_stable_interface.cpp b/src/server/xdgshell_stable_interface.cpp index c41517b..75427f8 100644 --- a/src/server/xdgshell_stable_interface.cpp +++ b/src/server/xdgshell_stable_interface.cpp @@ -1,980 +1,985 @@ /**************************************************************************** Copyright 2017 David Edmundson This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) version 3, or any later version accepted by the membership of KDE e.V. (or its successor approved by the membership of KDE e.V.), which shall act as a proxy defined in Section 6 of version 3 of the license. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library. If not, see . ****************************************************************************/ #include "xdgshell_stable_interface_p.h" #include "xdgshell_interface_p.h" #include "generic_shell_surface_p.h" #include "display.h" #include "global_p.h" #include "global.h" #include "resource_p.h" #include "output_interface.h" #include "seat_interface.h" #include "surface_interface.h" #include namespace KWayland { namespace Server { class XdgShellStableInterface::Private : public XdgShellInterface::Private { public: Private(XdgShellStableInterface *q, Display *d); QVector surfaces; QVector positioners; private: void createSurface(wl_client *client, uint32_t version, uint32_t id, SurfaceInterface *surface, wl_resource *parentResource); void createPositioner(wl_client *client, uint32_t version, uint32_t id, wl_resource *parentResource); void bind(wl_client *client, uint32_t version, uint32_t id) override; quint32 ping(XdgShellSurfaceInterface * surface) override; static void unbind(wl_resource *resource); static Private *cast(wl_resource *r) { return static_cast(wl_resource_get_user_data(r)); } static void destroyCallback(wl_client *client, wl_resource *resource); static void createPositionerCallback(wl_client *client, wl_resource *resource, uint32_t id); static void getXdgSurfaceCallback(wl_client *client, wl_resource *resource, uint32_t id, wl_resource * surface); static void pongCallback(wl_client *client, wl_resource *resource, uint32_t serial); XdgShellStableInterface *q; static const struct xdg_wm_base_interface s_interface; static const quint32 s_version; QHash resources; }; class XdgPopupStableInterface::Private : public XdgShellPopupInterface::Private { public: Private(XdgPopupStableInterface *q, XdgShellStableInterface *c, SurfaceInterface *surface, wl_resource *parentResource); ~Private() override; void ackConfigure(quint32 serial) { if (!configureSerials.contains(serial)) { return; } while (!configureSerials.isEmpty()) { quint32 i = configureSerials.takeFirst(); emit q_func()->configureAcknowledged(i); if (i == serial) { break; } } } void popupDone() override; quint32 configure(const QRect &rect) override; XdgPopupStableInterface *q_func() { return static_cast(q); } private: static void grabCallback(wl_client *client, wl_resource *resource, wl_resource *seat, uint32_t serial); static const struct xdg_popup_interface s_interface; }; class XdgSurfaceStableInterface::Private : public KWayland::Server::Resource::Private { public: Private(XdgSurfaceStableInterface* q, XdgShellStableInterface* c, SurfaceInterface* surface, wl_resource* parentResource); ~Private() override; XdgSurfaceStableInterface *q_func() { return static_cast(q); } void createTopLevel(wl_client *client, uint32_t version, uint32_t id, wl_resource *parentResource); void createPopup(wl_client *client, uint32_t version, uint32_t id, wl_resource *parentResource, wl_resource *parentWindow, wl_resource *positioner); XdgShellStableInterface *m_shell; SurfaceInterface *m_surface; //effectively a union, only one of these should be populated. //a surface cannot have two roles QPointer m_topLevel; QPointer m_popup; private: static void destroyCallback(wl_client *client, wl_resource *resource); static void getTopLevelCallback(wl_client *client, wl_resource *resource, uint32_t id); static void getPopupCallback(wl_client *client, wl_resource *resource, uint32_t id, wl_resource *parent, wl_resource *positioner); static void ackConfigureCallback(wl_client *client, wl_resource *resource, uint32_t serial); static void setWindowGeometryCallback(wl_client *client, wl_resource *resource, int32_t x, int32_t y, int32_t width, int32_t height); static const struct xdg_surface_interface s_interface; }; class XdgTopLevelStableInterface::Private : public XdgShellSurfaceInterface::Private { public: Private(XdgTopLevelStableInterface* q, XdgShellStableInterface* c, SurfaceInterface* surface, wl_resource* parentResource); ~Private() override; void close() override; void ackConfigure(quint32 serial) { if (!configureSerials.contains(serial)) { return; } while (!configureSerials.isEmpty()) { quint32 i = configureSerials.takeFirst(); emit q_func()->configureAcknowledged(i); if (i == serial) { break; } } } quint32 configure(States states, const QSize &size) override { if (!resource) { return 0; } const quint32 serial = global->display()->nextSerial(); wl_array configureStates; wl_array_init(&configureStates); if (states.testFlag(State::Maximized)) { uint32_t *s = static_cast(wl_array_add(&configureStates, sizeof(uint32_t))); *s = XDG_TOPLEVEL_STATE_MAXIMIZED; } if (states.testFlag(State::Fullscreen)) { uint32_t *s = static_cast(wl_array_add(&configureStates, sizeof(uint32_t))); *s = XDG_TOPLEVEL_STATE_FULLSCREEN; } if (states.testFlag(State::Resizing)) { uint32_t *s = static_cast(wl_array_add(&configureStates, sizeof(uint32_t))); *s = XDG_TOPLEVEL_STATE_RESIZING; } if (states.testFlag(State::Activated)) { uint32_t *s = static_cast(wl_array_add(&configureStates, sizeof(uint32_t))); *s = XDG_TOPLEVEL_STATE_ACTIVATED; } configureSerials << serial; xdg_toplevel_send_configure(resource, size.width(), size.height(), &configureStates); xdg_surface_send_configure(parentResource, serial); client->flush(); wl_array_release(&configureStates); return serial; }; XdgTopLevelStableInterface *q_func() { return static_cast(q); } private: static void destroyCallback(wl_client *client, wl_resource *resource); static void setParentCallback(struct wl_client *client, struct wl_resource *resource, wl_resource *parent); static void showWindowMenuCallback(wl_client *client, wl_resource *resource, wl_resource *seat, uint32_t serial, int32_t x, int32_t y); static void setMaxSizeCallback(wl_client *client, wl_resource *resource, int32_t width, int32_t height); static void setMinSizeCallback(wl_client *client, wl_resource *resource, int32_t width, int32_t height); static void setMaximizedCallback(wl_client *client, wl_resource *resource); static void unsetMaximizedCallback(wl_client *client, wl_resource *resource); static void setFullscreenCallback(wl_client *client, wl_resource *resource, wl_resource *output); static void unsetFullscreenCallback(wl_client *client, wl_resource *resource); static void setMinimizedCallback(wl_client *client, wl_resource *resource); static const struct xdg_toplevel_interface s_interface; }; const quint32 XdgShellStableInterface::Private::s_version = 1; #ifndef DOXYGEN_SHOULD_SKIP_THIS const struct xdg_wm_base_interface XdgShellStableInterface::Private::s_interface = { destroyCallback, createPositionerCallback, getXdgSurfaceCallback, pongCallback }; #endif void XdgShellStableInterface::Private::destroyCallback(wl_client *client, wl_resource *resource) { Q_UNUSED(client) auto s = cast(resource); if (!s->surfaces.isEmpty()) { wl_resource_post_error(resource, XDG_WM_BASE_ERROR_DEFUNCT_SURFACES, "WMBase destroyed before surfaces"); } wl_resource_destroy(resource); } void XdgShellStableInterface::Private::createPositionerCallback(wl_client *client, wl_resource *resource, uint32_t id) { auto s = cast(resource); s->createPositioner(client, wl_resource_get_version(resource), id, resource); } void XdgShellStableInterface::Private::getXdgSurfaceCallback(wl_client *client, wl_resource *resource, uint32_t id, wl_resource * surface) { auto s = cast(resource); s->createSurface(client, wl_resource_get_version(resource), id, SurfaceInterface::get(surface), resource); } void XdgShellStableInterface::Private::createSurface(wl_client *client, uint32_t version, uint32_t id, SurfaceInterface *surface, wl_resource *parentResource) { auto it = std::find_if(surfaces.constBegin(), surfaces.constEnd(), [surface](XdgSurfaceStableInterface *s) { return surface == s->surface(); } ); if (it != surfaces.constEnd()) { wl_resource_post_error(surface->resource(), XDG_WM_BASE_ERROR_ROLE, "XDG Surface already created"); return; } XdgSurfaceStableInterface *shellSurface = new XdgSurfaceStableInterface(q, surface, parentResource); surfaces << shellSurface; QObject::connect(shellSurface, &XdgSurfaceStableInterface::destroyed, q, [this, shellSurface] { surfaces.removeAll(shellSurface); } ); shellSurface->d->create(display->getConnection(client), version, id); } void XdgShellStableInterface::Private::createPositioner(wl_client *client, uint32_t version, uint32_t id, wl_resource *parentResource) { Q_UNUSED(client) XdgPositionerStableInterface *positioner = new XdgPositionerStableInterface(q, parentResource); positioners << positioner; QObject::connect(positioner, &Resource::destroyed, q, [this, positioner] { positioners.removeAll(positioner); } ); positioner->d->create(display->getConnection(client), version, id); } void XdgShellStableInterface::Private::pongCallback(wl_client *client, wl_resource *resource, uint32_t serial) { Q_UNUSED(client) auto s = cast(resource); auto timerIt = s->pingTimers.find(serial); if (timerIt != s->pingTimers.end() && timerIt.value()->isActive()) { delete timerIt.value(); s->pingTimers.erase(timerIt); emit s->q->pongReceived(serial); } } XdgShellStableInterface::Private::Private(XdgShellStableInterface *q, Display *d) : XdgShellInterface::Private(XdgShellInterfaceVersion::Stable, q, d, &xdg_wm_base_interface, 1) , q(q) { } void XdgShellStableInterface::Private::bind(wl_client *client, uint32_t version, uint32_t id) { auto c = display->getConnection(client); auto resource = c->createResource(&xdg_wm_base_interface, qMin(version, s_version), id); if (!resource) { wl_client_post_no_memory(client); return; } resources[client] = resource; wl_resource_set_implementation(resource, &s_interface, this, unbind); } void XdgShellStableInterface::Private::unbind(wl_resource *resource) { auto s = cast(resource); auto client = wl_resource_get_client(resource); s->resources.remove(client); } XdgTopLevelStableInterface *XdgShellStableInterface::getSurface(wl_resource *resource) { if (!resource) { return nullptr; } Q_D(); for (auto it = d->surfaces.constBegin(); it != d->surfaces.constEnd() ; it++) { auto topLevel = (*it)->topLevel(); if (topLevel && topLevel->resource() == resource) { return topLevel; } } return nullptr; } XdgSurfaceStableInterface *XdgShellStableInterface::realGetSurface(wl_resource *resource) { if (!resource) { return nullptr; } Q_D(); for (auto it = d->surfaces.constBegin(); it != d->surfaces.constEnd() ; it++) { if ((*it)->resource() == resource) { return (*it); } } return nullptr; } XdgPositionerStableInterface *XdgShellStableInterface::getPositioner(wl_resource *resource) { if (!resource) { return nullptr; } Q_D(); for (auto it = d->positioners.constBegin(); it != d->positioners.constEnd() ; it++) { if ((*it)->resource() == resource) { return *it; } } return nullptr; } quint32 XdgShellStableInterface::Private::ping(XdgShellSurfaceInterface *surface) { auto client = surface->client()->client(); //from here we can get the resource bound to our global. auto clientXdgShellResource = resources.value(client); if (!clientXdgShellResource) { return 0; } const quint32 pingSerial = display->nextSerial(); xdg_wm_base_send_ping(clientXdgShellResource, pingSerial); setupTimer(pingSerial); return pingSerial; } XdgShellStableInterface::Private *XdgShellStableInterface::d_func() const { return static_cast(d.data()); } namespace { template <> Qt::Edges edgesToQtEdges(xdg_toplevel_resize_edge edges) { Qt::Edges qtEdges; switch (edges) { case XDG_TOPLEVEL_RESIZE_EDGE_TOP: qtEdges = Qt::TopEdge; break; case XDG_TOPLEVEL_RESIZE_EDGE_BOTTOM: qtEdges = Qt::BottomEdge; break; case XDG_TOPLEVEL_RESIZE_EDGE_LEFT: qtEdges = Qt::LeftEdge; break; case XDG_TOPLEVEL_RESIZE_EDGE_TOP_LEFT: qtEdges = Qt::TopEdge | Qt::LeftEdge; break; case XDG_TOPLEVEL_RESIZE_EDGE_BOTTOM_LEFT: qtEdges = Qt::BottomEdge | Qt::LeftEdge; break; case XDG_TOPLEVEL_RESIZE_EDGE_RIGHT: qtEdges = Qt::RightEdge; break; case XDG_TOPLEVEL_RESIZE_EDGE_TOP_RIGHT: qtEdges = Qt::TopEdge | Qt::RightEdge; break; case XDG_TOPLEVEL_RESIZE_EDGE_BOTTOM_RIGHT: qtEdges = Qt::BottomEdge | Qt::RightEdge; break; case XDG_TOPLEVEL_RESIZE_EDGE_NONE: break; default: Q_UNREACHABLE(); break; } return qtEdges; } } #ifndef DOXYGEN_SHOULD_SKIP_THIS const struct xdg_surface_interface XdgSurfaceStableInterface::Private::s_interface = { destroyCallback, getTopLevelCallback, getPopupCallback, setWindowGeometryCallback, ackConfigureCallback }; #endif void XdgSurfaceStableInterface::Private::destroyCallback(wl_client *client, wl_resource *resource) { Q_UNUSED(client) wl_resource_destroy(resource); } void XdgSurfaceStableInterface::Private::getTopLevelCallback(wl_client *client, wl_resource *resource, uint32_t id) { auto s = cast(resource); s->createTopLevel(client, wl_resource_get_version(resource), id, resource); } void XdgSurfaceStableInterface::Private::createTopLevel(wl_client *client, uint32_t version, uint32_t id, wl_resource *parentResource) { if (m_topLevel) { wl_resource_post_error(parentResource, XDG_SURFACE_ERROR_ALREADY_CONSTRUCTED, "Toplevel already created on this surface"); return; } if (m_popup) { wl_resource_post_error(parentResource, XDG_SURFACE_ERROR_ALREADY_CONSTRUCTED, "Popup already created on this surface"); return; } m_topLevel = new XdgTopLevelStableInterface (m_shell, m_surface, parentResource); m_topLevel->d->create(m_shell->display()->getConnection(client), version, id); emit m_shell->surfaceCreated(m_topLevel); } void XdgSurfaceStableInterface::Private::getPopupCallback(wl_client *client, wl_resource *resource, uint32_t id, wl_resource *parent, wl_resource *positioner) { auto s = cast(resource); s->createPopup(client, wl_resource_get_version(resource), id, resource, parent, positioner); } void XdgSurfaceStableInterface::Private::createPopup(wl_client *client, uint32_t version, uint32_t id, wl_resource *parentResource, wl_resource *parentSurface, wl_resource *positioner) { if (m_topLevel) { wl_resource_post_error(parentResource, XDG_SURFACE_ERROR_ALREADY_CONSTRUCTED, "Toplevel already created on this surface"); return; } if (m_popup) { wl_resource_post_error(parentResource, XDG_SURFACE_ERROR_ALREADY_CONSTRUCTED, "Popup already created on this surface"); return; } auto xdgPositioner = m_shell->getPositioner(positioner); if (!xdgPositioner) { wl_resource_post_error(parentResource, XDG_WM_BASE_ERROR_INVALID_POSITIONER, "Invalid positioner"); return; } m_popup = new XdgPopupStableInterface(m_shell, m_surface, parentResource); auto pd = m_popup->d_func(); pd->create(m_shell->display()->getConnection(client), version, id); auto parentXdgSurface = m_shell->realGetSurface(parentSurface); if (!parentXdgSurface) { wl_resource_post_error(parentResource, XDG_WM_BASE_ERROR_INVALID_POPUP_PARENT, "Invalid popup parent"); return; } pd->parent = parentXdgSurface->surface(); pd->initialSize = xdgPositioner->initialSize(); pd->anchorRect = xdgPositioner->anchorRect(); pd->anchorEdge = xdgPositioner->anchorEdge(); pd->gravity = xdgPositioner->gravity(); pd->constraintAdjustments = xdgPositioner->constraintAdjustments(); pd->anchorOffset = xdgPositioner->anchorOffset(); emit m_shell->xdgPopupCreated(m_popup.data()); } void XdgSurfaceStableInterface::Private::ackConfigureCallback(wl_client *client, wl_resource *resource, uint32_t serial) { auto s = cast(resource); Q_ASSERT(client == *s->client); if (s->m_topLevel) { s->m_topLevel->d_func()->ackConfigure(serial); } else if (s->m_popup) { s->m_popup->d_func()->ackConfigure(serial); } } void XdgSurfaceStableInterface::Private::setWindowGeometryCallback(wl_client *client, wl_resource *resource, int32_t x, int32_t y, int32_t width, int32_t height) { - // TODO: implement - not done for v5 either - Q_UNUSED(client) - Q_UNUSED(resource) - Q_UNUSED(x) - Q_UNUSED(y) - Q_UNUSED(width) - Q_UNUSED(height) + auto s = cast(resource); + Q_ASSERT(client == *s->client); + + const QRect windowRect(x, y, width, height); + + if (s->m_topLevel) { + s->m_topLevel->d_func()->windowGeometry = windowRect; + emit s->m_topLevel->windowGeometryChanged(windowRect); + } else if (s->m_popup) { + s->m_popup->d_func()->windowGeometry = windowRect; + emit s->m_popup->windowGeometryChanged(windowRect); + } } XdgSurfaceStableInterface::Private::Private(XdgSurfaceStableInterface *q, XdgShellStableInterface *c, SurfaceInterface *surface, wl_resource *parentResource) : KWayland::Server::Resource::Private(q, c, parentResource, &xdg_surface_interface, &s_interface), m_shell(c), m_surface(surface) { } XdgSurfaceStableInterface::Private::~Private() = default; class XdgPositionerStableInterface::Private : public KWayland::Server::Resource::Private { public: Private(XdgPositionerStableInterface *q, XdgShellStableInterface *c, wl_resource* parentResource); QSize initialSize; QRect anchorRect; Qt::Edges anchorEdge; Qt::Edges gravity; PositionerConstraints constraintAdjustments; QPoint anchorOffset; private: static void setSizeCallback(wl_client *client, wl_resource *resource, int32_t width, int32_t height); static void setAnchorRectCallback(wl_client *client, wl_resource *resource, int32_t x, int32_t y, int32_t width, int32_t height); static void setAnchorCallback(wl_client *client, wl_resource *resource, uint32_t anchor); static void setGravityCallback(wl_client *client, wl_resource *resource, uint32_t gravity); static void setConstraintAdjustmentCallback(wl_client *client, wl_resource *resource, uint32_t constraint_adjustment); static void setOffsetCallback(wl_client *client, wl_resource *resource, int32_t x, int32_t y); static const struct xdg_positioner_interface s_interface; }; XdgPositionerStableInterface::Private::Private(XdgPositionerStableInterface *q, XdgShellStableInterface *c, wl_resource *parentResource) : KWayland::Server::Resource::Private(q, c, parentResource, &xdg_positioner_interface, &s_interface) { } #ifndef DOXYGEN_SHOULD_SKIP_THIS const struct xdg_positioner_interface XdgPositionerStableInterface::Private::s_interface = { resourceDestroyedCallback, setSizeCallback, setAnchorRectCallback, setAnchorCallback, setGravityCallback, setConstraintAdjustmentCallback, setOffsetCallback }; #endif void XdgPositionerStableInterface::Private::setSizeCallback(wl_client *client, wl_resource *resource, int32_t width, int32_t height) { Q_UNUSED(client) auto s = cast(resource); s->initialSize = QSize(width, height); } void XdgPositionerStableInterface::Private::setAnchorRectCallback(wl_client *client, wl_resource *resource, int32_t x, int32_t y, int32_t width, int32_t height) { Q_UNUSED(client) auto s = cast(resource); s->anchorRect = QRect(x, y, width, height); } void XdgPositionerStableInterface::Private::setAnchorCallback(wl_client *client, wl_resource *resource, uint32_t anchor) { Q_UNUSED(client) auto s = cast(resource); Qt::Edges qtEdges; switch (anchor) { case XDG_POSITIONER_ANCHOR_TOP: qtEdges = Qt::TopEdge; break; case XDG_POSITIONER_ANCHOR_BOTTOM: qtEdges = Qt::BottomEdge; break; case XDG_POSITIONER_ANCHOR_LEFT: qtEdges = Qt::LeftEdge; break; case XDG_POSITIONER_ANCHOR_TOP_LEFT: qtEdges = Qt::TopEdge | Qt::LeftEdge; break; case XDG_POSITIONER_ANCHOR_BOTTOM_LEFT: qtEdges = Qt::BottomEdge | Qt::LeftEdge; break; case XDG_POSITIONER_ANCHOR_RIGHT: qtEdges = Qt::RightEdge; break; case XDG_POSITIONER_ANCHOR_TOP_RIGHT: qtEdges = Qt::TopEdge | Qt::RightEdge; break; case XDG_POSITIONER_ANCHOR_BOTTOM_RIGHT: qtEdges = Qt::BottomEdge | Qt::RightEdge; break; case XDG_POSITIONER_ANCHOR_NONE: break; default: Q_UNREACHABLE(); break; } s->anchorEdge = qtEdges; } void XdgPositionerStableInterface::Private::setGravityCallback(wl_client *client, wl_resource *resource, uint32_t gravity) { Q_UNUSED(client) auto s = cast(resource); Qt::Edges qtEdges; switch (gravity) { case XDG_POSITIONER_GRAVITY_TOP: qtEdges = Qt::TopEdge; break; case XDG_POSITIONER_GRAVITY_BOTTOM: qtEdges = Qt::BottomEdge; break; case XDG_POSITIONER_GRAVITY_LEFT: qtEdges = Qt::LeftEdge; break; case XDG_POSITIONER_GRAVITY_TOP_LEFT: qtEdges = Qt::TopEdge | Qt::LeftEdge; break; case XDG_POSITIONER_GRAVITY_BOTTOM_LEFT: qtEdges = Qt::BottomEdge | Qt::LeftEdge; break; case XDG_POSITIONER_GRAVITY_RIGHT: qtEdges = Qt::RightEdge; break; case XDG_POSITIONER_GRAVITY_TOP_RIGHT: qtEdges = Qt::TopEdge | Qt::RightEdge; break; case XDG_POSITIONER_GRAVITY_BOTTOM_RIGHT: qtEdges = Qt::BottomEdge | Qt::RightEdge; break; case XDG_POSITIONER_GRAVITY_NONE: break; default: Q_UNREACHABLE(); break; } s->gravity = qtEdges; } void XdgPositionerStableInterface::Private::setConstraintAdjustmentCallback(wl_client *client, wl_resource *resource, uint32_t constraint_adjustment) { Q_UNUSED(client) auto s = cast(resource); PositionerConstraints constraints; if (constraint_adjustment & XDG_POSITIONER_CONSTRAINT_ADJUSTMENT_SLIDE_X) { constraints |= PositionerConstraint::SlideX; } if (constraint_adjustment & XDG_POSITIONER_CONSTRAINT_ADJUSTMENT_SLIDE_Y) { constraints |= PositionerConstraint::SlideY; } if (constraint_adjustment & XDG_POSITIONER_CONSTRAINT_ADJUSTMENT_FLIP_X) { constraints |= PositionerConstraint::FlipX; } if (constraint_adjustment & XDG_POSITIONER_CONSTRAINT_ADJUSTMENT_FLIP_Y) { constraints |= PositionerConstraint::FlipY; } if (constraint_adjustment & XDG_POSITIONER_CONSTRAINT_ADJUSTMENT_RESIZE_X) { constraints |= PositionerConstraint::ResizeX; } if (constraint_adjustment & XDG_POSITIONER_CONSTRAINT_ADJUSTMENT_RESIZE_Y) { constraints |= PositionerConstraint::ResizeY; } s->constraintAdjustments = constraints; } void XdgPositionerStableInterface::Private::setOffsetCallback(wl_client *client, wl_resource *resource, int32_t x, int32_t y) { Q_UNUSED(client) auto s = cast(resource); s->anchorOffset = QPoint(x,y); } void XdgTopLevelStableInterface::Private::close() { xdg_toplevel_send_close(resource); client->flush(); } void XdgTopLevelStableInterface::Private::setMaxSizeCallback(wl_client *client, wl_resource *resource, int32_t width, int32_t height) { auto s = cast(resource); Q_ASSERT(client == *s->client); s->q_func()->maxSizeChanged(QSize(width, height)); } void XdgTopLevelStableInterface::Private::setMinSizeCallback(wl_client *client, wl_resource *resource, int32_t width, int32_t height) { auto s = cast(resource); Q_ASSERT(client == *s->client); s->q_func()->minSizeChanged(QSize(width, height)); } const struct xdg_toplevel_interface XdgTopLevelStableInterface::Private::s_interface = { destroyCallback, setParentCallback, setTitleCallback, setAppIdCallback, showWindowMenuCallback, moveCallback, resizeCallback, setMaxSizeCallback, setMinSizeCallback, setMaximizedCallback, unsetMaximizedCallback, setFullscreenCallback, unsetFullscreenCallback, setMinimizedCallback }; void XdgTopLevelStableInterface::Private::destroyCallback(wl_client *client, wl_resource *resource) { Q_UNUSED(client) wl_resource_destroy(resource); } void XdgTopLevelStableInterface::Private::setParentCallback(wl_client *client, wl_resource *resource, wl_resource *parent) { auto s = cast(resource); Q_ASSERT(client == *s->client); if (!parent) { //setting null is valid API. Clear s->parent = nullptr; emit s->q_func()->transientForChanged(); } else { auto parentSurface = static_cast(s->q->global())->getSurface(parent); if (s->parent.data() != parentSurface) { s->parent = QPointer(parentSurface); emit s->q_func()->transientForChanged(); } } } void XdgTopLevelStableInterface::Private::showWindowMenuCallback(wl_client *client, wl_resource *resource, wl_resource *seat, uint32_t serial, int32_t x, int32_t y) { auto s = cast(resource); Q_ASSERT(client == *s->client); emit s->q_func()->windowMenuRequested(SeatInterface::get(seat), serial, QPoint(x, y)); } XdgTopLevelStableInterface::Private::Private(XdgTopLevelStableInterface *q, XdgShellStableInterface *c, SurfaceInterface *surface, wl_resource *parentResource) : XdgShellSurfaceInterface::Private(XdgShellInterfaceVersion::Stable, q, c, surface, parentResource, &xdg_toplevel_interface, &s_interface) { } void XdgTopLevelStableInterface::Private::setMaximizedCallback(wl_client *client, wl_resource *resource) { auto s = cast(resource); Q_ASSERT(client == *s->client); s->q_func()->maximizedChanged(true); } void XdgTopLevelStableInterface::Private::unsetMaximizedCallback(wl_client *client, wl_resource *resource) { auto s = cast(resource); Q_ASSERT(client == *s->client); s->q_func()->maximizedChanged(false); } void XdgTopLevelStableInterface::Private::setFullscreenCallback(wl_client *client, wl_resource *resource, wl_resource *output) { auto s = cast(resource); Q_ASSERT(client == *s->client); OutputInterface *o = nullptr; if (output) { o = OutputInterface::get(output); } s->q_func()->fullscreenChanged(true, o); } void XdgTopLevelStableInterface::Private::unsetFullscreenCallback(wl_client *client, wl_resource *resource) { auto s = cast(resource); Q_ASSERT(client == *s->client); s->q_func()->fullscreenChanged(false, nullptr); } void XdgTopLevelStableInterface::Private::setMinimizedCallback(wl_client *client, wl_resource *resource) { auto s = cast(resource); Q_ASSERT(client == *s->client); s->q_func()->minimizeRequested(); } XdgTopLevelStableInterface::Private::~Private() = default; #ifndef DOXYGEN_SHOULD_SKIP_THIS const struct xdg_popup_interface XdgPopupStableInterface::Private::s_interface = { resourceDestroyedCallback, grabCallback }; #endif XdgPopupStableInterface::Private::Private(XdgPopupStableInterface *q, XdgShellStableInterface *c, SurfaceInterface *surface, wl_resource *parentResource) : XdgShellPopupInterface::Private(XdgShellInterfaceVersion::Stable, q, c, surface, parentResource, &xdg_popup_interface, &s_interface) { } void XdgPopupStableInterface::Private::grabCallback(wl_client *client, wl_resource *resource, wl_resource *seat, uint32_t serial) { Q_UNUSED(client) auto s = cast(resource); auto seatInterface = SeatInterface::get(seat); s->q_func()->grabRequested(seatInterface, serial); } XdgPopupStableInterface::Private::~Private() = default; quint32 XdgPopupStableInterface::Private::configure(const QRect &rect) { if (!resource) { return 0; } const quint32 serial = global->display()->nextSerial(); configureSerials << serial; xdg_popup_send_configure(resource, rect.x(), rect.y(), rect.width(), rect.height()); xdg_surface_send_configure(parentResource, serial); client->flush(); return serial; } void XdgPopupStableInterface::Private::popupDone() { if (!resource) { return; } // TODO: dismiss all child popups xdg_popup_send_popup_done(resource); client->flush(); } XdgShellStableInterface::XdgShellStableInterface(Display *display, QObject *parent) : XdgShellInterface(new Private(this, display), parent) { } Display* XdgShellStableInterface::display() const { return d->display; } XdgShellStableInterface::~XdgShellStableInterface() = default; XdgSurfaceStableInterface::XdgSurfaceStableInterface(XdgShellStableInterface *parent, SurfaceInterface *surface, wl_resource *parentResource) : KWayland::Server::Resource(new Private(this, parent, surface, parentResource)) { } XdgSurfaceStableInterface::~XdgSurfaceStableInterface() = default; SurfaceInterface* XdgSurfaceStableInterface::surface() const { Q_D(); return d->m_surface; } XdgPositionerStableInterface::XdgPositionerStableInterface(XdgShellStableInterface *parent, wl_resource *parentResource) : KWayland::Server::Resource(new Private(this, parent, parentResource)) { } QSize XdgPositionerStableInterface::initialSize() const { Q_D(); return d->initialSize; } QRect XdgPositionerStableInterface::anchorRect() const { Q_D(); return d->anchorRect; } Qt::Edges XdgPositionerStableInterface::anchorEdge() const { Q_D(); return d->anchorEdge; } Qt::Edges XdgPositionerStableInterface::gravity() const { Q_D(); return d->gravity; } PositionerConstraints XdgPositionerStableInterface::constraintAdjustments() const { Q_D(); return d->constraintAdjustments; } QPoint XdgPositionerStableInterface::anchorOffset() const { Q_D(); return d->anchorOffset; } XdgPositionerStableInterface::Private *XdgPositionerStableInterface::d_func() const { return static_cast(d.data()); } XdgTopLevelStableInterface* XdgSurfaceStableInterface::topLevel() const { Q_D(); return d->m_topLevel.data(); } XdgPopupStableInterface* XdgSurfaceStableInterface::popup() const { Q_D(); return d->m_popup.data(); } XdgSurfaceStableInterface::Private *XdgSurfaceStableInterface::d_func() const { return static_cast(d.data()); } XdgTopLevelStableInterface::XdgTopLevelStableInterface(XdgShellStableInterface *parent, SurfaceInterface *surface, wl_resource *parentResource) : KWayland::Server::XdgShellSurfaceInterface(new Private(this, parent, surface, parentResource)) { } XdgTopLevelStableInterface::~XdgTopLevelStableInterface() = default; XdgTopLevelStableInterface::Private *XdgTopLevelStableInterface::d_func() const { return static_cast(d.data()); } XdgPopupStableInterface::XdgPopupStableInterface(XdgShellStableInterface *parent, SurfaceInterface *surface, wl_resource *parentResource) : XdgShellPopupInterface(new Private(this, parent, surface, parentResource)) { } XdgPopupStableInterface::~XdgPopupStableInterface() = default; XdgPopupStableInterface::Private *XdgPopupStableInterface::d_func() const { return static_cast(d.data()); } } }