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 "pointer_gestures_v1.h" 23 24 #include "wayland/global.h" 25 26 #include <wayland-pointer-gestures-unstable-v1-server-protocol.h> 27 28 namespace Wrapland::Server 29 { 30 31 class Pointer; 32 33 constexpr uint32_t PointerGesturesV1Version = 1; 34 using PointerGesturesV1Global = Wayland::Global<PointerGesturesV1, PointerGesturesV1Version>; 35 using PointerGesturesV1Bind = Wayland::Bind<PointerGesturesV1Global>; 36 37 class PointerGesturesV1::Private : public PointerGesturesV1Global 38 { 39 public: 40 Private(PointerGesturesV1* q, Display* display); 41 42 private: 43 static void 44 swipeGestureCallback(PointerGesturesV1Bind* bind, uint32_t id, wl_resource* wlPointer); 45 static void 46 pinchGestureCallback(PointerGesturesV1Bind* bind, uint32_t id, wl_resource* wlPointer); 47 48 static const struct zwp_pointer_gestures_v1_interface s_interface; 49 }; 50 51 class PointerSwipeGestureV1 : public QObject 52 { 53 Q_OBJECT 54 public: 55 PointerSwipeGestureV1(Client* client, uint32_t version, uint32_t id, Pointer* pointer); 56 57 void start(quint32 serial, quint32 fingerCount); 58 void update(const QSizeF& delta); 59 void end(quint32 serial, bool cancel = false); 60 void cancel(quint32 serial); 61 62 Pointer* pointer; 63 64 Q_SIGNALS: 65 void resourceDestroyed(); 66 67 private: 68 class Private; 69 Private* d_ptr; 70 }; 71 72 class PointerSwipeGestureV1::Private : public Wayland::Resource<PointerSwipeGestureV1> 73 { 74 public: 75 Private(Client* client, 76 uint32_t version, 77 uint32_t id, 78 Pointer* _pointer, 79 PointerSwipeGestureV1* q); 80 81 Pointer* pointer; 82 83 private: 84 static void swipeGestureCallback(wl_client* wlClient, 85 wl_resource* wlResource, 86 uint32_t id, 87 wl_resource* wlPointer); 88 static void pinchGestureCallback(wl_client* wlClient, 89 wl_resource* wlResource, 90 uint32_t id, 91 wl_resource* wlPointer); 92 93 static const struct zwp_pointer_gesture_swipe_v1_interface s_interface; 94 }; 95 96 class PointerPinchGestureV1 : public QObject 97 { 98 Q_OBJECT 99 public: 100 PointerPinchGestureV1(Client* client, uint32_t version, uint32_t id, Pointer* pointer); 101 102 void start(quint32 serial, quint32 fingerCount); 103 void update(const QSizeF& delta, qreal scale, qreal rotation); 104 void end(quint32 serial, bool cancel = false); 105 void cancel(quint32 serial); 106 107 Q_SIGNALS: 108 void resourceDestroyed(); 109 110 private: 111 class Private; 112 Private* d_ptr; 113 }; 114 115 class PointerPinchGestureV1::Private : public Wayland::Resource<PointerPinchGestureV1> 116 { 117 public: 118 Private(Client* client, 119 uint32_t version, 120 uint32_t id, 121 Pointer* pointer, 122 PointerPinchGestureV1* q); 123 124 Pointer* pointer; 125 126 private: 127 static const struct zwp_pointer_gesture_pinch_v1_interface s_interface; 128 }; 129 130 } 131