From 4fe4a50aa465e262c5756eee4a78300f87cd1e01 Mon Sep 17 00:00:00 2001 From: Carson Black Date: Mon, 30 Nov 2020 16:40:22 -0500 Subject: [PATCH] xdgshell: wrap v3 of xdgshell protocol --- src/wayland/xdgshell_interface.cpp | 48 +++++++++++++++++++++++++++++- src/wayland/xdgshell_interface.h | 21 +++++++++++++ src/wayland/xdgshell_interface_p.h | 7 +++++ 3 files changed, 75 insertions(+), 1 deletion(-) diff --git a/src/wayland/xdgshell_interface.cpp b/src/wayland/xdgshell_interface.cpp index 2376d3829c..54c8ac793e 100644 --- a/src/wayland/xdgshell_interface.cpp +++ b/src/wayland/xdgshell_interface.cpp @@ -17,7 +17,7 @@ namespace KWaylandServer { -static const int s_version = 2; +static const int s_version = 3; XdgShellInterfacePrivate::XdgShellInterfacePrivate(XdgShellInterface *shell) : q(shell) @@ -705,6 +705,13 @@ void XdgPopupInterfacePrivate::xdg_popup_grab(Resource *resource, ::wl_resource emit q->grabRequested(seat, serial); } +void XdgPopupInterfacePrivate::xdg_popup_reposition(Resource *resource, ::wl_resource *positionerResource, uint32_t token) +{ + Q_UNUSED(resource) + positioner = XdgPositioner::get(positionerResource); + emit q->repositionRequested(token); +} + XdgPopupInterface::XdgPopupInterface(XdgSurfaceInterface *surface, SurfaceInterface *parentSurface, const XdgPositioner &positioner, @@ -763,6 +770,12 @@ void XdgPopupInterface::sendPopupDone() d->send_popup_done(); } +void XdgPopupInterface::sendRepositioned(quint32 token) +{ + Q_ASSERT(d->resource()->version() >= XDG_POPUP_REPOSITIONED_SINCE_VERSION); + d->send_repositioned(token); +} + XdgPopupInterface *XdgPopupInterface::get(::wl_resource *resource) { if (auto popupPrivate = resource_cast(resource)) { @@ -852,6 +865,24 @@ void XdgPositionerPrivate::xdg_positioner_set_anchor(Resource *resource, uint32_ } } +void XdgPositionerPrivate::xdg_positioner_set_parent_size(Resource *resource, int32_t width, int32_t height) +{ + Q_UNUSED(resource) + data->parentSize = QSize(width, height); +} + +void XdgPositionerPrivate::xdg_positioner_set_reactive(Resource *resource) +{ + Q_UNUSED(resource) + data->isReactive = true; +} + +void XdgPositionerPrivate::xdg_positioner_set_parent_configure(Resource *resource, uint32_t serial) +{ + Q_UNUSED(resource) + data->parentConfigure = serial; +} + void XdgPositionerPrivate::xdg_positioner_set_gravity(Resource *resource, uint32_t gravity) { if (gravity > gravity_bottom_right) { @@ -1003,6 +1034,21 @@ QPoint XdgPositioner::offset() const return d->offset; } +QSize XdgPositioner::parentSize() const +{ + return d->parentSize; +} + +bool XdgPositioner::isReactive() const +{ + return d->isReactive; +} + +quint32 XdgPositioner::parentConfigure() const +{ + return d->parentConfigure; +} + XdgPositioner XdgPositioner::get(::wl_resource *resource) { XdgPositionerPrivate *xdgPositionerPrivate = XdgPositionerPrivate::get(resource); diff --git a/src/wayland/xdgshell_interface.h b/src/wayland/xdgshell_interface.h index 2243d02de2..ed61a44afd 100644 --- a/src/wayland/xdgshell_interface.h +++ b/src/wayland/xdgshell_interface.h @@ -453,6 +453,21 @@ public: */ QPoint offset() const; + /** + * Returns whether the surface should respond to movements in its parent window. + */ + bool isReactive() const; + + /** + * Returns the parent size to use when positioning the popup. + */ + QSize parentSize() const; + + /** + * Returns the serial of the configure event for the parent window. + */ + quint32 parentConfigure() const; + /** * Returns the current state of the xdg positioner object identified by \a resource. */ @@ -521,6 +536,11 @@ public: */ void sendPopupDone(); + /** + * Sends a popup repositioned event to the client. + */ + void sendRepositioned(quint32 token); + /** * Returns the XdgPopupInterface for the specified wayland resource object \a resource. */ @@ -533,6 +553,7 @@ Q_SIGNALS: */ void initializeRequested(); void grabRequested(SeatInterface *seat, quint32 serial); + void repositionRequested(quint32 token); private: QScopedPointer d; diff --git a/src/wayland/xdgshell_interface_p.h b/src/wayland/xdgshell_interface_p.h index 5d25cc3f01..5047befb13 100644 --- a/src/wayland/xdgshell_interface_p.h +++ b/src/wayland/xdgshell_interface_p.h @@ -56,6 +56,9 @@ public: QPoint offset; QSize size; QRect anchorRect; + bool isReactive; + QSize parentSize; + quint32 parentConfigure; }; class XdgPositionerPrivate : public QtWaylandServer::xdg_positioner @@ -76,6 +79,9 @@ protected: void xdg_positioner_set_gravity(Resource *resource, uint32_t gravity) override; void xdg_positioner_set_constraint_adjustment(Resource *resource, uint32_t constraint_adjustment) override; void xdg_positioner_set_offset(Resource *resource, int32_t x, int32_t y) override; + void xdg_positioner_set_reactive(Resource *resource) override; + void xdg_positioner_set_parent_size(Resource *resource, int32_t width, int32_t height) override; + void xdg_positioner_set_parent_configure(Resource *resource, uint32_t serial) override; }; class XdgSurfaceInterfacePrivate : public QtWaylandServer::xdg_surface @@ -178,6 +184,7 @@ protected: void xdg_popup_destroy_resource(Resource *resource) override; void xdg_popup_destroy(Resource *resource) override; void xdg_popup_grab(Resource *resource, ::wl_resource *seat, uint32_t serial) override; + void xdg_popup_reposition(Resource *resource, struct ::wl_resource *positioner, uint32_t token) override; }; } // namespace KWaylandServer