summaryrefslogtreecommitdiff
path: root/src/managers/KeybindManager.cpp
diff options
context:
space:
mode:
authorvaxerski <43317083+vaxerski@users.noreply.github.com>2022-10-05 21:41:27 +0100
committervaxerski <43317083+vaxerski@users.noreply.github.com>2022-10-05 21:41:27 +0100
commite90c5c634753bede3056bb7b3c55d001afb2ac45 (patch)
treea4ec48c4e3897936fe5dd76c55576205974b59d1 /src/managers/KeybindManager.cpp
parent11ce4689963f52a72817a9395ecccc1b034447a7 (diff)
fix tty switch freeze
Diffstat (limited to 'src/managers/KeybindManager.cpp')
-rw-r--r--src/managers/KeybindManager.cpp22
1 files changed, 17 insertions, 5 deletions
diff --git a/src/managers/KeybindManager.cpp b/src/managers/KeybindManager.cpp
index 44124e81..7201aad3 100644
--- a/src/managers/KeybindManager.cpp
+++ b/src/managers/KeybindManager.cpp
@@ -423,14 +423,26 @@ bool CKeybindManager::handleVT(xkb_keysym_t keysym) {
if (!(keysym >= XKB_KEY_XF86Switch_VT_1 && keysym <= XKB_KEY_XF86Switch_VT_12))
return false;
- const auto PSESSION = wlr_backend_get_session(g_pCompositor->m_sWLRBackend);
- if (PSESSION) {
+ if (g_pCompositor->m_sWLRSession) {
const unsigned int TTY = keysym - XKB_KEY_XF86Switch_VT_1 + 1;
- if (PSESSION->vtnr == TTY)
- return false; // don't do anything.
+ // vtnr is bugged for some reason.
+ const std::string TTYSTR = execAndGet("head -n 1 /sys/devices/virtual/tty/tty0/active").substr(3);
+ int ttynum = 0;
+ try {
+ ttynum = std::stoll(TTYSTR);
+ } catch (std::exception e) {
+ ; // oops?
+ }
+
+ if (ttynum == TTY)
+ return false;
+
+ Debug::log(LOG, "Switching from VT %i to VT %i", ttynum, TTY);
+
+ if (!wlr_session_change_vt(g_pCompositor->m_sWLRSession, TTY))
+ return false; // probably same session
- wlr_session_change_vt(PSESSION, TTY);
g_pCompositor->m_bSessionActive = false;
for (auto& m : g_pCompositor->m_vMonitors) {