diff options
| author | vaxerski <43317083+vaxerski@users.noreply.github.com> | 2022-06-09 18:09:09 +0200 |
|---|---|---|
| committer | vaxerski <43317083+vaxerski@users.noreply.github.com> | 2022-06-09 18:09:09 +0200 |
| commit | 6317f64ba0eb304de47bf3f5aa490d76ea0c4384 (patch) | |
| tree | 200ce9b8ca9b83975b66725dc4657cb5ea7a7ec6 /src/managers/input/Tablets.cpp | |
| parent | 824d8b954dd012a6a60c20ced71fdbb00ca3b35c (diff) | |
set proximity in tablets
Diffstat (limited to 'src/managers/input/Tablets.cpp')
| -rw-r--r-- | src/managers/input/Tablets.cpp | 45 |
1 files changed, 25 insertions, 20 deletions
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); + } +} |
