aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorvaxerski <[email protected]>2022-06-09 18:09:09 +0200
committervaxerski <[email protected]>2022-06-09 18:09:09 +0200
commit6317f64ba0eb304de47bf3f5aa490d76ea0c4384 (patch)
tree200ce9b8ca9b83975b66725dc4657cb5ea7a7ec6
parent824d8b954dd012a6a60c20ced71fdbb00ca3b35c (diff)
downloadHyprland-6317f64ba0eb304de47bf3f5aa490d76ea0c4384.tar.gz
Hyprland-6317f64ba0eb304de47bf3f5aa490d76ea0c4384.zip
set proximity in tablets
-rw-r--r--src/managers/input/InputManager.cpp2
-rw-r--r--src/managers/input/InputManager.hpp1
-rw-r--r--src/managers/input/Tablets.cpp45
3 files changed, 27 insertions, 21 deletions
diff --git a/src/managers/input/InputManager.cpp b/src/managers/input/InputManager.cpp
index 26e20ffb..775ee7b4 100644
--- a/src/managers/input/InputManager.cpp
+++ b/src/managers/input/InputManager.cpp
@@ -519,4 +519,4 @@ void CInputManager::updateCapabilities(wlr_input_device* pDev) {
}
wlr_seat_set_capabilities(g_pCompositor->m_sSeat.seat, m_uiCapabilities);
-} \ No newline at end of file
+}
diff --git a/src/managers/input/InputManager.hpp b/src/managers/input/InputManager.hpp
index e83a1e34..a1bc8db4 100644
--- a/src/managers/input/InputManager.hpp
+++ b/src/managers/input/InputManager.hpp
@@ -48,6 +48,7 @@ public:
void newTabletTool(wlr_input_device*);
void newTabletPad(wlr_input_device*);
+ void focusTablet(STablet*, wlr_tablet_tool*, bool motion = false);
SKeyboard* m_pActiveKeyboard = nullptr;
diff --git a/src/managers/input/Tablets.cpp b/src/managers/input/Tablets.cpp
index bb139000..75ee0316 100644
--- a/src/managers/input/Tablets.cpp
+++ b/src/managers/input/Tablets.cpp
@@ -47,15 +47,7 @@ void CInputManager::newTabletTool(wlr_input_device* pDevice) {
if (PTOOL->active) {
g_pInputManager->refocus();
- if (const auto PWINDOW = g_pCompositor->m_pLastWindow; g_pCompositor->windowValidMapped(PWINDOW)) {
- const auto CURSORPOS = g_pInputManager->getMouseCoordsInternal();
-
- const auto LOCAL = CURSORPOS - PWINDOW->m_vRealPosition.goalv();
-
- Debug::log(LOG, "Tablet Tool focus to %s", PWINDOW->m_szTitle.c_str());
-
- wlr_tablet_v2_tablet_tool_notify_motion(PTOOL->wlrTabletToolV2, LOCAL.x, LOCAL.y);
- }
+ g_pInputManager->focusTablet(PTAB, EVENT->tool, true);
}
if (EVENT->updated_axes & WLR_TABLET_TOOL_AXIS_PRESSURE) {
@@ -107,6 +99,7 @@ void CInputManager::newTabletTool(wlr_input_device* pDevice) {
if (EVENT->state == WLR_TABLET_TOOL_TIP_DOWN) {
Debug::log(LOG, "Tip down");
g_pInputManager->refocus();
+ g_pInputManager->focusTablet(PTAB, EVENT->tool);
wlr_send_tablet_v2_tablet_tool_down(PTOOL->wlrTabletToolV2);
}
else {
@@ -143,16 +136,7 @@ void CInputManager::newTabletTool(wlr_input_device* pDevice) {
PTOOL->active = true;
Debug::log(LOG, "Tool active -> true");
g_pInputManager->refocus();
-
- if (const auto PWINDOW = g_pCompositor->m_pLastWindow; g_pCompositor->windowValidMapped(PWINDOW)) {
- const auto CURSORPOS = g_pInputManager->getMouseCoordsInternal();
-
- const auto LOCAL = CURSORPOS - PWINDOW->m_vRealPosition.goalv();
-
- Debug::log(LOG, "Tablet Tool focus to %s", PWINDOW->m_szTitle.c_str());
-
- wlr_tablet_v2_tablet_tool_notify_motion(PTOOL->wlrTabletToolV2, LOCAL.x, LOCAL.y);
- }
+ g_pInputManager->focusTablet(PTAB, EVENT->tool);
}
}, PNEWTABLET, "Tablet");
@@ -246,4 +230,25 @@ void CInputManager::newTabletPad(wlr_input_device* pDevice) {
Debug::log(LOG, "Removed a tablet pad");
}, PNEWPAD, "Tablet Pad");
-} \ No newline at end of file
+}
+
+void CInputManager::focusTablet(STablet* pTab, wlr_tablet_tool* pTool, bool motion) {
+ const auto PTOOL = g_pInputManager->ensureTabletToolPresent(pTab, pTool);
+
+ if (const auto PWINDOW = g_pCompositor->m_pLastWindow; g_pCompositor->windowValidMapped(PWINDOW)) {
+ const auto CURSORPOS = g_pInputManager->getMouseCoordsInternal();
+
+ const auto LOCAL = CURSORPOS - PWINDOW->m_vRealPosition.goalv();
+
+ Debug::log(LOG, "Tablet Tool focus to %s", PWINDOW->m_szTitle.c_str());
+
+ if (PTOOL->wlrTabletToolV2->focused_surface != g_pCompositor->m_pLastFocus)
+ wlr_tablet_v2_tablet_tool_notify_proximity_out(PTOOL->wlrTabletToolV2);
+
+ if (g_pCompositor->m_pLastFocus)
+ wlr_tablet_v2_tablet_tool_notify_proximity_in(PTOOL->wlrTabletToolV2, pTab->wlrTabletV2, g_pCompositor->m_pLastFocus);
+
+ if (motion)
+ wlr_tablet_v2_tablet_tool_notify_motion(PTOOL->wlrTabletToolV2, LOCAL.x, LOCAL.y);
+ }
+}