diff options
author | vaxerski <[email protected]> | 2022-06-09 19:38:39 +0200 |
---|---|---|
committer | vaxerski <[email protected]> | 2022-06-09 19:38:39 +0200 |
commit | 09b130374df035188b34a36e55d6fdda935c7df8 (patch) | |
tree | 56777b555686dbdc808b6cfaaa812c3d8627f707 | |
parent | b53c093b8846c8029954908a5620e82a91b6090b (diff) | |
download | Hyprland-09b130374df035188b34a36e55d6fdda935c7df8.tar.gz Hyprland-09b130374df035188b34a36e55d6fdda935c7df8.zip |
unfocus tablets
-rw-r--r-- | src/managers/input/InputManager.cpp | 3 | ||||
-rw-r--r-- | src/managers/input/InputManager.hpp | 4 | ||||
-rw-r--r-- | src/managers/input/Tablets.cpp | 23 |
3 files changed, 23 insertions, 7 deletions
diff --git a/src/managers/input/InputManager.cpp b/src/managers/input/InputManager.cpp index 775ee7b4..79d4f305 100644 --- a/src/managers/input/InputManager.cpp +++ b/src/managers/input/InputManager.cpp @@ -2,6 +2,7 @@ #include "../../Compositor.hpp" void CInputManager::onMouseMoved(wlr_pointer_motion_event* e) { + unfocusAllTablets(); float sensitivity = g_pConfigManager->getFloat("general:sensitivity"); @@ -18,6 +19,8 @@ void CInputManager::onMouseMoved(wlr_pointer_motion_event* e) { } void CInputManager::onMouseWarp(wlr_pointer_motion_absolute_event* e) { + unfocusAllTablets(); + wlr_cursor_warp_absolute(g_pCompositor->m_sWLRCursor, &e->pointer->base, e->x, e->y); mouseMoveUnified(e->time_msec); diff --git a/src/managers/input/InputManager.hpp b/src/managers/input/InputManager.hpp index a1bc8db4..1cd99658 100644 --- a/src/managers/input/InputManager.hpp +++ b/src/managers/input/InputManager.hpp @@ -58,7 +58,9 @@ public: void mouseMoveUnified(uint32_t, bool refocus = false); - STabletTool* ensureTabletToolPresent(STablet*, wlr_tablet_tool*); + STabletTool* ensureTabletToolPresent(wlr_tablet_tool*); + + void unfocusAllTablets(); }; inline std::unique_ptr<CInputManager> g_pInputManager;
\ No newline at end of file diff --git a/src/managers/input/Tablets.cpp b/src/managers/input/Tablets.cpp index 32eef28d..5029ac45 100644 --- a/src/managers/input/Tablets.cpp +++ b/src/managers/input/Tablets.cpp @@ -39,7 +39,7 @@ void CInputManager::newTabletTool(wlr_input_device* pDevice) { break; } - const auto PTOOL = g_pInputManager->ensureTabletToolPresent(PTAB, EVENT->tool); + const auto PTOOL = g_pInputManager->ensureTabletToolPresent(EVENT->tool); // TODO: this might be wrong if (PTOOL->active) { @@ -78,7 +78,7 @@ void CInputManager::newTabletTool(wlr_input_device* pDevice) { const auto EVENT = (wlr_tablet_tool_tip_event*)data; const auto PTAB = (STablet*)owner; - const auto PTOOL = g_pInputManager->ensureTabletToolPresent(PTAB, EVENT->tool); + const auto PTOOL = g_pInputManager->ensureTabletToolPresent(EVENT->tool); // TODO: this might be wrong if (EVENT->state == WLR_TABLET_TOOL_TIP_DOWN) { @@ -96,7 +96,7 @@ void CInputManager::newTabletTool(wlr_input_device* pDevice) { const auto EVENT = (wlr_tablet_tool_button_event*)data; const auto PTAB = (STablet*)owner; - const auto PTOOL = g_pInputManager->ensureTabletToolPresent(PTAB, EVENT->tool); + const auto PTOOL = g_pInputManager->ensureTabletToolPresent(EVENT->tool); wlr_tablet_v2_tablet_tool_notify_button(PTOOL->wlrTabletToolV2, (zwp_tablet_pad_v2_button_state)EVENT->button, (zwp_tablet_pad_v2_button_state)EVENT->state); @@ -106,7 +106,7 @@ void CInputManager::newTabletTool(wlr_input_device* pDevice) { const auto EVENT = (wlr_tablet_tool_proximity_event*)data; const auto PTAB = (STablet*)owner; - const auto PTOOL = g_pInputManager->ensureTabletToolPresent(PTAB, EVENT->tool); + const auto PTOOL = g_pInputManager->ensureTabletToolPresent(EVENT->tool); if (EVENT->state == WLR_TABLET_TOOL_PROXIMITY_OUT) { PTOOL->active = false; @@ -119,7 +119,7 @@ void CInputManager::newTabletTool(wlr_input_device* pDevice) { }, PNEWTABLET, "Tablet"); } -STabletTool* CInputManager::ensureTabletToolPresent(STablet* pTablet, wlr_tablet_tool* pTool) { +STabletTool* CInputManager::ensureTabletToolPresent(wlr_tablet_tool* pTool) { if (pTool->data == nullptr) { const auto PTOOL = &m_lTabletTools.emplace_back(); @@ -200,7 +200,7 @@ void CInputManager::newTabletPad(wlr_input_device* pDevice) { } void CInputManager::focusTablet(STablet* pTab, wlr_tablet_tool* pTool, bool motion) { - const auto PTOOL = g_pInputManager->ensureTabletToolPresent(pTab, pTool); + const auto PTOOL = g_pInputManager->ensureTabletToolPresent(pTool); if (const auto PWINDOW = g_pCompositor->m_pLastWindow; g_pCompositor->windowValidMapped(PWINDOW)) { const auto CURSORPOS = g_pInputManager->getMouseCoordsInternal(); @@ -215,5 +215,16 @@ void CInputManager::focusTablet(STablet* pTab, wlr_tablet_tool* pTool, bool moti if (motion) wlr_tablet_v2_tablet_tool_notify_motion(PTOOL->wlrTabletToolV2, LOCAL.x, LOCAL.y); + } else { + wlr_tablet_v2_tablet_tool_notify_proximity_out(PTOOL->wlrTabletToolV2); } } + +void CInputManager::unfocusAllTablets() { + for (auto& tt : m_lTabletTools) { + if (!tt.wlrTabletTool->data) + continue; + + wlr_tablet_v2_tablet_tool_notify_proximity_out(((STabletTool*)tt.wlrTabletTool->data)->wlrTabletToolV2); + } +}
\ No newline at end of file |