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
4 changes: 2 additions & 2 deletions debian/control
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Build-Depends: cmake (>= 3.25.0),
debhelper-compat (= 13),
ninja-build,
extra-cmake-modules (>= 1.4.0~),
libddm-dev (>= 0.3.3),
libddm-dev (>> 0.3.4),
libdtk6core-bin,
libdtk6core-dev,
libdtk6declarative-dev,
Expand Down Expand Up @@ -55,7 +55,7 @@ Depends: qml6-module-qtquick-layouts,
${shlibs:Depends},
Conflicts: libwaylib, qwlroots
Replaces: libwaylib, qwlroots
Recommends: ddm (>= 0.3.3),
Recommends: ddm (>> 0.3.4),
Description: a Wayland compositor based on wlroots and QML, designed with an attractive and elegant appearance.

Package: treeland-dev
Expand Down
4 changes: 2 additions & 2 deletions misc/systemd/treeland.service.in
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ PartOf=graphical.target
StartLimitIntervalSec=30
StartLimitBurst=2

Requires=seatd.service
After=seatd.service
Requires=dde-seatd.service
After=dde-seatd.service

[Service]
User=dde
Expand Down
31 changes: 7 additions & 24 deletions src/modules/ddm/ddminterfacev1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,20 +49,22 @@
wl_resource_destroy(resource->handle);
}

void DDMInterfaceV1Private::bind_resource(Resource *resource)

Check warning on line 52 in src/modules/ddm/ddminterfacev1.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

The function 'bind_resource' is never used.
{
send_acquire_vt(resource->handle, 0);
Q_UNUSED(resource)
}

void DDMInterfaceV1Private::switch_to_greeter([[maybe_unused]] Resource *resource)

Check warning on line 57 in src/modules/ddm/ddminterfacev1.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

The function 'switch_to_greeter' is never used.
{
qCWarning(treelandCore) << "DDM protocol: switch_to_greeter";
Helper::instance()->showLockScreen(false);
}

void DDMInterfaceV1Private::switch_to_user([[maybe_unused]] Resource *resource, const QString &username)

Check warning on line 63 in src/modules/ddm/ddminterfacev1.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

The function 'switch_to_user' is never used.
{
qCWarning(treelandCore) << "DDM protocol: switch_to_user" << username;
auto helper = Helper::instance();
if (username == "ddm") {
if (username == "dde") {
helper->showLockScreen(false);
} else if (username != helper->userModel()->currentUserName()) {
helper->userModel()->setCurrentUserName(username);
Expand All @@ -70,18 +72,21 @@
}
}

void DDMInterfaceV1Private::activate_session([[maybe_unused]] Resource *resource)

Check warning on line 75 in src/modules/ddm/ddminterfacev1.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

The function 'activate_session' is never used.
{
qCWarning(treelandCore) << "DDM protocol: activate_session";
Helper::instance()->activateSession();
}

void DDMInterfaceV1Private::deactivate_session([[maybe_unused]] Resource *resource)

Check warning on line 81 in src/modules/ddm/ddminterfacev1.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

The function 'deactivate_session' is never used.
{
qCWarning(treelandCore) << "DDM protocol: deactivate_session";
Helper::instance()->deactivateSession();
}

void DDMInterfaceV1Private::enable_render([[maybe_unused]] Resource *resource)

Check warning on line 87 in src/modules/ddm/ddminterfacev1.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

The function 'enable_render' is never used.
{
qCWarning(treelandCore) << "DDM protocol: enable_render";
Helper::instance()->enableRender();
}

Expand Down Expand Up @@ -113,28 +118,6 @@
return !d->resourceMap().isEmpty();
}

void DDMInterfaceV1::switchToVt(const int vtnr)
{
if (isConnected()) {
for (const auto &resource : d->resourceMap()) {
d->send_switch_to_vt(resource->handle, vtnr);
}
} else {
qCWarning(treelandCore) << "DDM is not connected when trying to call switchToVt";
}
}

void DDMInterfaceV1::acquireVt(const int vtnr)
{
if (isConnected()) {
for (const auto &resource : d->resourceMap()) {
d->send_acquire_vt(resource->handle, vtnr);
}
} else {
qCWarning(treelandCore) << "DDM is not connected when trying to call acquireVt";
}
}

void DDMInterfaceV1::create(WServer *server)
{
d->init(server->handle()->handle(), InterfaceVersion);
Expand Down
2 changes: 0 additions & 2 deletions src/modules/ddm/ddminterfacev1.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ class DDMInterfaceV1 : public QObject , public WServerInterface
~DDMInterfaceV1() override;

bool isConnected() const;
void switchToVt(const int vtnr);
void acquireVt(const int vtnr);

QByteArrayView interfaceName() const override;
static constexpr int InterfaceVersion = 1;
Expand Down
58 changes: 23 additions & 35 deletions src/seat/helper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,13 +128,11 @@
#include <QQmlContext>
#include <QQuickWindow>
#include <QtConcurrent>
#include <rhi/qrhi.h>

Check warning on line 131 in src/seat/helper.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <rhi/qrhi.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.

#include <functional>

Check warning on line 133 in src/seat/helper.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <functional> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <linux/input.h>
#include <pwd.h>

Check warning on line 134 in src/seat/helper.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <pwd.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <sys/ioctl.h>
#include <unistd.h>

Check warning on line 135 in src/seat/helper.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <unistd.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <utility>
#include <wayland-util.h>

Expand Down Expand Up @@ -1761,6 +1759,29 @@
if (event->isInputEvent()) {
m_idleNotifier->notify_activity(seat->nativeHandle());
}

if (event->type() == QEvent::KeyPress) {
auto kevent = static_cast<QKeyEvent *>(event);
const auto modifiers = kevent->modifiers();
const auto ctrlAlt = Qt::ControlModifier | Qt::AltModifier;
if ((modifiers & ctrlAlt) == ctrlAlt) {
const auto key = kevent->key();
if (key >= Qt::Key_F1 && key <= Qt::Key_F12) {
const int vtnr = key - Qt::Key_F1 + 1;
const bool sessionActive = m_backend->isSessionActive();
qCWarning(treelandCore) << "Ctrl+Alt+Fn VT shortcut received"
<< vtnr << "sessionActive" << sessionActive;
if (!sessionActive) {
return true;
}

qCWarning(treelandCore) << "Ctrl+Alt+Fn VT shortcut requested" << vtnr;
m_backend->session()->change_vt(vtnr);
return true;
}
}
}

WSeat *targetSeat = seat;
if (event->device()) {
WInputDevice *device = WInputDevice::from(event->device());
Expand Down Expand Up @@ -1815,26 +1836,6 @@
}
#endif

// Switch TTY with Ctrl + Alt + F1-F12
if (kevent->modifiers() == (Qt::ControlModifier | Qt::AltModifier)) {
auto key = kevent->key();
// We don't call libseat_disable_seat after switching TTY by
// calling DDM, which will cause the keyboard stuck in current
// state (Ctrl + Alt + Fx), and send switchToVt repeatly.
// Check if the backend is active to avoid this.
if (key >= Qt::Key_F1 && key <= Qt::Key_F12 && m_backend->isSessionActive()) {
const int vtnr = key - Qt::Key_F1 + 1;
if (m_ddmInterfaceV1 && m_ddmInterfaceV1->isConnected()) {
m_ddmInterfaceV1->switchToVt(vtnr);
} else {
qCDebug(treelandCore) << "DDM is not connected";
showLockScreen(false);
m_backend->session()->change_vt(vtnr);
}
return true;
}
}

if (m_captureSelector) {
if (event->modifiers() == Qt::NoModifier && kevent->key() == Qt::Key_Escape)
m_captureSelector->cancelSelection();
Expand Down Expand Up @@ -2721,19 +2722,6 @@

void Helper::disableRender() {
m_renderWindow->setRenderEnabled(false);

// Revoke all evdev devices to prevent accidental events during switch
static const char prefix[] = "/dev/input/";
static const int prefixLen = strlen(prefix);
struct wlr_session *session = m_backend->session()->handle();
struct wlr_device *device = nullptr;
wl_list_for_each(device, &session->devices, link) {
char path[32];
if (readlink(qPrintable(QStringLiteral("/proc/self/fd/%1").arg(device->fd)), path, 32) < 0)
qCWarning(treelandCore) << "Failed to read path of file descriptor " << device->fd;
else if (strncmp(prefix, path, prefixLen))
ioctl(device->fd, EVIOCREVOKE, nullptr);
}
}

void Helper::setBlockActivateSurface(bool block)
Expand Down
3 changes: 2 additions & 1 deletion waylib/src/server/kernel/wseat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,8 @@ void WSeatPrivate::on_keyboard_key(wlr_keyboard_key_event *event, WInputDevice *
"XKB_KEY_XF86Switch_VT_1..12 and XKB_KEY_F1..F12 must be contiguous and ordered for keysym calculation"
);
if (sym >= XKB_KEY_XF86Switch_VT_1 && sym <= XKB_KEY_XF86Switch_VT_12) {
if (keyModifiers == (Qt::ControlModifier | Qt::AltModifier)) {
constexpr auto ctrlAlt = Qt::ControlModifier | Qt::AltModifier;
if ((keyModifiers & ctrlAlt) == ctrlAlt) {
sym = XKB_KEY_F1 + (sym - XKB_KEY_XF86Switch_VT_1);
}
}
Expand Down
Loading