MCPcopy Create free account
hub / github.com/KDE/kwin / updatePointerConstraints

Method updatePointerConstraints

src/pointer_input.cpp:709–802  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

707}
708
709void 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()) {

Callers

nothing calls this directly

Calls 15

waylandServerFunction · 0.85
workspaceFunction · 0.85
focusedPointerSurfaceMethod · 0.80
confinedPointerMethod · 0.80
setConfinedMethod · 0.80
mapToLocalMethod · 0.80
lockedPointerMethod · 0.80
cursorPositionHintMethod · 0.80
setLockedMethod · 0.80
mapFromLocalMethod · 0.80
surfaceMethod · 0.45
seatMethod · 0.45

Tested by

no test coverage detected