Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .reuse/dep5
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,8 @@ Files:
src/daemon/SeatManager.h
src/daemon/SocketServer.cpp
src/daemon/SocketServer.h
src/daemon/TreelandConnector.cpp
src/daemon/TreelandConnector.h
src/daemon/Utils.h
src/daemon/WaylandDisplayServer.cpp
src/daemon/WaylandDisplayServer.h
Expand Down
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ find_package(XCB REQUIRED)
# XKB
find_package(XKB REQUIRED)

# TreelandProtocols
find_package(TreelandProtocols REQUIRED)
Comment thread
calsys456 marked this conversation as resolved.

find_package(Qt6 CONFIG REQUIRED Core DBus Gui Qml Quick QuickControls2 LinguistTools Test QuickTest)
qt_standard_project_setup(REQUIRES 6.6)

Expand Down
1 change: 1 addition & 0 deletions debian/control
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ Build-Depends: debhelper-compat (= 13),
qt6-wayland,
qt6-wayland-dev,
qt6-wayland-private-dev,
treeland-protocols,
systemd [linux-any],
Standards-Version: 4.6.0
Section: libs
Expand Down
2 changes: 2 additions & 0 deletions nix/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
, pixman
, pam
, libxcrypt
, treeland-protocols
}:

stdenv.mkDerivation (finalAttrs: {
Expand Down Expand Up @@ -51,6 +52,7 @@ stdenv.mkDerivation (finalAttrs: {
pixman
pam
libxcrypt
treeland-protocols
];

cmakeFlags = [
Expand Down
3 changes: 0 additions & 3 deletions services/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@ if(SYSTEMD_FOUND)
configure_file(ddm.service.in ddm.service)
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/ddm.service" DESTINATION "${SYSTEMD_SYSTEM_UNIT_DIR}")

configure_file(seatd-dde.service.in seatd-dde.service)
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/seatd-dde.service" DESTINATION "${SYSTEMD_SYSTEM_UNIT_DIR}")

configure_file(ddm-sysuser.conf.in ddm-sysuser.conf)
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/ddm-sysuser.conf" DESTINATION "${SYSTEMD_SYSUSERS_DIR}" RENAME dde.conf)
endif()
Expand Down
4 changes: 2 additions & 2 deletions services/ddm.service.in
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ PartOf=graphical.target
StartLimitIntervalSec=30
StartLimitBurst=2

Requires=seatd-dde.service
Before=seatd-dde.service
Requires=seatd.service
Before=seatd.service

[Service]
ExecStart=@CMAKE_INSTALL_FULL_BINDIR@/ddm
Expand Down
62 changes: 0 additions & 62 deletions services/seatd-dde.service.in

This file was deleted.

30 changes: 23 additions & 7 deletions src/common/VirtualTerminal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,19 +75,30 @@ namespace DDM {
}
#endif

std::function<void()> onAcquireFunction = nullptr;
std::function<void()> onReleaseFunction = nullptr;

static void onAcquireDisplay([[maybe_unused]] int signal) {
int fd = open(defaultVtPath, O_RDWR | O_NOCTTY);
ioctl(fd, VT_RELDISP, VT_ACKACQ);
close(fd);
if (onAcquireFunction) {
onAcquireFunction();
} else {
int fd = open(defaultVtPath, O_RDWR | O_NOCTTY);
ioctl(fd, VT_RELDISP, VT_ACKACQ);
close(fd);
}
}

static void onReleaseDisplay([[maybe_unused]] int signal) {
int fd = open(defaultVtPath, O_RDWR | O_NOCTTY);
ioctl(fd, VT_RELDISP, 1);
close(fd);
if (onReleaseFunction) {
onReleaseFunction();
} else {
int fd = open(defaultVtPath, O_RDWR | O_NOCTTY);
ioctl(fd, VT_RELDISP, 1);
close(fd);
}
}

static bool handleVtSwitches(int fd) {
bool handleVtSwitches(int fd) {
vt_mode setModeRequest { };
bool ok = true;

Expand Down Expand Up @@ -254,5 +265,10 @@ namespace DDM {
if (vtFd != -1)
close(vtFd);
Comment thread
calsys456 marked this conversation as resolved.
}

void setVtSignalHandler(std::function<void()> onAcquireDisplay, std::function<void()> onReleaseDisplay) {
onAcquireFunction = onAcquireDisplay;
onReleaseFunction = onReleaseDisplay;
}
}
}
3 changes: 3 additions & 0 deletions src/common/VirtualTerminal.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,12 @@
namespace DDM {
namespace VirtualTerminal {
QString path(int vt);
int getVtActive(int fd);
bool handleVtSwitches(int fd);
int currentVt();
int setUpNewVt();
void jumpToVt(int vt, bool vt_auto);
void setVtSignalHandler(std::function<void()> onAcquireDisplay, std::function<void()> onReleaseDisplay);
}
}

Expand Down
12 changes: 12 additions & 0 deletions src/daemon/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,15 @@ include_directories(
"${LIBXCB_INCLUDE_DIR}"
)

pkg_search_module(WAYLAND REQUIRED IMPORTED_TARGET wayland-client)

add_custom_target(treeland-ddm ALL
COMMAND
wayland-scanner client-header < ${TREELAND_PROTOCOLS_DATA_DIR}/treeland-ddm-v1.xml > ${CMAKE_CURRENT_BINARY_DIR}/treeland-ddm-v1.h
COMMAND
wayland-scanner private-code < ${TREELAND_PROTOCOLS_DATA_DIR}/treeland-ddm-v1.xml > ${CMAKE_CURRENT_BINARY_DIR}/treeland-ddm-v1.c
)

configure_file(config.h.in config.h IMMEDIATE @ONLY)
set(DAEMON_SOURCES
DaemonApp.cpp
Expand All @@ -14,13 +23,15 @@ set(DAEMON_SOURCES
Seat.cpp
SeatManager.cpp
SocketServer.cpp
TreelandConnector.cpp
XorgDisplayServer.cpp
XorgUserDisplayServer.cpp
XorgUserDisplayServer.h
WaylandDisplayServer.cpp
WaylandDisplayServer.h
SingleWaylandDisplayServer.h
SingleWaylandDisplayServer.cpp
treeland-ddm-v1.c
)

qt_add_dbus_adaptor(DAEMON_SOURCES "${CMAKE_SOURCE_DIR}/data/interfaces/org.freedesktop.DisplayManager.xml" "DisplayManager.h" DDM::DisplayManager)
Expand Down Expand Up @@ -57,6 +68,7 @@ target_link_libraries(ddm
Qt${QT_MAJOR_VERSION}::Network
Qt${QT_MAJOR_VERSION}::Qml
${LIBXCB_LIBRARIES}
PkgConfig::WAYLAND
)

if(JOURNALD_FOUND)
Expand Down
7 changes: 7 additions & 0 deletions src/daemon/DaemonApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include "PowerManager.h"
#include "SeatManager.h"
#include "SignalHandler.h"
#include "TreelandConnector.h"

#include "MessageHandler.h"

Expand Down Expand Up @@ -85,6 +86,8 @@ namespace DDM {
// quit when SIGINT, SIGTERM received
connect(m_signalHandler, &SignalHandler::sigintReceived, this, &DaemonApp::quit);
connect(m_signalHandler, &SignalHandler::sigtermReceived, this, &DaemonApp::quit);

m_treelandConnector = new TreelandConnector();
// log message
qDebug() << "Starting...";

Expand Down Expand Up @@ -117,6 +120,10 @@ namespace DDM {
return m_signalHandler;
}

TreelandConnector *DaemonApp::treelandConnector() const {
return m_treelandConnector;
}

int DaemonApp::newSessionId() {
return m_lastSessionId++;
}
Expand Down
3 changes: 3 additions & 0 deletions src/daemon/DaemonApp.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ namespace DDM {
class PowerManager;
class SeatManager;
class SignalHandler;
class TreelandConnector;

class DaemonApp : public QCoreApplication {
Q_OBJECT
Expand All @@ -48,6 +49,7 @@ namespace DDM {
PowerManager *powerManager() const;
SeatManager *seatManager() const;
SignalHandler *signalHandler() const;
TreelandConnector *treelandConnector() const;

void backToNormal();

Expand All @@ -64,6 +66,7 @@ namespace DDM {
PowerManager *m_powerManager { nullptr };
SeatManager *m_seatManager { nullptr };
SignalHandler *m_signalHandler { nullptr };
TreelandConnector *m_treelandConnector { nullptr };
};
}

Expand Down
4 changes: 3 additions & 1 deletion src/daemon/Display.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,8 @@ namespace DDM {
m_displayServer = new SingleWaylandDisplayServer(m_socketServer, this);
m_greeter->setDisplayServerCommand(mainConfig.Single.CompositorCommand.get());
m_greeter->setSingleMode();
// Record current VT as ddm user session
DaemonApp::instance()->displayManager()->AddSession({}, seat()->name(), "ddm", static_cast<uint>(VirtualTerminal::currentVt()));
break;
}

Expand Down Expand Up @@ -537,7 +539,7 @@ namespace DDM {
// session id
{
const QString sessionId = QStringLiteral("Session%1").arg(daemonApp->newSessionId());
daemonApp->displayManager()->AddSession(sessionId, seat()->name(), user);
daemonApp->displayManager()->AddSession(sessionId, seat()->name(), user, auth->tty());
env.insert(QStringLiteral("XDG_SESSION_PATH"), daemonApp->displayManager()->sessionPath(sessionId));
auth->setSessionId(sessionId);
}
Expand Down
21 changes: 17 additions & 4 deletions src/daemon/DisplayManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include "displaymanageradaptor.h"
#include "seatadaptor.h"
#include "sessionadaptor.h"
#include "VirtualTerminal.h"

const QString DISPLAYMANAGER_SERVICE = QStringLiteral("org.freedesktop.DisplayManager");
const QString DISPLAYMANAGER_PATH = QStringLiteral("/org/freedesktop/DisplayManager");
Expand Down Expand Up @@ -132,9 +133,9 @@ namespace DDM {
}
}

void DisplayManager::AddSession(const QString &name, const QString &seat, const QString &user) {
void DisplayManager::AddSession(const QString &name, const QString &seat, const QString &user, const int &vtnr) {
// create session object
DisplayManagerSession *session = new DisplayManagerSession(name, seat, user, this);
DisplayManagerSession *session = new DisplayManagerSession(name, seat, user, vtnr, this);

// add to the list
m_sessions << session;
Expand Down Expand Up @@ -178,6 +179,14 @@ namespace DDM {
}
}

const QString DisplayManager::findUserByVt(int vtnr) {
for (auto session : m_sessions) {
Comment thread
calsys456 marked this conversation as resolved.
if (vtnr == session->VTNr())
return session->User();
}
return QString();
}

DisplayManagerSeat::DisplayManagerSeat(const QString &name, QObject *parent)
: QObject(parent), m_name(name), m_path(DISPLAYMANAGER_SEAT_PATH + name.mid(4)) {
// create adaptor
Expand Down Expand Up @@ -217,8 +226,8 @@ namespace DDM {
return daemonApp->displayManager()->Sessions(this);
}

DisplayManagerSession::DisplayManagerSession(const QString &name, const QString &seat, const QString &user, QObject *parent)
: QObject(parent), m_name(name), m_path(DISPLAYMANAGER_SESSION_PATH + name.mid(7)), m_seat(seat), m_user(user) {
DisplayManagerSession::DisplayManagerSession(const QString &name, const QString &seat, const QString &user, const int &vtnr, QObject *parent)
: QObject(parent), m_name(name), m_path(DISPLAYMANAGER_SESSION_PATH + name.mid(7)), m_seat(seat), m_user(user), m_vtnr(vtnr) {
// create adaptor
new SessionAdaptor(this);

Expand All @@ -240,6 +249,10 @@ namespace DDM {
return m_seat;
}

const int &DisplayManagerSession::VTNr() const {
return m_vtnr;
}

void DisplayManagerSession::Lock() {
// TODO: IMPLEMENT
}
Expand Down
8 changes: 6 additions & 2 deletions src/daemon/DisplayManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,12 @@ namespace DDM {
QString AuthInfo() const;
QString LastActivatedUser() const;

const QString findUserByVt(int vtnr);

public slots:
void AddSeat(const QString &name);
void RemoveSeat(const QString &name);
void AddSession(const QString &name, const QString &seat, const QString &user);
void AddSession(const QString &name, const QString &seat, const QString &user, const int &vtnr);
void RemoveSession(const QString &name);
void setLastSession(const QString &session);
void setAuthInfo(const QString &authSocket);
Expand Down Expand Up @@ -124,12 +126,13 @@ namespace DDM {
Q_PROPERTY(QDBusObjectPath Seat READ SeatPath)
Q_PROPERTY(QString UserName READ User)
public:
DisplayManagerSession(const QString &name, const QString &seat, const QString &user, QObject *parent = 0);
DisplayManagerSession(const QString &name, const QString &seat, const QString &user, const int &vtnr, QObject *parent = 0);

const QString &Name() const;
const QString &Path() const;
const QString &Seat() const;
const QString &User() const;
const int &VTNr() const;

void Lock();

Expand All @@ -140,6 +143,7 @@ namespace DDM {
QString m_path;
QString m_seat;
QString m_user;
int m_vtnr;
};
}

Expand Down
Loading