chore: clean up lints

This commit is contained in:
outfoxxed 2024-02-28 21:30:06 -08:00
parent 4eac0b40c3
commit cbdfba1a3f
Signed by: outfoxxed
GPG key ID: 4C88A185FB89301E
13 changed files with 32 additions and 52 deletions

View file

@ -1,17 +1,21 @@
#include "session_lock.hpp" #include "session_lock.hpp"
#include <qcolor.h> #include <qcolor.h>
#include <qcoreapplication.h>
#include <qguiapplication.h> #include <qguiapplication.h>
#include <qlogging.h> #include <qlogging.h>
#include <qobject.h> #include <qobject.h>
#include <qqmlcomponent.h> #include <qqmlcomponent.h>
#include <qqmlengine.h> #include <qqmlengine.h>
#include <qqmllist.h>
#include <qquickitem.h> #include <qquickitem.h>
#include <qquickwindow.h> #include <qquickwindow.h>
#include <qscreen.h> #include <qscreen.h>
#include <qtmetamacros.h> #include <qtmetamacros.h>
#include <qtypes.h> #include <qtypes.h>
#include "../core/qmlscreen.hpp"
#include "../core/reload.hpp"
#include "session_lock/session_lock.hpp" #include "session_lock/session_lock.hpp"
void SessionLock::onReload(QObject* oldInstance) { void SessionLock::onReload(QObject* oldInstance) {
@ -136,12 +140,6 @@ void SessionLock::setLocked(bool locked) {
QQmlComponent* SessionLock::surfaceComponent() const { return this->mSurfaceComponent; } QQmlComponent* SessionLock::surfaceComponent() const { return this->mSurfaceComponent; }
void SessionLock::rip() {
if (this->isLocked()) {
exit(1);
}
}
void SessionLock::setSurfaceComponent(QQmlComponent* surfaceComponent) { void SessionLock::setSurfaceComponent(QQmlComponent* surfaceComponent) {
if (this->mSurfaceComponent != nullptr) this->mSurfaceComponent->deleteLater(); if (this->mSurfaceComponent != nullptr) this->mSurfaceComponent->deleteLater();
if (surfaceComponent != nullptr) surfaceComponent->setParent(this); if (surfaceComponent != nullptr) surfaceComponent->setParent(this);
@ -194,7 +192,7 @@ void SessionLockSurface::onReload(QObject* oldInstance) {
// clang-format on // clang-format on
if (auto* parent = qobject_cast<SessionLock*>(this->parent())) { if (auto* parent = qobject_cast<SessionLock*>(this->parent())) {
if (!this->ext->attach(window, parent->manager)) { if (!this->ext->attach(this->window, parent->manager)) {
qWarning( qWarning(
) << "Failed to attach LockWindowExtension to window. Surface will not behave correctly."; ) << "Failed to attach LockWindowExtension to window. Surface will not behave correctly.";
} }
@ -202,9 +200,6 @@ void SessionLockSurface::onReload(QObject* oldInstance) {
qWarning( qWarning(
) << "SessionLockSurface parent is not a SessionLock. Surface will not behave correctly."; ) << "SessionLockSurface parent is not a SessionLock. Surface will not behave correctly.";
} }
// without this the dangling screen pointer wont be updated to a real screen
emit this->screenChanged();
} }
QQuickWindow* SessionLockSurface::disownWindow() { QQuickWindow* SessionLockSurface::disownWindow() {

View file

@ -15,7 +15,6 @@
#include <qtmetamacros.h> #include <qtmetamacros.h>
#include <qtypes.h> #include <qtypes.h>
#include "../core/doc.hpp"
#include "../core/qmlscreen.hpp" #include "../core/qmlscreen.hpp"
#include "../core/reload.hpp" #include "../core/reload.hpp"
#include "session_lock/session_lock.hpp" #include "session_lock/session_lock.hpp"
@ -49,8 +48,6 @@ public:
[[nodiscard]] QQmlComponent* surfaceComponent() const; [[nodiscard]] QQmlComponent* surfaceComponent() const;
void setSurfaceComponent(QQmlComponent* surfaceComponent); void setSurfaceComponent(QQmlComponent* surfaceComponent);
QSDOC_HIDE Q_INVOKABLE void rip();
signals: signals:
void lockStateChanged(); void lockStateChanged();
void secureStateChanged(); void secureStateChanged();

View file

@ -1,7 +1,7 @@
#include "lock.hpp" #include "lock.hpp"
#include <private/qwaylandshellintegration_p.h>
#include <qtmetamacros.h> #include <qtmetamacros.h>
#include <wayland-ext-session-lock-v1-client-protocol.h>
#include "manager.hpp" #include "manager.hpp"

View file

@ -1,7 +1,5 @@
#include "manager.hpp" #include "manager.hpp"
#include <qdebug.h>
#include <qlogging.h>
#include <qwaylandclientextension.h> #include <qwaylandclientextension.h>
#include "lock.hpp" #include "lock.hpp"

View file

@ -10,8 +10,9 @@
#include "shell_integration.hpp" #include "shell_integration.hpp"
#include "surface.hpp" #include "surface.hpp"
static QSWaylandSessionLockManager* manager() { namespace {
static QSWaylandSessionLockManager* manager = nullptr; QSWaylandSessionLockManager* manager() {
static QSWaylandSessionLockManager* manager = nullptr; // NOLINT
if (manager == nullptr) { if (manager == nullptr) {
manager = new QSWaylandSessionLockManager(); manager = new QSWaylandSessionLockManager();
@ -19,6 +20,7 @@ static QSWaylandSessionLockManager* manager() {
return manager; return manager;
} }
} // namespace
bool SessionLockManager::lock() { bool SessionLockManager::lock() {
if (this->isLocked() || SessionLockManager::sessionLocked()) return false; if (this->isLocked() || SessionLockManager::sessionLocked()) return false;
@ -79,7 +81,7 @@ bool LockWindowExtension::attach(QWindow* window, SessionLockManager* manager) {
return false; return false;
} }
static QSWaylandSessionLockIntegration* lockIntegration = nullptr; static QSWaylandSessionLockIntegration* lockIntegration = nullptr; // NOLINT
if (lockIntegration == nullptr) { if (lockIntegration == nullptr) {
lockIntegration = new QSWaylandSessionLockIntegration(); lockIntegration = new QSWaylandSessionLockIntegration();
if (!lockIntegration->initialize(waylandWindow->display())) { if (!lockIntegration->initialize(waylandWindow->display())) {
@ -105,6 +107,6 @@ bool LockWindowExtension::attach(QWindow* window, SessionLockManager* manager) {
} }
void LockWindowExtension::setVisible() { void LockWindowExtension::setVisible() {
if (this->surface == nullptr) immediatelyVisible = true; if (this->surface == nullptr) this->immediatelyVisible = true;
else this->surface->setVisible(); else this->surface->setVisible();
} }

View file

@ -14,7 +14,6 @@ class SessionLockManager: public QObject {
public: public:
explicit SessionLockManager(QObject* parent = nullptr): QObject(parent) {} explicit SessionLockManager(QObject* parent = nullptr): QObject(parent) {}
Q_DISABLE_COPY_MOVE(SessionLockManager);
// Returns true if a lock was acquired. // Returns true if a lock was acquired.
// If true is returned the caller must watch the global screen list and create/destroy // If true is returned the caller must watch the global screen list and create/destroy
@ -59,6 +58,7 @@ class LockWindowExtension: public QObject {
public: public:
explicit LockWindowExtension(QObject* parent = nullptr): QObject(parent) {} explicit LockWindowExtension(QObject* parent = nullptr): QObject(parent) {}
~LockWindowExtension() override; ~LockWindowExtension() override;
Q_DISABLE_COPY_MOVE(LockWindowExtension);
// Attach this lock extension to the given window. // Attach this lock extension to the given window.
// The extension is reparented to the window and replaces any existing lock extension. // The extension is reparented to the window and replaces any existing lock extension.

View file

@ -7,7 +7,7 @@
#include <private/qwaylandwindow_p.h> #include <private/qwaylandwindow_p.h>
#include <qlogging.h> #include <qlogging.h>
#include <qobject.h> #include <qobject.h>
#include <wayland-client-protocol.h> #include <qtypes.h>
#include "lock.hpp" #include "lock.hpp"
#include "session_lock.hpp" #include "session_lock.hpp"
@ -27,7 +27,7 @@ QSWaylandSessionLockSurface::QSWaylandSessionLockSurface(QtWaylandClient::QWayla
throw nullptr; throw nullptr;
} }
wl_output* output = nullptr; wl_output* output = nullptr; // NOLINT (include)
auto* waylandScreen = dynamic_cast<QtWaylandClient::QWaylandScreen*>(qwindow->screen()->handle()); auto* waylandScreen = dynamic_cast<QtWaylandClient::QWaylandScreen*>(qwindow->screen()->handle());
if (waylandScreen != nullptr) { if (waylandScreen != nullptr) {
@ -75,7 +75,7 @@ void QSWaylandSessionLockSurface::setExtension(LockWindowExtension* ext) {
} }
void QSWaylandSessionLockSurface::setVisible() { void QSWaylandSessionLockSurface::setVisible() {
if (this->configured && !this->visible) initVisible(); if (this->configured && !this->visible) this->initVisible();
this->visible = true; this->visible = true;
} }
@ -92,7 +92,7 @@ void QSWaylandSessionLockSurface::ext_session_lock_surface_v1_configure(
this->window()->resizeFromApplyConfigure(this->size); this->window()->resizeFromApplyConfigure(this->size);
this->window()->handleExpose(QRect(QPoint(), this->size)); this->window()->handleExpose(QRect(QPoint(), this->size));
if (this->visible) initVisible(); if (this->visible) this->initVisible();
} else { } else {
this->window()->applyConfigureWhenPossible(); this->window()->applyConfigureWhenPossible();
} }
@ -105,10 +105,10 @@ void QSWaylandSessionLockSurface::initVisible() {
// We attach a dummy buffer to satisfy ext_session_lock_v1. // We attach a dummy buffer to satisfy ext_session_lock_v1.
this->initBuf = new QtWaylandClient::QWaylandShmBuffer( this->initBuf = new QtWaylandClient::QWaylandShmBuffer(
this->window()->display(), this->window()->display(),
size, this->size,
QImage::Format_ARGB32 QImage::Format_ARGB32
); );
this->window()->waylandSurface()->attach(initBuf->buffer(), 0, 0); this->window()->waylandSurface()->attach(this->initBuf->buffer(), 0, 0);
this->window()->window()->setVisible(true); this->window()->window()->setVisible(true);
} }

View file

@ -22,7 +22,7 @@ public:
void applyConfigure() override; void applyConfigure() override;
bool handleExpose(const QRegion& region) override; bool handleExpose(const QRegion& region) override;
void setExtension(LockWindowExtension*); void setExtension(LockWindowExtension* ext);
void setVisible(); void setVisible();
private: private:

View file

@ -5,14 +5,13 @@
#include <private/qwaylandwindow_p.h> #include <private/qwaylandwindow_p.h>
#include "surface.hpp" #include "surface.hpp"
#include "wayland-wlr-layer-shell-unstable-v1-client-protocol.h"
QSWaylandLayerShellIntegration::QSWaylandLayerShellIntegration() QSWaylandLayerShellIntegration::QSWaylandLayerShellIntegration()
: QtWaylandClient::QWaylandShellIntegrationTemplate<QSWaylandLayerShellIntegration>(4) {} : QtWaylandClient::QWaylandShellIntegrationTemplate<QSWaylandLayerShellIntegration>(4) {}
QSWaylandLayerShellIntegration::~QSWaylandLayerShellIntegration() { QSWaylandLayerShellIntegration::~QSWaylandLayerShellIntegration() {
if (this->object() != nullptr) { if (this->isInitialized()) {
zwlr_layer_shell_v1_destroy(this->object()); this->destroy();
} }
} }

View file

@ -2,7 +2,7 @@
#include <private/qwaylandshellintegration_p.h> #include <private/qwaylandshellintegration_p.h>
#include <private/qwaylandshellsurface_p.h> #include <private/qwaylandshellsurface_p.h>
#include <qtwaylandclientexports.h> #include <qtclasshelpermacros.h>
#include <qwayland-wlr-layer-shell-unstable-v1.h> #include <qwayland-wlr-layer-shell-unstable-v1.h>
class QSWaylandLayerShellIntegration class QSWaylandLayerShellIntegration
@ -11,10 +11,7 @@ class QSWaylandLayerShellIntegration
public: public:
QSWaylandLayerShellIntegration(); QSWaylandLayerShellIntegration();
~QSWaylandLayerShellIntegration() override; ~QSWaylandLayerShellIntegration() override;
QSWaylandLayerShellIntegration(QSWaylandLayerShellIntegration&&) = delete; Q_DISABLE_COPY_MOVE(QSWaylandLayerShellIntegration);
QSWaylandLayerShellIntegration(const QSWaylandLayerShellIntegration&) = delete;
void operator=(QSWaylandLayerShellIntegration&&) = delete;
void operator=(const QSWaylandLayerShellIntegration&) = delete;
QtWaylandClient::QWaylandShellSurface* createShellSurface(QtWaylandClient::QWaylandWindow* window QtWaylandClient::QWaylandShellSurface* createShellSurface(QtWaylandClient::QWaylandWindow* window
) override; ) override;

View file

@ -23,12 +23,11 @@
[[nodiscard]] QSize constrainedSize(const Anchors& anchors, const QSize& size) noexcept; [[nodiscard]] QSize constrainedSize(const Anchors& anchors, const QSize& size) noexcept;
// clang-format on // clang-format on
// clang-format off
QSWaylandLayerSurface::QSWaylandLayerSurface( QSWaylandLayerSurface::QSWaylandLayerSurface(
QSWaylandLayerShellIntegration* shell, QSWaylandLayerShellIntegration* shell,
QtWaylandClient::QWaylandWindow* window QtWaylandClient::QWaylandWindow* window
): QtWaylandClient::QWaylandShellSurface(window) { )
// clang-format on : QtWaylandClient::QWaylandShellSurface(window) {
auto* qwindow = window->window(); auto* qwindow = window->window();
this->ext = LayershellWindowExtension::get(qwindow); this->ext = LayershellWindowExtension::get(qwindow);
@ -37,7 +36,7 @@ QSWaylandLayerSurface::QSWaylandLayerSurface(
throw "QSWaylandLayerSurface created with null LayershellWindowExtension"; throw "QSWaylandLayerSurface created with null LayershellWindowExtension";
} }
wl_output* output = nullptr; // NOLINT (import) wl_output* output = nullptr; // NOLINT (include)
if (this->ext->useWindowScreen) { if (this->ext->useWindowScreen) {
auto* waylandScreen = auto* waylandScreen =
dynamic_cast<QtWaylandClient::QWaylandScreen*>(qwindow->screen()->handle()); dynamic_cast<QtWaylandClient::QWaylandScreen*>(qwindow->screen()->handle());
@ -45,8 +44,8 @@ QSWaylandLayerSurface::QSWaylandLayerSurface(
if (waylandScreen != nullptr) { if (waylandScreen != nullptr) {
output = waylandScreen->output(); output = waylandScreen->output();
} else { } else {
qWarning() << "Layershell screen is set but does not corrospond to a real screen. Letting " qWarning(
"the compositor pick."; ) << "Layershell screen does not corrospond to a real screen. Letting the compositor pick.";
} }
} }

View file

@ -2,6 +2,7 @@
#include <private/qwaylandshellsurface_p.h> #include <private/qwaylandshellsurface_p.h>
#include <private/qwaylandwindow_p.h> #include <private/qwaylandwindow_p.h>
#include <qtclasshelpermacros.h>
#include <qtwaylandclientexports.h> #include <qtwaylandclientexports.h>
#include <qtypes.h> #include <qtypes.h>
#include <qwayland-wlr-layer-shell-unstable-v1.h> #include <qwayland-wlr-layer-shell-unstable-v1.h>
@ -20,10 +21,7 @@ public:
); );
~QSWaylandLayerSurface() override; ~QSWaylandLayerSurface() override;
QSWaylandLayerSurface(QSWaylandLayerSurface&&) = delete; Q_DISABLE_COPY_MOVE(QSWaylandLayerSurface);
QSWaylandLayerSurface(const QSWaylandLayerSurface&) = delete;
void operator=(QSWaylandLayerSurface&&) = delete;
void operator=(const QSWaylandLayerSurface&) = delete;
[[nodiscard]] bool isExposed() const override; [[nodiscard]] bool isExposed() const override;
void applyConfigure() override; void applyConfigure() override;

View file

@ -56,17 +56,12 @@ class LayershellWindowExtension: public QObject {
public: public:
LayershellWindowExtension(QObject* parent = nullptr): QObject(parent) {} LayershellWindowExtension(QObject* parent = nullptr): QObject(parent) {}
~LayershellWindowExtension() override = default;
LayershellWindowExtension(LayershellWindowExtension&&) = delete;
LayershellWindowExtension(const LayershellWindowExtension&) = delete;
void operator=(LayershellWindowExtension&&) = delete;
void operator=(const LayershellWindowExtension&) = delete;
// returns the layershell extension if attached, otherwise nullptr // returns the layershell extension if attached, otherwise nullptr
static LayershellWindowExtension* get(QWindow* window); static LayershellWindowExtension* get(QWindow* window);
// Attach this layershell extension to the given window. // Attach this layershell extension to the given window.
// The extension is reparented to the window and replaces any existing extensions. // The extension is reparented to the window and replaces any existing layershell extension.
// Returns false if the window cannot be used. // Returns false if the window cannot be used.
bool attach(QWindow* window); bool attach(QWindow* window);