mirror of
https://github.com/hyprwm/Hyprland
synced 2024-11-26 18:25:59 +01:00
handle touch devices internally as objects
This commit is contained in:
parent
d44cc9f112
commit
79c645f8cd
5 changed files with 58 additions and 1 deletions
|
@ -381,6 +381,23 @@ R"#( {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// remove trailing comma
|
||||||
|
result.pop_back();
|
||||||
|
result += "\n],\n";
|
||||||
|
|
||||||
|
result += "\"touch\": [\n";
|
||||||
|
|
||||||
|
for (auto& d : g_pInputManager->m_lTouchDevices) {
|
||||||
|
result += getFormat(
|
||||||
|
R"#( {
|
||||||
|
"address": "0x%x",
|
||||||
|
"name": "%s"
|
||||||
|
},)#",
|
||||||
|
&d,
|
||||||
|
d.pWlrDevice ? d.pWlrDevice->name : ""
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
// remove trailing comma
|
// remove trailing comma
|
||||||
if (result[result.size() - 1] == ',')
|
if (result[result.size() - 1] == ',')
|
||||||
result.pop_back();
|
result.pop_back();
|
||||||
|
@ -415,6 +432,12 @@ R"#( {
|
||||||
for (auto& d : g_pInputManager->m_lTabletTools) {
|
for (auto& d : g_pInputManager->m_lTabletTools) {
|
||||||
result += getFormat("\tTablet Tool at %x (belongs to %x)\n", &d, d.wlrTabletTool ? d.wlrTabletTool->data : 0);
|
result += getFormat("\tTablet Tool at %x (belongs to %x)\n", &d, d.wlrTabletTool ? d.wlrTabletTool->data : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
result += "\n\nTouch:\n";
|
||||||
|
|
||||||
|
for (auto& d : g_pInputManager->m_lTouchDevices) {
|
||||||
|
result += getFormat("\tTouch Device at %x:\n\t\t%s\n", &d, d.pWlrDevice ? d.pWlrDevice->name : "");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|
|
@ -72,7 +72,7 @@ void Events::listener_newInput(wl_listener* listener, void* data) {
|
||||||
break;
|
break;
|
||||||
case WLR_INPUT_DEVICE_TOUCH:
|
case WLR_INPUT_DEVICE_TOUCH:
|
||||||
Debug::log(LOG, "Attached a touch device with name %s", DEVICE->name);
|
Debug::log(LOG, "Attached a touch device with name %s", DEVICE->name);
|
||||||
wlr_cursor_attach_input_device(g_pCompositor->m_sWLRCursor, DEVICE);
|
g_pInputManager->newTouchDevice(DEVICE);
|
||||||
break;
|
break;
|
||||||
case WLR_INPUT_DEVICE_TABLET_TOOL:
|
case WLR_INPUT_DEVICE_TABLET_TOOL:
|
||||||
Debug::log(LOG, "Attached a tablet tool with name %s", DEVICE->name);
|
Debug::log(LOG, "Attached a tablet tool with name %s", DEVICE->name);
|
||||||
|
|
|
@ -322,3 +322,13 @@ struct SIMEPopup {
|
||||||
return pSurface == other.pSurface;
|
return pSurface == other.pSurface;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct STouchDevice {
|
||||||
|
wlr_input_device* pWlrDevice = nullptr;
|
||||||
|
|
||||||
|
DYNLISTENER(destroy);
|
||||||
|
|
||||||
|
bool operator==(const STouchDevice& other) {
|
||||||
|
return pWlrDevice == other.pWlrDevice;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
|
@ -987,3 +987,22 @@ void CInputManager::disableAllKeyboards(bool virt) {
|
||||||
k.active = false;
|
k.active = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CInputManager::newTouchDevice(wlr_input_device* pDevice) {
|
||||||
|
const auto PNEWDEV = &m_lTouchDevices.emplace_back();
|
||||||
|
PNEWDEV->pWlrDevice = pDevice;
|
||||||
|
|
||||||
|
wlr_cursor_attach_input_device(g_pCompositor->m_sWLRCursor, pDevice);
|
||||||
|
|
||||||
|
Debug::log(LOG, "New touch device added at %x", PNEWDEV);
|
||||||
|
|
||||||
|
PNEWDEV->hyprListener_destroy.initCallback(&pDevice->events.destroy, [&](void* owner, void* data) {
|
||||||
|
destroyTouchDevice((STouchDevice*)data);
|
||||||
|
}, PNEWDEV, "TouchDevice");
|
||||||
|
}
|
||||||
|
|
||||||
|
void CInputManager::destroyTouchDevice(STouchDevice* pDevice) {
|
||||||
|
Debug::log(LOG, "Touch device at %x removed", pDevice);
|
||||||
|
|
||||||
|
m_lTouchDevices.remove(*pDevice);
|
||||||
|
}
|
||||||
|
|
|
@ -36,6 +36,8 @@ public:
|
||||||
void newKeyboard(wlr_input_device*);
|
void newKeyboard(wlr_input_device*);
|
||||||
void newVirtualKeyboard(wlr_input_device*);
|
void newVirtualKeyboard(wlr_input_device*);
|
||||||
void newMouse(wlr_input_device*, bool virt = false);
|
void newMouse(wlr_input_device*, bool virt = false);
|
||||||
|
void newTouchDevice(wlr_input_device*);
|
||||||
|
void destroyTouchDevice(STouchDevice*);
|
||||||
void destroyKeyboard(SKeyboard*);
|
void destroyKeyboard(SKeyboard*);
|
||||||
void destroyMouse(wlr_input_device*);
|
void destroyMouse(wlr_input_device*);
|
||||||
|
|
||||||
|
@ -81,6 +83,9 @@ public:
|
||||||
// idle inhibitors
|
// idle inhibitors
|
||||||
std::list<SIdleInhibitor> m_lIdleInhibitors;
|
std::list<SIdleInhibitor> m_lIdleInhibitors;
|
||||||
|
|
||||||
|
// Touch devices
|
||||||
|
std::list<STouchDevice> m_lTouchDevices;
|
||||||
|
|
||||||
void newTabletTool(wlr_input_device*);
|
void newTabletTool(wlr_input_device*);
|
||||||
void newTabletPad(wlr_input_device*);
|
void newTabletPad(wlr_input_device*);
|
||||||
void focusTablet(STablet*, wlr_tablet_tool*, bool motion = false);
|
void focusTablet(STablet*, wlr_tablet_tool*, bool motion = false);
|
||||||
|
|
Loading…
Reference in a new issue