parent
fa263e6139
commit
ffb9d96c00
@ -0,0 +1,66 @@
|
|||||||
|
From e128a1b4ea74f02bc4a9047ea0e95e7563e6d3ac Mon Sep 17 00:00:00 2001
|
||||||
|
From: Martin Briza <mbriza@redhat.com>
|
||||||
|
Date: Wed, 2 Nov 2016 17:13:40 +0100
|
||||||
|
Subject: [PATCH] Switch to another managed VT when the current one quits
|
||||||
|
|
||||||
|
---
|
||||||
|
src/daemon/Seat.cpp | 27 +++++++++++++++++++++++++--
|
||||||
|
1 file changed, 25 insertions(+), 2 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/src/daemon/Seat.cpp b/src/daemon/Seat.cpp
|
||||||
|
index 3ef1b2f..966d445 100644
|
||||||
|
--- a/src/daemon/Seat.cpp
|
||||||
|
+++ b/src/daemon/Seat.cpp
|
||||||
|
@@ -30,6 +30,12 @@
|
||||||
|
|
||||||
|
#include <functional>
|
||||||
|
|
||||||
|
+#include <linux/vt.h>
|
||||||
|
+#include <linux/kd.h>
|
||||||
|
+#include <sys/ioctl.h>
|
||||||
|
+#include <fcntl.h>
|
||||||
|
+#include <unistd.h>
|
||||||
|
+
|
||||||
|
namespace SDDM {
|
||||||
|
int findUnused(int minimum, std::function<bool(const int)> used) {
|
||||||
|
// initialize with minimum
|
||||||
|
@@ -84,7 +90,6 @@ namespace SDDM {
|
||||||
|
void Seat::removeDisplay(Display* display) {
|
||||||
|
qDebug() << "Removing display" << display->displayId() << "...";
|
||||||
|
|
||||||
|
-
|
||||||
|
// remove display from list
|
||||||
|
m_displays.removeAll(display);
|
||||||
|
|
||||||
|
@@ -102,12 +107,30 @@ namespace SDDM {
|
||||||
|
|
||||||
|
void Seat::displayStopped() {
|
||||||
|
Display *display = qobject_cast<Display *>(sender());
|
||||||
|
+ int oldVT = display->terminalId();
|
||||||
|
|
||||||
|
// remove display
|
||||||
|
removeDisplay(display);
|
||||||
|
|
||||||
|
+ // try switching to some other active VT
|
||||||
|
+ bool success = false;
|
||||||
|
+ char path[33] = { 0 };
|
||||||
|
+ snprintf(path, 32, "/dev/tty%d", oldVT);
|
||||||
|
+ int ttyfd = open(path, O_RDONLY);
|
||||||
|
+
|
||||||
|
+ if (ttyfd >= 0) {
|
||||||
|
+ for (int newVT : m_terminalIds) {
|
||||||
|
+ int result = ioctl(ttyfd, VT_ACTIVATE, newVT);
|
||||||
|
+ if (result == 0) {
|
||||||
|
+ success = true;
|
||||||
|
+ break;
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+ close(ttyfd);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
// restart otherwise
|
||||||
|
- if (m_displays.isEmpty())
|
||||||
|
+ if (!success)
|
||||||
|
createDisplay();
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in new issue