File indexing completed on 2024-05-12 05:32:25

0001 /*
0002     SPDX-FileCopyrightText: 2016 Martin Gräßlin <mgraesslin@kde.org>
0003     SPDX-FileCopyrightText: 2020 Vlad Zahorodnii <vlad.zahorodnii@kde.org>
0004 
0005     SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
0006 */
0007 
0008 #pragma once
0009 
0010 #include "qwayland-server-pointer-gestures-unstable-v1.h"
0011 
0012 #include <QPointer>
0013 
0014 namespace KWin
0015 {
0016 class ClientConnection;
0017 class Display;
0018 class PointerInterface;
0019 class SurfaceInterface;
0020 
0021 class PointerGesturesV1InterfacePrivate : public QtWaylandServer::zwp_pointer_gestures_v1
0022 {
0023 public:
0024     explicit PointerGesturesV1InterfacePrivate(Display *display);
0025 
0026 protected:
0027     void zwp_pointer_gestures_v1_get_swipe_gesture(Resource *resource, uint32_t id, struct ::wl_resource *pointer_resource) override;
0028     void zwp_pointer_gestures_v1_get_pinch_gesture(Resource *resource, uint32_t id, struct ::wl_resource *pointer_resource) override;
0029     void zwp_pointer_gestures_v1_get_hold_gesture(Resource *resource, uint32_t id, struct ::wl_resource *pointer_resource) override;
0030     void zwp_pointer_gestures_v1_release(Resource *resource) override;
0031 };
0032 
0033 class PointerSwipeGestureV1Interface : public QtWaylandServer::zwp_pointer_gesture_swipe_v1
0034 {
0035 public:
0036     explicit PointerSwipeGestureV1Interface(PointerInterface *pointer);
0037 
0038     static PointerSwipeGestureV1Interface *get(PointerInterface *pointer);
0039 
0040     void sendBegin(quint32 serial, quint32 fingerCount);
0041     void sendUpdate(const QPointF &delta);
0042     void sendEnd(quint32 serial);
0043     void sendCancel(quint32 serial);
0044 
0045 protected:
0046     void zwp_pointer_gesture_swipe_v1_destroy(Resource *resource) override;
0047 
0048 private:
0049     PointerInterface *pointer;
0050     QPointer<ClientConnection> focusedClient;
0051 };
0052 
0053 class PointerPinchGestureV1Interface : public QtWaylandServer::zwp_pointer_gesture_pinch_v1
0054 {
0055 public:
0056     explicit PointerPinchGestureV1Interface(PointerInterface *pointer);
0057 
0058     static PointerPinchGestureV1Interface *get(PointerInterface *pointer);
0059 
0060     void sendBegin(quint32 serial, quint32 fingerCount);
0061     void sendUpdate(const QPointF &delta, qreal scale, qreal rotation);
0062     void sendEnd(quint32 serial);
0063     void sendCancel(quint32 serial);
0064 
0065 protected:
0066     void zwp_pointer_gesture_pinch_v1_destroy(Resource *resource) override;
0067 
0068 private:
0069     PointerInterface *pointer;
0070     QPointer<ClientConnection> focusedClient;
0071 };
0072 
0073 class PointerHoldGestureV1Interface : public QtWaylandServer::zwp_pointer_gesture_hold_v1
0074 {
0075 public:
0076     explicit PointerHoldGestureV1Interface(PointerInterface *pointer);
0077 
0078     static PointerHoldGestureV1Interface *get(PointerInterface *pointer);
0079 
0080     void sendBegin(quint32 serial, quint32 fingerCount);
0081     void sendEnd(quint32 serial);
0082     void sendCancel(quint32 serial);
0083 
0084 protected:
0085     void zwp_pointer_gesture_hold_v1_destroy(Resource *resource) override;
0086 
0087 private:
0088     PointerInterface *pointer;
0089     QPointer<ClientConnection> focusedClient;
0090 };
0091 
0092 } // namespace KWin