From cbdfba1a3f82cf201b4255abbb172b815d2cae8d Mon Sep 17 00:00:00 2001 From: outfoxxed Date: Wed, 28 Feb 2024 21:30:06 -0800 Subject: [PATCH] chore: clean up lints --- src/wayland/session_lock.cpp | 15 +++++---------- src/wayland/session_lock.hpp | 3 --- src/wayland/session_lock/lock.cpp | 2 +- src/wayland/session_lock/manager.cpp | 2 -- src/wayland/session_lock/session_lock.cpp | 10 ++++++---- src/wayland/session_lock/session_lock.hpp | 2 +- src/wayland/session_lock/surface.cpp | 12 ++++++------ src/wayland/session_lock/surface.hpp | 2 +- src/wayland/wlr_layershell/shell_integration.cpp | 5 ++--- src/wayland/wlr_layershell/shell_integration.hpp | 7 ++----- src/wayland/wlr_layershell/surface.cpp | 11 +++++------ src/wayland/wlr_layershell/surface.hpp | 6 ++---- src/wayland/wlr_layershell/window.hpp | 7 +------ 13 files changed, 32 insertions(+), 52 deletions(-) diff --git a/src/wayland/session_lock.cpp b/src/wayland/session_lock.cpp index b11e414..be8136f 100644 --- a/src/wayland/session_lock.cpp +++ b/src/wayland/session_lock.cpp @@ -1,17 +1,21 @@ #include "session_lock.hpp" #include +#include #include #include #include #include #include +#include #include #include #include #include #include +#include "../core/qmlscreen.hpp" +#include "../core/reload.hpp" #include "session_lock/session_lock.hpp" void SessionLock::onReload(QObject* oldInstance) { @@ -136,12 +140,6 @@ void SessionLock::setLocked(bool locked) { QQmlComponent* SessionLock::surfaceComponent() const { return this->mSurfaceComponent; } -void SessionLock::rip() { - if (this->isLocked()) { - exit(1); - } -} - void SessionLock::setSurfaceComponent(QQmlComponent* surfaceComponent) { if (this->mSurfaceComponent != nullptr) this->mSurfaceComponent->deleteLater(); if (surfaceComponent != nullptr) surfaceComponent->setParent(this); @@ -194,7 +192,7 @@ void SessionLockSurface::onReload(QObject* oldInstance) { // clang-format on if (auto* parent = qobject_cast(this->parent())) { - if (!this->ext->attach(window, parent->manager)) { + if (!this->ext->attach(this->window, parent->manager)) { qWarning( ) << "Failed to attach LockWindowExtension to window. Surface will not behave correctly."; } @@ -202,9 +200,6 @@ void SessionLockSurface::onReload(QObject* oldInstance) { qWarning( ) << "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() { diff --git a/src/wayland/session_lock.hpp b/src/wayland/session_lock.hpp index 2582aac..9ebf137 100644 --- a/src/wayland/session_lock.hpp +++ b/src/wayland/session_lock.hpp @@ -15,7 +15,6 @@ #include #include -#include "../core/doc.hpp" #include "../core/qmlscreen.hpp" #include "../core/reload.hpp" #include "session_lock/session_lock.hpp" @@ -49,8 +48,6 @@ public: [[nodiscard]] QQmlComponent* surfaceComponent() const; void setSurfaceComponent(QQmlComponent* surfaceComponent); - QSDOC_HIDE Q_INVOKABLE void rip(); - signals: void lockStateChanged(); void secureStateChanged(); diff --git a/src/wayland/session_lock/lock.cpp b/src/wayland/session_lock/lock.cpp index 95b9c5c..fb53ce2 100644 --- a/src/wayland/session_lock/lock.cpp +++ b/src/wayland/session_lock/lock.cpp @@ -1,7 +1,7 @@ #include "lock.hpp" -#include #include +#include #include "manager.hpp" diff --git a/src/wayland/session_lock/manager.cpp b/src/wayland/session_lock/manager.cpp index 60c24f6..db6852b 100644 --- a/src/wayland/session_lock/manager.cpp +++ b/src/wayland/session_lock/manager.cpp @@ -1,7 +1,5 @@ #include "manager.hpp" -#include -#include #include #include "lock.hpp" diff --git a/src/wayland/session_lock/session_lock.cpp b/src/wayland/session_lock/session_lock.cpp index ef1e9b1..65ceef6 100644 --- a/src/wayland/session_lock/session_lock.cpp +++ b/src/wayland/session_lock/session_lock.cpp @@ -10,8 +10,9 @@ #include "shell_integration.hpp" #include "surface.hpp" -static QSWaylandSessionLockManager* manager() { - static QSWaylandSessionLockManager* manager = nullptr; +namespace { +QSWaylandSessionLockManager* manager() { + static QSWaylandSessionLockManager* manager = nullptr; // NOLINT if (manager == nullptr) { manager = new QSWaylandSessionLockManager(); @@ -19,6 +20,7 @@ static QSWaylandSessionLockManager* manager() { return manager; } +} // namespace bool SessionLockManager::lock() { if (this->isLocked() || SessionLockManager::sessionLocked()) return false; @@ -79,7 +81,7 @@ bool LockWindowExtension::attach(QWindow* window, SessionLockManager* manager) { return false; } - static QSWaylandSessionLockIntegration* lockIntegration = nullptr; + static QSWaylandSessionLockIntegration* lockIntegration = nullptr; // NOLINT if (lockIntegration == nullptr) { lockIntegration = new QSWaylandSessionLockIntegration(); if (!lockIntegration->initialize(waylandWindow->display())) { @@ -105,6 +107,6 @@ bool LockWindowExtension::attach(QWindow* window, SessionLockManager* manager) { } void LockWindowExtension::setVisible() { - if (this->surface == nullptr) immediatelyVisible = true; + if (this->surface == nullptr) this->immediatelyVisible = true; else this->surface->setVisible(); } diff --git a/src/wayland/session_lock/session_lock.hpp b/src/wayland/session_lock/session_lock.hpp index 8c8f1f0..45e86d6 100644 --- a/src/wayland/session_lock/session_lock.hpp +++ b/src/wayland/session_lock/session_lock.hpp @@ -14,7 +14,6 @@ class SessionLockManager: public QObject { public: explicit SessionLockManager(QObject* parent = nullptr): QObject(parent) {} - Q_DISABLE_COPY_MOVE(SessionLockManager); // Returns true if a lock was acquired. // If true is returned the caller must watch the global screen list and create/destroy @@ -59,6 +58,7 @@ class LockWindowExtension: public QObject { public: explicit LockWindowExtension(QObject* parent = nullptr): QObject(parent) {} ~LockWindowExtension() override; + Q_DISABLE_COPY_MOVE(LockWindowExtension); // Attach this lock extension to the given window. // The extension is reparented to the window and replaces any existing lock extension. diff --git a/src/wayland/session_lock/surface.cpp b/src/wayland/session_lock/surface.cpp index e9cbbf2..ec713f6 100644 --- a/src/wayland/session_lock/surface.cpp +++ b/src/wayland/session_lock/surface.cpp @@ -7,7 +7,7 @@ #include #include #include -#include +#include #include "lock.hpp" #include "session_lock.hpp" @@ -27,7 +27,7 @@ QSWaylandSessionLockSurface::QSWaylandSessionLockSurface(QtWaylandClient::QWayla throw nullptr; } - wl_output* output = nullptr; + wl_output* output = nullptr; // NOLINT (include) auto* waylandScreen = dynamic_cast(qwindow->screen()->handle()); if (waylandScreen != nullptr) { @@ -75,7 +75,7 @@ void QSWaylandSessionLockSurface::setExtension(LockWindowExtension* ext) { } void QSWaylandSessionLockSurface::setVisible() { - if (this->configured && !this->visible) initVisible(); + if (this->configured && !this->visible) this->initVisible(); this->visible = true; } @@ -92,7 +92,7 @@ void QSWaylandSessionLockSurface::ext_session_lock_surface_v1_configure( this->window()->resizeFromApplyConfigure(this->size); this->window()->handleExpose(QRect(QPoint(), this->size)); - if (this->visible) initVisible(); + if (this->visible) this->initVisible(); } else { this->window()->applyConfigureWhenPossible(); } @@ -105,10 +105,10 @@ void QSWaylandSessionLockSurface::initVisible() { // We attach a dummy buffer to satisfy ext_session_lock_v1. this->initBuf = new QtWaylandClient::QWaylandShmBuffer( this->window()->display(), - size, + this->size, 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); } diff --git a/src/wayland/session_lock/surface.hpp b/src/wayland/session_lock/surface.hpp index fd5e0a1..f7abc77 100644 --- a/src/wayland/session_lock/surface.hpp +++ b/src/wayland/session_lock/surface.hpp @@ -22,7 +22,7 @@ public: void applyConfigure() override; bool handleExpose(const QRegion& region) override; - void setExtension(LockWindowExtension*); + void setExtension(LockWindowExtension* ext); void setVisible(); private: diff --git a/src/wayland/wlr_layershell/shell_integration.cpp b/src/wayland/wlr_layershell/shell_integration.cpp index 2939f5c..8c7bce7 100644 --- a/src/wayland/wlr_layershell/shell_integration.cpp +++ b/src/wayland/wlr_layershell/shell_integration.cpp @@ -5,14 +5,13 @@ #include #include "surface.hpp" -#include "wayland-wlr-layer-shell-unstable-v1-client-protocol.h" QSWaylandLayerShellIntegration::QSWaylandLayerShellIntegration() : QtWaylandClient::QWaylandShellIntegrationTemplate(4) {} QSWaylandLayerShellIntegration::~QSWaylandLayerShellIntegration() { - if (this->object() != nullptr) { - zwlr_layer_shell_v1_destroy(this->object()); + if (this->isInitialized()) { + this->destroy(); } } diff --git a/src/wayland/wlr_layershell/shell_integration.hpp b/src/wayland/wlr_layershell/shell_integration.hpp index 1004e43..132b0d7 100644 --- a/src/wayland/wlr_layershell/shell_integration.hpp +++ b/src/wayland/wlr_layershell/shell_integration.hpp @@ -2,7 +2,7 @@ #include #include -#include +#include #include class QSWaylandLayerShellIntegration @@ -11,10 +11,7 @@ class QSWaylandLayerShellIntegration public: QSWaylandLayerShellIntegration(); ~QSWaylandLayerShellIntegration() override; - QSWaylandLayerShellIntegration(QSWaylandLayerShellIntegration&&) = delete; - QSWaylandLayerShellIntegration(const QSWaylandLayerShellIntegration&) = delete; - void operator=(QSWaylandLayerShellIntegration&&) = delete; - void operator=(const QSWaylandLayerShellIntegration&) = delete; + Q_DISABLE_COPY_MOVE(QSWaylandLayerShellIntegration); QtWaylandClient::QWaylandShellSurface* createShellSurface(QtWaylandClient::QWaylandWindow* window ) override; diff --git a/src/wayland/wlr_layershell/surface.cpp b/src/wayland/wlr_layershell/surface.cpp index 4da2451..48e76af 100644 --- a/src/wayland/wlr_layershell/surface.cpp +++ b/src/wayland/wlr_layershell/surface.cpp @@ -23,12 +23,11 @@ [[nodiscard]] QSize constrainedSize(const Anchors& anchors, const QSize& size) noexcept; // clang-format on -// clang-format off QSWaylandLayerSurface::QSWaylandLayerSurface( QSWaylandLayerShellIntegration* shell, QtWaylandClient::QWaylandWindow* window -): QtWaylandClient::QWaylandShellSurface(window) { - // clang-format on +) + : QtWaylandClient::QWaylandShellSurface(window) { auto* qwindow = window->window(); this->ext = LayershellWindowExtension::get(qwindow); @@ -37,7 +36,7 @@ QSWaylandLayerSurface::QSWaylandLayerSurface( throw "QSWaylandLayerSurface created with null LayershellWindowExtension"; } - wl_output* output = nullptr; // NOLINT (import) + wl_output* output = nullptr; // NOLINT (include) if (this->ext->useWindowScreen) { auto* waylandScreen = dynamic_cast(qwindow->screen()->handle()); @@ -45,8 +44,8 @@ QSWaylandLayerSurface::QSWaylandLayerSurface( if (waylandScreen != nullptr) { output = waylandScreen->output(); } else { - qWarning() << "Layershell screen is set but does not corrospond to a real screen. Letting " - "the compositor pick."; + qWarning( + ) << "Layershell screen does not corrospond to a real screen. Letting the compositor pick."; } } diff --git a/src/wayland/wlr_layershell/surface.hpp b/src/wayland/wlr_layershell/surface.hpp index beb86a5..e3a8d9b 100644 --- a/src/wayland/wlr_layershell/surface.hpp +++ b/src/wayland/wlr_layershell/surface.hpp @@ -2,6 +2,7 @@ #include #include +#include #include #include #include @@ -20,10 +21,7 @@ public: ); ~QSWaylandLayerSurface() override; - QSWaylandLayerSurface(QSWaylandLayerSurface&&) = delete; - QSWaylandLayerSurface(const QSWaylandLayerSurface&) = delete; - void operator=(QSWaylandLayerSurface&&) = delete; - void operator=(const QSWaylandLayerSurface&) = delete; + Q_DISABLE_COPY_MOVE(QSWaylandLayerSurface); [[nodiscard]] bool isExposed() const override; void applyConfigure() override; diff --git a/src/wayland/wlr_layershell/window.hpp b/src/wayland/wlr_layershell/window.hpp index 73c3f4f..7e4828a 100644 --- a/src/wayland/wlr_layershell/window.hpp +++ b/src/wayland/wlr_layershell/window.hpp @@ -56,17 +56,12 @@ class LayershellWindowExtension: public QObject { public: 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 static LayershellWindowExtension* get(QWindow* 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. bool attach(QWindow* window);