Changeset View
Changeset View
Standalone View
Standalone View
src/client/pointer.cpp
Show First 20 Lines • Show All 44 Lines • ▼ Show 20 Line(s) | 43 | private: | |||
---|---|---|---|---|---|
45 | void leave(uint32_t serial); | 45 | void leave(uint32_t serial); | ||
46 | static void enterCallback(void *data, wl_pointer *pointer, uint32_t serial, wl_surface *surface, | 46 | static void enterCallback(void *data, wl_pointer *pointer, uint32_t serial, wl_surface *surface, | ||
47 | wl_fixed_t sx, wl_fixed_t sy); | 47 | wl_fixed_t sx, wl_fixed_t sy); | ||
48 | static void leaveCallback(void *data, wl_pointer *pointer, uint32_t serial, wl_surface *surface); | 48 | static void leaveCallback(void *data, wl_pointer *pointer, uint32_t serial, wl_surface *surface); | ||
49 | static void motionCallback(void *data, wl_pointer *pointer, uint32_t time, wl_fixed_t sx, wl_fixed_t sy); | 49 | static void motionCallback(void *data, wl_pointer *pointer, uint32_t time, wl_fixed_t sx, wl_fixed_t sy); | ||
50 | static void buttonCallback(void *data, wl_pointer *pointer, uint32_t serial, uint32_t time, | 50 | static void buttonCallback(void *data, wl_pointer *pointer, uint32_t serial, uint32_t time, | ||
51 | uint32_t button, uint32_t state); | 51 | uint32_t button, uint32_t state); | ||
52 | static void axisCallback(void *data, wl_pointer *pointer, uint32_t time, uint32_t axis, wl_fixed_t value); | 52 | static void axisCallback(void *data, wl_pointer *pointer, uint32_t time, uint32_t axis, wl_fixed_t value); | ||
53 | static void frameCallback(void *data, wl_pointer *pointer); | ||||
54 | static void axisSourceCallback(void *data, wl_pointer *pointer, uint32_t axis_source); | ||||
55 | static void axisStopCallback(void *data, wl_pointer *pointer, uint32_t time, uint32_t axis); | ||||
56 | static void axisDiscreteCallback(void *data, wl_pointer *pointer, uint32_t axis, int32_t discrete); | ||||
53 | 57 | | |||
54 | Pointer *q; | 58 | Pointer *q; | ||
55 | static const wl_pointer_listener s_listener; | 59 | static const wl_pointer_listener s_listener; | ||
56 | }; | 60 | }; | ||
57 | 61 | | |||
58 | Pointer::Private::Private(Pointer *q) | 62 | Pointer::Private::Private(Pointer *q) | ||
59 | : q(q) | 63 | : q(q) | ||
60 | { | 64 | { | ||
61 | } | 65 | } | ||
62 | 66 | | |||
63 | void Pointer::Private::setup(wl_pointer *p) | 67 | void Pointer::Private::setup(wl_pointer *p) | ||
64 | { | 68 | { | ||
65 | Q_ASSERT(p); | 69 | Q_ASSERT(p); | ||
66 | Q_ASSERT(!pointer); | 70 | Q_ASSERT(!pointer); | ||
67 | pointer.setup(p); | 71 | pointer.setup(p); | ||
68 | wl_pointer_add_listener(pointer, &s_listener, this); | 72 | wl_pointer_add_listener(pointer, &s_listener, this); | ||
69 | } | 73 | } | ||
70 | 74 | | |||
71 | const wl_pointer_listener Pointer::Private::s_listener = { | 75 | const wl_pointer_listener Pointer::Private::s_listener = { | ||
72 | enterCallback, | 76 | enterCallback, | ||
73 | leaveCallback, | 77 | leaveCallback, | ||
74 | motionCallback, | 78 | motionCallback, | ||
75 | buttonCallback, | 79 | buttonCallback, | ||
76 | axisCallback | 80 | axisCallback, | ||
81 | frameCallback, | ||||
82 | axisSourceCallback, | ||||
83 | axisStopCallback, | ||||
84 | axisDiscreteCallback | ||||
77 | }; | 85 | }; | ||
78 | 86 | | |||
79 | Pointer::Pointer(QObject *parent) | 87 | Pointer::Pointer(QObject *parent) | ||
80 | : QObject(parent) | 88 | : QObject(parent) | ||
81 | , d(new Private(this)) | 89 | , d(new Private(this)) | ||
82 | { | 90 | { | ||
83 | } | 91 | } | ||
84 | 92 | | |||
▲ Show 20 Lines • Show All 76 Lines • ▼ Show 20 Line(s) | 168 | if (axis == WL_POINTER_AXIS_HORIZONTAL_SCROLL) { | |||
161 | return Axis::Horizontal; | 169 | return Axis::Horizontal; | ||
162 | } else { | 170 | } else { | ||
163 | return Axis::Vertical; | 171 | return Axis::Vertical; | ||
164 | } | 172 | } | ||
165 | }; | 173 | }; | ||
166 | emit p->q->axisChanged(time, toAxis(), wl_fixed_to_double(value)); | 174 | emit p->q->axisChanged(time, toAxis(), wl_fixed_to_double(value)); | ||
167 | } | 175 | } | ||
168 | 176 | | |||
177 | void Pointer::Private::frameCallback(void *data, wl_pointer *pointer) | ||||
178 | { | ||||
179 | auto p = reinterpret_cast<Pointer::Private*>(data); | ||||
180 | Q_ASSERT(p->pointer == pointer); | ||||
181 | emit p->q->frame(); | ||||
182 | } | ||||
183 | | ||||
184 | void Pointer::Private::axisSourceCallback(void *data, wl_pointer *pointer, uint32_t axis_source) | ||||
185 | { | ||||
186 | Q_UNUSED(data) | ||||
187 | Q_UNUSED(pointer) | ||||
188 | Q_UNUSED(axis_source) | ||||
189 | // TODO: implement | ||||
190 | } | ||||
191 | | ||||
192 | void Pointer::Private::axisStopCallback(void *data, wl_pointer *pointer, uint32_t time, uint32_t axis) | ||||
193 | { | ||||
194 | Q_UNUSED(data) | ||||
195 | Q_UNUSED(pointer) | ||||
196 | Q_UNUSED(time) | ||||
197 | Q_UNUSED(axis) | ||||
198 | // TODO: implement | ||||
199 | } | ||||
200 | | ||||
201 | void Pointer::Private::axisDiscreteCallback(void *data, wl_pointer *pointer, uint32_t axis, int32_t discrete) | ||||
202 | { | ||||
203 | Q_UNUSED(data) | ||||
204 | Q_UNUSED(pointer) | ||||
205 | Q_UNUSED(axis) | ||||
206 | Q_UNUSED(discrete) | ||||
207 | // TODO: implement | ||||
208 | } | ||||
209 | | ||||
169 | void Pointer::setCursor(Surface *surface, const QPoint &hotspot) | 210 | void Pointer::setCursor(Surface *surface, const QPoint &hotspot) | ||
170 | { | 211 | { | ||
171 | Q_ASSERT(isValid()); | 212 | Q_ASSERT(isValid()); | ||
172 | wl_surface *s = nullptr; | 213 | wl_surface *s = nullptr; | ||
173 | if (surface) { | 214 | if (surface) { | ||
174 | s = *surface; | 215 | s = *surface; | ||
175 | } | 216 | } | ||
176 | wl_pointer_set_cursor(d->pointer, d->enteredSerial, s, hotspot.x(), hotspot.y()); | 217 | wl_pointer_set_cursor(d->pointer, d->enteredSerial, s, hotspot.x(), hotspot.y()); | ||
Show All 34 Lines |