Changeset View
Changeset View
Standalone View
Standalone View
pointer_input.cpp
Show First 20 Lines • Show All 550 Lines • ▼ Show 20 Line(s) | 538 | [this] { | |||
---|---|---|---|---|---|
551 | seat->setFocusedPointerSurfaceTransformation(m_window.data()->inputTransformation()); | 551 | seat->setFocusedPointerSurfaceTransformation(m_window.data()->inputTransformation()); | ||
552 | } | 552 | } | ||
553 | ); | 553 | ); | ||
554 | m_constraintsConnection = connect(m_window->surface(), &KWayland::Server::SurfaceInterface::pointerConstraintsChanged, | 554 | m_constraintsConnection = connect(m_window->surface(), &KWayland::Server::SurfaceInterface::pointerConstraintsChanged, | ||
555 | this, &PointerInputRedirection::updatePointerConstraints); | 555 | this, &PointerInputRedirection::updatePointerConstraints); | ||
556 | m_constraintsActivatedConnection = connect(workspace(), &Workspace::clientActivated, | 556 | m_constraintsActivatedConnection = connect(workspace(), &Workspace::clientActivated, | ||
557 | this, &PointerInputRedirection::updatePointerConstraints); | 557 | this, &PointerInputRedirection::updatePointerConstraints); | ||
558 | // check whether a pointer confinement/lock fires | 558 | // check whether a pointer confinement/lock fires | ||
559 | m_blockConstraint = false; | | |||
560 | updatePointerConstraints(); | 559 | updatePointerConstraints(); | ||
561 | } else { | 560 | } else { | ||
562 | m_window.clear(); | 561 | m_window.clear(); | ||
563 | warpXcbOnSurfaceLeft(nullptr); | 562 | warpXcbOnSurfaceLeft(nullptr); | ||
564 | seat->setFocusedPointerSurface(nullptr); | 563 | seat->setFocusedPointerSurface(nullptr); | ||
565 | t = nullptr; | 564 | t = nullptr; | ||
566 | } | 565 | } | ||
567 | } | 566 | } | ||
Show All 11 Lines | 577 | if (l && l->isLocked()) { | |||
579 | l->setLocked(false); | 578 | l->setLocked(false); | ||
580 | } | 579 | } | ||
581 | } | 580 | } | ||
582 | disconnectConfinedPointerRegionConnection(); | 581 | disconnectConfinedPointerRegionConnection(); | ||
583 | m_confined = false; | 582 | m_confined = false; | ||
584 | m_locked = false; | 583 | m_locked = false; | ||
585 | } | 584 | } | ||
586 | 585 | | |||
587 | void PointerInputRedirection::breakPointerConstraints() | | |||
588 | { | | |||
589 | breakPointerConstraints(m_window ? m_window->surface() : nullptr); | | |||
590 | } | | |||
591 | | ||||
592 | void PointerInputRedirection::disconnectConfinedPointerRegionConnection() | 586 | void PointerInputRedirection::disconnectConfinedPointerRegionConnection() | ||
593 | { | 587 | { | ||
594 | disconnect(m_confinedPointerRegionConnection); | 588 | disconnect(m_confinedPointerRegionConnection); | ||
595 | m_confinedPointerRegionConnection = QMetaObject::Connection(); | 589 | m_confinedPointerRegionConnection = QMetaObject::Connection(); | ||
596 | } | 590 | } | ||
597 | 591 | | |||
598 | void PointerInputRedirection::disconnectLockedPointerAboutToBeUnboundConnection() | 592 | void PointerInputRedirection::disconnectLockedPointerAboutToBeUnboundConnection() | ||
599 | { | 593 | { | ||
Show All 38 Lines | 631 | if (!s) { | |||
638 | return; | 632 | return; | ||
639 | } | 633 | } | ||
640 | if (s != waylandServer()->seat()->focusedPointerSurface()) { | 634 | if (s != waylandServer()->seat()->focusedPointerSurface()) { | ||
641 | return; | 635 | return; | ||
642 | } | 636 | } | ||
643 | if (!supportsWarping()) { | 637 | if (!supportsWarping()) { | ||
644 | return; | 638 | return; | ||
645 | } | 639 | } | ||
646 | if (m_blockConstraint) { | | |||
647 | return; | | |||
648 | } | | |||
649 | const bool canConstrain = m_enableConstraints && m_window == workspace()->activeClient(); | 640 | const bool canConstrain = m_enableConstraints && m_window == workspace()->activeClient(); | ||
650 | const auto cf = s->confinedPointer(); | 641 | const auto cf = s->confinedPointer(); | ||
651 | if (cf) { | 642 | if (cf) { | ||
652 | if (cf->isConfined()) { | 643 | if (cf->isConfined()) { | ||
653 | if (!canConstrain) { | 644 | if (!canConstrain) { | ||
654 | cf->setConfined(false); | 645 | cf->setConfined(false); | ||
655 | m_confined = false; | 646 | m_confined = false; | ||
656 | disconnectConfinedPointerRegionConnection(); | 647 | disconnectConfinedPointerRegionConnection(); | ||
Show All 21 Lines | 656 | [this] { | |||
678 | } else { | 669 | } else { | ||
679 | if (!cf->isConfined()) { | 670 | if (!cf->isConfined()) { | ||
680 | cf->setConfined(true); | 671 | cf->setConfined(true); | ||
681 | m_confined = true; | 672 | m_confined = true; | ||
682 | } | 673 | } | ||
683 | } | 674 | } | ||
684 | } | 675 | } | ||
685 | ); | 676 | ); | ||
686 | OSD::show(i18nc("notification about mouse pointer confined", | | |||
687 | "Pointer motion confined to the current window.\nTo release pointer hold Escape for 3 seconds."), | | |||
688 | QStringLiteral("preferences-desktop-mouse"), 5000); | | |||
689 | return; | 677 | return; | ||
690 | } | 678 | } | ||
691 | } else { | 679 | } else { | ||
692 | m_confined = false; | 680 | m_confined = false; | ||
693 | disconnectConfinedPointerRegionConnection(); | 681 | disconnectConfinedPointerRegionConnection(); | ||
694 | } | 682 | } | ||
695 | const auto lock = s->lockedPointer(); | 683 | const auto lock = s->lockedPointer(); | ||
696 | if (lock) { | 684 | if (lock) { | ||
Show All 26 Lines | 705 | [this, lock]() { | |||
723 | 711 | | |||
724 | // When the resource finally goes away, reposition the cursor according to the hint | 712 | // When the resource finally goes away, reposition the cursor according to the hint | ||
725 | connect(lock.data(), &KWayland::Server::LockedPointerInterface::unbound, this, | 713 | connect(lock.data(), &KWayland::Server::LockedPointerInterface::unbound, this, | ||
726 | [this, globalHint]() { | 714 | [this, globalHint]() { | ||
727 | processMotion(globalHint, waylandServer()->seat()->timestamp()); | 715 | processMotion(globalHint, waylandServer()->seat()->timestamp()); | ||
728 | }); | 716 | }); | ||
729 | } | 717 | } | ||
730 | ); | 718 | ); | ||
731 | OSD::show(i18nc("notification about mouse pointer locked", | | |||
732 | "Pointer locked to current position.\nTo end pointer lock hold Escape for 3 seconds."), | | |||
733 | QStringLiteral("preferences-desktop-mouse"), 5000); | | |||
734 | // TODO: connect to region change - is it needed at all? If the pointer is locked it's always in the region | 719 | // TODO: connect to region change - is it needed at all? If the pointer is locked it's always in the region | ||
735 | } | 720 | } | ||
736 | } else { | 721 | } else { | ||
737 | m_locked = false; | 722 | m_locked = false; | ||
738 | disconnectLockedPointerAboutToBeUnboundConnection(); | 723 | disconnectLockedPointerAboutToBeUnboundConnection(); | ||
739 | } | 724 | } | ||
740 | } | 725 | } | ||
741 | 726 | | |||
▲ Show 20 Lines • Show All 643 Lines • Show Last 20 Lines |