From 308226a4fc2c9b63fa19894d5f85e79e05d75e03 Mon Sep 17 00:00:00 2001 From: Luke Barkess <57995669+Brumus14@users.noreply.github.com> Date: Tue, 11 Nov 2025 22:59:21 +0000 Subject: config/keybinds: add a submap universal keybind flag (#12100) --- hyprtester/src/tests/main/keybinds.cpp | 41 +++++++++++++++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) (limited to 'hyprtester/src/tests/main/keybinds.cpp') diff --git a/hyprtester/src/tests/main/keybinds.cpp b/hyprtester/src/tests/main/keybinds.cpp index 4e224749..a2fe2f37 100644 --- a/hyprtester/src/tests/main/keybinds.cpp +++ b/hyprtester/src/tests/main/keybinds.cpp @@ -34,6 +34,17 @@ static bool checkFlag() { 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() { std::string output = Tests::execAndGet("kitten @ --to unix:/tmp/hyprtester-kitty.sock get-text --extent all"); // chop off shell prompt @@ -443,6 +454,34 @@ static void testSubmap() { 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() { NLog::log("{}Testing keybinds", Colors::GREEN); @@ -462,8 +501,8 @@ static bool test() { testShortcutLongPressKeyRelease(); testShortcutRepeat(); testShortcutRepeatKeyRelease(); - testSubmap(); + testSubmapUniversal(); clearFlag(); return !ret; -- cgit v1.2.3