config/keybinds: add a submap universal keybind flag (#12100)
This commit is contained in:
parent
ee2168c665
commit
308226a4fc
5 changed files with 107 additions and 72 deletions
|
|
@ -34,6 +34,17 @@ static bool checkFlag() {
|
||||||
return exists;
|
return exists;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool attemptCheckFlag(int attempts, int intervalMs) {
|
||||||
|
for (int i = 0; i < attempts; i++) {
|
||||||
|
if (checkFlag())
|
||||||
|
return true;
|
||||||
|
|
||||||
|
std::this_thread::sleep_for(std::chrono::milliseconds(intervalMs));
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
static std::string readKittyOutput() {
|
static std::string readKittyOutput() {
|
||||||
std::string output = Tests::execAndGet("kitten @ --to unix:/tmp/hyprtester-kitty.sock get-text --extent all");
|
std::string output = Tests::execAndGet("kitten @ --to unix:/tmp/hyprtester-kitty.sock get-text --extent all");
|
||||||
// chop off shell prompt
|
// chop off shell prompt
|
||||||
|
|
@ -443,6 +454,34 @@ static void testSubmap() {
|
||||||
Tests::killAllWindows();
|
Tests::killAllWindows();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void testSubmapUniversal() {
|
||||||
|
NLog::log("{}Testing submap universal", Colors::GREEN);
|
||||||
|
|
||||||
|
EXPECT(checkFlag(), false);
|
||||||
|
EXPECT(getFromSocket("/keyword bindu SUPER,Y,exec,touch " + flagFile), "ok");
|
||||||
|
EXPECT_CONTAINS(getFromSocket("/submap"), "default");
|
||||||
|
|
||||||
|
// keybind works on default submap
|
||||||
|
OK(getFromSocket("/dispatch plugin:test:keybind 1,7,29"));
|
||||||
|
OK(getFromSocket("/dispatch plugin:test:keybind 0,7,29"));
|
||||||
|
EXPECT(attemptCheckFlag(30, 5), true);
|
||||||
|
|
||||||
|
// keybind works on submap1
|
||||||
|
getFromSocket("/dispatch plugin:test:keybind 1,7,30");
|
||||||
|
getFromSocket("/dispatch plugin:test:keybind 0,7,30");
|
||||||
|
EXPECT_CONTAINS(getFromSocket("/submap"), "submap1");
|
||||||
|
OK(getFromSocket("/dispatch plugin:test:keybind 1,7,29"));
|
||||||
|
OK(getFromSocket("/dispatch plugin:test:keybind 0,7,29"));
|
||||||
|
EXPECT(attemptCheckFlag(30, 5), true);
|
||||||
|
|
||||||
|
// reset to default submap
|
||||||
|
getFromSocket("/dispatch plugin:test:keybind 1,0,33");
|
||||||
|
getFromSocket("/dispatch plugin:test:keybind 0,0,33");
|
||||||
|
EXPECT_CONTAINS(getFromSocket("/submap"), "default");
|
||||||
|
|
||||||
|
EXPECT(getFromSocket("/keyword unbind SUPER,Y"), "ok");
|
||||||
|
}
|
||||||
|
|
||||||
static bool test() {
|
static bool test() {
|
||||||
NLog::log("{}Testing keybinds", Colors::GREEN);
|
NLog::log("{}Testing keybinds", Colors::GREEN);
|
||||||
|
|
||||||
|
|
@ -462,8 +501,8 @@ static bool test() {
|
||||||
testShortcutLongPressKeyRelease();
|
testShortcutLongPressKeyRelease();
|
||||||
testShortcutRepeat();
|
testShortcutRepeat();
|
||||||
testShortcutRepeatKeyRelease();
|
testShortcutRepeatKeyRelease();
|
||||||
|
|
||||||
testSubmap();
|
testSubmap();
|
||||||
|
testSubmapUniversal();
|
||||||
|
|
||||||
clearFlag();
|
clearFlag();
|
||||||
return !ret;
|
return !ret;
|
||||||
|
|
|
||||||
|
|
@ -2552,39 +2552,32 @@ std::optional<std::string> CConfigManager::handleBind(const std::string& command
|
||||||
bool dontInhibit = false;
|
bool dontInhibit = false;
|
||||||
bool click = false;
|
bool click = false;
|
||||||
bool drag = false;
|
bool drag = false;
|
||||||
|
bool submapUniversal = false;
|
||||||
const auto BINDARGS = command.substr(4);
|
const auto BINDARGS = command.substr(4);
|
||||||
|
|
||||||
for (auto const& arg : BINDARGS) {
|
for (auto const& arg : BINDARGS) {
|
||||||
if (arg == 'l') {
|
switch (arg) {
|
||||||
locked = true;
|
case 'l': locked = true; break;
|
||||||
} else if (arg == 'r') {
|
case 'r': release = true; break;
|
||||||
release = true;
|
case 'e': repeat = true; break;
|
||||||
} else if (arg == 'e') {
|
case 'm': mouse = true; break;
|
||||||
repeat = true;
|
case 'n': nonConsuming = true; break;
|
||||||
} else if (arg == 'm') {
|
case 't': transparent = true; break;
|
||||||
mouse = true;
|
case 'i': ignoreMods = true; break;
|
||||||
} else if (arg == 'n') {
|
case 's': multiKey = true; break;
|
||||||
nonConsuming = true;
|
case 'o': longPress = true; break;
|
||||||
} else if (arg == 't') {
|
case 'd': hasDescription = true; break;
|
||||||
transparent = true;
|
case 'p': dontInhibit = true; break;
|
||||||
} else if (arg == 'i') {
|
case 'c':
|
||||||
ignoreMods = true;
|
|
||||||
} else if (arg == 's') {
|
|
||||||
multiKey = true;
|
|
||||||
} else if (arg == 'o') {
|
|
||||||
longPress = true;
|
|
||||||
} else if (arg == 'd') {
|
|
||||||
hasDescription = true;
|
|
||||||
} else if (arg == 'p') {
|
|
||||||
dontInhibit = true;
|
|
||||||
} else if (arg == 'c') {
|
|
||||||
click = true;
|
click = true;
|
||||||
release = true;
|
release = true;
|
||||||
} else if (arg == 'g') {
|
break;
|
||||||
|
case 'g':
|
||||||
drag = true;
|
drag = true;
|
||||||
release = true;
|
release = true;
|
||||||
} else {
|
break;
|
||||||
return "bind: invalid flag";
|
case 'u': submapUniversal = true; break;
|
||||||
|
default: return "bind: invalid flag";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -2657,7 +2650,7 @@ std::optional<std::string> CConfigManager::handleBind(const std::string& command
|
||||||
g_pKeybindManager->addKeybind(SKeybind{parsedKey.key, KEYSYMS, parsedKey.keycode, parsedKey.catchAll, MOD, MODS, HANDLER,
|
g_pKeybindManager->addKeybind(SKeybind{parsedKey.key, KEYSYMS, parsedKey.keycode, parsedKey.catchAll, MOD, MODS, HANDLER,
|
||||||
COMMAND, locked, m_currentSubmap, DESCRIPTION, release, repeat, longPress,
|
COMMAND, locked, m_currentSubmap, DESCRIPTION, release, repeat, longPress,
|
||||||
mouse, nonConsuming, transparent, ignoreMods, multiKey, hasDescription, dontInhibit,
|
mouse, nonConsuming, transparent, ignoreMods, multiKey, hasDescription, dontInhibit,
|
||||||
click, drag});
|
click, drag, submapUniversal});
|
||||||
}
|
}
|
||||||
|
|
||||||
return {};
|
return {};
|
||||||
|
|
|
||||||
|
|
@ -1025,6 +1025,7 @@ static std::string bindsRequest(eHyprCtlOutputFormat format, std::string request
|
||||||
"has_description": {},
|
"has_description": {},
|
||||||
"modmask": {},
|
"modmask": {},
|
||||||
"submap": "{}",
|
"submap": "{}",
|
||||||
|
"submap_universal": "{}",
|
||||||
"key": "{}",
|
"key": "{}",
|
||||||
"keycode": {},
|
"keycode": {},
|
||||||
"catch_all": {},
|
"catch_all": {},
|
||||||
|
|
@ -1033,8 +1034,9 @@ static std::string bindsRequest(eHyprCtlOutputFormat format, std::string request
|
||||||
"arg": "{}"
|
"arg": "{}"
|
||||||
}},)#",
|
}},)#",
|
||||||
kb->locked ? "true" : "false", kb->mouse ? "true" : "false", kb->release ? "true" : "false", kb->repeat ? "true" : "false", kb->longPress ? "true" : "false",
|
kb->locked ? "true" : "false", kb->mouse ? "true" : "false", kb->release ? "true" : "false", kb->repeat ? "true" : "false", kb->longPress ? "true" : "false",
|
||||||
kb->nonConsuming ? "true" : "false", kb->hasDescription ? "true" : "false", kb->modmask, escapeJSONStrings(kb->submap.name), escapeJSONStrings(kb->key),
|
kb->nonConsuming ? "true" : "false", kb->hasDescription ? "true" : "false", kb->modmask, escapeJSONStrings(kb->submap.name), kb->submapUniversal,
|
||||||
kb->keycode, kb->catchAll ? "true" : "false", escapeJSONStrings(kb->description), escapeJSONStrings(kb->handler), escapeJSONStrings(kb->arg));
|
escapeJSONStrings(kb->key), kb->keycode, kb->catchAll ? "true" : "false", escapeJSONStrings(kb->description), escapeJSONStrings(kb->handler),
|
||||||
|
escapeJSONStrings(kb->arg));
|
||||||
}
|
}
|
||||||
trimTrailingComma(ret);
|
trimTrailingComma(ret);
|
||||||
ret += "]";
|
ret += "]";
|
||||||
|
|
|
||||||
|
|
@ -680,7 +680,7 @@ SDispatchResult CKeybindManager::handleKeybinds(const uint32_t modmask, const SP
|
||||||
if (!k->locked && g_pSessionLockManager->isSessionLocked())
|
if (!k->locked && g_pSessionLockManager->isSessionLocked())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (!IGNORECONDITIONS && ((modmask != k->modmask && !k->ignoreMods) || k->submap != m_currentSelectedSubmap || k->shadowed))
|
if (!IGNORECONDITIONS && ((modmask != k->modmask && !k->ignoreMods) || (k->submap != m_currentSelectedSubmap && !k->submapUniversal) || k->shadowed))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (k->multiKey) {
|
if (k->multiKey) {
|
||||||
|
|
|
||||||
|
|
@ -49,6 +49,7 @@ struct SKeybind {
|
||||||
bool dontInhibit = false;
|
bool dontInhibit = false;
|
||||||
bool click = false;
|
bool click = false;
|
||||||
bool drag = false;
|
bool drag = false;
|
||||||
|
bool submapUniversal = false;
|
||||||
|
|
||||||
// DO NOT INITIALIZE
|
// DO NOT INITIALIZE
|
||||||
bool shadowed = false;
|
bool shadowed = false;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue