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 <QObject> 23 24 #include <Wrapland/Server/wraplandserver_export.h> 25 #include <memory> 26 27 namespace Wrapland::Server 28 { 29 class Client; 30 class Seat; 31 32 class Cursor; 33 class Seat; 34 class Surface; 35 36 enum class PointerAxisSource; 37 38 class WRAPLANDSERVER_EXPORT Pointer : public QObject 39 { 40 Q_OBJECT 41 public: 42 Seat* seat() const; 43 Surface* focusedSurface() const; 44 45 Cursor* cursor() const; 46 Client* client() const; 47 48 // legacy 49 static Pointer* get(void* data); 50 // 51 52 Q_SIGNALS: 53 void cursorChanged(); 54 void resourceDestroyed(); 55 56 private: 57 void setFocusedSurface(quint32 serial, Surface* surface); 58 59 void motion(QPointF const& position); 60 void buttonPressed(quint32 serial, quint32 button); 61 void buttonReleased(quint32 serial, quint32 button); 62 void 63 axis(Qt::Orientation orientation, qreal delta, qint32 discreteDelta, PointerAxisSource source); 64 void axis(Qt::Orientation orientation, quint32 delta); 65 void 66 relativeMotion(const QSizeF& delta, const QSizeF& deltaNonAccelerated, quint64 microseconds); 67 68 friend class RelativePointerManagerV1; 69 friend class PointerGesturesV1; 70 friend class PointerConstraintsV1; 71 72 friend class Seat; 73 friend class pointer_pool; 74 friend class touch_pool; 75 Pointer(Client* client, uint32_t version, uint32_t id, Seat* seat); 76 77 class Private; 78 Private* d_ptr; 79 }; 80 81 class WRAPLANDSERVER_EXPORT Cursor : public QObject 82 { 83 Q_OBJECT 84 public: 85 ~Cursor() override; 86 87 QPoint hotspot() const; 88 quint32 enteredSerial() const; 89 90 Pointer* pointer() const; 91 92 QPointer<Surface> surface() const; 93 94 Q_SIGNALS: 95 void hotspotChanged(); 96 void enteredSerialChanged(); 97 void surfaceChanged(); 98 void changed(); 99 100 private: 101 friend class Pointer; 102 explicit Cursor(Pointer* pointer); 103 104 class Private; 105 std::unique_ptr<Private> d_ptr; 106 }; 107 108 } 109 110 Q_DECLARE_METATYPE(Wrapland::Server::Pointer*) 111