mirror of
https://github.com/hyprwm/Hyprland
synced 2024-11-26 14:05:58 +01:00
unfocus tablets
This commit is contained in:
parent
b53c093b88
commit
09b130374d
3 changed files with 23 additions and 7 deletions
|
@ -2,6 +2,7 @@
|
||||||
#include "../../Compositor.hpp"
|
#include "../../Compositor.hpp"
|
||||||
|
|
||||||
void CInputManager::onMouseMoved(wlr_pointer_motion_event* e) {
|
void CInputManager::onMouseMoved(wlr_pointer_motion_event* e) {
|
||||||
|
unfocusAllTablets();
|
||||||
|
|
||||||
float sensitivity = g_pConfigManager->getFloat("general:sensitivity");
|
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) {
|
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);
|
wlr_cursor_warp_absolute(g_pCompositor->m_sWLRCursor, &e->pointer->base, e->x, e->y);
|
||||||
|
|
||||||
mouseMoveUnified(e->time_msec);
|
mouseMoveUnified(e->time_msec);
|
||||||
|
|
|
@ -58,7 +58,9 @@ public:
|
||||||
|
|
||||||
void mouseMoveUnified(uint32_t, bool refocus = false);
|
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;
|
inline std::unique_ptr<CInputManager> g_pInputManager;
|
|
@ -39,7 +39,7 @@ void CInputManager::newTabletTool(wlr_input_device* pDevice) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto PTOOL = g_pInputManager->ensureTabletToolPresent(PTAB, EVENT->tool);
|
const auto PTOOL = g_pInputManager->ensureTabletToolPresent(EVENT->tool);
|
||||||
|
|
||||||
// TODO: this might be wrong
|
// TODO: this might be wrong
|
||||||
if (PTOOL->active) {
|
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 EVENT = (wlr_tablet_tool_tip_event*)data;
|
||||||
const auto PTAB = (STablet*)owner;
|
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
|
// TODO: this might be wrong
|
||||||
if (EVENT->state == WLR_TABLET_TOOL_TIP_DOWN) {
|
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 EVENT = (wlr_tablet_tool_button_event*)data;
|
||||||
const auto PTAB = (STablet*)owner;
|
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);
|
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 EVENT = (wlr_tablet_tool_proximity_event*)data;
|
||||||
const auto PTAB = (STablet*)owner;
|
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) {
|
if (EVENT->state == WLR_TABLET_TOOL_PROXIMITY_OUT) {
|
||||||
PTOOL->active = false;
|
PTOOL->active = false;
|
||||||
|
@ -119,7 +119,7 @@ void CInputManager::newTabletTool(wlr_input_device* pDevice) {
|
||||||
}, PNEWTABLET, "Tablet");
|
}, PNEWTABLET, "Tablet");
|
||||||
}
|
}
|
||||||
|
|
||||||
STabletTool* CInputManager::ensureTabletToolPresent(STablet* pTablet, wlr_tablet_tool* pTool) {
|
STabletTool* CInputManager::ensureTabletToolPresent(wlr_tablet_tool* pTool) {
|
||||||
if (pTool->data == nullptr) {
|
if (pTool->data == nullptr) {
|
||||||
const auto PTOOL = &m_lTabletTools.emplace_back();
|
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) {
|
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)) {
|
if (const auto PWINDOW = g_pCompositor->m_pLastWindow; g_pCompositor->windowValidMapped(PWINDOW)) {
|
||||||
const auto CURSORPOS = g_pInputManager->getMouseCoordsInternal();
|
const auto CURSORPOS = g_pInputManager->getMouseCoordsInternal();
|
||||||
|
@ -215,5 +215,16 @@ void CInputManager::focusTablet(STablet* pTab, wlr_tablet_tool* pTool, bool moti
|
||||||
|
|
||||||
if (motion)
|
if (motion)
|
||||||
wlr_tablet_v2_tablet_tool_notify_motion(PTOOL->wlrTabletToolV2, LOCAL.x, LOCAL.y);
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in a new issue