199 auto serial = libinput_tablet_tool_get_serial(tool);
200 auto toolId = libinput_tablet_tool_get_tool_id(tool);
201 auto type = libinput_tablet_tool_get_type(tool);
204 case LIBINPUT_TABLET_TOOL_TYPE_PEN:
207 case LIBINPUT_TABLET_TOOL_TYPE_ERASER:
210 case LIBINPUT_TABLET_TOOL_TYPE_BRUSH:
213 case LIBINPUT_TABLET_TOOL_TYPE_PENCIL:
216 case LIBINPUT_TABLET_TOOL_TYPE_AIRBRUSH:
219 case LIBINPUT_TABLET_TOOL_TYPE_MOUSE:
222 case LIBINPUT_TABLET_TOOL_TYPE_LENS:
225 case LIBINPUT_TABLET_TOOL_TYPE_TOTEM:
229 QList<InputRedirection::Capability> capabilities;
230 if (libinput_tablet_tool_has_pressure(tool)) {
233 if (libinput_tablet_tool_has_distance(tool)) {
236 if (libinput_tablet_tool_has_rotation(tool)) {
239 if (libinput_tablet_tool_has_tilt(tool)) {
242 if (libinput_tablet_tool_has_slider(tool)) {
245 if (libinput_tablet_tool_has_wheel(tool)) {
263void Connection::processEvents()
265 QMutexLocker locker(&m_mutex);
266 while (m_eventQueue.size() != 0) {
267 std::unique_ptr<Event>
event = std::move(m_eventQueue.front());
268 m_eventQueue.pop_front();
269 switch (event->type()) {
270 case LIBINPUT_EVENT_DEVICE_ADDED: {
271 auto device =
new Device(event->nativeDevice());
272 device->moveToThread(thread());
275 applyDeviceConfig(device);
276 applyScreenToDevice(device);
278 connect(device, &Device::outputNameChanged,
this, [
this, device] {
281 if (device->outputName().isEmpty()) {
282 applyScreenToDevice(device);
286 Q_EMIT deviceAdded(device);
289 case LIBINPUT_EVENT_DEVICE_REMOVED: {
290 auto it = std::find_if(m_devices.begin(), m_devices.end(), [&event](
Device *d) {
291 return event->device() == d;
293 if (it == m_devices.end()) {
299 Q_EMIT deviceRemoved(device);
300 device->deleteLater();
303 case LIBINPUT_EVENT_KEYBOARD_KEY: {
308 case LIBINPUT_EVENT_POINTER_SCROLL_WHEEL: {
310 const auto axes = pointerEvent->
axis();
316 pointerEvent->
time(),
322 case LIBINPUT_EVENT_POINTER_SCROLL_FINGER: {
324 const auto axes = pointerEvent->
axis();
330 pointerEvent->
time(),
336 case LIBINPUT_EVENT_POINTER_SCROLL_CONTINUOUS: {
338 const auto axes = pointerEvent->
axis();
344 pointerEvent->
time(),
350 case LIBINPUT_EVENT_POINTER_BUTTON: {
356 case LIBINPUT_EVENT_POINTER_MOTION: {
358 auto delta = pe->
delta();
360 auto latestTime = pe->
time();
361 auto it = m_eventQueue.begin();
362 while (it != m_eventQueue.end()) {
363 if ((*it)->type() == LIBINPUT_EVENT_POINTER_MOTION) {
364 std::unique_ptr<PointerEvent> p{
static_cast<PointerEvent *
>(it->release())};
366 deltaNonAccel += p->deltaUnaccelerated();
367 latestTime = p->time();
368 it = m_eventQueue.erase(it);
377 case LIBINPUT_EVENT_POINTER_MOTION_ABSOLUTE: {
385 case LIBINPUT_EVENT_TOUCH_DOWN: {
386#ifndef KWIN_BUILD_TESTING
390 qCWarning(KWIN_LIBINPUT) <<
"Touch down received for device with no output assigned";
398 case LIBINPUT_EVENT_TOUCH_UP: {
407 case LIBINPUT_EVENT_TOUCH_MOTION: {
408#ifndef KWIN_BUILD_TESTING
419 case LIBINPUT_EVENT_TOUCH_CANCEL: {
420 Q_EMIT
event->device()->touchCanceled(event->device());
423 case LIBINPUT_EVENT_TOUCH_FRAME: {
424 Q_EMIT
event->device()->touchFrame(event->device());
427 case LIBINPUT_EVENT_GESTURE_PINCH_BEGIN: {
432 case LIBINPUT_EVENT_GESTURE_PINCH_UPDATE: {
437 case LIBINPUT_EVENT_GESTURE_PINCH_END: {
446 case LIBINPUT_EVENT_GESTURE_SWIPE_BEGIN: {
451 case LIBINPUT_EVENT_GESTURE_SWIPE_UPDATE: {
456 case LIBINPUT_EVENT_GESTURE_SWIPE_END: {
465 case LIBINPUT_EVENT_GESTURE_HOLD_BEGIN: {
470 case LIBINPUT_EVENT_GESTURE_HOLD_END: {
479 case LIBINPUT_EVENT_SWITCH_TOGGLE: {
481 switch (se->
state()) {
493 case LIBINPUT_EVENT_TABLET_TOOL_AXIS:
494 case LIBINPUT_EVENT_TABLET_TOOL_PROXIMITY:
495 case LIBINPUT_EVENT_TABLET_TOOL_TIP: {
499 switch (event->type()) {
500 case LIBINPUT_EVENT_TABLET_TOOL_AXIS:
503 case LIBINPUT_EVENT_TABLET_TOOL_PROXIMITY:
506 case LIBINPUT_EVENT_TABLET_TOOL_TIP:
513#ifndef KWIN_BUILD_TESTING
515 if (tte->device()->isMapToWorkspace()) {
518 Output *output = tte->device()->output();
519 if (!output &&
workspace()->activeWindow()) {
528 const QPointF globalPos;
530 Q_EMIT
event->device()->tabletToolEvent(tabletEventType,
531 globalPos, tte->pressure(),
532 tte->xTilt(), tte->yTilt(), tte->rotation(),
533 tte->isTipDown(), tte->isNearby(),
createTabletId(tte->tool(), event->device()), tte->time());
537 case LIBINPUT_EVENT_TABLET_TOOL_BUTTON: {
540 tabletEvent->isButtonPressed(),
541 createTabletId(tabletEvent->tool(), event->device()), tabletEvent->time());
544 case LIBINPUT_EVENT_TABLET_PAD_BUTTON: {
547 tabletEvent->isButtonPressed(),
548 createTabletPadId(event->device()), tabletEvent->time());
551 case LIBINPUT_EVENT_TABLET_PAD_RING: {
554 Q_EMIT
event->device()->tabletPadRingEvent(tabletEvent->number(),
555 tabletEvent->position(),
556 tabletEvent->source() == LIBINPUT_TABLET_PAD_RING_SOURCE_FINGER,
557 createTabletPadId(event->device()), tabletEvent->time());
560 case LIBINPUT_EVENT_TABLET_PAD_STRIP: {
563 tabletEvent->position(),
564 tabletEvent->source() == LIBINPUT_TABLET_PAD_STRIP_SOURCE_FINGER,
565 createTabletPadId(event->device()), tabletEvent->time());