Skip to content

Commit 7277846

Browse files
committed
fix: screensaver_dbus.cpp and session_lock.cpp linting errors
1 parent e6c6402 commit 7277846

File tree

7 files changed

+59
-26
lines changed

7 files changed

+59
-26
lines changed

src/dbus/objectmanager.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,4 @@ class DBusObjectManager: public QObject {
3434
DBusObjectManagerInterface* mInterface = nullptr;
3535
};
3636

37-
} // namespace qs::dbus
37+
} // namespace qs::dbus

src/dbus/org.freedesktop.ScreenSaver.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
<node>
22
<interface name="org.freedesktop.ScreenSaver">
33
<!-- Get the current lock state -->
4-
<method name="getActive">
4+
<method name="GetActive">
55
<arg name="active" direction="out" type="b"/>
66
</method>
77

88
<!-- Signal emitted when lock state changes -->
9-
<signal name="activeChanged">
9+
<signal name="ActiveChanged">
1010
<arg name="active" type="b"/>
1111
</signal>
1212

1313
<!-- Get whether the compositor has confirmed the lock (secure state) -->
14-
<method name="getSecure">
14+
<method name="GetSecure">
1515
<arg name="secure" direction="out" type="b"/>
1616
</method>
1717
</interface>

src/dbus/screensaver_dbus.cpp

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,19 @@
11
#include "screensaver_dbus.hpp"
22

3-
#include <QDBusConnection>
4-
#include <QDBusError>
5-
#include <QLoggingCategory>
6-
#include <QObject> // emit
7-
#include <QtGlobal> // QtWarningMsg
3+
#include <qdbusabstractadaptor.h>
4+
#include <qdbusconnection.h>
5+
#include <qdbuserror.h>
6+
#include <qlogging.h>
7+
#include <qloggingcategory.h>
8+
#include <qobject.h>
9+
#include <qtmetamacros.h>
810

911
#include "../core/logcat.hpp"
1012

1113
namespace {
14+
1215
QS_LOGGING_CATEGORY(logDbusScreenSaver, "quickshell.dbus.screensaver", QtWarningMsg);
16+
1317
}
1418

1519
namespace qs::dbus {
@@ -39,7 +43,7 @@ void ScreenSaverAdaptor::setActive(bool active) {
3943
if (this->mActive != active) {
4044
this->mActive = active;
4145
qCDebug(logDbusScreenSaver) << "Lock state changed to:" << active;
42-
emit activeChanged(active); // method name fixed
46+
emit this->ActiveChanged(active);
4347
}
4448
}
4549

@@ -50,13 +54,13 @@ void ScreenSaverAdaptor::setSecure(bool secure) {
5054
}
5155
}
5256

53-
bool ScreenSaverAdaptor::getActive() const { // method name fixed
54-
qCDebug(logDbusScreenSaver) << "getActive called, returning:" << this->mActive;
57+
bool ScreenSaverAdaptor::GetActive() const {
58+
qCDebug(logDbusScreenSaver) << "GetActive called, returning:" << this->mActive;
5559
return this->mActive;
5660
}
5761

58-
bool ScreenSaverAdaptor::getSecure() const { // method name fixed
59-
qCDebug(logDbusScreenSaver) << "getSecure called, returning:" << this->mSecure;
62+
bool ScreenSaverAdaptor::GetSecure() const {
63+
qCDebug(logDbusScreenSaver) << "GetSecure called, returning:" << this->mSecure;
6064
return this->mSecure;
6165
}
6266

src/dbus/screensaver_dbus.hpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
#pragma once
22

3-
#include <QDBusAbstractAdaptor>
4-
#include <QObject>
5-
#include <QtGlobal> // QtWarningMsg
3+
#include <qdbusabstractadaptor.h>
4+
#include <qobject.h>
5+
#include <qtmetamacros.h>
66

77
namespace qs::dbus {
88

99
class ScreenSaverAdaptor: public QDBusAbstractAdaptor {
10-
Q_OBJECT
10+
Q_OBJECT;
1111
Q_CLASSINFO("D-Bus Interface", "org.freedesktop.ScreenSaver")
1212

1313
public:
@@ -19,11 +19,11 @@ class ScreenSaverAdaptor: public QDBusAbstractAdaptor {
1919
void setSecure(bool secure);
2020

2121
public slots:
22-
[[nodiscard]] bool getActive() const;
23-
[[nodiscard]] bool getSecure() const;
22+
[[nodiscard]] bool GetActive() const; // NOLINT(readability-identifier-naming)
23+
[[nodiscard]] bool GetSecure() const; // NOLINT(readability-identifier-naming)
2424

2525
signals:
26-
void activeChanged(bool active);
26+
void ActiveChanged(bool active); // NOLINT(readability-identifier-naming)
2727

2828
private:
2929
bool mActive = false;

src/wayland/session_lock/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ qt_add_library(quickshell-wayland-sessionlock STATIC
66
session_lock.cpp
77
)
88
wl_proto(wlp-session-lock ext-session-lock-v1 "${WAYLAND_PROTOCOLS}/staging/ext-session-lock")
9+
target_include_directories(quickshell-wayland-sessionlock PRIVATE ${CMAKE_SOURCE_DIR}/src)
910
target_link_libraries(quickshell-wayland-sessionlock PRIVATE
1011
Qt::Quick Qt::WaylandClient Qt::WaylandClientPrivate Qt::DBus wayland-client
1112
wlp-session-lock

src/wayland/session_lock/session_lock.cpp

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,32 @@
33
#include <private/qwaylanddisplay_p.h>
44
#include <qlogging.h>
55
#include <qobject.h>
6+
#include <qtmetamacros.h>
67
#include <qwindow.h>
78

89
#include "../../dbus/screensaver_dbus.hpp"
910
#include "lock.hpp"
1011
#include "manager.hpp"
1112
#include "shell_integration.hpp"
1213
#include "surface.hpp"
14+
1315
namespace {
16+
1417
QSWaylandSessionLockManager* manager() {
1518
static QSWaylandSessionLockManager* manager = nullptr; // NOLINT
1619
if (manager == nullptr) {
1720
manager = new QSWaylandSessionLockManager();
1821
}
1922
return manager;
2023
}
24+
2125
} // namespace
26+
2227
bool SessionLockManager::lockAvailable() { return manager()->isActive(); }
28+
2329
bool SessionLockManager::lock() {
2430
if (this->isLocked() || SessionLockManager::sessionLocked()) return false;
31+
2532
this->mLock = manager()->acquireLock();
2633
this->mLock->setParent(this);
2734

@@ -39,30 +46,40 @@ bool SessionLockManager::lock() {
3946
this->mDbusAdaptor->setSecure(true);
4047
emit this->locked();
4148
});
49+
4250
QObject::connect(this->mLock, &QSWaylandSessionLock::unlocked, this, [this]() {
4351
this->mDbusAdaptor->setActive(false);
4452
this->mDbusAdaptor->setSecure(false);
4553
emit this->unlocked();
4654
});
4755
// clang-format on
56+
4857
return true;
4958
}
59+
5060
bool SessionLockManager::unlock() {
5161
if (!this->isLocked()) return false;
62+
5263
this->mLock->unlock();
5364
auto* lock = this->mLock;
5465
this->mLock = nullptr;
5566
delete lock;
67+
5668
return true;
5769
}
70+
5871
bool SessionLockManager::isLocked() const { return this->mLock != nullptr; }
72+
5973
bool SessionLockManager::sessionLocked() { return manager()->isLocked(); }
74+
6075
bool SessionLockManager::isSecure() { return manager()->isSecure(); }
76+
6177
LockWindowExtension::~LockWindowExtension() {
6278
if (this->surface != nullptr) {
6379
this->surface->setExtension(nullptr);
6480
}
6581
}
82+
6683
LockWindowExtension* LockWindowExtension::get(QWindow* window) {
6784
auto v = window->property("sessionlock_ext");
6885
if (v.canConvert<LockWindowExtension*>()) {
@@ -71,24 +88,30 @@ LockWindowExtension* LockWindowExtension::get(QWindow* window) {
7188
return nullptr;
7289
}
7390
}
91+
7492
bool LockWindowExtension::isAttached() const { return this->surface != nullptr; }
93+
7594
bool LockWindowExtension::attach(QWindow* window, SessionLockManager* manager) {
7695
if (this->surface != nullptr)
7796
qFatal() << "Cannot change the attached window of a LockWindowExtension";
97+
7898
auto* current = LockWindowExtension::get(window);
7999
QtWaylandClient::QWaylandWindow* waylandWindow = nullptr;
100+
80101
if (current != nullptr) {
81102
current->surface->setExtension(this);
82103
} else {
83104
// Qt appears to be resetting the window's screen on creation on some systems. This works around it.
84105
auto* screen = window->screen();
85106
window->create();
86107
window->setScreen(screen);
108+
87109
waylandWindow = dynamic_cast<QtWaylandClient::QWaylandWindow*>(window->handle());
88110
if (waylandWindow == nullptr) {
89111
qWarning() << window << "is not a wayland window. Cannot create lock surface.";
90112
return false;
91113
}
114+
92115
static QSWaylandSessionLockIntegration* lockIntegration = nullptr; // NOLINT
93116
if (lockIntegration == nullptr) {
94117
lockIntegration = new QSWaylandSessionLockIntegration();
@@ -98,17 +121,23 @@ bool LockWindowExtension::attach(QWindow* window, SessionLockManager* manager) {
98121
qWarning() << "Failed to initialize lockscreen integration";
99122
}
100123
}
124+
101125
waylandWindow->setShellIntegration(lockIntegration);
102126
}
127+
103128
this->setParent(window);
104129
window->setProperty("sessionlock_ext", QVariant::fromValue(this));
130+
105131
this->lock = manager->mLock;
132+
106133
if (waylandWindow != nullptr) {
107134
this->surface = new QSWaylandSessionLockSurface(waylandWindow);
108135
if (this->immediatelyVisible) this->surface->setVisible();
109136
}
137+
110138
return true;
111139
}
140+
112141
void LockWindowExtension::setVisible() {
113142
if (this->surface == nullptr) this->immediatelyVisible = true;
114143
else this->surface->setVisible();

src/wayland/session_lock/session_lock.hpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class ScreenSaverAdaptor;
1414
}
1515

1616
class SessionLockManager: public QObject {
17-
Q_OBJECT;
17+
Q_OBJECT
1818

1919
public:
2020
explicit SessionLockManager(QObject* parent = nullptr): QObject(parent) {}
@@ -30,11 +30,10 @@ class SessionLockManager: public QObject {
3030
bool unlock();
3131

3232
[[nodiscard]] bool isLocked() const;
33-
3433
static bool sessionLocked();
3534
static bool isSecure();
3635

37-
signals:
36+
Q_SIGNALS:
3837
// This signal is sent once the compositor considers the session to be fully locked.
3938
// This corrosponds to the ext_session_lock_v1::locked event.
4039
void locked();
@@ -58,7 +57,7 @@ class SessionLockManager: public QObject {
5857
};
5958

6059
class LockWindowExtension: public QObject {
61-
Q_OBJECT;
60+
Q_OBJECT
6261

6362
public:
6463
explicit LockWindowExtension(QObject* parent = nullptr): QObject(parent) {}
@@ -78,7 +77,7 @@ class LockWindowExtension: public QObject {
7877

7978
static LockWindowExtension* get(QWindow* window);
8079

81-
signals:
80+
Q_SIGNALS:
8281
// This signal is sent once the compositor considers the session to be fully locked.
8382
// See SessionLockManager::locked for details.
8483
void locked();

0 commit comments

Comments
 (0)