| 707 | } |
| 708 | |
| 709 | void PointerInputRedirection::updatePointerConstraints() |
| 710 | { |
| 711 | if (!focus()) { |
| 712 | return; |
| 713 | } |
| 714 | const auto s = focus()->surface(); |
| 715 | if (!s) { |
| 716 | return; |
| 717 | } |
| 718 | if (s != waylandServer()->seat()->focusedPointerSurface()) { |
| 719 | return; |
| 720 | } |
| 721 | if (!supportsWarping()) { |
| 722 | return; |
| 723 | } |
| 724 | const bool canConstrain = m_enableConstraints && focus() == workspace()->activeWindow(); |
| 725 | const auto cf = s->confinedPointer(); |
| 726 | if (cf) { |
| 727 | if (cf->isConfined()) { |
| 728 | if (!canConstrain) { |
| 729 | cf->setConfined(false); |
| 730 | m_confined = false; |
| 731 | disconnectConfinedPointerRegionConnection(); |
| 732 | } |
| 733 | return; |
| 734 | } |
| 735 | if (canConstrain && cf->region().contains(focus()->mapToLocal(m_pos))) { |
| 736 | cf->setConfined(true); |
| 737 | m_confined = true; |
| 738 | m_confinedPointerRegionConnection = connect(cf, &ConfinedPointerV1Interface::regionChanged, this, [this]() { |
| 739 | if (!focus()) { |
| 740 | return; |
| 741 | } |
| 742 | const auto s = focus()->surface(); |
| 743 | if (!s) { |
| 744 | return; |
| 745 | } |
| 746 | const auto cf = s->confinedPointer(); |
| 747 | if (!cf->region().contains(focus()->mapToLocal(m_pos))) { |
| 748 | // pointer no longer in confined region, break the confinement |
| 749 | cf->setConfined(false); |
| 750 | m_confined = false; |
| 751 | } else { |
| 752 | if (!cf->isConfined()) { |
| 753 | cf->setConfined(true); |
| 754 | m_confined = true; |
| 755 | } |
| 756 | } |
| 757 | }); |
| 758 | return; |
| 759 | } |
| 760 | } else { |
| 761 | m_confined = false; |
| 762 | disconnectConfinedPointerRegionConnection(); |
| 763 | } |
| 764 | const auto lock = s->lockedPointer(); |
| 765 | if (lock) { |
| 766 | if (lock->isLocked()) { |
nothing calls this directly
no test coverage detected