summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorvaxerski <vaxry@vaxry.net>2022-08-09 20:36:21 +0200
committervaxerski <vaxry@vaxry.net>2022-08-09 20:36:21 +0200
commit8e5985d70e3370bc2c6155b58488499d5f6f067d (patch)
tree8bba4fb7e80693b0dc71a3c6dcf796910497dee1 /src
parent9255a4d2ffee15cf6cd54d92a52837fc9f253d5c (diff)
clean up unconstraining logic
Diffstat (limited to 'src')
-rw-r--r--src/managers/KeybindManager.cpp4
-rw-r--r--src/managers/input/InputManager.cpp29
-rw-r--r--src/managers/input/InputManager.hpp1
-rw-r--r--src/managers/input/Swipe.cpp4
4 files changed, 31 insertions, 7 deletions
diff --git a/src/managers/KeybindManager.cpp b/src/managers/KeybindManager.cpp
index 5e8a0a8a..c5899bf9 100644
--- a/src/managers/KeybindManager.cpp
+++ b/src/managers/KeybindManager.cpp
@@ -467,7 +467,7 @@ void CKeybindManager::changeworkspace(std::string args) {
}
// remove constraints
- g_pCompositor->m_sSeat.mouse->constraintActive = false;
+ g_pInputManager->unconstrainMouse();
// if it exists, we warp to it
if (g_pCompositor->getWorkspaceByID(workspaceToChangeTo)) {
@@ -745,7 +745,7 @@ void CKeybindManager::moveFocusTo(std::string args) {
return;
// remove constraints
- g_pCompositor->m_sSeat.mouse->constraintActive = false;
+ g_pInputManager->unconstrainMouse();
auto switchToWindow = [&](CWindow* PWINDOWTOCHANGETO) {
diff --git a/src/managers/input/InputManager.cpp b/src/managers/input/InputManager.cpp
index e8f204b7..597d87fa 100644
--- a/src/managers/input/InputManager.cpp
+++ b/src/managers/input/InputManager.cpp
@@ -68,7 +68,7 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus) {
const auto CONSTRAINTWINDOW = g_pCompositor->getConstraintWindow(g_pCompositor->m_sSeat.mouse);
if (!CONSTRAINTWINDOW) {
- g_pCompositor->m_sSeat.mouse->currentConstraint = nullptr;
+ unconstrainMouse();
} else {
// Native Wayland apps know how 2 constrain themselves.
// XWayland, we just have to accept them. Might cause issues, but thats XWayland for ya.
@@ -315,7 +315,7 @@ void CInputManager::setClickMode(eClickBehaviorMode mode) {
m_ecbClickBehavior = CLICKMODE_KILL;
// remove constraints
- g_pCompositor->m_sSeat.mouse->constraintActive = false;
+ g_pInputManager->unconstrainMouse();
refocus();
// set cursor
@@ -690,7 +690,7 @@ void CInputManager::destroyMouse(wlr_input_device* mouse) {
g_pCompositor->m_sSeat.mouse = m_lMice.size() > 0 ? &m_lMice.front() : nullptr;
if (g_pCompositor->m_sSeat.mouse)
- g_pCompositor->m_sSeat.mouse->currentConstraint = nullptr;
+ unconstrainMouse();
}
void CInputManager::onKeyboardKey(wlr_keyboard_key_event* e, SKeyboard* pKeyboard) {
@@ -817,6 +817,29 @@ void CInputManager::constrainMouse(SMouse* pMouse, wlr_pointer_constraint_v1* co
Debug::log(LOG, "Constrained mouse to %x", pMouse->currentConstraint);
}
+void CInputManager::unconstrainMouse() {
+ if (!g_pCompositor->m_sSeat.mouse->currentConstraint)
+ return;
+
+ const auto CONSTRAINTWINDOW = g_pCompositor->getConstraintWindow(g_pCompositor->m_sSeat.mouse);
+
+ if (CONSTRAINTWINDOW) {
+ if (CONSTRAINTWINDOW->m_bIsX11) {
+ wlr_xwayland_surface_activate(CONSTRAINTWINDOW->m_uSurface.xwayland, false);
+ } else {
+ wlr_xdg_toplevel_set_activated(CONSTRAINTWINDOW->m_uSurface.xdg->toplevel, false);
+ }
+ }
+
+ wlr_pointer_constraint_v1_send_deactivated(g_pCompositor->m_sSeat.mouse->currentConstraint);
+ g_pCompositor->m_sSeat.mouse->constraintActive = false;
+
+ // TODO: its better to somehow detect the workspace...
+ g_pCompositor->m_sSeat.mouse->currentConstraint = nullptr;
+
+ g_pCompositor->m_sSeat.mouse->hyprListener_commitConstraint.removeCallback();
+}
+
void Events::listener_commitConstraint(void* owner, void* data) {
//g_pInputManager->recheckConstraint((SMouse*)owner);
}
diff --git a/src/managers/input/InputManager.hpp b/src/managers/input/InputManager.hpp
index 188d288f..b9e04d23 100644
--- a/src/managers/input/InputManager.hpp
+++ b/src/managers/input/InputManager.hpp
@@ -34,6 +34,7 @@ public:
void constrainMouse(SMouse*, wlr_pointer_constraint_v1*);
void recheckConstraint(SMouse*);
+ void unconstrainMouse();
Vector2D getMouseCoordsInternal();
void refocus();
diff --git a/src/managers/input/Swipe.cpp b/src/managers/input/Swipe.cpp
index 7dd3128a..195882c3 100644
--- a/src/managers/input/Swipe.cpp
+++ b/src/managers/input/Swipe.cpp
@@ -79,7 +79,7 @@ void CInputManager::onSwipeEnd(wlr_pointer_swipe_end_event* e) {
m_sActiveSwipe.pWorkspaceBegin->m_vRenderOffset = Vector2D(m_sActiveSwipe.pMonitor->vecSize.x, 0);
m_sActiveSwipe.pWorkspaceBegin->m_fAlpha.setValueAndWarp(255.f);
- g_pCompositor->m_sSeat.mouse->currentConstraint = nullptr;
+ g_pInputManager->unconstrainMouse();
Debug::log(LOG, "Ended swipe to the left");
} else {
@@ -95,7 +95,7 @@ void CInputManager::onSwipeEnd(wlr_pointer_swipe_end_event* e) {
m_sActiveSwipe.pWorkspaceBegin->m_vRenderOffset = Vector2D(-m_sActiveSwipe.pMonitor->vecSize.x, 0);
m_sActiveSwipe.pWorkspaceBegin->m_fAlpha.setValueAndWarp(255.f);
- g_pCompositor->m_sSeat.mouse->currentConstraint = nullptr;
+ g_pInputManager->unconstrainMouse();
Debug::log(LOG, "Ended swipe to the right");
}