413
414
quint32 nativeModifiers,
414
415
const QString& text, bool autorep, ushort count) override
418
#if (QT_VERSION < QT_VERSION_CHECK(5, 6, 0)) || (QT_VERSION >= QT_VERSION_CHECK(5, 8, 0))
416
419
QWindowSystemInterface::handleExtendedKeyEvent(window, timestamp, type, key, modifiers,
417
420
nativeScanCode, nativeVirtualKey, nativeModifiers, text, autorep, count);
422
// The version above is the right one, but we have to workaround a FIXME hack in
423
// QWindowSystemInterface::handleShortcutEvent which forcibly sets sync mode from the GUI thread.
424
// Sending an event synchronously from the mir input thread risks a deadlock with the main/GUI thread
425
// from a miral mutex locked by both thread (eg. holding Alt + dragging a window with the the mouse)
426
// See: https://bugreports.qt.io/browse/QTBUG-56274
427
// Bug was introduced by commit c7e5e1d9e01849347a9e59b8285477a20d82002b and fixed by commit
428
// 33d748bb88676b69e596ae77badfeaf5a69a33d1
429
QWindowSystemInterfacePrivate::KeyEvent *e =
430
new QWindowSystemInterfacePrivate::KeyEvent(window, timestamp, type, key, modifiers,
431
nativeScanCode, nativeVirtualKey, nativeModifiers, text, autorep, count);
432
QWindowSystemInterfacePrivate::postWindowSystemEvent(e);
420
437
void handleTouchEvent(QWindow *window, ulong timestamp, QTouchDevice *device,
421
438
const QList<struct QWindowSystemInterface::TouchPoint> &points, Qt::KeyboardModifiers mods) override
440
// See comment in handleExtendedKeyEvent
441
#if (QT_VERSION < QT_VERSION_CHECK(5, 6, 0)) || (QT_VERSION >= QT_VERSION_CHECK(5, 8, 0))
423
442
QWindowSystemInterface::handleTouchEvent(window, timestamp, device, points, mods);
445
if (!points.size()) // Touch events must have at least one point
448
QList<QTouchEvent::TouchPoint> touchPoints = QWindowSystemInterfacePrivate::fromNativeTouchPoints(points, window, &type);
450
QWindowSystemInterfacePrivate::TouchEvent *e =
451
new QWindowSystemInterfacePrivate::TouchEvent(window, timestamp, type, device, touchPoints, mods);
452
QWindowSystemInterfacePrivate::postWindowSystemEvent(e);
426
457
void handleMouseEvent(ulong timestamp, QPointF relative, QPointF absolute, Qt::MouseButtons buttons,
511
542
switch (mir_input_event_get_type(iev)) {
512
543
case mir_input_event_type_key:
544
dispatchKey(mir_input_event_get_keyboard_event(iev));
515
546
case mir_input_event_type_touch:
547
dispatchTouch(mir_input_event_get_touch_event(iev));
518
549
case mir_input_event_type_pointer:
519
dispatchPointer(iev);
550
dispatchPointer(mir_input_event_get_pointer_event(iev));
569
void QtEventFeeder::dispatchPointer(MirInputEvent const* ev)
600
void QtEventFeeder::dispatchPointer(const MirPointerEvent *pev)
571
auto timestamp = qtmir::compressTimestamp<qtmir::Timestamp>(std::chrono::nanoseconds(mir_input_event_get_event_time(ev)));
572
auto pev = mir_input_event_get_pointer_event(ev);
602
auto timestamp = qtmir::compressTimestamp<qtmir::Timestamp>(
603
std::chrono::nanoseconds(mir_input_event_get_event_time(
604
mir_pointer_event_input_event(pev))));
573
605
auto action = mir_pointer_event_action(pev);
574
606
qCDebug(QTMIR_MIR_INPUT) << "Received" << qPrintable(mirPointerEventToString(pev));
607
void QtEventFeeder::dispatchKey(MirInputEvent const* event)
639
void QtEventFeeder::dispatchKey(const MirKeyboardEvent *kev)
609
auto timestamp = qtmir::compressTimestamp<qtmir::Timestamp>(std::chrono::nanoseconds(mir_input_event_get_event_time(event)));
641
auto timestamp = qtmir::compressTimestamp<qtmir::Timestamp>(
642
std::chrono::nanoseconds(mir_input_event_get_event_time(
643
mir_keyboard_event_input_event(kev))));
611
auto kev = mir_input_event_get_keyboard_event(event);
612
645
xkb_keysym_t xk_sym = mir_keyboard_event_key_code(kev);
614
647
// Key modifier and unicode index mapping.
669
702
mir_keyboard_event_modifiers(kev), text, is_auto_rep);
672
void QtEventFeeder::dispatchTouch(MirInputEvent const* event)
705
void QtEventFeeder::dispatchTouch(const MirTouchEvent *tev)
674
auto timestamp = qtmir::compressTimestamp<qtmir::Timestamp>(std::chrono::nanoseconds(mir_input_event_get_event_time(event)));
707
auto timestamp = qtmir::compressTimestamp<qtmir::Timestamp>(
708
std::chrono::nanoseconds(mir_input_event_get_event_time(
709
mir_touch_event_input_event(tev))));
676
711
tracepoint(qtmirserver, touchEventDispatch_start, std::chrono::nanoseconds(timestamp).count());
678
auto tev = mir_input_event_get_touch_event(event);
679
713
qCDebug(QTMIR_MIR_INPUT) << "Received" << qPrintable(mirTouchEventToString(tev));
681
715
// FIXME(loicm) Max pressure is device specific. That one is for the Samsung Galaxy Nexus. That
746
780
tracepoint(qtmirserver, touchEventDispatch_end, std::chrono::nanoseconds(timestamp).count());
749
void QtEventFeeder::start()
754
void QtEventFeeder::stop()
759
783
void QtEventFeeder::validateTouches(QWindow *window, ulong timestamp,
760
784
QList<QWindowSystemInterface::TouchPoint> &touchPoints)