diff --git a/CMakeLists.txt b/CMakeLists.txt index f951d968..23e6add8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -69,6 +69,9 @@ include(cmake/util.cmake) add_compile_options(-Wall -Wextra) +# pipewire defines this, breaking PCH +add_compile_definitions(_REENTRANT) + if (FRAME_POINTERS) add_compile_options(-fno-omit-frame-pointer) endif() diff --git a/src/core/logging.cpp b/src/core/logging.cpp index 1564e895..45f5b3e7 100644 --- a/src/core/logging.cpp +++ b/src/core/logging.cpp @@ -369,6 +369,7 @@ void ThreadLogging::initFs() { .l_whence = SEEK_SET, .l_start = 0, .l_len = 0, + .l_pid = 0, }; if (fcntl(detailedFile->handle(), F_SETLK, &lock) != 0) { // NOLINT @@ -455,6 +456,8 @@ CompressedLogType compressedTypeOf(QtMsgType type) { case QtCriticalMsg: case QtFatalMsg: return CompressedLogType::Critical; } + + return CompressedLogType::Info; // unreachable under normal conditions } QtMsgType typeOfCompressed(CompressedLogType type) { @@ -464,6 +467,8 @@ QtMsgType typeOfCompressed(CompressedLogType type) { case CompressedLogType::Warn: return QtWarningMsg; case CompressedLogType::Critical: return QtCriticalMsg; } + + return QtInfoMsg; // unreachable under normal conditions } void WriteBuffer::setDevice(QIODevice* device) { this->device = device; } @@ -636,7 +641,7 @@ start: if (!this->readVarInt(&secondDelta)) return false; } - if (index < 0 || index >= this->recentMessages.size()) return false; + if (index >= this->recentMessages.size()) return false; *slot = this->recentMessages.at(index); this->lastMessageTime = this->lastMessageTime.addSecs(static_cast(secondDelta)); slot->time = this->lastMessageTime; @@ -858,6 +863,7 @@ void LogFollower::FcntlWaitThread::run() { .l_whence = SEEK_SET, .l_start = 0, .l_len = 0, + .l_pid = 0, }; auto r = fcntl(this->follower->reader->file->handle(), F_SETLKW, &lock); // NOLINT diff --git a/src/core/model.hpp b/src/core/model.hpp index 5ab3e79f..d0981fd7 100644 --- a/src/core/model.hpp +++ b/src/core/model.hpp @@ -1,5 +1,6 @@ #pragma once +#include #include #include #include @@ -85,11 +86,11 @@ public: explicit ObjectModel(QObject* parent): UntypedObjectModel(parent) {} [[nodiscard]] QVector& valueList() { - return *reinterpret_cast*>(&this->valuesList); // NOLINT + return *std::bit_cast*>(&this->valuesList); } [[nodiscard]] const QVector& valueList() const { - return *reinterpret_cast*>(&this->valuesList); // NOLINT + return *std::bit_cast*>(&this->valuesList); } void insertObject(T* object, qsizetype index = -1) { diff --git a/src/core/paths.cpp b/src/core/paths.cpp index e2b15307..e108da03 100644 --- a/src/core/paths.cpp +++ b/src/core/paths.cpp @@ -242,6 +242,7 @@ void QsPaths::createLock() { .l_whence = SEEK_SET, .l_start = 0, .l_len = 0, + .l_pid = 0, }; if (fcntl(file->handle(), F_SETLK, &lock) != 0) { // NOLINT @@ -268,6 +269,7 @@ bool QsPaths::checkLock(const QString& path, InstanceLockInfo* info) { .l_whence = SEEK_SET, .l_start = 0, .l_len = 0, + .l_pid = 0, }; fcntl(file.handle(), F_GETLK, &lock); // NOLINT diff --git a/src/core/util.hpp b/src/core/util.hpp index 3ca095e4..1ff9b22b 100644 --- a/src/core/util.hpp +++ b/src/core/util.hpp @@ -1,10 +1,24 @@ #pragma once +#include #include +#include #include #include #include +template +struct StringLiteral { + constexpr StringLiteral(const char (&str)[Length]) { // NOLINT + std::copy_n(str, Length, this->value); + } + + constexpr operator const char*() const noexcept { return this->value; } + operator QLatin1StringView() const { return QLatin1String(this->value, Length); } + + char value[Length]; // NOLINT +}; + // NOLINTBEGIN #define DROP_EMIT(object, func) \ DropEmitter(object, static_cast([](typeof(object) o) { o->func(); })) diff --git a/src/io/fileview.cpp b/src/io/fileview.cpp index 40dde6d7..6cfe4bc4 100644 --- a/src/io/fileview.cpp +++ b/src/io/fileview.cpp @@ -153,7 +153,7 @@ void FileView::loadSync() { auto state = FileViewState(); this->updateState(state); } else if (!this->blockUntilLoaded()) { - auto state = FileViewState {.path = this->targetPath}; + auto state = FileViewState(this->targetPath); FileViewReader::read(state, false); this->updateState(state); } diff --git a/src/io/fileview.hpp b/src/io/fileview.hpp index 04ed421a..715962f6 100644 --- a/src/io/fileview.hpp +++ b/src/io/fileview.hpp @@ -1,5 +1,7 @@ #pragma once +#include + #include #include #include @@ -15,6 +17,9 @@ namespace qs::io { struct FileViewState { + FileViewState() = default; + explicit FileViewState(QString path): path(std::move(path)) {} + QString path; QString text; QByteArray data; diff --git a/src/io/ipchandler.cpp b/src/io/ipchandler.cpp index d2a549b2..510b2055 100644 --- a/src/io/ipchandler.cpp +++ b/src/io/ipchandler.cpp @@ -247,7 +247,7 @@ void IpcHandlerRegistry::deregisterHandler(IpcHandler* handler) { } } - handler->registeredState = {.enabled = false, .target = ""}; + handler->registeredState = IpcHandler::RegistrationState(false); } QString IpcHandler::listMembers(qsizetype indent) { diff --git a/src/io/ipchandler.hpp b/src/io/ipchandler.hpp index 97519807..cc4ee5f4 100644 --- a/src/io/ipchandler.hpp +++ b/src/io/ipchandler.hpp @@ -172,12 +172,14 @@ private: void updateRegistration(bool destroying = false); struct RegistrationState { + explicit RegistrationState(bool enabled = false): enabled(enabled) {} + bool enabled = false; QString target; }; RegistrationState registeredState; - RegistrationState targetState {.enabled = true}; + RegistrationState targetState {true}; bool complete = false; QHash functionMap; diff --git a/src/services/notifications/notification.cpp b/src/services/notifications/notification.cpp index c090c135..18c8ff15 100644 --- a/src/services/notifications/notification.cpp +++ b/src/services/notifications/notification.cpp @@ -85,7 +85,7 @@ void Notification::updateProperties( qint32 expireTimeout ) { auto urgency = hints.contains("urgency") ? hints.value("urgency").value() - : NotificationUrgency::Normal; + : static_cast(NotificationUrgency::Normal); auto hasActionIcons = hints.value("action-icons").value(); auto resident = hints.value("resident").value(); diff --git a/src/services/pipewire/device.hpp b/src/services/pipewire/device.hpp index ed6b6c53..2e14d615 100644 --- a/src/services/pipewire/device.hpp +++ b/src/services/pipewire/device.hpp @@ -17,8 +17,7 @@ namespace qs::service::pipewire { class PwDevice; -constexpr const char TYPE_INTERFACE_Device[] = PW_TYPE_INTERFACE_Device; // NOLINT -class PwDevice: public PwBindable { +class PwDevice: public PwBindable { Q_OBJECT; public: diff --git a/src/services/pipewire/link.hpp b/src/services/pipewire/link.hpp index 0c7bde29..55bbcf0e 100644 --- a/src/services/pipewire/link.hpp +++ b/src/services/pipewire/link.hpp @@ -35,8 +35,7 @@ public: Q_INVOKABLE static QString toString(qs::service::pipewire::PwLinkState::Enum value); }; -constexpr const char TYPE_INTERFACE_Link[] = PW_TYPE_INTERFACE_Link; // NOLINT -class PwLink: public PwBindable { // NOLINT +class PwLink: public PwBindable { Q_OBJECT; public: diff --git a/src/services/pipewire/metadata.hpp b/src/services/pipewire/metadata.hpp index 812a8534..f257dc23 100644 --- a/src/services/pipewire/metadata.hpp +++ b/src/services/pipewire/metadata.hpp @@ -11,9 +11,7 @@ namespace qs::service::pipewire { -constexpr const char TYPE_INTERFACE_Metadata[] = PW_TYPE_INTERFACE_Metadata; // NOLINT -class PwMetadata - : public PwBindable { // NOLINT +class PwMetadata: public PwBindable { Q_OBJECT; public: diff --git a/src/services/pipewire/node.hpp b/src/services/pipewire/node.hpp index 783614ac..5a67db7d 100644 --- a/src/services/pipewire/node.hpp +++ b/src/services/pipewire/node.hpp @@ -156,8 +156,7 @@ private: PwNode* node; }; -constexpr const char TYPE_INTERFACE_Node[] = PW_TYPE_INTERFACE_Node; // NOLINT -class PwNode: public PwBindable { // NOLINT +class PwNode: public PwBindable { Q_OBJECT; public: diff --git a/src/services/pipewire/qml.cpp b/src/services/pipewire/qml.cpp index a8186ea3..be50ec6e 100644 --- a/src/services/pipewire/qml.cpp +++ b/src/services/pipewire/qml.cpp @@ -429,7 +429,7 @@ void PwObjectTracker::setObjects(const QList& objects) { // connect destroy for (auto* object: objects) { - if (auto* pwObject = dynamic_cast(object)) { + if (dynamic_cast(object) != nullptr) { QObject::connect(object, &QObject::destroyed, this, &PwObjectTracker::objectDestroyed); } } diff --git a/src/services/pipewire/registry.cpp b/src/services/pipewire/registry.cpp index 1370fa10..04bd9ace 100644 --- a/src/services/pipewire/registry.cpp +++ b/src/services/pipewire/registry.cpp @@ -63,6 +63,12 @@ void PwBindableObject::unref() { if (this->refcount == 0) this->unbind(); } +void PwBindableObject::registryBind(const char* interface, quint32 version) { + // NOLINTNEXTLINE + auto* object = pw_registry_bind(this->registry->object, this->id, interface, version, 0); + this->object = static_cast(object); +} + void PwBindableObject::bind() { qCDebug(logRegistry) << "Bound object" << this; this->bindHooks(); diff --git a/src/services/pipewire/registry.hpp b/src/services/pipewire/registry.hpp index c61773b2..59aac757 100644 --- a/src/services/pipewire/registry.hpp +++ b/src/services/pipewire/registry.hpp @@ -12,6 +12,7 @@ #include #include +#include "../../core/util.hpp" #include "core.hpp" namespace qs::service::pipewire { @@ -50,6 +51,7 @@ signals: void destroying(PwBindableObject* self); protected: + void registryBind(const char* interface, quint32 version); virtual void bind(); void unbind(); virtual void bindHooks() {}; @@ -62,7 +64,7 @@ protected: QDebug operator<<(QDebug debug, const PwBindableObject* object); -template +template class PwBindable: public PwBindableObject { public: T* proxy() { @@ -72,9 +74,7 @@ public: protected: void bind() override { if (this->object != nullptr) return; - auto* object = - pw_registry_bind(this->registry->object, this->id, INTERFACE, VERSION, 0); // NOLINT - this->object = static_cast(object); + this->registryBind(INTERFACE, VERSION); this->PwBindableObject::bind(); } diff --git a/src/wayland/hyprland/focus_grab/grab.cpp b/src/wayland/hyprland/focus_grab/grab.cpp index 62298699..188c2063 100644 --- a/src/wayland/hyprland/focus_grab/grab.cpp +++ b/src/wayland/hyprland/focus_grab/grab.cpp @@ -39,7 +39,7 @@ void FocusGrab::addWindow(QWindow* window) { if (auto* waylandWindow = dynamic_cast(window->handle())) { tryAddWayland(waylandWindow); } else { - QObject::connect(window, &QWindow::visibleChanged, this, [this, window, tryAddWayland]() { + QObject::connect(window, &QWindow::visibleChanged, this, [window, tryAddWayland]() { if (window->isVisible()) { if (window->handle() == nullptr) { window->create(); diff --git a/src/widgets/CMakeLists.txt b/src/widgets/CMakeLists.txt index 226d950d..def0aaf0 100644 --- a/src/widgets/CMakeLists.txt +++ b/src/widgets/CMakeLists.txt @@ -11,4 +11,5 @@ install_qml_module(quickshell-widgets) qs_module_pch(quickshell-widgets) +target_link_libraries(quickshell-widgets PRIVATE Qt::Quick) target_link_libraries(quickshell PRIVATE quickshell-widgetsplugin)