summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--hyprtester/clients/shortcut-inhibitor.cpp1
-rw-r--r--hyprtester/src/tests/main/keybinds.cpp8
-rw-r--r--hyprtester/test.lua1
-rw-r--r--meta/hl.meta.lua1
-rw-r--r--src/config/legacy/ConfigManager.cpp1
-rw-r--r--src/config/lua/bindings/LuaBindingsConfigRules.cpp1
-rw-r--r--src/devices/IHID.hpp6
-rw-r--r--src/managers/KeybindManager.cpp7
-rw-r--r--src/managers/input/InputManager.cpp8
9 files changed, 31 insertions, 3 deletions
diff --git a/hyprtester/clients/shortcut-inhibitor.cpp b/hyprtester/clients/shortcut-inhibitor.cpp
index 0c6b4341..208043a2 100644
--- a/hyprtester/clients/shortcut-inhibitor.cpp
+++ b/hyprtester/clients/shortcut-inhibitor.cpp
@@ -1,6 +1,7 @@
#include <sys/poll.h>
#include <sys/mman.h>
#include <fcntl.h>
+#include <unistd.h>
#include <print>
#include <wayland-client.h>
diff --git a/hyprtester/src/tests/main/keybinds.cpp b/hyprtester/src/tests/main/keybinds.cpp
index 567d078b..589d5bb5 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 d1f8657e..f3c77fd7 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 d6a44567..cf247ba6 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 37b819e3..e4c485e0 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 14e17264..51548c04 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 c57778ff..eae2f965 100644
--- a/src/devices/IHID.hpp
+++ b/src/devices/IHID.hpp
@@ -2,6 +2,7 @@
#include <cstdint>
#include <string>
+#include <set>
#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<std::string> m_deviceTags;
};
diff --git a/src/managers/KeybindManager.cpp b/src/managers/KeybindManager.cpp
index 2496a0a5..c9b5650a 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 65a98181..85699b14 100644
--- a/src/managers/input/InputManager.cpp
+++ b/src/managers/input/InputManager.cpp
@@ -1167,6 +1167,10 @@ void CInputManager::applyConfigToKeyboard(SP<IKeyboard> 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"))