From 3ef4e0dc4d333a1d6c9482cb55119dcfd282e867 Mon Sep 17 00:00:00 2001 From: BENDI <83127964+bendi-github@users.noreply.github.com> Date: Fri, 29 May 2026 14:19:25 +0200 Subject: [PATCH] binds/submap: fix submap enter bind == bind inside submap (#14856) * Only process submap bindings if its the same on press Move the check below the pattern match and check if the key was pressed Address comment: Remove {} Remove the new submap check and replace the old one * tests/keybinds: add additional submap testcase This tests for cases where the keybind to enter the submap is also bound inside it --------- Co-authored-by: 0xdeadcode-arch --- hyprtester/src/tests/main/keybinds.cpp | 8 ++++++++ hyprtester/test.lua | 1 + src/managers/KeybindManager.cpp | 2 +- 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/hyprtester/src/tests/main/keybinds.cpp b/hyprtester/src/tests/main/keybinds.cpp index 589d5bb5a..fabf11028 100644 --- a/hyprtester/src/tests/main/keybinds.cpp +++ b/hyprtester/src/tests/main/keybinds.cpp @@ -459,6 +459,14 @@ SUBTEST(submap) { press(KEY_P); EXPECT_CONTAINS(getFromSocket("/submap"), "default"); + // submap 1 with identical keybind bound inside it + press(KEY_U, MOD_META); + EXPECT_CONTAINS(getFromSocket("/submap"), "submap1"); + press(KEY_U, MOD_META); + EXPECT_CONTAINS(getFromSocket("/submap"), "submap3"); + press(KEY_O); + Tests::waitUntilWindowsN(4); + EXPECT_CONTAINS(getFromSocket("/submap"), "default"); Tests::killAllWindows(); } diff --git a/hyprtester/test.lua b/hyprtester/test.lua index 693513aeb..98956f6ae 100644 --- a/hyprtester/test.lua +++ b/hyprtester/test.lua @@ -201,6 +201,7 @@ hl.bind(mainMod .. " + u", hl.dsp.submap("submap1")) hl.define_submap("submap1", function() hl.bind("u", hl.dsp.submap("submap2")) + hl.bind(mainMod .. " + u", hl.dsp.submap("submap3")) hl.bind("i", hl.dsp.submap("submap3")) hl.bind("o", hl.dsp.exec_cmd(terminal)) hl.bind("p", hl.dsp.submap("reset")) diff --git a/src/managers/KeybindManager.cpp b/src/managers/KeybindManager.cpp index a8e9dab9b..acbca0f28 100644 --- a/src/managers/KeybindManager.cpp +++ b/src/managers/KeybindManager.cpp @@ -613,7 +613,7 @@ SDispatchResult CKeybindManager::handleKeybinds(const uint32_t modmask, const SP if (!k->locked && g_pSessionLockManager->isSessionLocked()) continue; - if (!IGNORECONDITIONS && ((modmask != k->modmask && !k->ignoreMods) || (k->submap.name != Config::Actions::state()->m_currentSubmap && !k->submapUniversal) || k->shadowed)) + if (!IGNORECONDITIONS && ((modmask != k->modmask && !k->ignoreMods) || ((k->submap.name != key.submapAtPress.name) && !k->submapUniversal) || k->shadowed)) continue; if (device) {