From a21ad8d4fa6aad524961e76cd7ffdc899b587903 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Tue, 19 Apr 2016 09:36:28 +0200 Subject: [PATCH] Switch virtual teminal through logind seat When we get the key code for virtual terminal switching we pass it to Logind instead of going through the "legacy" ioctl interface. --- input.cpp | 2 +- logind.cpp | 13 +++++++++++++ logind.h | 1 + 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/input.cpp b/input.cpp index 4eccbf826a..fe902c4a7a 100644 --- a/input.cpp +++ b/input.cpp @@ -114,7 +114,7 @@ public: if (event->type() == QEvent::KeyPress && !event->isAutoRepeat()) { const xkb_keysym_t keysym = event->nativeVirtualKey(); if (keysym >= XKB_KEY_XF86Switch_VT_1 && keysym <= XKB_KEY_XF86Switch_VT_12) { - VirtualTerminal::self()->activate(keysym - XKB_KEY_XF86Switch_VT_1 + 1); + LogindIntegration::self()->switchVirtualTerminal(keysym - XKB_KEY_XF86Switch_VT_1 + 1); return true; } } diff --git a/logind.cpp b/logind.cpp index c4ac031995..cdd7d940a0 100644 --- a/logind.cpp +++ b/logind.cpp @@ -362,4 +362,17 @@ void LogindIntegration::getSeat() ); } +void LogindIntegration::switchVirtualTerminal(quint32 vtNr) +{ + if (!m_connected || m_seatPath.isEmpty()) { + return; + } + QDBusMessage message = QDBusMessage::createMethodCall(s_login1Service, + m_seatPath, + QStringLiteral("org.freedesktop.login1.Seat"), + QStringLiteral("SwitchTo")); + message.setArguments(QVariantList{vtNr}); + m_bus.asyncCall(message); +} + } // namespace diff --git a/logind.h b/logind.h index d4c81ba6de..8bb02062d3 100644 --- a/logind.h +++ b/logind.h @@ -48,6 +48,7 @@ public: int vt() const { return m_vt; } + void switchVirtualTerminal(quint32 vtNr); void takeControl(); void releaseControl();