input: add transparent binds

adds a new flag for binds to be transparent (non-shadowable)
fixes #3058
This commit is contained in:
vaxerski 2023-08-25 12:35:24 +02:00
parent ad085666c1
commit 6a5a5ed11e
3 changed files with 22 additions and 12 deletions

View file

@ -795,6 +795,7 @@ void CConfigManager::handleBind(const std::string& command, const std::string& v
bool repeat = false; bool repeat = false;
bool mouse = false; bool mouse = false;
bool nonConsuming = false; bool nonConsuming = false;
bool transparent = false;
const auto BINDARGS = command.substr(4); const auto BINDARGS = command.substr(4);
for (auto& arg : BINDARGS) { for (auto& arg : BINDARGS) {
@ -808,6 +809,8 @@ void CConfigManager::handleBind(const std::string& command, const std::string& v
mouse = true; mouse = true;
} else if (arg == 'n') { } else if (arg == 'n') {
nonConsuming = true; nonConsuming = true;
} else if (arg == 't') {
transparent = true;
} else { } else {
parseError = "bind: invalid flag"; parseError = "bind: invalid flag";
return; return;
@ -865,11 +868,12 @@ void CConfigManager::handleBind(const std::string& command, const std::string& v
if (KEY != "") { if (KEY != "") {
if (isNumber(KEY) && std::stoi(KEY) > 9) if (isNumber(KEY) && std::stoi(KEY) > 9)
g_pKeybindManager->addKeybind(SKeybind{"", std::stoi(KEY), MOD, HANDLER, COMMAND, locked, m_szCurrentSubmap, release, repeat, mouse, nonConsuming}); g_pKeybindManager->addKeybind(SKeybind{"", std::stoi(KEY), MOD, HANDLER, COMMAND, locked, m_szCurrentSubmap, release, repeat, mouse, nonConsuming, transparent});
else if (KEY.find("code:") == 0 && isNumber(KEY.substr(5))) else if (KEY.find("code:") == 0 && isNumber(KEY.substr(5)))
g_pKeybindManager->addKeybind(SKeybind{"", std::stoi(KEY.substr(5)), MOD, HANDLER, COMMAND, locked, m_szCurrentSubmap, release, repeat, mouse, nonConsuming}); g_pKeybindManager->addKeybind(
SKeybind{"", std::stoi(KEY.substr(5)), MOD, HANDLER, COMMAND, locked, m_szCurrentSubmap, release, repeat, mouse, nonConsuming, transparent});
else else
g_pKeybindManager->addKeybind(SKeybind{KEY, -1, MOD, HANDLER, COMMAND, locked, m_szCurrentSubmap, release, repeat, mouse, nonConsuming}); g_pKeybindManager->addKeybind(SKeybind{KEY, -1, MOD, HANDLER, COMMAND, locked, m_szCurrentSubmap, release, repeat, mouse, nonConsuming, transparent});
} }
} }

View file

@ -388,10 +388,11 @@ bool CKeybindManager::handleKeybinds(const uint32_t& modmask, const std::string&
if (g_pCompositor->m_sSeat.exclusiveClient) if (g_pCompositor->m_sSeat.exclusiveClient)
Debug::log(LOG, "Keybind handling only locked (inhibitor)"); Debug::log(LOG, "Keybind handling only locked (inhibitor)");
if (pressed && m_kHeldBack) { if (pressed && !m_vHeldBack.empty()) {
// release the held back event // release the held back events
wlr_seat_keyboard_notify_key(g_pCompositor->m_sSeat.seat, time, m_kHeldBack, WL_KEYBOARD_KEY_STATE_PRESSED); for (auto& k : m_vHeldBack)
m_kHeldBack = 0; wlr_seat_keyboard_notify_key(g_pCompositor->m_sSeat.seat, time, k, WL_KEYBOARD_KEY_STATE_PRESSED);
m_vHeldBack.clear();
} }
for (auto& k : m_lKeybinds) { for (auto& k : m_lKeybinds) {
@ -420,11 +421,15 @@ bool CKeybindManager::handleKeybinds(const uint32_t& modmask, const std::string&
if (pressed && k.release) { if (pressed && k.release) {
if (k.nonConsuming) if (k.nonConsuming)
return false; continue;
found = true;
if (k.transparent)
continue;
// suppress down event // suppress down event
m_kHeldBack = keysym; m_vHeldBack.push_back(keysym);
return true;
} }
const auto DISPATCHER = m_mDispatchers.find(k.mouse ? "mouse" : k.handler); const auto DISPATCHER = m_mDispatchers.find(k.mouse ? "mouse" : k.handler);
@ -474,7 +479,7 @@ void CKeybindManager::shadowKeybinds(const xkb_keysym_t& doesntHave, const int&
bool shadow = false; bool shadow = false;
if (k.handler == "global") if (k.handler == "global" || k.transparent)
continue; // can't be shadowed continue; // can't be shadowed
const auto KBKEY = xkb_keysym_from_name(k.key.c_str(), XKB_KEYSYM_CASE_INSENSITIVE); const auto KBKEY = xkb_keysym_from_name(k.key.c_str(), XKB_KEYSYM_CASE_INSENSITIVE);

View file

@ -22,6 +22,7 @@ struct SKeybind {
bool repeat = false; bool repeat = false;
bool mouse = false; bool mouse = false;
bool nonConsuming = false; bool nonConsuming = false;
bool transparent = false;
// DO NOT INITIALIZE // DO NOT INITIALIZE
bool shadowed = false; bool shadowed = false;
@ -67,7 +68,7 @@ class CKeybindManager {
inline static std::string m_szCurrentSelectedSubmap = ""; inline static std::string m_szCurrentSelectedSubmap = "";
xkb_keysym_t m_kHeldBack = 0; std::vector<xkb_keysym_t> m_vHeldBack;
SKeybind* m_pActiveKeybind = nullptr; SKeybind* m_pActiveKeybind = nullptr;