1 /**************************************************************************** 2 Copyright © 2020 Roman Gilg <subdiff@gmail.com> 3 4 This library is free software; you can redistribute it and/or 5 modify it under the terms of the GNU Lesser General Public 6 License as published by the Free Software Foundation; either 7 version 2.1 of the License, or (at your option) version 3, or any 8 later version accepted by the membership of KDE e.V. (or its 9 successor approved by the membership of KDE e.V.), which shall 10 act as a proxy defined in Section 6 of version 3 of the license. 11 12 This library is distributed in the hope that it will be useful, 13 but WITHOUT ANY WARRANTY; without even the implied warranty of 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 Lesser General Public License for more details. 16 17 You should have received a copy of the GNU Lesser General Public 18 License along with this library. If not, see <http://www.gnu.org/licenses/>. 19 ****************************************************************************/ 20 #pragma once 21 22 #include "xdg_shell_surface.h" 23 24 #include "wayland/resource.h" 25 26 #include <QObject> 27 #include <QPoint> 28 #include <QRect> 29 #include <QSize> 30 31 #include <wayland-xdg-shell-server-protocol.h> 32 33 namespace Wrapland::Server 34 { 35 36 // TODO(romangg): The QObject dependency is only necessary because of the resourceDestroyed signal. 37 // Refactor Resource, such that it is not necessary anymore. 38 class XdgShellPositioner : public QObject 39 { 40 Q_OBJECT 41 public: 42 XdgShellPositioner(Client* client, uint32_t version, uint32_t id); 43 44 QSize initialSize() const; 45 QRect anchorRect() const; 46 Qt::Edges anchorEdge() const; 47 Qt::Edges gravity() const; 48 XdgShellSurface::ConstraintAdjustments constraintAdjustments() const; 49 QPoint anchorOffset() const; 50 51 Q_SIGNALS: 52 void resourceDestroyed(); 53 54 private: 55 friend class XdgShell; 56 57 class Private; 58 Private* d_ptr; 59 }; 60 61 class XdgShellPositioner::Private : public Wayland::Resource<XdgShellPositioner> 62 { 63 public: 64 Private(Client* client, uint32_t version, uint32_t id, XdgShellPositioner* q); 65 66 QSize initialSize; 67 QRect anchorRect; 68 Qt::Edges anchorEdge; 69 Qt::Edges gravity; 70 XdgShellSurface::ConstraintAdjustments constraintAdjustments; 71 QPoint anchorOffset; 72 73 private: 74 static void 75 setSizeCallback(wl_client* wlClient, wl_resource* wlResource, int32_t width, int32_t height); 76 static void setAnchorRectCallback(wl_client* wlClient, 77 wl_resource* wlResource, 78 int32_t x, 79 int32_t y, 80 int32_t width, 81 int32_t height); 82 static void setAnchorCallback(wl_client* wlClient, wl_resource* wlResource, uint32_t anchor); 83 static void setGravityCallback(wl_client* wlClient, wl_resource* wlResource, uint32_t gravity); 84 static void setConstraintAdjustmentCallback(wl_client* wlClient, 85 wl_resource* wlResource, 86 uint32_t constraint_adjustment); 87 static void 88 setOffsetCallback(wl_client* wlClient, wl_resource* wlResource, int32_t x, int32_t y); 89 90 static const struct xdg_positioner_interface s_interface; 91 }; 92 93 } 94