KWaylandServer

pointergestures_v1_interface.cpp
1 /*
2  SPDX-FileCopyrightText: 2016 Martin Gräßlin <[email protected]>
3  SPDX-FileCopyrightText: 2020 Vlad Zahorodnii <[email protected]>
4 
5  SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
6 */
7 
8 #include "pointergestures_v1_interface.h"
9 #include "display.h"
10 #include "pointer_interface_p.h"
11 #include "pointergestures_v1_interface_p.h"
12 
13 namespace KWaylandServer
14 {
15 
16 static const int s_version = 1;
17 
18 PointerGesturesV1InterfacePrivate::PointerGesturesV1InterfacePrivate(Display *display)
19  : QtWaylandServer::zwp_pointer_gestures_v1(*display, s_version)
20 {
21 }
22 
23 void PointerGesturesV1InterfacePrivate::zwp_pointer_gestures_v1_get_swipe_gesture(Resource *resource, uint32_t id, struct ::wl_resource *pointer_resource)
24 {
25  PointerInterface *pointer = PointerInterface::get(pointer_resource);
26  if (!pointer) {
27  wl_resource_post_error(resource->handle, WL_DISPLAY_ERROR_INVALID_OBJECT,
28  "invalid pointer");
29  return;
30  }
31 
32  wl_resource *swipeResource = wl_resource_create(resource->client(), &zwp_pointer_gesture_swipe_v1_interface,
33  resource->version(), id);
34  if (!swipeResource) {
35  wl_resource_post_no_memory(resource->handle);
36  return;
37  }
38 
39  new PointerSwipeGestureV1Interface(pointer, swipeResource);
40 }
41 
42 void PointerGesturesV1InterfacePrivate::zwp_pointer_gestures_v1_get_pinch_gesture(Resource *resource, uint32_t id, struct ::wl_resource *pointer_resource)
43 {
44  PointerInterface *pointer = PointerInterface::get(pointer_resource);
45  if (!pointer) {
46  wl_resource_post_error(resource->handle, WL_DISPLAY_ERROR_INVALID_OBJECT,
47  "invalid pointer");
48  return;
49  }
50 
51  wl_resource *pinchResource = wl_resource_create(resource->client(), &zwp_pointer_gesture_pinch_v1_interface,
52  resource->version(), id);
53  if (!pinchResource) {
54  wl_resource_post_no_memory(resource->handle);
55  return;
56  }
57 
58  new PointerPinchGestureV1Interface(pointer, pinchResource);
59 }
60 
61 void PointerGesturesV1InterfacePrivate::zwp_pointer_gestures_v1_release(Resource *resource)
62 {
63  wl_resource_destroy(resource->handle);
64 }
65 
66 PointerGesturesV1Interface::PointerGesturesV1Interface(Display *display, QObject *parent)
67  : QObject(parent)
68  , d(new PointerGesturesV1InterfacePrivate(display))
69 {
70 }
71 
72 PointerGesturesV1Interface::~PointerGesturesV1Interface()
73 {
74 }
75 
76 PointerSwipeGestureV1Interface::PointerSwipeGestureV1Interface(PointerInterface *pointer,
77  ::wl_resource *resource)
78  : QtWaylandServer::zwp_pointer_gesture_swipe_v1(resource)
79  , pointer(pointer)
80 {
81  pointer->d_func()->registerSwipeGestureV1(this);
82 }
83 
84 PointerSwipeGestureV1Interface::~PointerSwipeGestureV1Interface()
85 {
86  if (pointer) {
87  pointer->d_func()->unregisterSwipeGestureV1(this);
88  }
89 }
90 
91 void PointerSwipeGestureV1Interface::zwp_pointer_gesture_swipe_v1_destroy_resource(Resource *resource)
92 {
93  Q_UNUSED(resource)
94  delete this;
95 }
96 
97 void PointerSwipeGestureV1Interface::zwp_pointer_gesture_swipe_v1_destroy(Resource *resource)
98 {
99  wl_resource_destroy(resource->handle);
100 }
101 
102 PointerPinchGestureV1Interface::PointerPinchGestureV1Interface(PointerInterface *pointer,
103  ::wl_resource *resource)
104  : QtWaylandServer::zwp_pointer_gesture_pinch_v1(resource)
105  , pointer(pointer)
106 {
107  pointer->d_func()->registerPinchGestureV1(this);
108 }
109 
110 PointerPinchGestureV1Interface::~PointerPinchGestureV1Interface()
111 {
112  if (pointer) {
113  pointer->d_func()->unregisterPinchGestureV1(this);
114  }
115 }
116 
117 void PointerPinchGestureV1Interface::zwp_pointer_gesture_pinch_v1_destroy_resource(Resource *resource)
118 {
119  Q_UNUSED(resource)
120  delete this;
121 }
122 
123 void PointerPinchGestureV1Interface::zwp_pointer_gesture_pinch_v1_destroy(Resource *resource)
124 {
125  wl_resource_destroy(resource->handle);
126 }
127 
128 } // namespace KWaylandServer
static PointerInterface * get(wl_resource *native)
QObject * parent() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Thu Mar 4 2021 23:09:07 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.