summaryrefslogtreecommitdiff
path: root/src/managers/input
diff options
context:
space:
mode:
authorVaxry <vaxry@vaxry.net>2024-04-26 23:55:41 +0100
committerVaxry <vaxry@vaxry.net>2024-04-27 03:17:04 +0100
commit25aec3ac8ce65ed224f025f8f6dfef73780577a4 (patch)
tree9fa63de1670bd2f535f3bc237800fc6b7a81f646 /src/managers/input
parentf94264928a8ab4da8759d4ded25a46af44451d38 (diff)
pointer-constraints: move to new impl
Diffstat (limited to 'src/managers/input')
-rw-r--r--src/managers/input/InputManager.cpp19
-rw-r--r--src/managers/input/InputManager.hpp31
2 files changed, 31 insertions, 19 deletions
diff --git a/src/managers/input/InputManager.cpp b/src/managers/input/InputManager.cpp
index b5d6bb5c..b930838b 100644
--- a/src/managers/input/InputManager.cpp
+++ b/src/managers/input/InputManager.cpp
@@ -7,6 +7,7 @@
#include "../../protocols/CursorShape.hpp"
#include "../../protocols/IdleInhibit.hpp"
#include "../../protocols/RelativePointer.hpp"
+#include "../../protocols/PointerConstraints.hpp"
CInputManager::CInputManager() {
m_sListeners.setCursorShape = PROTO::cursorShape->events.setShape.registerListener([this](std::any data) {
@@ -193,7 +194,7 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus) {
return;
} else
- Debug::log(ERR, "BUG THIS: Null SURF/CONSTRAINT in mouse refocus. Ignoring constraints. {:x} {:x}", (uintptr_t)SURF, (uintptr_t)CONSTRAINT);
+ Debug::log(ERR, "BUG THIS: Null SURF/CONSTRAINT in mouse refocus. Ignoring constraints. {:x} {:x}", (uintptr_t)SURF, (uintptr_t)CONSTRAINT.get());
}
// update stuff
@@ -1298,16 +1299,26 @@ void CInputManager::unconstrainMouse() {
return;
for (auto& c : m_vConstraints) {
- if (!c->active())
+ const auto C = c.lock();
+
+ if (!C)
+ continue;
+
+ if (!C->isActive())
continue;
- c->deactivate();
+ C->deactivate();
}
}
bool CInputManager::isConstrained() {
for (auto& c : m_vConstraints) {
- if (!c->active() || c->owner()->wlr() != g_pCompositor->m_pLastFocus)
+ const auto C = c.lock();
+
+ if (!C)
+ continue;
+
+ if (!C->isActive() || C->owner()->wlr() != g_pCompositor->m_pLastFocus)
continue;
return true;
diff --git a/src/managers/input/InputManager.hpp b/src/managers/input/InputManager.hpp
index bb5d1cf7..2795d410 100644
--- a/src/managers/input/InputManager.hpp
+++ b/src/managers/input/InputManager.hpp
@@ -8,7 +8,7 @@
#include "InputMethodRelay.hpp"
#include "../../helpers/signal/Listener.hpp"
-class CConstraint;
+class CPointerConstraint;
class CWindow;
class CIdleInhibitor;
@@ -141,27 +141,28 @@ class CInputManager {
std::deque<SLayerSurface*> m_dExclusiveLSes;
// constraints
- std::vector<CConstraint*> m_vConstraints;
+ std::vector<std::weak_ptr<CPointerConstraint>> m_vConstraints;
- void newTabletTool(wlr_input_device*);
- void newTabletPad(wlr_input_device*);
- void focusTablet(STablet*, wlr_tablet_tool*, bool motion = false);
- void newIdleInhibitor(std::any);
- void recheckIdleInhibitorStatus();
+ //
+ void newTabletTool(wlr_input_device*);
+ void newTabletPad(wlr_input_device*);
+ void focusTablet(STablet*, wlr_tablet_tool*, bool motion = false);
+ void newIdleInhibitor(std::any);
+ void recheckIdleInhibitorStatus();
- void onSwipeBegin(wlr_pointer_swipe_begin_event*);
- void onSwipeEnd(wlr_pointer_swipe_end_event*);
- void onSwipeUpdate(wlr_pointer_swipe_update_event*);
+ void onSwipeBegin(wlr_pointer_swipe_begin_event*);
+ void onSwipeEnd(wlr_pointer_swipe_end_event*);
+ void onSwipeUpdate(wlr_pointer_swipe_update_event*);
- SSwipeGesture m_sActiveSwipe;
+ SSwipeGesture m_sActiveSwipe;
- SKeyboard* m_pActiveKeyboard = nullptr;
+ SKeyboard* m_pActiveKeyboard = nullptr;
- CTimer m_tmrLastCursorMovement;
+ CTimer m_tmrLastCursorMovement;
- CInputMethodRelay m_sIMERelay;
+ CInputMethodRelay m_sIMERelay;
- void updateKeyboardsLeds(wlr_input_device* pKeyboard);
+ void updateKeyboardsLeds(wlr_input_device* pKeyboard);
// for shared mods
uint32_t accumulateModsFromAllKBs();