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
29 changes: 27 additions & 2 deletions src/daemon/TreelandConnector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,25 @@ static void onAcquireDisplay() {
auto user = daemonApp->displayManager()->findUserByVt(vtnr);
if (!user.isEmpty()) {
qDebug("Activate session at VT %d for user %s", vtnr, qPrintable(user));
daemonApp->treelandConnector()->switchToUser(user);
daemonApp->treelandConnector()->activateSession();
daemonApp->treelandConnector()->enableRender();
daemonApp->treelandConnector()->switchToUser(user);
}
}

static void onReleaseDisplay() {
// TODO: Wayland request is asynchronous, which may leads a late execution,
// makes treeland still possible to draw on DRM after VT switching.
daemonApp->treelandConnector()->disableRender();

int fd = open(defaultVtPath, O_RDWR | O_NOCTTY);
ioctl(fd, VT_RELDISP, 1);
close(fd);

int activeVtFd = open(defaultVtPath, O_RDWR | O_NOCTTY);
int activeVt = VirtualTerminal::getVtActive(activeVtFd);
auto user = daemonApp->displayManager()->findUserByVt(activeVt);
qDebug("Next VT: %d, user: %s", activeVt, qPrintable(user));
qDebug("Next VT: %d, user: %s", activeVt, user.isEmpty() ? "None" : qPrintable(user));
if (user.isEmpty()) {
// We must switch Treeland to greeter mode before we switch back to it,
// or it will get stuck.
Expand All @@ -58,6 +64,7 @@ static void onReleaseDisplay() {
// ddm-helper. It uses VT signals from VirtualTerminal.h,
// which is not what we want, so we should acquire VT control here.
VirtualTerminal::handleVtSwitches(activeVtFd);
daemonApp->treelandConnector()->enableRender();
}
close(activeVtFd);
}
Expand Down Expand Up @@ -184,4 +191,22 @@ void TreelandConnector::deactivateSession() {
}
}

void TreelandConnector::enableRender() {
if (isConnected()) {
treeland_ddm_enable_render(m_ddm);
wl_display_flush(m_display);
} else {
qWarning("Treeland is not connected when trying to call enableRender");
}
}

void TreelandConnector::disableRender() {
if (isConnected()) {
treeland_ddm_disable_render(m_ddm);
wl_display_flush(m_display);
} else {
qWarning("Treeland is not connected when trying to call disableRender");
}
}

}
2 changes: 2 additions & 0 deletions src/daemon/TreelandConnector.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ class TreelandConnector : QObject {
void switchToUser(const QString username);
void activateSession();
void deactivateSession();
void enableRender();
void disableRender();
private:
struct wl_display *m_display { nullptr };
QSocketNotifier *m_notifier { nullptr };
Expand Down