Changeset View
Changeset View
Standalone View
Standalone View
input.cpp
Show First 20 Lines • Show All 86 Lines • ▼ Show 20 Line(s) | |||||
87 | } | 87 | } | ||
88 | 88 | | |||
89 | bool InputEventFilter::keyEvent(QKeyEvent *event) | 89 | bool InputEventFilter::keyEvent(QKeyEvent *event) | ||
90 | { | 90 | { | ||
91 | Q_UNUSED(event) | 91 | Q_UNUSED(event) | ||
92 | return false; | 92 | return false; | ||
93 | } | 93 | } | ||
94 | 94 | | |||
95 | bool InputEventFilter::touchDown(quint32 id, const QPointF &point, quint32 time) | 95 | bool InputEventFilter::touchDown(qint32 id, const QPointF &point, quint32 time) | ||
96 | { | 96 | { | ||
97 | Q_UNUSED(id) | 97 | Q_UNUSED(id) | ||
98 | Q_UNUSED(point) | 98 | Q_UNUSED(point) | ||
99 | Q_UNUSED(time) | 99 | Q_UNUSED(time) | ||
100 | return false; | 100 | return false; | ||
101 | } | 101 | } | ||
102 | 102 | | |||
103 | bool InputEventFilter::touchMotion(quint32 id, const QPointF &point, quint32 time) | 103 | bool InputEventFilter::touchMotion(qint32 id, const QPointF &point, quint32 time) | ||
104 | { | 104 | { | ||
105 | Q_UNUSED(id) | 105 | Q_UNUSED(id) | ||
106 | Q_UNUSED(point) | 106 | Q_UNUSED(point) | ||
107 | Q_UNUSED(time) | 107 | Q_UNUSED(time) | ||
108 | return false; | 108 | return false; | ||
109 | } | 109 | } | ||
110 | 110 | | |||
111 | bool InputEventFilter::touchUp(quint32 id, quint32 time) | 111 | bool InputEventFilter::touchUp(qint32 id, quint32 time) | ||
112 | { | 112 | { | ||
113 | Q_UNUSED(id) | 113 | Q_UNUSED(id) | ||
114 | Q_UNUSED(time) | 114 | Q_UNUSED(time) | ||
115 | return false; | 115 | return false; | ||
116 | } | 116 | } | ||
117 | 117 | | |||
118 | bool InputEventFilter::pinchGestureBegin(int fingerCount, quint32 time) | 118 | bool InputEventFilter::pinchGestureBegin(int fingerCount, quint32 time) | ||
119 | { | 119 | { | ||
▲ Show 20 Lines • Show All 168 Lines • ▼ Show 20 Line(s) | 259 | bool keyEvent(QKeyEvent * event) override { | |||
288 | case QEvent::KeyRelease: | 288 | case QEvent::KeyRelease: | ||
289 | seat->keyReleased(event->nativeScanCode()); | 289 | seat->keyReleased(event->nativeScanCode()); | ||
290 | break; | 290 | break; | ||
291 | default: | 291 | default: | ||
292 | break; | 292 | break; | ||
293 | } | 293 | } | ||
294 | return true; | 294 | return true; | ||
295 | } | 295 | } | ||
296 | bool touchDown(quint32 id, const QPointF &pos, quint32 time) override { | 296 | bool touchDown(qint32 id, const QPointF &pos, quint32 time) override { | ||
297 | if (!waylandServer()->isScreenLocked()) { | 297 | if (!waylandServer()->isScreenLocked()) { | ||
298 | return false; | 298 | return false; | ||
299 | } | 299 | } | ||
300 | auto seat = waylandServer()->seat(); | 300 | auto seat = waylandServer()->seat(); | ||
301 | seat->setTimestamp(time); | 301 | seat->setTimestamp(time); | ||
302 | if (touchSurfaceAllowed()) { | 302 | if (touchSurfaceAllowed()) { | ||
303 | input()->touch()->insertId(id, seat->touchDown(pos)); | 303 | input()->touch()->insertId(id, seat->touchDown(pos)); | ||
304 | } | 304 | } | ||
305 | return true; | 305 | return true; | ||
306 | } | 306 | } | ||
307 | bool touchMotion(quint32 id, const QPointF &pos, quint32 time) override { | 307 | bool touchMotion(qint32 id, const QPointF &pos, quint32 time) override { | ||
308 | if (!waylandServer()->isScreenLocked()) { | 308 | if (!waylandServer()->isScreenLocked()) { | ||
309 | return false; | 309 | return false; | ||
310 | } | 310 | } | ||
311 | auto seat = waylandServer()->seat(); | 311 | auto seat = waylandServer()->seat(); | ||
312 | seat->setTimestamp(time); | 312 | seat->setTimestamp(time); | ||
313 | if (touchSurfaceAllowed()) { | 313 | if (touchSurfaceAllowed()) { | ||
314 | const qint32 kwaylandId = input()->touch()->mappedId(id); | 314 | const qint32 kwaylandId = input()->touch()->mappedId(id); | ||
315 | if (kwaylandId != -1) { | 315 | if (kwaylandId != -1) { | ||
316 | seat->touchMove(kwaylandId, pos); | 316 | seat->touchMove(kwaylandId, pos); | ||
317 | } | 317 | } | ||
318 | } | 318 | } | ||
319 | return true; | 319 | return true; | ||
320 | } | 320 | } | ||
321 | bool touchUp(quint32 id, quint32 time) override { | 321 | bool touchUp(qint32 id, quint32 time) override { | ||
322 | if (!waylandServer()->isScreenLocked()) { | 322 | if (!waylandServer()->isScreenLocked()) { | ||
323 | return false; | 323 | return false; | ||
324 | } | 324 | } | ||
325 | auto seat = waylandServer()->seat(); | 325 | auto seat = waylandServer()->seat(); | ||
326 | seat->setTimestamp(time); | 326 | seat->setTimestamp(time); | ||
327 | if (touchSurfaceAllowed()) { | 327 | if (touchSurfaceAllowed()) { | ||
328 | const qint32 kwaylandId = input()->touch()->mappedId(id); | 328 | const qint32 kwaylandId = input()->touch()->mappedId(id); | ||
329 | if (kwaylandId != -1) { | 329 | if (kwaylandId != -1) { | ||
▲ Show 20 Lines • Show All 84 Lines • ▼ Show 20 Line(s) | 413 | bool keyEvent(QKeyEvent *event) override { | |||
414 | if (!effects || !static_cast< EffectsHandlerImpl* >(effects)->hasKeyboardGrab()) { | 414 | if (!effects || !static_cast< EffectsHandlerImpl* >(effects)->hasKeyboardGrab()) { | ||
415 | return false; | 415 | return false; | ||
416 | } | 416 | } | ||
417 | waylandServer()->seat()->setFocusedKeyboardSurface(nullptr); | 417 | waylandServer()->seat()->setFocusedKeyboardSurface(nullptr); | ||
418 | passToWaylandServer(event); | 418 | passToWaylandServer(event); | ||
419 | static_cast< EffectsHandlerImpl* >(effects)->grabbedKeyboardEvent(event); | 419 | static_cast< EffectsHandlerImpl* >(effects)->grabbedKeyboardEvent(event); | ||
420 | return true; | 420 | return true; | ||
421 | } | 421 | } | ||
422 | bool touchDown(quint32 id, const QPointF &pos, quint32 time) override { | 422 | bool touchDown(qint32 id, const QPointF &pos, quint32 time) override { | ||
423 | if (!effects) { | 423 | if (!effects) { | ||
424 | return false; | 424 | return false; | ||
425 | } | 425 | } | ||
426 | return static_cast< EffectsHandlerImpl* >(effects)->touchDown(id, pos, time); | 426 | return static_cast< EffectsHandlerImpl* >(effects)->touchDown(id, pos, time); | ||
427 | } | 427 | } | ||
428 | bool touchMotion(quint32 id, const QPointF &pos, quint32 time) override { | 428 | bool touchMotion(qint32 id, const QPointF &pos, quint32 time) override { | ||
429 | if (!effects) { | 429 | if (!effects) { | ||
430 | return false; | 430 | return false; | ||
431 | } | 431 | } | ||
432 | return static_cast< EffectsHandlerImpl* >(effects)->touchMotion(id, pos, time); | 432 | return static_cast< EffectsHandlerImpl* >(effects)->touchMotion(id, pos, time); | ||
433 | } | 433 | } | ||
434 | bool touchUp(quint32 id, quint32 time) override { | 434 | bool touchUp(qint32 id, quint32 time) override { | ||
435 | if (!effects) { | 435 | if (!effects) { | ||
436 | return false; | 436 | return false; | ||
437 | } | 437 | } | ||
438 | return static_cast< EffectsHandlerImpl* >(effects)->touchUp(id, time); | 438 | return static_cast< EffectsHandlerImpl* >(effects)->touchUp(id, time); | ||
439 | } | 439 | } | ||
440 | }; | 440 | }; | ||
441 | 441 | | |||
442 | class MoveResizeFilter : public InputEventFilter { | 442 | class MoveResizeFilter : public InputEventFilter { | ||
Show All 33 Lines | 474 | if (event->type() == QEvent::KeyPress) { | |||
476 | if (c->isMove() || c->isResize()) { | 476 | if (c->isMove() || c->isResize()) { | ||
477 | // only update if mode didn't end | 477 | // only update if mode didn't end | ||
478 | c->updateMoveResize(input()->globalPointer()); | 478 | c->updateMoveResize(input()->globalPointer()); | ||
479 | } | 479 | } | ||
480 | } | 480 | } | ||
481 | return true; | 481 | return true; | ||
482 | } | 482 | } | ||
483 | 483 | | |||
484 | bool touchDown(quint32 id, const QPointF &pos, quint32 time) override { | 484 | bool touchDown(qint32 id, const QPointF &pos, quint32 time) override { | ||
485 | Q_UNUSED(id) | 485 | Q_UNUSED(id) | ||
486 | Q_UNUSED(pos) | 486 | Q_UNUSED(pos) | ||
487 | Q_UNUSED(time) | 487 | Q_UNUSED(time) | ||
488 | AbstractClient *c = workspace()->moveResizeClient(); | 488 | AbstractClient *c = workspace()->moveResizeClient(); | ||
489 | if (!c) { | 489 | if (!c) { | ||
490 | return false; | 490 | return false; | ||
491 | } | 491 | } | ||
492 | return true; | 492 | return true; | ||
493 | } | 493 | } | ||
494 | 494 | | |||
495 | bool touchMotion(quint32 id, const QPointF &pos, quint32 time) override { | 495 | bool touchMotion(qint32 id, const QPointF &pos, quint32 time) override { | ||
496 | Q_UNUSED(time) | 496 | Q_UNUSED(time) | ||
497 | AbstractClient *c = workspace()->moveResizeClient(); | 497 | AbstractClient *c = workspace()->moveResizeClient(); | ||
498 | if (!c) { | 498 | if (!c) { | ||
499 | return false; | 499 | return false; | ||
500 | } | 500 | } | ||
501 | if (!m_set) { | 501 | if (!m_set) { | ||
502 | m_id = id; | 502 | m_id = id; | ||
503 | m_set = true; | 503 | m_set = true; | ||
504 | } | 504 | } | ||
505 | if (m_id == id) { | 505 | if (m_id == id) { | ||
506 | c->updateMoveResize(pos.toPoint()); | 506 | c->updateMoveResize(pos.toPoint()); | ||
507 | } | 507 | } | ||
508 | return true; | 508 | return true; | ||
509 | } | 509 | } | ||
510 | 510 | | |||
511 | bool touchUp(quint32 id, quint32 time) override { | 511 | bool touchUp(qint32 id, quint32 time) override { | ||
512 | Q_UNUSED(time) | 512 | Q_UNUSED(time) | ||
513 | AbstractClient *c = workspace()->moveResizeClient(); | 513 | AbstractClient *c = workspace()->moveResizeClient(); | ||
514 | if (!c) { | 514 | if (!c) { | ||
515 | return false; | 515 | return false; | ||
516 | } | 516 | } | ||
517 | if (m_id == id || !m_set) { | 517 | if (m_id == id || !m_set) { | ||
518 | c->endMoveResize(); | 518 | c->endMoveResize(); | ||
519 | m_set = false; | 519 | m_set = false; | ||
520 | // pass through to update decoration filter later on | 520 | // pass through to update decoration filter later on | ||
521 | return false; | 521 | return false; | ||
522 | } | 522 | } | ||
523 | m_set = false; | 523 | m_set = false; | ||
524 | return true; | 524 | return true; | ||
525 | } | 525 | } | ||
526 | private: | 526 | private: | ||
527 | quint32 m_id = 0; | 527 | qint32 m_id = 0; | ||
528 | bool m_set = false; | 528 | bool m_set = false; | ||
529 | }; | 529 | }; | ||
530 | 530 | | |||
531 | class WindowSelectorFilter : public InputEventFilter { | 531 | class WindowSelectorFilter : public InputEventFilter { | ||
532 | public: | 532 | public: | ||
533 | bool pointerEvent(QMouseEvent *event, quint32 nativeButton) override { | 533 | bool pointerEvent(QMouseEvent *event, quint32 nativeButton) override { | ||
534 | Q_UNUSED(nativeButton) | 534 | Q_UNUSED(nativeButton) | ||
535 | if (!m_active) { | 535 | if (!m_active) { | ||
▲ Show 20 Lines • Show All 57 Lines • ▼ Show 20 Line(s) | 575 | if (input()->supportsPointerWarping()) { | |||
593 | } | 593 | } | ||
594 | input()->warpPointer(input()->globalPointer() + QPointF(mx, my)); | 594 | input()->warpPointer(input()->globalPointer() + QPointF(mx, my)); | ||
595 | } | 595 | } | ||
596 | } | 596 | } | ||
597 | // filter out while selecting a window | 597 | // filter out while selecting a window | ||
598 | return true; | 598 | return true; | ||
599 | } | 599 | } | ||
600 | 600 | | |||
601 | bool touchDown(quint32 id, const QPointF &pos, quint32 time) override { | 601 | bool touchDown(qint32 id, const QPointF &pos, quint32 time) override { | ||
602 | Q_UNUSED(time) | 602 | Q_UNUSED(time) | ||
603 | if (!isActive()) { | 603 | if (!isActive()) { | ||
604 | return false; | 604 | return false; | ||
605 | } | 605 | } | ||
606 | m_touchPoints.insert(id, pos); | 606 | m_touchPoints.insert(id, pos); | ||
607 | return true; | 607 | return true; | ||
608 | } | 608 | } | ||
609 | 609 | | |||
610 | bool touchMotion(quint32 id, const QPointF &pos, quint32 time) override { | 610 | bool touchMotion(qint32 id, const QPointF &pos, quint32 time) override { | ||
611 | Q_UNUSED(time) | 611 | Q_UNUSED(time) | ||
612 | if (!isActive()) { | 612 | if (!isActive()) { | ||
613 | return false; | 613 | return false; | ||
614 | } | 614 | } | ||
615 | auto it = m_touchPoints.find(id); | 615 | auto it = m_touchPoints.find(id); | ||
616 | if (it != m_touchPoints.end()) { | 616 | if (it != m_touchPoints.end()) { | ||
617 | *it = pos; | 617 | *it = pos; | ||
618 | } | 618 | } | ||
619 | return true; | 619 | return true; | ||
620 | } | 620 | } | ||
621 | 621 | | |||
622 | bool touchUp(quint32 id, quint32 time) override { | 622 | bool touchUp(qint32 id, quint32 time) override { | ||
623 | Q_UNUSED(time) | 623 | Q_UNUSED(time) | ||
624 | if (!isActive()) { | 624 | if (!isActive()) { | ||
625 | return false; | 625 | return false; | ||
626 | } | 626 | } | ||
627 | auto it = m_touchPoints.find(id); | 627 | auto it = m_touchPoints.find(id); | ||
628 | if (it != m_touchPoints.end()) { | 628 | if (it != m_touchPoints.end()) { | ||
629 | const auto pos = it.value(); | 629 | const auto pos = it.value(); | ||
630 | m_touchPoints.erase(it); | 630 | m_touchPoints.erase(it); | ||
▲ Show 20 Lines • Show All 281 Lines • ▼ Show 20 Line(s) | 870 | bool keyEvent(QKeyEvent *event) override { | |||
912 | if (QCoreApplication::sendEvent(found, &internalEvent)) { | 912 | if (QCoreApplication::sendEvent(found, &internalEvent)) { | ||
913 | waylandServer()->seat()->setFocusedKeyboardSurface(nullptr); | 913 | waylandServer()->seat()->setFocusedKeyboardSurface(nullptr); | ||
914 | passToWaylandServer(event); | 914 | passToWaylandServer(event); | ||
915 | return true; | 915 | return true; | ||
916 | } | 916 | } | ||
917 | return false; | 917 | return false; | ||
918 | } | 918 | } | ||
919 | 919 | | |||
920 | bool touchDown(quint32 id, const QPointF &pos, quint32 time) override { | 920 | bool touchDown(qint32 id, const QPointF &pos, quint32 time) override { | ||
921 | auto seat = waylandServer()->seat(); | 921 | auto seat = waylandServer()->seat(); | ||
922 | if (seat->isTouchSequence()) { | 922 | if (seat->isTouchSequence()) { | ||
923 | // something else is getting the events | 923 | // something else is getting the events | ||
924 | return false; | 924 | return false; | ||
925 | } | 925 | } | ||
926 | auto touch = input()->touch(); | 926 | auto touch = input()->touch(); | ||
927 | if (touch->internalPressId() != -1) { | 927 | if (touch->internalPressId() != -1) { | ||
928 | // already on internal window, ignore further touch points, but filter out | 928 | // already on internal window, ignore further touch points, but filter out | ||
Show All 13 Lines | |||||
942 | QEnterEvent enterEvent(m_lastLocalTouchPos, m_lastLocalTouchPos, pos); | 942 | QEnterEvent enterEvent(m_lastLocalTouchPos, m_lastLocalTouchPos, pos); | ||
943 | QCoreApplication::sendEvent(internal.data(), &enterEvent); | 943 | QCoreApplication::sendEvent(internal.data(), &enterEvent); | ||
944 | 944 | | |||
945 | QMouseEvent e(QEvent::MouseButtonPress, m_lastLocalTouchPos, pos, Qt::LeftButton, Qt::LeftButton, input()->keyboardModifiers()); | 945 | QMouseEvent e(QEvent::MouseButtonPress, m_lastLocalTouchPos, pos, Qt::LeftButton, Qt::LeftButton, input()->keyboardModifiers()); | ||
946 | e.setAccepted(false); | 946 | e.setAccepted(false); | ||
947 | QCoreApplication::sendEvent(internal.data(), &e); | 947 | QCoreApplication::sendEvent(internal.data(), &e); | ||
948 | return true; | 948 | return true; | ||
949 | } | 949 | } | ||
950 | bool touchMotion(quint32 id, const QPointF &pos, quint32 time) override { | 950 | bool touchMotion(qint32 id, const QPointF &pos, quint32 time) override { | ||
951 | auto touch = input()->touch(); | 951 | auto touch = input()->touch(); | ||
952 | auto internal = touch->internalWindow(); | 952 | auto internal = touch->internalWindow(); | ||
953 | if (!internal) { | 953 | if (!internal) { | ||
954 | return false; | 954 | return false; | ||
955 | } | 955 | } | ||
956 | if (touch->internalPressId() == -1) { | 956 | if (touch->internalPressId() == -1) { | ||
957 | return false; | 957 | return false; | ||
958 | } | 958 | } | ||
959 | waylandServer()->seat()->setTimestamp(time); | 959 | waylandServer()->seat()->setTimestamp(time); | ||
960 | if (touch->internalPressId() != qint32(id)) { | 960 | if (touch->internalPressId() != qint32(id)) { | ||
961 | // ignore, but filter out | 961 | // ignore, but filter out | ||
962 | return true; | 962 | return true; | ||
963 | } | 963 | } | ||
964 | m_lastGlobalTouchPos = pos; | 964 | m_lastGlobalTouchPos = pos; | ||
965 | m_lastLocalTouchPos = pos - QPointF(internal->x(), internal->y()); | 965 | m_lastLocalTouchPos = pos - QPointF(internal->x(), internal->y()); | ||
966 | 966 | | |||
967 | QMouseEvent e(QEvent::MouseMove, m_lastLocalTouchPos, m_lastGlobalTouchPos, Qt::LeftButton, Qt::LeftButton, input()->keyboardModifiers()); | 967 | QMouseEvent e(QEvent::MouseMove, m_lastLocalTouchPos, m_lastGlobalTouchPos, Qt::LeftButton, Qt::LeftButton, input()->keyboardModifiers()); | ||
968 | QCoreApplication::instance()->sendEvent(internal.data(), &e); | 968 | QCoreApplication::instance()->sendEvent(internal.data(), &e); | ||
969 | return true; | 969 | return true; | ||
970 | } | 970 | } | ||
971 | bool touchUp(quint32 id, quint32 time) override { | 971 | bool touchUp(qint32 id, quint32 time) override { | ||
972 | auto touch = input()->touch(); | 972 | auto touch = input()->touch(); | ||
973 | auto internal = touch->internalWindow(); | 973 | auto internal = touch->internalWindow(); | ||
974 | if (!internal) { | 974 | if (!internal) { | ||
975 | return false; | 975 | return false; | ||
976 | } | 976 | } | ||
977 | if (touch->internalPressId() == -1) { | 977 | if (touch->internalPressId() == -1) { | ||
978 | return false; | 978 | return false; | ||
979 | } | 979 | } | ||
▲ Show 20 Lines • Show All 85 Lines • ▼ Show 20 Line(s) | 1064 | if (e.isAccepted()) { | |||
1065 | return true; | 1065 | return true; | ||
1066 | } | 1066 | } | ||
1067 | if ((orientation == Qt::Vertical) && decoration->client()->titlebarPositionUnderMouse()) { | 1067 | if ((orientation == Qt::Vertical) && decoration->client()->titlebarPositionUnderMouse()) { | ||
1068 | decoration->client()->performMouseCommand(options->operationTitlebarMouseWheel(delta * -1), | 1068 | decoration->client()->performMouseCommand(options->operationTitlebarMouseWheel(delta * -1), | ||
1069 | event->globalPosF().toPoint()); | 1069 | event->globalPosF().toPoint()); | ||
1070 | } | 1070 | } | ||
1071 | return true; | 1071 | return true; | ||
1072 | } | 1072 | } | ||
1073 | bool touchDown(quint32 id, const QPointF &pos, quint32 time) override { | 1073 | bool touchDown(qint32 id, const QPointF &pos, quint32 time) override { | ||
1074 | auto seat = waylandServer()->seat(); | 1074 | auto seat = waylandServer()->seat(); | ||
1075 | if (seat->isTouchSequence()) { | 1075 | if (seat->isTouchSequence()) { | ||
1076 | return false; | 1076 | return false; | ||
1077 | } | 1077 | } | ||
1078 | if (input()->touch()->decorationPressId() != -1) { | 1078 | if (input()->touch()->decorationPressId() != -1) { | ||
1079 | // already on a decoration, ignore further touch points, but filter out | 1079 | // already on a decoration, ignore further touch points, but filter out | ||
1080 | return true; | 1080 | return true; | ||
1081 | } | 1081 | } | ||
Show All 13 Lines | |||||
1095 | QMouseEvent e(QEvent::MouseButtonPress, m_lastLocalTouchPos, pos, Qt::LeftButton, Qt::LeftButton, input()->keyboardModifiers()); | 1095 | QMouseEvent e(QEvent::MouseButtonPress, m_lastLocalTouchPos, pos, Qt::LeftButton, Qt::LeftButton, input()->keyboardModifiers()); | ||
1096 | e.setAccepted(false); | 1096 | e.setAccepted(false); | ||
1097 | QCoreApplication::sendEvent(decoration->decoration(), &e); | 1097 | QCoreApplication::sendEvent(decoration->decoration(), &e); | ||
1098 | if (!e.isAccepted()) { | 1098 | if (!e.isAccepted()) { | ||
1099 | decoration->client()->processDecorationButtonPress(&e); | 1099 | decoration->client()->processDecorationButtonPress(&e); | ||
1100 | } | 1100 | } | ||
1101 | return true; | 1101 | return true; | ||
1102 | } | 1102 | } | ||
1103 | bool touchMotion(quint32 id, const QPointF &pos, quint32 time) override { | 1103 | bool touchMotion(qint32 id, const QPointF &pos, quint32 time) override { | ||
1104 | Q_UNUSED(time) | 1104 | Q_UNUSED(time) | ||
1105 | auto decoration = input()->touch()->decoration(); | 1105 | auto decoration = input()->touch()->decoration(); | ||
1106 | if (!decoration) { | 1106 | if (!decoration) { | ||
1107 | return false; | 1107 | return false; | ||
1108 | } | 1108 | } | ||
1109 | if (input()->touch()->decorationPressId() == -1) { | 1109 | if (input()->touch()->decorationPressId() == -1) { | ||
1110 | return false; | 1110 | return false; | ||
1111 | } | 1111 | } | ||
1112 | if (input()->touch()->decorationPressId() != qint32(id)) { | 1112 | if (input()->touch()->decorationPressId() != qint32(id)) { | ||
1113 | // ignore, but filter out | 1113 | // ignore, but filter out | ||
1114 | return true; | 1114 | return true; | ||
1115 | } | 1115 | } | ||
1116 | m_lastGlobalTouchPos = pos; | 1116 | m_lastGlobalTouchPos = pos; | ||
1117 | m_lastLocalTouchPos = pos - decoration->client()->pos(); | 1117 | m_lastLocalTouchPos = pos - decoration->client()->pos(); | ||
1118 | 1118 | | |||
1119 | QHoverEvent e(QEvent::HoverMove, m_lastLocalTouchPos, m_lastLocalTouchPos); | 1119 | QHoverEvent e(QEvent::HoverMove, m_lastLocalTouchPos, m_lastLocalTouchPos); | ||
1120 | QCoreApplication::instance()->sendEvent(decoration->decoration(), &e); | 1120 | QCoreApplication::instance()->sendEvent(decoration->decoration(), &e); | ||
1121 | decoration->client()->processDecorationMove(m_lastLocalTouchPos.toPoint(), pos.toPoint()); | 1121 | decoration->client()->processDecorationMove(m_lastLocalTouchPos.toPoint(), pos.toPoint()); | ||
1122 | return true; | 1122 | return true; | ||
1123 | } | 1123 | } | ||
1124 | bool touchUp(quint32 id, quint32 time) override { | 1124 | bool touchUp(qint32 id, quint32 time) override { | ||
1125 | Q_UNUSED(time); | 1125 | Q_UNUSED(time); | ||
1126 | auto decoration = input()->touch()->decoration(); | 1126 | auto decoration = input()->touch()->decoration(); | ||
1127 | if (!decoration) { | 1127 | if (!decoration) { | ||
1128 | return false; | 1128 | return false; | ||
1129 | } | 1129 | } | ||
1130 | if (input()->touch()->decorationPressId() == -1) { | 1130 | if (input()->touch()->decorationPressId() == -1) { | ||
1131 | return false; | 1131 | return false; | ||
1132 | } | 1132 | } | ||
▲ Show 20 Lines • Show All 63 Lines • ▼ Show 20 Line(s) | |||||
1196 | { | 1196 | { | ||
1197 | public: | 1197 | public: | ||
1198 | bool pointerEvent(QMouseEvent *event, quint32 nativeButton) override { | 1198 | bool pointerEvent(QMouseEvent *event, quint32 nativeButton) override { | ||
1199 | Q_UNUSED(nativeButton) | 1199 | Q_UNUSED(nativeButton) | ||
1200 | ScreenEdges::self()->isEntered(event); | 1200 | ScreenEdges::self()->isEntered(event); | ||
1201 | // always forward | 1201 | // always forward | ||
1202 | return false; | 1202 | return false; | ||
1203 | } | 1203 | } | ||
1204 | bool touchDown(quint32 id, const QPointF &pos, quint32 time) override { | 1204 | bool touchDown(qint32 id, const QPointF &pos, quint32 time) override { | ||
1205 | Q_UNUSED(time) | 1205 | Q_UNUSED(time) | ||
1206 | // TODO: better check whether a touch sequence is in progress | 1206 | // TODO: better check whether a touch sequence is in progress | ||
1207 | if (m_touchInProgress || waylandServer()->seat()->isTouchSequence()) { | 1207 | if (m_touchInProgress || waylandServer()->seat()->isTouchSequence()) { | ||
1208 | // cancel existing touch | 1208 | // cancel existing touch | ||
1209 | ScreenEdges::self()->gestureRecognizer()->cancelSwipeGesture(); | 1209 | ScreenEdges::self()->gestureRecognizer()->cancelSwipeGesture(); | ||
1210 | m_touchInProgress = false; | 1210 | m_touchInProgress = false; | ||
1211 | m_id = 0; | 1211 | m_id = 0; | ||
1212 | return false; | 1212 | return false; | ||
1213 | } | 1213 | } | ||
1214 | if (ScreenEdges::self()->gestureRecognizer()->startSwipeGesture(pos) > 0) { | 1214 | if (ScreenEdges::self()->gestureRecognizer()->startSwipeGesture(pos) > 0) { | ||
1215 | m_touchInProgress = true; | 1215 | m_touchInProgress = true; | ||
1216 | m_id = id; | 1216 | m_id = id; | ||
1217 | m_lastPos = pos; | 1217 | m_lastPos = pos; | ||
1218 | return true; | 1218 | return true; | ||
1219 | } | 1219 | } | ||
1220 | return false; | 1220 | return false; | ||
1221 | } | 1221 | } | ||
1222 | bool touchMotion(quint32 id, const QPointF &pos, quint32 time) override { | 1222 | bool touchMotion(qint32 id, const QPointF &pos, quint32 time) override { | ||
1223 | Q_UNUSED(time) | 1223 | Q_UNUSED(time) | ||
1224 | if (m_touchInProgress && m_id == id) { | 1224 | if (m_touchInProgress && m_id == id) { | ||
1225 | ScreenEdges::self()->gestureRecognizer()->updateSwipeGesture(QSizeF(pos.x() - m_lastPos.x(), pos.y() - m_lastPos.y())); | 1225 | ScreenEdges::self()->gestureRecognizer()->updateSwipeGesture(QSizeF(pos.x() - m_lastPos.x(), pos.y() - m_lastPos.y())); | ||
1226 | m_lastPos = pos; | 1226 | m_lastPos = pos; | ||
1227 | return true; | 1227 | return true; | ||
1228 | } | 1228 | } | ||
1229 | return false; | 1229 | return false; | ||
1230 | } | 1230 | } | ||
1231 | bool touchUp(quint32 id, quint32 time) override { | 1231 | bool touchUp(qint32 id, quint32 time) override { | ||
1232 | Q_UNUSED(time) | 1232 | Q_UNUSED(time) | ||
1233 | if (m_touchInProgress && m_id == id) { | 1233 | if (m_touchInProgress && m_id == id) { | ||
1234 | ScreenEdges::self()->gestureRecognizer()->endSwipeGesture(); | 1234 | ScreenEdges::self()->gestureRecognizer()->endSwipeGesture(); | ||
1235 | m_touchInProgress = false; | 1235 | m_touchInProgress = false; | ||
1236 | return true; | 1236 | return true; | ||
1237 | } | 1237 | } | ||
1238 | return false; | 1238 | return false; | ||
1239 | } | 1239 | } | ||
1240 | private: | 1240 | private: | ||
1241 | bool m_touchInProgress = false; | 1241 | bool m_touchInProgress = false; | ||
1242 | quint32 m_id = 0; | 1242 | qint32 m_id = 0; | ||
1243 | QPointF m_lastPos; | 1243 | QPointF m_lastPos; | ||
1244 | }; | 1244 | }; | ||
1245 | 1245 | | |||
1246 | /** | 1246 | /** | ||
1247 | * This filter implements window actions. If the event should not be passed to the | 1247 | * This filter implements window actions. If the event should not be passed to the | ||
1248 | * current pointer window it will filter out the event | 1248 | * current pointer window it will filter out the event | ||
1249 | */ | 1249 | */ | ||
1250 | class WindowActionInputFilter : public InputEventFilter | 1250 | class WindowActionInputFilter : public InputEventFilter | ||
Show All 24 Lines | 1274 | if (!c) { | |||
1275 | return false; | 1275 | return false; | ||
1276 | } | 1276 | } | ||
1277 | const auto actionResult = performClientWheelAction(event, c, MouseAction::ModifierAndWindow); | 1277 | const auto actionResult = performClientWheelAction(event, c, MouseAction::ModifierAndWindow); | ||
1278 | if (actionResult.first) { | 1278 | if (actionResult.first) { | ||
1279 | return actionResult.second; | 1279 | return actionResult.second; | ||
1280 | } | 1280 | } | ||
1281 | return false; | 1281 | return false; | ||
1282 | } | 1282 | } | ||
1283 | bool touchDown(quint32 id, const QPointF &pos, quint32 time) override { | 1283 | bool touchDown(qint32 id, const QPointF &pos, quint32 time) override { | ||
1284 | Q_UNUSED(id) | 1284 | Q_UNUSED(id) | ||
1285 | Q_UNUSED(time) | 1285 | Q_UNUSED(time) | ||
1286 | auto seat = waylandServer()->seat(); | 1286 | auto seat = waylandServer()->seat(); | ||
1287 | if (seat->isTouchSequence()) { | 1287 | if (seat->isTouchSequence()) { | ||
1288 | return false; | 1288 | return false; | ||
1289 | } | 1289 | } | ||
1290 | AbstractClient *c = dynamic_cast<AbstractClient*>(input()->touch()->focus().data()); | 1290 | AbstractClient *c = dynamic_cast<AbstractClient*>(input()->touch()->focus().data()); | ||
1291 | if (!c) { | 1291 | if (!c) { | ||
▲ Show 20 Lines • Show All 72 Lines • ▼ Show 20 Line(s) | 1362 | if (event->isAutoRepeat()) { | |||
1364 | return false; | 1364 | return false; | ||
1365 | } | 1365 | } | ||
1366 | auto seat = waylandServer()->seat(); | 1366 | auto seat = waylandServer()->seat(); | ||
1367 | input()->keyboard()->update(); | 1367 | input()->keyboard()->update(); | ||
1368 | seat->setTimestamp(event->timestamp()); | 1368 | seat->setTimestamp(event->timestamp()); | ||
1369 | passToWaylandServer(event); | 1369 | passToWaylandServer(event); | ||
1370 | return true; | 1370 | return true; | ||
1371 | } | 1371 | } | ||
1372 | bool touchDown(quint32 id, const QPointF &pos, quint32 time) override { | 1372 | bool touchDown(qint32 id, const QPointF &pos, quint32 time) override { | ||
1373 | if (!workspace()) { | 1373 | if (!workspace()) { | ||
1374 | return false; | 1374 | return false; | ||
1375 | } | 1375 | } | ||
1376 | auto seat = waylandServer()->seat(); | 1376 | auto seat = waylandServer()->seat(); | ||
1377 | seat->setTimestamp(time); | 1377 | seat->setTimestamp(time); | ||
1378 | input()->touch()->insertId(id, seat->touchDown(pos)); | 1378 | input()->touch()->insertId(id, seat->touchDown(pos)); | ||
1379 | return true; | 1379 | return true; | ||
1380 | } | 1380 | } | ||
1381 | bool touchMotion(quint32 id, const QPointF &pos, quint32 time) override { | 1381 | bool touchMotion(qint32 id, const QPointF &pos, quint32 time) override { | ||
1382 | if (!workspace()) { | 1382 | if (!workspace()) { | ||
1383 | return false; | 1383 | return false; | ||
1384 | } | 1384 | } | ||
1385 | auto seat = waylandServer()->seat(); | 1385 | auto seat = waylandServer()->seat(); | ||
1386 | seat->setTimestamp(time); | 1386 | seat->setTimestamp(time); | ||
1387 | const qint32 kwaylandId = input()->touch()->mappedId(id); | 1387 | const qint32 kwaylandId = input()->touch()->mappedId(id); | ||
1388 | if (kwaylandId != -1) { | 1388 | if (kwaylandId != -1) { | ||
1389 | seat->touchMove(kwaylandId, pos); | 1389 | seat->touchMove(kwaylandId, pos); | ||
1390 | } | 1390 | } | ||
1391 | return true; | 1391 | return true; | ||
1392 | } | 1392 | } | ||
1393 | bool touchUp(quint32 id, quint32 time) override { | 1393 | bool touchUp(qint32 id, quint32 time) override { | ||
1394 | if (!workspace()) { | 1394 | if (!workspace()) { | ||
1395 | return false; | 1395 | return false; | ||
1396 | } | 1396 | } | ||
1397 | auto seat = waylandServer()->seat(); | 1397 | auto seat = waylandServer()->seat(); | ||
1398 | seat->setTimestamp(time); | 1398 | seat->setTimestamp(time); | ||
1399 | const qint32 kwaylandId = input()->touch()->mappedId(id); | 1399 | const qint32 kwaylandId = input()->touch()->mappedId(id); | ||
1400 | if (kwaylandId != -1) { | 1400 | if (kwaylandId != -1) { | ||
1401 | seat->touchUp(kwaylandId); | 1401 | seat->touchUp(kwaylandId); | ||
▲ Show 20 Lines • Show All 127 Lines • ▼ Show 20 Line(s) | 1527 | case QEvent::MouseButtonRelease: | |||
1529 | break; | 1529 | break; | ||
1530 | default: | 1530 | default: | ||
1531 | break; | 1531 | break; | ||
1532 | } | 1532 | } | ||
1533 | // TODO: should we pass through effects? | 1533 | // TODO: should we pass through effects? | ||
1534 | return true; | 1534 | return true; | ||
1535 | } | 1535 | } | ||
1536 | 1536 | | |||
1537 | bool touchDown(quint32 id, const QPointF &pos, quint32 time) override { | 1537 | bool touchDown(qint32 id, const QPointF &pos, quint32 time) override { | ||
1538 | auto seat = waylandServer()->seat(); | 1538 | auto seat = waylandServer()->seat(); | ||
1539 | if (seat->isDragPointer()) { | 1539 | if (seat->isDragPointer()) { | ||
1540 | return true; | 1540 | return true; | ||
1541 | } | 1541 | } | ||
1542 | if (!seat->isDragTouch()) { | 1542 | if (!seat->isDragTouch()) { | ||
1543 | return false; | 1543 | return false; | ||
1544 | } | 1544 | } | ||
1545 | if (m_touchId != id) { | 1545 | if (m_touchId != id) { | ||
1546 | return true; | 1546 | return true; | ||
1547 | } | 1547 | } | ||
1548 | seat->setTimestamp(time); | 1548 | seat->setTimestamp(time); | ||
1549 | input()->touch()->insertId(id, seat->touchDown(pos)); | 1549 | input()->touch()->insertId(id, seat->touchDown(pos)); | ||
1550 | return true; | 1550 | return true; | ||
1551 | } | 1551 | } | ||
1552 | bool touchMotion(quint32 id, const QPointF &pos, quint32 time) override { | 1552 | bool touchMotion(qint32 id, const QPointF &pos, quint32 time) override { | ||
1553 | auto seat = waylandServer()->seat(); | 1553 | auto seat = waylandServer()->seat(); | ||
1554 | if (seat->isDragPointer()) { | 1554 | if (seat->isDragPointer()) { | ||
1555 | return true; | 1555 | return true; | ||
1556 | } | 1556 | } | ||
1557 | if (!seat->isDragTouch()) { | 1557 | if (!seat->isDragTouch()) { | ||
1558 | return false; | 1558 | return false; | ||
1559 | } | 1559 | } | ||
1560 | if (m_touchId < 0) { | 1560 | if (m_touchId < 0) { | ||
Show All 22 Lines | 1579 | if (t->surface() != seat->dragSurface()) { | |||
1583 | seat->setDragTarget(t->surface(), pos, t->inputTransformation()); | 1583 | seat->setDragTarget(t->surface(), pos, t->inputTransformation()); | ||
1584 | } | 1584 | } | ||
1585 | } else { | 1585 | } else { | ||
1586 | // no window at that place, if we have a surface we need to reset | 1586 | // no window at that place, if we have a surface we need to reset | ||
1587 | seat->setDragTarget(nullptr); | 1587 | seat->setDragTarget(nullptr); | ||
1588 | } | 1588 | } | ||
1589 | return true; | 1589 | return true; | ||
1590 | } | 1590 | } | ||
1591 | bool touchUp(quint32 id, quint32 time) override { | 1591 | bool touchUp(qint32 id, quint32 time) override { | ||
1592 | auto seat = waylandServer()->seat(); | 1592 | auto seat = waylandServer()->seat(); | ||
1593 | if (!seat->isDragTouch()) { | 1593 | if (!seat->isDragTouch()) { | ||
1594 | return false; | 1594 | return false; | ||
1595 | } | 1595 | } | ||
1596 | seat->setTimestamp(time); | 1596 | seat->setTimestamp(time); | ||
1597 | const qint32 kwaylandId = input()->touch()->mappedId(id); | 1597 | const qint32 kwaylandId = input()->touch()->mappedId(id); | ||
1598 | if (kwaylandId != -1) { | 1598 | if (kwaylandId != -1) { | ||
1599 | seat->touchUp(kwaylandId); | 1599 | seat->touchUp(kwaylandId); | ||
▲ Show 20 Lines • Show All 144 Lines • ▼ Show 20 Line(s) | 1742 | default: | |||
1744 | break; | 1744 | break; | ||
1745 | } | 1745 | } | ||
1746 | // TODO: Fix time | 1746 | // TODO: Fix time | ||
1747 | m_pointer->processAxis(axis, delta, 0, InputRedirection::PointerAxisSourceUnknown, 0); | 1747 | m_pointer->processAxis(axis, delta, 0, InputRedirection::PointerAxisSourceUnknown, 0); | ||
1748 | waylandServer()->simulateUserActivity(); | 1748 | waylandServer()->simulateUserActivity(); | ||
1749 | } | 1749 | } | ||
1750 | ); | 1750 | ); | ||
1751 | connect(device, &FakeInputDevice::touchDownRequested, this, | 1751 | connect(device, &FakeInputDevice::touchDownRequested, this, | ||
1752 | [this] (quint32 id, const QPointF &pos) { | 1752 | [this] (qint32 id, const QPointF &pos) { | ||
1753 | // TODO: Fix time | 1753 | // TODO: Fix time | ||
1754 | m_touch->processDown(id, pos, 0); | 1754 | m_touch->processDown(id, pos, 0); | ||
1755 | waylandServer()->simulateUserActivity(); | 1755 | waylandServer()->simulateUserActivity(); | ||
1756 | } | 1756 | } | ||
1757 | ); | 1757 | ); | ||
1758 | connect(device, &FakeInputDevice::touchMotionRequested, this, | 1758 | connect(device, &FakeInputDevice::touchMotionRequested, this, | ||
1759 | [this] (quint32 id, const QPointF &pos) { | 1759 | [this] (qint32 id, const QPointF &pos) { | ||
1760 | // TODO: Fix time | 1760 | // TODO: Fix time | ||
1761 | m_touch->processMotion(id, pos, 0); | 1761 | m_touch->processMotion(id, pos, 0); | ||
1762 | waylandServer()->simulateUserActivity(); | 1762 | waylandServer()->simulateUserActivity(); | ||
1763 | } | 1763 | } | ||
1764 | ); | 1764 | ); | ||
1765 | connect(device, &FakeInputDevice::touchUpRequested, this, | 1765 | connect(device, &FakeInputDevice::touchUpRequested, this, | ||
1766 | [this] (quint32 id) { | 1766 | [this] (qint32 id) { | ||
1767 | // TODO: Fix time | 1767 | // TODO: Fix time | ||
1768 | m_touch->processUp(id, 0); | 1768 | m_touch->processUp(id, 0); | ||
1769 | waylandServer()->simulateUserActivity(); | 1769 | waylandServer()->simulateUserActivity(); | ||
1770 | } | 1770 | } | ||
1771 | ); | 1771 | ); | ||
1772 | connect(device, &FakeInputDevice::touchCancelRequested, this, | 1772 | connect(device, &FakeInputDevice::touchCancelRequested, this, | ||
1773 | [this] () { | 1773 | [this] () { | ||
1774 | m_touch->cancel(); | 1774 | m_touch->cancel(); | ||
▲ Show 20 Lines • Show All 652 Lines • Show Last 20 Lines |