diff --git a/hyprtester/clients/shortcut-inhibitor.cpp b/hyprtester/clients/shortcut-inhibitor.cpp index 0c6b43419..208043a23 100644 --- a/hyprtester/clients/shortcut-inhibitor.cpp +++ b/hyprtester/clients/shortcut-inhibitor.cpp @@ -1,6 +1,7 @@ #include #include #include +#include #include #include diff --git a/hyprtester/src/tests/main/keybinds.cpp b/hyprtester/src/tests/main/keybinds.cpp index 567d078bc..589d5bb5a 100644 --- a/hyprtester/src/tests/main/keybinds.cpp +++ b/hyprtester/src/tests/main/keybinds.cpp @@ -547,6 +547,14 @@ SUBTEST(perDeviceKeybind) { EXPECT(attemptCheckFlag(20, 50), true); OK(getFromSocket(pluginKeybindCmd(false, 0, 29))); EXPECT(getFromSocket("/eval hl.unbind('SUPER + Y')"), "ok"); + + // Tags + EXPECT(checkFlag(), false); + EXPECT(getFromSocket("/eval hl.bind('SUPER + Y', hl.dsp.exec_cmd('touch " + flagFile + "'), { device = { inclusive = true, list = { 'test-tag' } } })"), "ok"); + OK(getFromSocket(pluginKeybindCmd(true, 7, 29))); + EXPECT(attemptCheckFlag(20, 50), true); + OK(getFromSocket(pluginKeybindCmd(false, 0, 29))); + EXPECT(getFromSocket("/eval hl.unbind('SUPER + Y')"), "ok"); } SUBTEST(unbind) { diff --git a/hyprtester/test.lua b/hyprtester/test.lua index d1f8657e8..f3c77fd72 100644 --- a/hyprtester/test.lua +++ b/hyprtester/test.lua @@ -93,6 +93,7 @@ hl.animation({ leaf = "workspacesIn", enabled = true, speed = 1.21, bezier = "al hl.animation({ leaf = "workspacesOut", enabled = true, speed = 1.94, bezier = "almostLinear", style = "fade" }) hl.device({ name = "test-mouse-1", enabled = true }) +hl.device({ name = "test-keyboard-1", enabled = true, tags = "test-tag"}) hl.config({ dwindle = { diff --git a/meta/hl.meta.lua b/meta/hl.meta.lua index d6a44567d..cf247ba6b 100644 --- a/meta/hl.meta.lua +++ b/meta/hl.meta.lua @@ -488,6 +488,7 @@ local __HL_WindowQueryFilter = {} ---@field scroll_points? string ---@field sensitivity? number|boolean ---@field share_states? integer|boolean +---@field tags? string ---@field tap_and_drag? boolean ---@field tap_button_map? string ---@field tap_to_click? boolean diff --git a/src/config/legacy/ConfigManager.cpp b/src/config/legacy/ConfigManager.cpp index 37b819e32..e4c485e03 100644 --- a/src/config/legacy/ConfigManager.cpp +++ b/src/config/legacy/ConfigManager.cpp @@ -555,6 +555,7 @@ CConfigManager::CConfigManager() { m_config->addSpecialConfigValue("device", "keybinds", Hyprlang::INT{1}); // enable/disable keybinds m_config->addSpecialConfigValue("device", "share_states", Hyprlang::INT{0}); // only for virtualkeyboards m_config->addSpecialConfigValue("device", "release_pressed_on_close", Hyprlang::INT{0}); // only for virtualkeyboards + m_config->addSpecialConfigValue("device", "tags", STRVAL_EMPTY); // only for keyboards and mice m_config->addSpecialCategory("monitorv2", {.key = "output"}); m_config->addSpecialConfigValue("monitorv2", "disabled", Hyprlang::INT{0}); diff --git a/src/config/lua/bindings/LuaBindingsConfigRules.cpp b/src/config/lua/bindings/LuaBindingsConfigRules.cpp index 14e172649..51548c044 100644 --- a/src/config/lua/bindings/LuaBindingsConfigRules.cpp +++ b/src/config/lua/bindings/LuaBindingsConfigRules.cpp @@ -265,6 +265,7 @@ namespace { {"keybinds", []() -> ILuaConfigValue* { return new CLuaConfigBool(true); }}, {"share_states", []() -> ILuaConfigValue* { return new CLuaConfigInt(0, 0, 2); }}, {"release_pressed_on_close", []() -> ILuaConfigValue* { return new CLuaConfigBool(false); }}, + {"tags", []() -> ILuaConfigValue* { return new CLuaConfigString(STRVAL_EMPTY); }}, }; } diff --git a/src/devices/IHID.hpp b/src/devices/IHID.hpp index c57778ffb..eae2f9656 100644 --- a/src/devices/IHID.hpp +++ b/src/devices/IHID.hpp @@ -2,6 +2,7 @@ #include #include +#include #include "../helpers/signal/Signal.hpp" enum eHIDCapabilityType : uint8_t { @@ -36,6 +37,7 @@ class IHID { CSignalT<> destroy; } m_events; - std::string m_deviceName; - std::string m_hlName; + std::string m_deviceName; + std::string m_hlName; + std::set m_deviceTags; }; diff --git a/src/managers/KeybindManager.cpp b/src/managers/KeybindManager.cpp index 2496a0a50..c9b5650aa 100644 --- a/src/managers/KeybindManager.cpp +++ b/src/managers/KeybindManager.cpp @@ -605,7 +605,12 @@ SDispatchResult CKeybindManager::handleKeybinds(const uint32_t modmask, const SP continue; if (device) { - if (k->deviceInclusive ^ k->devices.contains(device->m_hlName)) + bool isTagValid = false; + for (const auto& tag : device->m_deviceTags) { + if (k->devices.contains(tag)) + isTagValid = true; + } + if (k->deviceInclusive ^ (k->devices.contains(device->m_hlName) || isTagValid)) continue; } diff --git a/src/managers/input/InputManager.cpp b/src/managers/input/InputManager.cpp index 65a981814..85699b14c 100644 --- a/src/managers/input/InputManager.cpp +++ b/src/managers/input/InputManager.cpp @@ -1167,6 +1167,10 @@ void CInputManager::applyConfigToKeyboard(SP pKeyboard) { const auto ENABLED = HASCONFIG && Config::mgr()->deviceConfigExplicitlySet(devname, "enabled") ? Config::mgr()->getDeviceInt(devname, "enabled") : true; const auto ALLOWBINDS = HASCONFIG && Config::mgr()->deviceConfigExplicitlySet(devname, "keybinds") ? Config::mgr()->getDeviceInt(devname, "keybinds") : true; + for (const auto& tagString : CVarList2(Config::mgr()->getDeviceString(devname, "tags"))) { + pKeyboard->m_deviceTags.emplace(std::string_view(tagString)); + } + pKeyboard->m_enabled = ENABLED; pKeyboard->m_resolveBindsBySym = RESOLVEBINDSBYSYM; pKeyboard->m_allowBinds = ALLOWBINDS; @@ -1293,6 +1297,10 @@ void CInputManager::setPointerConfigs() { g_pPointerManager->detachPointer(m); m->m_connected = false; } + + for (const auto tagString : CVarList2(Config::mgr()->getDeviceString(devname, "tags"))) { + m->m_deviceTags.emplace(std::string_view(tagString)); + } } if (Config::mgr()->deviceConfigExplicitlySet(devname, "scroll_factor"))