diff --git a/0001-Redesign-Xauth-handling.patch b/0001-Redesign-Xauth-handling.patch index 088e736..daadb5d 100644 --- a/0001-Redesign-Xauth-handling.patch +++ b/0001-Redesign-Xauth-handling.patch @@ -153,7 +153,7 @@ index cf44a62..a7e0585 100644 - Entry(UserAuthFile, QString, _S(".Xauthority"), _S("Path to the Xauthority file")); Entry(DisplayCommand, QString, _S(DATA_INSTALL_DIR "/scripts/Xsetup"), _S("Path to a script to execute when starting the display server")); Entry(DisplayStopCommand, QString, _S(DATA_INSTALL_DIR "/scripts/Xstop"), _S("Path to a script to execute when stopping the display server")); - Entry(MinimumVT, int, MINIMUM_VT, _S("The lowest virtual terminal number that will be used.")); + Entry(EnableHiDPI, bool, false, _S("Enable Qt's automatic high-DPI scaling")); diff --git a/src/common/XauthUtils.cpp b/src/common/XauthUtils.cpp new file mode 100644 index 0000000..da1c691 diff --git a/0001-Retry-starting-the-display-server.patch b/0001-Retry-starting-the-display-server.patch new file mode 100644 index 0000000..18fcff4 --- /dev/null +++ b/0001-Retry-starting-the-display-server.patch @@ -0,0 +1,118 @@ +From 42c51761cc82edbaa50d702a4614e179ad4bcd63 Mon Sep 17 00:00:00 2001 +From: Fabian Vogt +Date: Thu, 12 Nov 2020 20:30:55 +0100 +Subject: [PATCH] Retry starting the display server + +Even if the CanGraphical property of a Seat is true, it's possible that it's +still too early for X to start, as it might need some driver or device which +isn't present yet. + +Fixes #1316 +--- + src/daemon/Seat.cpp | 23 ++++++++++++++++++----- + src/daemon/Seat.h | 4 +++- + src/daemon/XorgDisplayServer.cpp | 10 ++++++---- + 3 files changed, 27 insertions(+), 10 deletions(-) + +diff --git a/src/daemon/Seat.cpp b/src/daemon/Seat.cpp +index eef26da..838c222 100644 +--- a/src/daemon/Seat.cpp ++++ b/src/daemon/Seat.cpp +@@ -28,6 +28,7 @@ + + #include + #include ++#include + + #include + +@@ -52,7 +53,7 @@ namespace SDDM { + return m_name; + } + +- bool Seat::createDisplay(int terminalId) { ++ void Seat::createDisplay(int terminalId) { + //reload config if needed + mainConfig.load(); + +@@ -84,12 +85,24 @@ namespace SDDM { + m_displays << display; + + // start the display +- if (!display->start()) { +- qCritical() << "Could not start Display server on vt" << terminalId; +- return false; ++ startDisplay(display); ++ } ++ ++ void Seat::startDisplay(Display *display, int tryNr) { ++ if (display->start()) ++ return; ++ ++ // It's possible that the system isn't ready yet (driver not loaded, ++ // device not enumerated, ...). It's not possible to tell when that changes, ++ // so try a few times with a delay in between. ++ qWarning() << "Attempt" << tryNr << "starting the Display server on vt" << display->terminalId() << "failed"; ++ ++ if(tryNr >= 3) { ++ qCritical() << "Could not start Display server on vt" << display->terminalId(); ++ return; + } + +- return true; ++ QTimer::singleShot(2000, display, [=] { startDisplay(display, tryNr + 1); }); + } + + void Seat::removeDisplay(Display* display) { +diff --git a/src/daemon/Seat.h b/src/daemon/Seat.h +index bf22566..f9fe733 100644 +--- a/src/daemon/Seat.h ++++ b/src/daemon/Seat.h +@@ -35,13 +35,15 @@ namespace SDDM { + const QString &name() const; + + public slots: +- bool createDisplay(int terminalId = -1); ++ void createDisplay(int terminalId = -1); + void removeDisplay(SDDM::Display* display); + + private slots: + void displayStopped(); + + private: ++ void startDisplay(SDDM::Display *display, int tryNr = 1); ++ + QString m_name; + + QVector m_displays; +diff --git a/src/daemon/XorgDisplayServer.cpp b/src/daemon/XorgDisplayServer.cpp +index e60c022..5f40fe8 100644 +--- a/src/daemon/XorgDisplayServer.cpp ++++ b/src/daemon/XorgDisplayServer.cpp +@@ -248,6 +248,12 @@ namespace SDDM { + } + + void XorgDisplayServer::finished() { ++ // clean up ++ if (process) { ++ process->deleteLater(); ++ process = nullptr; ++ } ++ + // check flag + if (!m_started) + return; +@@ -283,10 +289,6 @@ namespace SDDM { + displayStopScript->deleteLater(); + displayStopScript = nullptr; + +- // clean up +- process->deleteLater(); +- process = nullptr; +- + // remove authority file + QFile::remove(m_authPath); + +-- +2.31.1 + diff --git a/308fd0df2583b02251f0d80c397ccbf9fa7a9e04.patch b/308fd0df2583b02251f0d80c397ccbf9fa7a9e04.patch new file mode 100644 index 0000000..5372fe4 --- /dev/null +++ b/308fd0df2583b02251f0d80c397ccbf9fa7a9e04.patch @@ -0,0 +1,216 @@ +From 308fd0df2583b02251f0d80c397ccbf9fa7a9e04 Mon Sep 17 00:00:00 2001 +From: Pier Luigi Fiorini +Date: Sun, 28 Feb 2021 12:07:33 +0100 +Subject: [PATCH] Allocate VT for the display + +Replace the old crude algorithm to find the next available VT with a +more reliable method using the VT_OPENQRY ioctl. + +General.MinimumVT setting is now obsolete and it's no longer used. +--- + CMakeLists.txt | 4 ---- + data/man/sddm.conf.rst.in | 2 +- + src/common/Configuration.h | 1 - + src/common/Constants.h.in | 1 - + src/daemon/Display.cpp | 8 +++++--- + src/daemon/Display.h | 2 +- + src/daemon/Seat.cpp | 38 +++----------------------------------- + src/daemon/Seat.h | 3 +-- + 8 files changed, 11 insertions(+), 48 deletions(-) + +diff --git a/CMakeLists.txt b/CMakeLists.txt +index e52e0e90..9614b4e1 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -141,7 +141,6 @@ if(SYSTEMD_FOUND) + string(REGEX REPLACE "[ \t\n]+" "" SYSTEMD_SYSTEM_UNIT_DIR ${SYSTEMD_SYSTEM_UNIT_DIR}) + endif() + +- set(MINIMUM_VT 1) + set(HALT_COMMAND "/usr/bin/systemctl poweroff") + set(REBOOT_COMMAND "/usr/bin/systemctl reboot") + else() +@@ -159,7 +158,6 @@ if(ELOGIND_FOUND) + add_definitions(-DHAVE_ELOGIND) + set(CMAKE_AUTOMOC_MOC_OPTIONS -DHAVE_ELOGIND) + +- set(MINIMUM_VT 7) + set(HALT_COMMAND "/usr/bin/loginctl poweroff") + set(REBOOT_COMMAND "/usr/bin/loginctl reboot") + endif() +@@ -171,10 +169,8 @@ if (NOT ELOGIND_FOUND AND NOT SYSTEMD_FOUND) + # commands for shutdown and reboot. On FreeBSD, there are + # normally more getty's running than on Linux. + if("${CMAKE_SYSTEM_NAME}" STREQUAL "FreeBSD") +- set(MINIMUM_VT 9) + set(HALT_COMMAND "/sbin/shutdown -p now") + else() +- set(MINIMUM_VT 7) + set(HALT_COMMAND "/sbin/shutdown -h -P now") + endif() + set(REBOOT_COMMAND "/sbin/shutdown -r now") +diff --git a/data/man/sddm.conf.rst.in b/data/man/sddm.conf.rst.in +index bee07681..1061540c 100644 +--- a/data/man/sddm.conf.rst.in ++++ b/data/man/sddm.conf.rst.in +@@ -144,7 +144,7 @@ OPTIONS + Minimum virtual terminal number that will be used + by the first display. Virtual terminal number will + increase as new displays added. +- Default value is @MINIMUM_VT@. ++ This setting is no longer available since SDDM v0.20. + + `EnableHiDPI=` + Enables Qt's automatic HiDPI scaling. +diff --git a/src/common/Configuration.h b/src/common/Configuration.h +index cf44a629..b7987198 100644 +--- a/src/common/Configuration.h ++++ b/src/common/Configuration.h +@@ -70,7 +70,6 @@ namespace SDDM { + Entry(UserAuthFile, QString, _S(".Xauthority"), _S("Path to the Xauthority file")); + Entry(DisplayCommand, QString, _S(DATA_INSTALL_DIR "/scripts/Xsetup"), _S("Path to a script to execute when starting the display server")); + Entry(DisplayStopCommand, QString, _S(DATA_INSTALL_DIR "/scripts/Xstop"), _S("Path to a script to execute when stopping the display server")); +- Entry(MinimumVT, int, MINIMUM_VT, _S("The lowest virtual terminal number that will be used.")); + Entry(EnableHiDPI, bool, false, _S("Enable Qt's automatic high-DPI scaling")); + ); + +diff --git a/src/common/Constants.h.in b/src/common/Constants.h.in +index e174b5bf..48051288 100644 +--- a/src/common/Constants.h.in ++++ b/src/common/Constants.h.in +@@ -37,7 +37,6 @@ + #define SYSTEM_CONFIG_DIR "@SYSTEM_CONFIG_DIR@" + + #define LOG_FILE "@LOG_FILE@" +-#define MINIMUM_VT @MINIMUM_VT@ + + #define UID_MIN @UID_MIN@ + #define UID_MAX @UID_MAX@ +diff --git a/src/daemon/Display.cpp b/src/daemon/Display.cpp +index a65df3f0..dbef510d 100644 +--- a/src/daemon/Display.cpp ++++ b/src/daemon/Display.cpp +@@ -45,17 +45,19 @@ + + #include "Login1Manager.h" + #include "Login1Session.h" +- ++#include "VirtualTerminal.h" + + namespace SDDM { +- Display::Display(const int terminalId, Seat *parent) : QObject(parent), +- m_terminalId(terminalId), ++ Display::Display(Seat *parent) : QObject(parent), + m_auth(new Auth(this)), + m_displayServer(new XorgDisplayServer(this)), + m_seat(parent), + m_socketServer(new SocketServer(this)), + m_greeter(new Greeter(this)) { + ++ // Allocate vt ++ m_terminalId = VirtualTerminal::setUpNewVt(); ++ + // respond to authentication requests + m_auth->setVerbose(true); + connect(m_auth, &Auth::requestChanged, this, &Display::slotRequestChanged); +diff --git a/src/daemon/Display.h b/src/daemon/Display.h +index e68bc128..9db954d1 100644 +--- a/src/daemon/Display.h ++++ b/src/daemon/Display.h +@@ -41,7 +41,7 @@ namespace SDDM { + Q_OBJECT + Q_DISABLE_COPY(Display) + public: +- explicit Display(int terminalId, Seat *parent); ++ explicit Display(Seat *parent); + ~Display(); + + QString displayId() const; +diff --git a/src/daemon/Seat.cpp b/src/daemon/Seat.cpp +index 838c2221..a2f3d0c3 100644 +--- a/src/daemon/Seat.cpp ++++ b/src/daemon/Seat.cpp +@@ -33,18 +33,6 @@ + #include + + namespace SDDM { +- int findUnused(int minimum, std::function used) { +- // initialize with minimum +- int number = minimum; +- +- // find unused +- while (used(number)) +- number++; +- +- // return number; +- return number; +- } +- + Seat::Seat(const QString &name, QObject *parent) : QObject(parent), m_name(name) { + createDisplay(); + } +@@ -53,30 +41,13 @@ namespace SDDM { + return m_name; + } + +- void Seat::createDisplay(int terminalId) { ++ void Seat::createDisplay() { + //reload config if needed + mainConfig.load(); + +- if (m_name == QLatin1String("seat0")) { +- if (terminalId == -1) { +- // find unused terminal +- terminalId = findUnused(mainConfig.X11.MinimumVT.get(), [&](const int number) { +- return m_terminalIds.contains(number); +- }); +- } +- +- // mark terminal as used +- m_terminalIds << terminalId; +- +- // log message +- qDebug() << "Adding new display" << "on vt" << terminalId << "..."; +- } +- else { +- qDebug() << "Adding new VT-less display..."; +- } +- + // create a new display +- Display *display = new Display(terminalId, this); ++ qDebug() << "Adding new display..."; ++ Display *display = new Display(this); + + // restart display on stop + connect(display, &Display::stopped, this, &Seat::displayStopped); +@@ -112,9 +83,6 @@ namespace SDDM { + // remove display from list + m_displays.removeAll(display); + +- // mark display and terminal ids as unused +- m_terminalIds.removeAll(display->terminalId()); +- + // stop the display + display->blockSignals(true); + display->stop(); +diff --git a/src/daemon/Seat.h b/src/daemon/Seat.h +index f9fe7331..685eaedd 100644 +--- a/src/daemon/Seat.h ++++ b/src/daemon/Seat.h +@@ -35,7 +35,7 @@ namespace SDDM { + const QString &name() const; + + public slots: +- void createDisplay(int terminalId = -1); ++ void createDisplay(); + void removeDisplay(SDDM::Display* display); + + private slots: +@@ -47,7 +47,6 @@ namespace SDDM { + QString m_name; + + QVector m_displays; +- QVector m_terminalIds; + }; + } + diff --git a/sddm-0.19.0-fedora_config.patch b/sddm-0.19.0-fedora_config.patch index e376f93..dcfcb16 100644 --- a/sddm-0.19.0-fedora_config.patch +++ b/sddm-0.19.0-fedora_config.patch @@ -21,9 +21,9 @@ index a7e0585..36cf9d0 100644 + Entry(SessionLogFile, QString, _S(".cache/xsession-errors"), _S("Path to the user session log file")); + Entry(DisplayCommand, QString, _S(SYS_CONFIG_DIR "/sddm/Xsetup"), _S("Path to a script to execute when starting the display server")); + Entry(DisplayStopCommand, QString, _S(SYS_CONFIG_DIR "/sddm/Xstop"), _S("Path to a script to execute when stopping the display server")); - Entry(MinimumVT, int, MINIMUM_VT, _S("The lowest virtual terminal number that will be used.")); Entry(EnableHiDPI, bool, false, _S("Enable Qt's automatic high-DPI scaling")); ); + @@ -75,7 +75,7 @@ namespace SDDM { Section(Wayland, Entry(SessionDir, QString, _S("/usr/share/wayland-sessions"), _S("Directory containing available Wayland sessions")); diff --git a/sddm.spec b/sddm.spec index 01a9c80..cef1f26 100644 --- a/sddm.spec +++ b/sddm.spec @@ -9,7 +9,7 @@ Name: sddm Version: 0.19.0 -Release: 9%{?dist} +Release: 10%{?dist} License: GPLv2+ Summary: QML based X11 desktop manager @@ -31,6 +31,13 @@ Patch052: 0001-Redesign-Xauth-handling.patch # newer(?) pristine one from upstream PR has xauth locking issues wrt RUNTIME_DIR #Patch52: 0001-Redesign-Xauth-handling-1.patch +# First two commits from: +# https://github.com/sddm/sddm/pull/1371 +# Fixes several (but not all) issues with session switching: +# https://bugzilla.redhat.com/show_bug.cgi?id=1929643 +Patch053: 0001-Retry-starting-the-display-server.patch +Patch054: 308fd0df2583b02251f0d80c397ccbf9fa7a9e04.patch + ## downstream patches Patch101: sddm-0.19.0-fedora_config.patch @@ -237,6 +244,9 @@ fi %changelog +* Tue Apr 13 2021 Adam Williamson - 0.19.0-10 +- Backport part of PR #1371 to improve session switching (#1929643) + * Fri Apr 02 2021 Rex Dieter - 0.19.0-9 - initial support for sddm.conf.d snippets