Changeset View
Changeset View
Standalone View
Standalone View
src/server/fakeinput_interface.cpp
Show First 20 Lines • Show All 44 Lines • ▼ Show 20 Line(s) | 41 | private: | |||
---|---|---|---|---|---|
45 | static void pointerMotionAbsoluteCallback(wl_client *client, wl_resource *resource, wl_fixed_t x, wl_fixed_t y); | 45 | static void pointerMotionAbsoluteCallback(wl_client *client, wl_resource *resource, wl_fixed_t x, wl_fixed_t y); | ||
46 | static void buttonCallback(wl_client *client, wl_resource *resource, uint32_t button, uint32_t state); | 46 | static void buttonCallback(wl_client *client, wl_resource *resource, uint32_t button, uint32_t state); | ||
47 | static void axisCallback(wl_client *client, wl_resource *resource, uint32_t axis, wl_fixed_t value); | 47 | static void axisCallback(wl_client *client, wl_resource *resource, uint32_t axis, wl_fixed_t value); | ||
48 | static void touchDownCallback(wl_client *client, wl_resource *resource, quint32 id, wl_fixed_t x, wl_fixed_t y); | 48 | static void touchDownCallback(wl_client *client, wl_resource *resource, quint32 id, wl_fixed_t x, wl_fixed_t y); | ||
49 | static void touchMotionCallback(wl_client *client, wl_resource *resource, quint32 id, wl_fixed_t x, wl_fixed_t y); | 49 | static void touchMotionCallback(wl_client *client, wl_resource *resource, quint32 id, wl_fixed_t x, wl_fixed_t y); | ||
50 | static void touchUpCallback(wl_client *client, wl_resource *resource, quint32 id); | 50 | static void touchUpCallback(wl_client *client, wl_resource *resource, quint32 id); | ||
51 | static void touchCancelCallback(wl_client *client, wl_resource *resource); | 51 | static void touchCancelCallback(wl_client *client, wl_resource *resource); | ||
52 | static void touchFrameCallback(wl_client *client, wl_resource *resource); | 52 | static void touchFrameCallback(wl_client *client, wl_resource *resource); | ||
53 | static void keyboardKeyCallback(wl_client *client, wl_resource *resource, uint32_t button, uint32_t state); | ||||
53 | 54 | | |||
54 | static void unbind(wl_resource *resource); | 55 | static void unbind(wl_resource *resource); | ||
55 | static Private *cast(wl_resource *r) { | 56 | static Private *cast(wl_resource *r) { | ||
56 | return reinterpret_cast<Private*>(wl_resource_get_user_data(r)); | 57 | return reinterpret_cast<Private*>(wl_resource_get_user_data(r)); | ||
57 | } | 58 | } | ||
58 | static FakeInputDevice *device(wl_resource *r); | 59 | static FakeInputDevice *device(wl_resource *r); | ||
59 | 60 | | |||
60 | FakeInputInterface *q; | 61 | FakeInputInterface *q; | ||
Show All 9 Lines | 69 | public: | |||
70 | wl_resource *resource; | 71 | wl_resource *resource; | ||
71 | FakeInputInterface *interface; | 72 | FakeInputInterface *interface; | ||
72 | bool authenticated = false; | 73 | bool authenticated = false; | ||
73 | 74 | | |||
74 | private: | 75 | private: | ||
75 | FakeInputDevice *q; | 76 | FakeInputDevice *q; | ||
76 | }; | 77 | }; | ||
77 | 78 | | |||
78 | const quint32 FakeInputInterface::Private::s_version = 3; | 79 | const quint32 FakeInputInterface::Private::s_version = 4; | ||
79 | QList<quint32> FakeInputInterface::Private::touchIds = QList<quint32>(); | 80 | QList<quint32> FakeInputInterface::Private::touchIds = QList<quint32>(); | ||
80 | 81 | | |||
81 | #ifndef DOXYGEN_SHOULD_SKIP_THIS | 82 | #ifndef DOXYGEN_SHOULD_SKIP_THIS | ||
82 | const struct org_kde_kwin_fake_input_interface FakeInputInterface::Private::s_interface = { | 83 | const struct org_kde_kwin_fake_input_interface FakeInputInterface::Private::s_interface = { | ||
83 | authenticateCallback, | 84 | authenticateCallback, | ||
84 | pointerMotionCallback, | 85 | pointerMotionCallback, | ||
85 | buttonCallback, | 86 | buttonCallback, | ||
86 | axisCallback, | 87 | axisCallback, | ||
87 | touchDownCallback, | 88 | touchDownCallback, | ||
88 | touchMotionCallback, | 89 | touchMotionCallback, | ||
89 | touchUpCallback, | 90 | touchUpCallback, | ||
90 | touchCancelCallback, | 91 | touchCancelCallback, | ||
91 | touchFrameCallback, | 92 | touchFrameCallback, | ||
92 | pointerMotionAbsoluteCallback | 93 | pointerMotionAbsoluteCallback, | ||
94 | keyboardKeyCallback | ||||
93 | }; | 95 | }; | ||
94 | #endif | 96 | #endif | ||
95 | 97 | | |||
96 | FakeInputInterface::Private::Private(FakeInputInterface *q, Display *d) | 98 | FakeInputInterface::Private::Private(FakeInputInterface *q, Display *d) | ||
97 | : Global::Private(d, &org_kde_kwin_fake_input_interface, s_version) | 99 | : Global::Private(d, &org_kde_kwin_fake_input_interface, s_version) | ||
98 | , q(q) | 100 | , q(q) | ||
99 | { | 101 | { | ||
100 | } | 102 | } | ||
▲ Show 20 Lines • Show All 159 Lines • ▼ Show 20 Line(s) | 261 | { | |||
260 | Q_UNUSED(client) | 262 | Q_UNUSED(client) | ||
261 | FakeInputDevice *d = device(resource); | 263 | FakeInputDevice *d = device(resource); | ||
262 | if (!d || !d->isAuthenticated()) { | 264 | if (!d || !d->isAuthenticated()) { | ||
263 | return; | 265 | return; | ||
264 | } | 266 | } | ||
265 | emit d->touchFrameRequested(); | 267 | emit d->touchFrameRequested(); | ||
266 | } | 268 | } | ||
267 | 269 | | |||
270 | void FakeInputInterface::Private::keyboardKeyCallback(wl_client *client, wl_resource *resource, uint32_t button, uint32_t state) | ||||
271 | { | ||||
272 | Q_UNUSED(client) | ||||
273 | FakeInputDevice *d = device(resource); | ||||
274 | if (!d || !d->isAuthenticated()) { | ||||
275 | return; | ||||
276 | } | ||||
277 | switch (state) { | ||||
278 | case WL_KEYBOARD_KEY_STATE_PRESSED: | ||||
279 | emit d->keyboardKeyPressRequested(button); | ||||
280 | break; | ||||
281 | case WL_KEYBOARD_KEY_STATE_RELEASED: | ||||
282 | emit d->keyboardKeyReleaseRequested(button); | ||||
283 | break; | ||||
284 | default: | ||||
285 | // nothing | ||||
286 | break; | ||||
287 | } | ||||
288 | } | ||||
289 | | ||||
268 | FakeInputInterface::FakeInputInterface(Display *display, QObject *parent) | 290 | FakeInputInterface::FakeInputInterface(Display *display, QObject *parent) | ||
269 | : Global(new Private(this, display), parent) | 291 | : Global(new Private(this, display), parent) | ||
270 | { | 292 | { | ||
271 | } | 293 | } | ||
272 | 294 | | |||
273 | FakeInputInterface::~FakeInputInterface() = default; | 295 | FakeInputInterface::~FakeInputInterface() = default; | ||
274 | 296 | | |||
275 | FakeInputDevice::Private::Private(wl_resource *resource, FakeInputInterface *interface, FakeInputDevice *q) | 297 | FakeInputDevice::Private::Private(wl_resource *resource, FakeInputInterface *interface, FakeInputDevice *q) | ||
Show All 31 Lines |