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
19 changes: 14 additions & 5 deletions src/modules/ddm/ddminterfacev1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,13 @@
}

static void switchToUser([[maybe_unused]] struct wl_client *client, [[maybe_unused]] struct wl_resource *resource, const char *username) {
if (strcmp(username, "ddm") != 0) {
Helper::instance()->userModel()->setCurrentUserName(QString(username));
auto user = QString::fromLocal8Bit(username);
auto helper = Helper::instance();
if (user == "ddm") {
helper->showLockScreen(false);
} else if (user != helper->userModel()->currentUserName()) {
helper->userModel()->setCurrentUserName(QString(username));
helper->showLockScreen(false);
}
}

Expand All @@ -40,8 +45,12 @@
Helper::instance()->enableRender();
}

static void disableRender([[maybe_unused]] struct wl_client *client, [[maybe_unused]] struct wl_resource *resource) {
static void disableRender(struct wl_client *client, [[maybe_unused]] struct wl_resource *resource, uint32_t id) {
Helper::instance()->disableRender();
auto callback = wl_resource_create(client, &wl_callback_interface, 1, id);
auto serial = wl_display_get_serial(wl_client_get_display(client));
wl_callback_send_done(callback, serial);
wl_resource_destroy(callback);
}

static const struct treeland_ddm_interface treeland_ddm_impl {
Expand Down Expand Up @@ -110,15 +119,15 @@

// Event wrapper

void DDMInterfaceV1::switchToVt(int vtnr) {
void DDMInterfaceV1::switchToVt(const int vtnr) {

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

View workflow job for this annotation

GitHub Actions / cppcheck

The function 'switchToVt' is never used.
auto ddm = static_cast<struct treeland_ddm *>(m_handle);
if (isConnected())
treeland_ddm_send_switch_to_vt(ddm->resource, vtnr);
else
qCWarning(treelandCore) << "DDM is not conected when trying to call switchToVt";
}

void DDMInterfaceV1::acquireVt(int vtnr) {
void DDMInterfaceV1::acquireVt(const int vtnr) {

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

View workflow job for this annotation

GitHub Actions / cppcheck

The function 'acquireVt' is never used.
auto ddm = static_cast<struct treeland_ddm *>(m_handle);
if (isConnected())
treeland_ddm_send_acquire_vt(ddm->resource, vtnr);
Expand Down
4 changes: 2 additions & 2 deletions src/modules/ddm/ddminterfacev1.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ class DDMInterfaceV1 : public Waylib::Server::WServerInterface {
~DDMInterfaceV1() override;
QByteArrayView interfaceName() const override;
bool isConnected() const;
void switchToVt(int vtnr);
void acquireVt(int vtnr);
void switchToVt(const int vtnr);
void acquireVt(const int vtnr);
protected:
void create(Waylib::Server::WServer *server) override;
void destroy(Waylib::Server::WServer *server) override;
Expand Down
16 changes: 16 additions & 0 deletions src/seat/helper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,11 @@
#include <QDBusInterface>
#include <QDBusObjectPath>

#include <pwd.h>

Check warning on line 105 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 <utility>

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

View workflow job for this annotation

GitHub Actions / cppcheck

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

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

View workflow job for this annotation

GitHub Actions / cppcheck

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

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

View workflow job for this annotation

GitHub Actions / cppcheck

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

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

View workflow job for this annotation

GitHub Actions / cppcheck

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

#define WLR_FRACTIONAL_SCALE_V1_VERSION 1
#define EXT_DATA_CONTROL_MANAGER_V1_VERSION 1
Expand Down Expand Up @@ -2205,4 +2208,17 @@

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);
}
}
Loading