diff --git a/input.cpp b/input.cpp index 045873b880..de215cfef7 100644 --- a/input.cpp +++ b/input.cpp @@ -1197,6 +1197,7 @@ public: } auto seat = waylandServer()->seat(); seat->setFocusedKeyboardSurface(nullptr); + input()->pointer()->setEnableConstraints(false); // pass the key event to the seat, so that it has a proper model of the currently hold keys // this is important for combinations like alt+shift to ensure that shift is not considered pressed passToWaylandServer(event); diff --git a/pointer_input.cpp b/pointer_input.cpp index 4831ae50f7..68c9e7e08a 100644 --- a/pointer_input.cpp +++ b/pointer_input.cpp @@ -612,6 +612,15 @@ static QRegion getConstraintRegion(Toplevel *t, T *constraint) return intersected.translated(t->pos() + t->clientPos()); } +void PointerInputRedirection::setEnableConstraints(bool set) +{ + if (m_enableConstraints == set) { + return; + } + m_enableConstraints = set; + updatePointerConstraints(); +} + void PointerInputRedirection::updatePointerConstraints() { if (m_window.isNull()) { @@ -630,11 +639,11 @@ void PointerInputRedirection::updatePointerConstraints() if (m_blockConstraint) { return; } - const bool windowIsActive = m_window == workspace()->activeClient(); + const bool canConstrain = m_enableConstraints && m_window == workspace()->activeClient(); const auto cf = s->confinedPointer(); if (cf) { if (cf->isConfined()) { - if (!windowIsActive) { + if (!canConstrain) { cf->setConfined(false); m_confined = false; disconnectConfinedPointerRegionConnection(); @@ -642,7 +651,7 @@ void PointerInputRedirection::updatePointerConstraints() return; } const QRegion r = getConstraintRegion(m_window.data(), cf.data()); - if (windowIsActive && r.contains(m_pos.toPoint())) { + if (canConstrain && r.contains(m_pos.toPoint())) { cf->setConfined(true); m_confined = true; m_confinedPointerRegionConnection = connect(cf.data(), &KWayland::Server::ConfinedPointerInterface::regionChanged, this, @@ -679,14 +688,14 @@ void PointerInputRedirection::updatePointerConstraints() const auto lock = s->lockedPointer(); if (lock) { if (lock->isLocked()) { - if (!windowIsActive) { + if (!canConstrain) { lock->setLocked(false); m_locked = false; } return; } const QRegion r = getConstraintRegion(m_window.data(), lock.data()); - if (windowIsActive && r.contains(m_pos.toPoint())) { + if (canConstrain && r.contains(m_pos.toPoint())) { lock->setLocked(true); m_locked = true; OSD::show(i18nc("notification about mouse pointer locked", diff --git a/pointer_input.h b/pointer_input.h index 8226e2982d..05d7f4c6ef 100644 --- a/pointer_input.h +++ b/pointer_input.h @@ -92,6 +92,8 @@ public: m_blockConstraint = true; } + void setEnableConstraints(bool set); + bool isConstrained() const { return m_confined || m_locked; } @@ -171,6 +173,7 @@ private: bool m_confined = false; bool m_locked = false; bool m_blockConstraint = false; + bool m_enableConstraints = true; }; class CursorImage : public QObject diff --git a/tabbox/tabbox.cpp b/tabbox/tabbox.cpp index 42651c6be8..473e501302 100644 --- a/tabbox/tabbox.cpp +++ b/tabbox/tabbox.cpp @@ -38,6 +38,7 @@ along with this program. If not, see . #include "effects.h" #include "input.h" #include "keyboard_input.h" +#include "pointer_input.h" #include "focuschain.h" #include "screenedge.h" #include "screens.h" @@ -1483,6 +1484,7 @@ void TabBox::close(bool abort) removeTabBoxGrab(); } hide(abort); + input()->pointer()->setEnableConstraints(true); m_tabGrab = false; m_desktopGrab = false; m_noModifierGrab = false;