diff --git a/src/client/xdgshell.cpp b/src/client/xdgshell.cpp index 968e8c8..6acf2a4 100644 --- a/src/client/xdgshell.cpp +++ b/src/client/xdgshell.cpp @@ -1,481 +1,486 @@ /**************************************************************************** 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::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); +} + 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 20aaf4c..a888db1 100644 --- a/src/client/xdgshell.h +++ b/src/client/xdgshell.h @@ -1,635 +1,645 @@ /**************************************************************************** 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); 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); + 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 2d4adc7..f1366fc 100644 --- a/src/client/xdgshell_p.h +++ b/src/client/xdgshell_p.h @@ -1,350 +1,354 @@ /**************************************************************************** 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; 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 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 e09f297..49d4b6e 100644 --- a/src/client/xdgshell_stable.cpp +++ b/src/client/xdgshell_stable.cpp @@ -1,607 +1,612 @@ /**************************************************************************** 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; 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()); } 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; 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); +} XdgShellPopupStable::XdgShellPopupStable(QObject *parent) : XdgShellPopup(new Private(this), parent) { } XdgShellPopupStable::~XdgShellPopupStable() = default; } } diff --git a/src/client/xdgshell_v6.cpp b/src/client/xdgshell_v6.cpp index f3e2162..58cd44c 100644 --- a/src/client/xdgshell_v6.cpp +++ b/src/client/xdgshell_v6.cpp @@ -1,592 +1,597 @@ /**************************************************************************** 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 #include namespace KWayland { namespace Client { class XdgShellUnstableV6::Private : public XdgShell::Private { public: void setupV6(zxdg_shell_v6 *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_wm_base*; using XdgShell::Private::operator xdg_shell*; operator zxdg_shell_v6*() override { return xdgshellv6; } operator zxdg_shell_v6*() const override { return xdgshellv6; } private: XdgShellPopup *internalGetXdgPopup(Surface *surface, zxdg_surface_v6 *parentSurface, const XdgPositioner &positioner, QObject *parent); static void pingCallback(void *data, struct zxdg_shell_v6 *shell, uint32_t serial); WaylandPointer xdgshellv6; static const struct zxdg_shell_v6_listener s_shellListener; }; const struct zxdg_shell_v6_listener XdgShellUnstableV6::Private::s_shellListener = { pingCallback, }; void XdgShellUnstableV6::Private::pingCallback(void *data, struct zxdg_shell_v6 *shell, uint32_t serial) { Q_UNUSED(data) zxdg_shell_v6_pong(shell, serial); } void XdgShellUnstableV6::Private::setupV6(zxdg_shell_v6 *shell) { Q_ASSERT(shell); Q_ASSERT(!xdgshellv6); xdgshellv6.setup(shell); zxdg_shell_v6_add_listener(shell, &s_shellListener, this); } void XdgShellUnstableV6::Private::release() { xdgshellv6.release(); } void XdgShellUnstableV6::Private::destroy() { xdgshellv6.destroy(); } bool XdgShellUnstableV6::Private::isValid() const { return xdgshellv6.isValid(); } XdgShellSurface *XdgShellUnstableV6::Private::getXdgSurface(Surface *surface, QObject *parent) { Q_ASSERT(isValid()); auto ss = zxdg_shell_v6_get_xdg_surface(xdgshellv6, *surface); if (!ss) { return nullptr; } auto s = new XdgTopLevelUnstableV6(parent); auto toplevel = zxdg_surface_v6_get_toplevel(ss); if (queue) { queue->addProxy(ss); queue->addProxy(toplevel); } s->setup(ss, toplevel); return s; } XdgShellPopup *XdgShellUnstableV6::Private::getXdgPopup(Surface *surface, XdgShellSurface *parentSurface, const XdgPositioner &positioner, QObject *parent) { return internalGetXdgPopup(surface, *parentSurface, positioner, parent); } XdgShellPopup *XdgShellUnstableV6::Private::getXdgPopup(Surface *surface, XdgShellPopup *parentSurface, const XdgPositioner &positioner, QObject *parent) { return internalGetXdgPopup(surface, *parentSurface, positioner, parent); } XdgShellPopup *XdgShellUnstableV6::Private::internalGetXdgPopup(Surface *surface, zxdg_surface_v6 *parentSurface, const XdgPositioner &positioner, QObject *parent) { Q_ASSERT(isValid()); auto ss = zxdg_shell_v6_get_xdg_surface(xdgshellv6, *surface); if (!ss) { return nullptr; } auto p = zxdg_shell_v6_create_positioner(xdgshellv6); auto anchorRect = positioner.anchorRect(); zxdg_positioner_v6_set_anchor_rect(p, anchorRect.x(), anchorRect.y(), anchorRect.width(), anchorRect.height()); QSize initialSize = positioner.initialSize(); zxdg_positioner_v6_set_size(p, initialSize.width(), initialSize.height()); QPoint anchorOffset = positioner.anchorOffset(); if (!anchorOffset.isNull()) { zxdg_positioner_v6_set_offset(p, anchorOffset.x(), anchorOffset.y()); } uint32_t anchor = 0; if (positioner.anchorEdge().testFlag(Qt::LeftEdge)) { anchor |= ZXDG_POSITIONER_V6_ANCHOR_LEFT; } if (positioner.anchorEdge().testFlag(Qt::TopEdge)) { anchor |= ZXDG_POSITIONER_V6_ANCHOR_TOP; } if (positioner.anchorEdge().testFlag(Qt::RightEdge)) { anchor |= ZXDG_POSITIONER_V6_ANCHOR_RIGHT; } if (positioner.anchorEdge().testFlag(Qt::BottomEdge)) { anchor |= ZXDG_POSITIONER_V6_ANCHOR_BOTTOM; } if (anchor != 0) { zxdg_positioner_v6_set_anchor(p, anchor); } uint32_t gravity = 0; if (positioner.gravity().testFlag(Qt::LeftEdge)) { gravity |= ZXDG_POSITIONER_V6_GRAVITY_LEFT; } if (positioner.gravity().testFlag(Qt::TopEdge)) { gravity |= ZXDG_POSITIONER_V6_GRAVITY_TOP; } if (positioner.gravity().testFlag(Qt::RightEdge)) { gravity |= ZXDG_POSITIONER_V6_GRAVITY_RIGHT; } if (positioner.gravity().testFlag(Qt::BottomEdge)) { gravity |= ZXDG_POSITIONER_V6_GRAVITY_BOTTOM; } if (gravity != 0) { zxdg_positioner_v6_set_gravity(p, gravity); } uint32_t constraint = 0; if (positioner.constraints().testFlag(XdgPositioner::Constraint::SlideX)) { constraint |= ZXDG_POSITIONER_V6_CONSTRAINT_ADJUSTMENT_SLIDE_X; } if (positioner.constraints().testFlag(XdgPositioner::Constraint::SlideY)) { constraint |= ZXDG_POSITIONER_V6_CONSTRAINT_ADJUSTMENT_SLIDE_Y; } if (positioner.constraints().testFlag(XdgPositioner::Constraint::FlipX)) { constraint |= ZXDG_POSITIONER_V6_CONSTRAINT_ADJUSTMENT_FLIP_X; } if (positioner.constraints().testFlag(XdgPositioner::Constraint::FlipY)) { constraint |= ZXDG_POSITIONER_V6_CONSTRAINT_ADJUSTMENT_FLIP_Y; } if (positioner.constraints().testFlag(XdgPositioner::Constraint::ResizeX)) { constraint |= ZXDG_POSITIONER_V6_CONSTRAINT_ADJUSTMENT_RESIZE_X; } if (positioner.constraints().testFlag(XdgPositioner::Constraint::ResizeY)) { constraint |= ZXDG_POSITIONER_V6_CONSTRAINT_ADJUSTMENT_RESIZE_Y; } if (constraint != 0) { zxdg_positioner_v6_set_constraint_adjustment(p, constraint); } XdgShellPopup *s = new XdgShellPopupUnstableV6(parent); auto popup = zxdg_surface_v6_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); zxdg_positioner_v6_destroy(p); return s; } XdgShellUnstableV6::XdgShellUnstableV6(QObject *parent) : XdgShell(new Private, parent) { } XdgShellUnstableV6::~XdgShellUnstableV6() = default; //A top level wraps both xdg_surface_v6 and xdg_top_level into the public API XdgShelllSurface class XdgTopLevelUnstableV6::Private : public XdgShellSurface::Private { public: Private(XdgShellSurface *q); WaylandPointer xdgtoplevelv6; WaylandPointer xdgsurfacev6; void setupV6(zxdg_surface_v6 *surface, zxdg_toplevel_v6 *toplevel) override; void release() override; void destroy() override; bool isValid() const override; using XdgShellSurface::Private::operator xdg_surface*; using XdgShellSurface::Private::operator xdg_toplevel*; operator zxdg_surface_v6*() override { return xdgsurfacev6; } operator zxdg_surface_v6*() const override { return xdgsurfacev6; } operator zxdg_toplevel_v6*() override { return xdgtoplevelv6; } operator zxdg_toplevel_v6*() const override { return xdgtoplevelv6; } 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; private: QSize pendingSize; States pendingState; static void configureCallback(void *data, struct zxdg_toplevel_v6 *xdg_toplevel, int32_t width, int32_t height, struct wl_array *state); static void closeCallback(void *data, zxdg_toplevel_v6 *xdg_toplevel); static void surfaceConfigureCallback(void *data, zxdg_surface_v6 *xdg_surface, uint32_t serial); static const struct zxdg_toplevel_v6_listener s_toplevelListener; static const struct zxdg_surface_v6_listener s_surfaceListener; }; const struct zxdg_toplevel_v6_listener XdgTopLevelUnstableV6::Private::s_toplevelListener = { configureCallback, closeCallback }; const struct zxdg_surface_v6_listener XdgTopLevelUnstableV6::Private::s_surfaceListener = { surfaceConfigureCallback }; void XdgTopLevelUnstableV6::Private::surfaceConfigureCallback(void *data, struct zxdg_surface_v6 *surface, uint32_t serial) { Q_UNUSED(surface) auto s = reinterpret_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 XdgTopLevelUnstableV6::Private::configureCallback(void *data, struct zxdg_toplevel_v6 *xdg_toplevel, int32_t width, int32_t height, struct wl_array *state) { Q_UNUSED(xdg_toplevel) auto s = reinterpret_cast(data); States states; uint32_t *statePtr = reinterpret_cast(state->data); for (size_t i = 0; i < state->size / sizeof(uint32_t); i++) { switch (statePtr[i]) { case ZXDG_TOPLEVEL_V6_STATE_MAXIMIZED: states = states | XdgShellSurface::State::Maximized; break; case ZXDG_TOPLEVEL_V6_STATE_FULLSCREEN: states = states | XdgShellSurface::State::Fullscreen; break; case ZXDG_TOPLEVEL_V6_STATE_RESIZING: states = states | XdgShellSurface::State::Resizing; break; case ZXDG_TOPLEVEL_V6_STATE_ACTIVATED: states = states | XdgShellSurface::State::Activated; break; } } s->pendingSize = QSize(width, height); s->pendingState = states; } void XdgTopLevelUnstableV6::Private::closeCallback(void *data, zxdg_toplevel_v6 *xdg_toplevel) { auto s = reinterpret_cast(data); Q_ASSERT(s->xdgtoplevelv6 == xdg_toplevel); emit s->q->closeRequested(); } XdgTopLevelUnstableV6::Private::Private(XdgShellSurface *q) : XdgShellSurface::Private(q) { } void XdgTopLevelUnstableV6::Private::setupV6(zxdg_surface_v6 *surface, zxdg_toplevel_v6 *topLevel) { Q_ASSERT(surface); Q_ASSERT(!xdgtoplevelv6); xdgsurfacev6.setup(surface); xdgtoplevelv6.setup(topLevel); zxdg_surface_v6_add_listener(xdgsurfacev6, &s_surfaceListener, this); zxdg_toplevel_v6_add_listener(xdgtoplevelv6, &s_toplevelListener, this); } void XdgTopLevelUnstableV6::Private::release() { xdgtoplevelv6.release(); xdgsurfacev6.release(); } void XdgTopLevelUnstableV6::Private::destroy() { xdgtoplevelv6.destroy(); xdgsurfacev6.destroy(); } bool XdgTopLevelUnstableV6::Private::isValid() const { return xdgtoplevelv6.isValid() && xdgsurfacev6.isValid(); } void XdgTopLevelUnstableV6::Private::setTransientFor(XdgShellSurface *parent) { zxdg_toplevel_v6 *parentSurface = nullptr; if (parent) { parentSurface = *parent; } zxdg_toplevel_v6_set_parent(xdgtoplevelv6, parentSurface); } void XdgTopLevelUnstableV6::Private::setTitle(const QString & title) { zxdg_toplevel_v6_set_title(xdgtoplevelv6, title.toUtf8().constData()); } void XdgTopLevelUnstableV6::Private::setAppId(const QByteArray & appId) { zxdg_toplevel_v6_set_app_id(xdgtoplevelv6, appId.constData()); } void XdgTopLevelUnstableV6::Private::showWindowMenu(Seat *seat, quint32 serial, qint32 x, qint32 y) { zxdg_toplevel_v6_show_window_menu(xdgtoplevelv6, *seat, serial, x, y); } void XdgTopLevelUnstableV6::Private::move(Seat *seat, quint32 serial) { zxdg_toplevel_v6_move(xdgtoplevelv6, *seat, serial); } void XdgTopLevelUnstableV6::Private::resize(Seat *seat, quint32 serial, Qt::Edges edges) { uint wlEdge = ZXDG_TOPLEVEL_V6_RESIZE_EDGE_NONE; if (edges.testFlag(Qt::TopEdge)) { if (edges.testFlag(Qt::LeftEdge) && ((edges & ~Qt::LeftEdge) == Qt::TopEdge)) { wlEdge = ZXDG_TOPLEVEL_V6_RESIZE_EDGE_TOP_LEFT; } else if (edges.testFlag(Qt::RightEdge) && ((edges & ~Qt::RightEdge) == Qt::TopEdge)) { wlEdge = ZXDG_TOPLEVEL_V6_RESIZE_EDGE_TOP_RIGHT; } else if ((edges & ~Qt::TopEdge) == Qt::Edges()) { wlEdge = ZXDG_TOPLEVEL_V6_RESIZE_EDGE_TOP; } } else if (edges.testFlag(Qt::BottomEdge)) { if (edges.testFlag(Qt::LeftEdge) && ((edges & ~Qt::LeftEdge) == Qt::BottomEdge)) { wlEdge = ZXDG_TOPLEVEL_V6_RESIZE_EDGE_BOTTOM_LEFT; } else if (edges.testFlag(Qt::RightEdge) && ((edges & ~Qt::RightEdge) == Qt::BottomEdge)) { wlEdge = ZXDG_TOPLEVEL_V6_RESIZE_EDGE_BOTTOM_RIGHT; } else if ((edges & ~Qt::BottomEdge) == Qt::Edges()) { wlEdge = ZXDG_TOPLEVEL_V6_RESIZE_EDGE_BOTTOM; } } else if (edges.testFlag(Qt::RightEdge) && ((edges & ~Qt::RightEdge) == Qt::Edges())) { wlEdge = ZXDG_TOPLEVEL_V6_RESIZE_EDGE_RIGHT; } else if (edges.testFlag(Qt::LeftEdge) && ((edges & ~Qt::LeftEdge) == Qt::Edges())) { wlEdge = ZXDG_TOPLEVEL_V6_RESIZE_EDGE_LEFT; } zxdg_toplevel_v6_resize(xdgtoplevelv6, *seat, serial, wlEdge); } void XdgTopLevelUnstableV6::Private::ackConfigure(quint32 serial) { zxdg_surface_v6_ack_configure(xdgsurfacev6, serial); } void XdgTopLevelUnstableV6::Private::setMaximized() { zxdg_toplevel_v6_set_maximized(xdgtoplevelv6); } void XdgTopLevelUnstableV6::Private::unsetMaximized() { zxdg_toplevel_v6_unset_maximized(xdgtoplevelv6); } void XdgTopLevelUnstableV6::Private::setFullscreen(Output *output) { wl_output *o = nullptr; if (output) { o = *output; } zxdg_toplevel_v6_set_fullscreen(xdgtoplevelv6, o); } void XdgTopLevelUnstableV6::Private::unsetFullscreen() { zxdg_toplevel_v6_unset_fullscreen(xdgtoplevelv6); } void XdgTopLevelUnstableV6::Private::setMinimized() { zxdg_toplevel_v6_set_minimized(xdgtoplevelv6); } void XdgTopLevelUnstableV6::Private::setMaxSize(const QSize &size) { zxdg_toplevel_v6_set_max_size(xdgtoplevelv6, size.width(), size.height()); } void XdgTopLevelUnstableV6::Private::setMinSize(const QSize &size) { zxdg_toplevel_v6_set_min_size(xdgtoplevelv6, size.width(), size.height()); } XdgTopLevelUnstableV6::XdgTopLevelUnstableV6(QObject *parent) : XdgShellSurface(new Private(this), parent) { } XdgTopLevelUnstableV6::~XdgTopLevelUnstableV6() = default; class XdgShellPopupUnstableV6::Private : public XdgShellPopup::Private { public: Private(XdgShellPopup *q); void setupV6(zxdg_surface_v6 *s, zxdg_popup_v6 *p) override; void release() override; void destroy() override; bool isValid() const override; void requestGrab(Seat *seat, quint32 serial) override; + void ackConfigure(quint32 serial) override; using XdgShellPopup::Private::operator xdg_popup*; using XdgShellPopup::Private::operator xdg_surface*; operator zxdg_surface_v6*() override { return xdgsurfacev6; } operator zxdg_surface_v6*() const override { return xdgsurfacev6; } operator zxdg_popup_v6*() override { return xdgpopupv6; } operator zxdg_popup_v6*() const override { return xdgpopupv6; } WaylandPointer xdgsurfacev6; WaylandPointer xdgpopupv6; QRect pendingRect; private: static void configureCallback(void *data, zxdg_popup_v6 *xdg_popup, int32_t x, int32_t y, int32_t width, int32_t height); static void popupDoneCallback(void *data, zxdg_popup_v6 *xdg_popup); static void surfaceConfigureCallback(void *data, zxdg_surface_v6 *xdg_surface, uint32_t serial); static const struct zxdg_popup_v6_listener s_popupListener; static const struct zxdg_surface_v6_listener s_surfaceListener; }; const struct zxdg_popup_v6_listener XdgShellPopupUnstableV6::Private::s_popupListener = { configureCallback, popupDoneCallback }; const struct zxdg_surface_v6_listener XdgShellPopupUnstableV6::Private::s_surfaceListener = { surfaceConfigureCallback, }; void XdgShellPopupUnstableV6::Private::configureCallback(void *data, zxdg_popup_v6 *xdg_popup, int32_t x, int32_t y, int32_t width, int32_t height) { Q_UNUSED(xdg_popup); auto s = reinterpret_cast(data); s->pendingRect = QRect(x, y, width, height); } void XdgShellPopupUnstableV6::Private::surfaceConfigureCallback(void *data, struct zxdg_surface_v6 *surface, uint32_t serial) { Q_UNUSED(surface); auto s = reinterpret_cast(data); s->q->configureRequested(s->pendingRect, serial); s->pendingRect = QRect(); } void XdgShellPopupUnstableV6::Private::popupDoneCallback(void *data, zxdg_popup_v6 *xdg_popup) { auto s = reinterpret_cast(data); Q_ASSERT(s->xdgpopupv6 == xdg_popup); emit s->q->popupDone(); } XdgShellPopupUnstableV6::Private::Private(XdgShellPopup *q) : XdgShellPopup::Private(q) { } void XdgShellPopupUnstableV6::Private::setupV6(zxdg_surface_v6 *s, zxdg_popup_v6 *p) { Q_ASSERT(p); Q_ASSERT(!xdgsurfacev6); Q_ASSERT(!xdgpopupv6); xdgsurfacev6.setup(s); xdgpopupv6.setup(p); zxdg_surface_v6_add_listener(xdgsurfacev6, &s_surfaceListener, this); zxdg_popup_v6_add_listener(xdgpopupv6, &s_popupListener, this); } void XdgShellPopupUnstableV6::Private::release() { xdgpopupv6.release(); } void XdgShellPopupUnstableV6::Private::destroy() { xdgpopupv6.destroy(); } bool XdgShellPopupUnstableV6::Private::isValid() const { return xdgpopupv6.isValid(); } void XdgShellPopupUnstableV6::Private::requestGrab(Seat *seat, quint32 serial) { zxdg_popup_v6_grab(xdgpopupv6, *seat, serial); } +void XdgShellPopupUnstableV6::Private::ackConfigure(quint32 serial) +{ + zxdg_surface_v6_ack_configure(xdgsurfacev6, serial); +} XdgShellPopupUnstableV6::XdgShellPopupUnstableV6(QObject *parent) : XdgShellPopup(new Private(this), parent) { } XdgShellPopupUnstableV6::~XdgShellPopupUnstableV6() = default; } }