mirror of
https://github.com/hyprwm/Hyprland
synced 2026-05-07 17:58:44 +02:00
config: add device tags (#13728)
--------- Co-authored-by: Mio Argillander <mio@argillander.me>
This commit is contained in:
parent
eff3bfe261
commit
497b48e852
9 changed files with 31 additions and 3 deletions
|
|
@ -1,6 +1,7 @@
|
|||
#include <sys/poll.h>
|
||||
#include <sys/mman.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <print>
|
||||
|
||||
#include <wayland-client.h>
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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 = {
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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});
|
||||
|
|
|
|||
|
|
@ -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); }},
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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"))
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue