mirror of
https://github.com/hyprwm/Hyprland
synced 2024-11-26 08:45:58 +01:00
fix tty switch freeze
This commit is contained in:
parent
11ce468996
commit
e90c5c6347
1 changed files with 17 additions and 5 deletions
|
@ -423,14 +423,26 @@ bool CKeybindManager::handleVT(xkb_keysym_t keysym) {
|
||||||
if (!(keysym >= XKB_KEY_XF86Switch_VT_1 && keysym <= XKB_KEY_XF86Switch_VT_12))
|
if (!(keysym >= XKB_KEY_XF86Switch_VT_1 && keysym <= XKB_KEY_XF86Switch_VT_12))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
const auto PSESSION = wlr_backend_get_session(g_pCompositor->m_sWLRBackend);
|
if (g_pCompositor->m_sWLRSession) {
|
||||||
if (PSESSION) {
|
|
||||||
const unsigned int TTY = keysym - XKB_KEY_XF86Switch_VT_1 + 1;
|
const unsigned int TTY = keysym - XKB_KEY_XF86Switch_VT_1 + 1;
|
||||||
|
|
||||||
if (PSESSION->vtnr == TTY)
|
// vtnr is bugged for some reason.
|
||||||
return false; // don't do anything.
|
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;
|
g_pCompositor->m_bSessionActive = false;
|
||||||
|
|
||||||
for (auto& m : g_pCompositor->m_vMonitors) {
|
for (auto& m : g_pCompositor->m_vMonitors) {
|
||||||
|
|
Loading…
Reference in a new issue