forked from quickshell/quickshell
all: fix gcc warnings
This commit is contained in:
parent
92252c36a3
commit
b528be9426
19 changed files with 57 additions and 22 deletions
|
@ -69,6 +69,9 @@ include(cmake/util.cmake)
|
||||||
|
|
||||||
add_compile_options(-Wall -Wextra)
|
add_compile_options(-Wall -Wextra)
|
||||||
|
|
||||||
|
# pipewire defines this, breaking PCH
|
||||||
|
add_compile_definitions(_REENTRANT)
|
||||||
|
|
||||||
if (FRAME_POINTERS)
|
if (FRAME_POINTERS)
|
||||||
add_compile_options(-fno-omit-frame-pointer)
|
add_compile_options(-fno-omit-frame-pointer)
|
||||||
endif()
|
endif()
|
||||||
|
|
|
@ -369,6 +369,7 @@ void ThreadLogging::initFs() {
|
||||||
.l_whence = SEEK_SET,
|
.l_whence = SEEK_SET,
|
||||||
.l_start = 0,
|
.l_start = 0,
|
||||||
.l_len = 0,
|
.l_len = 0,
|
||||||
|
.l_pid = 0,
|
||||||
};
|
};
|
||||||
|
|
||||||
if (fcntl(detailedFile->handle(), F_SETLK, &lock) != 0) { // NOLINT
|
if (fcntl(detailedFile->handle(), F_SETLK, &lock) != 0) { // NOLINT
|
||||||
|
@ -455,6 +456,8 @@ CompressedLogType compressedTypeOf(QtMsgType type) {
|
||||||
case QtCriticalMsg:
|
case QtCriticalMsg:
|
||||||
case QtFatalMsg: return CompressedLogType::Critical;
|
case QtFatalMsg: return CompressedLogType::Critical;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return CompressedLogType::Info; // unreachable under normal conditions
|
||||||
}
|
}
|
||||||
|
|
||||||
QtMsgType typeOfCompressed(CompressedLogType type) {
|
QtMsgType typeOfCompressed(CompressedLogType type) {
|
||||||
|
@ -464,6 +467,8 @@ QtMsgType typeOfCompressed(CompressedLogType type) {
|
||||||
case CompressedLogType::Warn: return QtWarningMsg;
|
case CompressedLogType::Warn: return QtWarningMsg;
|
||||||
case CompressedLogType::Critical: return QtCriticalMsg;
|
case CompressedLogType::Critical: return QtCriticalMsg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return QtInfoMsg; // unreachable under normal conditions
|
||||||
}
|
}
|
||||||
|
|
||||||
void WriteBuffer::setDevice(QIODevice* device) { this->device = device; }
|
void WriteBuffer::setDevice(QIODevice* device) { this->device = device; }
|
||||||
|
@ -636,7 +641,7 @@ start:
|
||||||
if (!this->readVarInt(&secondDelta)) return false;
|
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);
|
*slot = this->recentMessages.at(index);
|
||||||
this->lastMessageTime = this->lastMessageTime.addSecs(static_cast<qint64>(secondDelta));
|
this->lastMessageTime = this->lastMessageTime.addSecs(static_cast<qint64>(secondDelta));
|
||||||
slot->time = this->lastMessageTime;
|
slot->time = this->lastMessageTime;
|
||||||
|
@ -858,6 +863,7 @@ void LogFollower::FcntlWaitThread::run() {
|
||||||
.l_whence = SEEK_SET,
|
.l_whence = SEEK_SET,
|
||||||
.l_start = 0,
|
.l_start = 0,
|
||||||
.l_len = 0,
|
.l_len = 0,
|
||||||
|
.l_pid = 0,
|
||||||
};
|
};
|
||||||
|
|
||||||
auto r = fcntl(this->follower->reader->file->handle(), F_SETLKW, &lock); // NOLINT
|
auto r = fcntl(this->follower->reader->file->handle(), F_SETLKW, &lock); // NOLINT
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <bit>
|
||||||
#include <qabstractitemmodel.h>
|
#include <qabstractitemmodel.h>
|
||||||
#include <qcontainerfwd.h>
|
#include <qcontainerfwd.h>
|
||||||
#include <qobject.h>
|
#include <qobject.h>
|
||||||
|
@ -85,11 +86,11 @@ public:
|
||||||
explicit ObjectModel(QObject* parent): UntypedObjectModel(parent) {}
|
explicit ObjectModel(QObject* parent): UntypedObjectModel(parent) {}
|
||||||
|
|
||||||
[[nodiscard]] QVector<T*>& valueList() {
|
[[nodiscard]] QVector<T*>& valueList() {
|
||||||
return *reinterpret_cast<QVector<T*>*>(&this->valuesList); // NOLINT
|
return *std::bit_cast<QVector<T*>*>(&this->valuesList);
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] const QVector<T*>& valueList() const {
|
[[nodiscard]] const QVector<T*>& valueList() const {
|
||||||
return *reinterpret_cast<const QVector<T*>*>(&this->valuesList); // NOLINT
|
return *std::bit_cast<const QVector<T*>*>(&this->valuesList);
|
||||||
}
|
}
|
||||||
|
|
||||||
void insertObject(T* object, qsizetype index = -1) {
|
void insertObject(T* object, qsizetype index = -1) {
|
||||||
|
|
|
@ -242,6 +242,7 @@ void QsPaths::createLock() {
|
||||||
.l_whence = SEEK_SET,
|
.l_whence = SEEK_SET,
|
||||||
.l_start = 0,
|
.l_start = 0,
|
||||||
.l_len = 0,
|
.l_len = 0,
|
||||||
|
.l_pid = 0,
|
||||||
};
|
};
|
||||||
|
|
||||||
if (fcntl(file->handle(), F_SETLK, &lock) != 0) { // NOLINT
|
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_whence = SEEK_SET,
|
||||||
.l_start = 0,
|
.l_start = 0,
|
||||||
.l_len = 0,
|
.l_len = 0,
|
||||||
|
.l_pid = 0,
|
||||||
};
|
};
|
||||||
|
|
||||||
fcntl(file.handle(), F_GETLK, &lock); // NOLINT
|
fcntl(file.handle(), F_GETLK, &lock); // NOLINT
|
||||||
|
|
|
@ -1,10 +1,24 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
#include <algorithm>
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
|
|
||||||
|
#include <qlatin1stringview.h>
|
||||||
#include <qobject.h>
|
#include <qobject.h>
|
||||||
#include <qtclasshelpermacros.h>
|
#include <qtclasshelpermacros.h>
|
||||||
#include <qtmetamacros.h>
|
#include <qtmetamacros.h>
|
||||||
|
|
||||||
|
template <size_t Length>
|
||||||
|
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
|
// NOLINTBEGIN
|
||||||
#define DROP_EMIT(object, func) \
|
#define DROP_EMIT(object, func) \
|
||||||
DropEmitter(object, static_cast<void (*)(typeof(object))>([](typeof(object) o) { o->func(); }))
|
DropEmitter(object, static_cast<void (*)(typeof(object))>([](typeof(object) o) { o->func(); }))
|
||||||
|
|
|
@ -153,7 +153,7 @@ void FileView::loadSync() {
|
||||||
auto state = FileViewState();
|
auto state = FileViewState();
|
||||||
this->updateState(state);
|
this->updateState(state);
|
||||||
} else if (!this->blockUntilLoaded()) {
|
} else if (!this->blockUntilLoaded()) {
|
||||||
auto state = FileViewState {.path = this->targetPath};
|
auto state = FileViewState(this->targetPath);
|
||||||
FileViewReader::read(state, false);
|
FileViewReader::read(state, false);
|
||||||
this->updateState(state);
|
this->updateState(state);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <utility>
|
||||||
|
|
||||||
#include <qlogging.h>
|
#include <qlogging.h>
|
||||||
#include <qmutex.h>
|
#include <qmutex.h>
|
||||||
#include <qobject.h>
|
#include <qobject.h>
|
||||||
|
@ -15,6 +17,9 @@
|
||||||
namespace qs::io {
|
namespace qs::io {
|
||||||
|
|
||||||
struct FileViewState {
|
struct FileViewState {
|
||||||
|
FileViewState() = default;
|
||||||
|
explicit FileViewState(QString path): path(std::move(path)) {}
|
||||||
|
|
||||||
QString path;
|
QString path;
|
||||||
QString text;
|
QString text;
|
||||||
QByteArray data;
|
QByteArray data;
|
||||||
|
|
|
@ -247,7 +247,7 @@ void IpcHandlerRegistry::deregisterHandler(IpcHandler* handler) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
handler->registeredState = {.enabled = false, .target = ""};
|
handler->registeredState = IpcHandler::RegistrationState(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString IpcHandler::listMembers(qsizetype indent) {
|
QString IpcHandler::listMembers(qsizetype indent) {
|
||||||
|
|
|
@ -172,12 +172,14 @@ private:
|
||||||
void updateRegistration(bool destroying = false);
|
void updateRegistration(bool destroying = false);
|
||||||
|
|
||||||
struct RegistrationState {
|
struct RegistrationState {
|
||||||
|
explicit RegistrationState(bool enabled = false): enabled(enabled) {}
|
||||||
|
|
||||||
bool enabled = false;
|
bool enabled = false;
|
||||||
QString target;
|
QString target;
|
||||||
};
|
};
|
||||||
|
|
||||||
RegistrationState registeredState;
|
RegistrationState registeredState;
|
||||||
RegistrationState targetState {.enabled = true};
|
RegistrationState targetState {true};
|
||||||
bool complete = false;
|
bool complete = false;
|
||||||
|
|
||||||
QHash<QString, IpcFunction> functionMap;
|
QHash<QString, IpcFunction> functionMap;
|
||||||
|
|
|
@ -85,7 +85,7 @@ void Notification::updateProperties(
|
||||||
qint32 expireTimeout
|
qint32 expireTimeout
|
||||||
) {
|
) {
|
||||||
auto urgency = hints.contains("urgency") ? hints.value("urgency").value<quint8>()
|
auto urgency = hints.contains("urgency") ? hints.value("urgency").value<quint8>()
|
||||||
: NotificationUrgency::Normal;
|
: static_cast<quint8>(NotificationUrgency::Normal);
|
||||||
|
|
||||||
auto hasActionIcons = hints.value("action-icons").value<bool>();
|
auto hasActionIcons = hints.value("action-icons").value<bool>();
|
||||||
auto resident = hints.value("resident").value<bool>();
|
auto resident = hints.value("resident").value<bool>();
|
||||||
|
|
|
@ -17,8 +17,7 @@ namespace qs::service::pipewire {
|
||||||
|
|
||||||
class PwDevice;
|
class PwDevice;
|
||||||
|
|
||||||
constexpr const char TYPE_INTERFACE_Device[] = PW_TYPE_INTERFACE_Device; // NOLINT
|
class PwDevice: public PwBindable<pw_device, PW_TYPE_INTERFACE_Device, PW_VERSION_DEVICE> {
|
||||||
class PwDevice: public PwBindable<pw_device, TYPE_INTERFACE_Device, PW_VERSION_DEVICE> {
|
|
||||||
Q_OBJECT;
|
Q_OBJECT;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -35,8 +35,7 @@ public:
|
||||||
Q_INVOKABLE static QString toString(qs::service::pipewire::PwLinkState::Enum value);
|
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<pw_link, PW_TYPE_INTERFACE_Link, PW_VERSION_LINK> {
|
||||||
class PwLink: public PwBindable<pw_link, TYPE_INTERFACE_Link, PW_VERSION_LINK> { // NOLINT
|
|
||||||
Q_OBJECT;
|
Q_OBJECT;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -11,9 +11,7 @@
|
||||||
|
|
||||||
namespace qs::service::pipewire {
|
namespace qs::service::pipewire {
|
||||||
|
|
||||||
constexpr const char TYPE_INTERFACE_Metadata[] = PW_TYPE_INTERFACE_Metadata; // NOLINT
|
class PwMetadata: public PwBindable<pw_metadata, PW_TYPE_INTERFACE_Metadata, PW_VERSION_METADATA> {
|
||||||
class PwMetadata
|
|
||||||
: public PwBindable<pw_metadata, TYPE_INTERFACE_Metadata, PW_VERSION_METADATA> { // NOLINT
|
|
||||||
Q_OBJECT;
|
Q_OBJECT;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -156,8 +156,7 @@ private:
|
||||||
PwNode* node;
|
PwNode* node;
|
||||||
};
|
};
|
||||||
|
|
||||||
constexpr const char TYPE_INTERFACE_Node[] = PW_TYPE_INTERFACE_Node; // NOLINT
|
class PwNode: public PwBindable<pw_node, PW_TYPE_INTERFACE_Node, PW_VERSION_NODE> {
|
||||||
class PwNode: public PwBindable<pw_node, TYPE_INTERFACE_Node, PW_VERSION_NODE> { // NOLINT
|
|
||||||
Q_OBJECT;
|
Q_OBJECT;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -429,7 +429,7 @@ void PwObjectTracker::setObjects(const QList<QObject*>& objects) {
|
||||||
|
|
||||||
// connect destroy
|
// connect destroy
|
||||||
for (auto* object: objects) {
|
for (auto* object: objects) {
|
||||||
if (auto* pwObject = dynamic_cast<PwObjectRefIface*>(object)) {
|
if (dynamic_cast<PwObjectRefIface*>(object) != nullptr) {
|
||||||
QObject::connect(object, &QObject::destroyed, this, &PwObjectTracker::objectDestroyed);
|
QObject::connect(object, &QObject::destroyed, this, &PwObjectTracker::objectDestroyed);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,6 +63,12 @@ void PwBindableObject::unref() {
|
||||||
if (this->refcount == 0) this->unbind();
|
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<pw_proxy*>(object);
|
||||||
|
}
|
||||||
|
|
||||||
void PwBindableObject::bind() {
|
void PwBindableObject::bind() {
|
||||||
qCDebug(logRegistry) << "Bound object" << this;
|
qCDebug(logRegistry) << "Bound object" << this;
|
||||||
this->bindHooks();
|
this->bindHooks();
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
#include <qtmetamacros.h>
|
#include <qtmetamacros.h>
|
||||||
#include <qtypes.h>
|
#include <qtypes.h>
|
||||||
|
|
||||||
|
#include "../../core/util.hpp"
|
||||||
#include "core.hpp"
|
#include "core.hpp"
|
||||||
|
|
||||||
namespace qs::service::pipewire {
|
namespace qs::service::pipewire {
|
||||||
|
@ -50,6 +51,7 @@ signals:
|
||||||
void destroying(PwBindableObject* self);
|
void destroying(PwBindableObject* self);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
void registryBind(const char* interface, quint32 version);
|
||||||
virtual void bind();
|
virtual void bind();
|
||||||
void unbind();
|
void unbind();
|
||||||
virtual void bindHooks() {};
|
virtual void bindHooks() {};
|
||||||
|
@ -62,7 +64,7 @@ protected:
|
||||||
|
|
||||||
QDebug operator<<(QDebug debug, const PwBindableObject* object);
|
QDebug operator<<(QDebug debug, const PwBindableObject* object);
|
||||||
|
|
||||||
template <typename T, const char* INTERFACE, quint32 VERSION>
|
template <typename T, StringLiteral INTERFACE, quint32 VERSION>
|
||||||
class PwBindable: public PwBindableObject {
|
class PwBindable: public PwBindableObject {
|
||||||
public:
|
public:
|
||||||
T* proxy() {
|
T* proxy() {
|
||||||
|
@ -72,9 +74,7 @@ public:
|
||||||
protected:
|
protected:
|
||||||
void bind() override {
|
void bind() override {
|
||||||
if (this->object != nullptr) return;
|
if (this->object != nullptr) return;
|
||||||
auto* object =
|
this->registryBind(INTERFACE, VERSION);
|
||||||
pw_registry_bind(this->registry->object, this->id, INTERFACE, VERSION, 0); // NOLINT
|
|
||||||
this->object = static_cast<pw_proxy*>(object);
|
|
||||||
this->PwBindableObject::bind();
|
this->PwBindableObject::bind();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -39,7 +39,7 @@ void FocusGrab::addWindow(QWindow* window) {
|
||||||
if (auto* waylandWindow = dynamic_cast<QWaylandWindow*>(window->handle())) {
|
if (auto* waylandWindow = dynamic_cast<QWaylandWindow*>(window->handle())) {
|
||||||
tryAddWayland(waylandWindow);
|
tryAddWayland(waylandWindow);
|
||||||
} else {
|
} else {
|
||||||
QObject::connect(window, &QWindow::visibleChanged, this, [this, window, tryAddWayland]() {
|
QObject::connect(window, &QWindow::visibleChanged, this, [window, tryAddWayland]() {
|
||||||
if (window->isVisible()) {
|
if (window->isVisible()) {
|
||||||
if (window->handle() == nullptr) {
|
if (window->handle() == nullptr) {
|
||||||
window->create();
|
window->create();
|
||||||
|
|
|
@ -11,4 +11,5 @@ install_qml_module(quickshell-widgets)
|
||||||
|
|
||||||
qs_module_pch(quickshell-widgets)
|
qs_module_pch(quickshell-widgets)
|
||||||
|
|
||||||
|
target_link_libraries(quickshell-widgets PRIVATE Qt::Quick)
|
||||||
target_link_libraries(quickshell PRIVATE quickshell-widgetsplugin)
|
target_link_libraries(quickshell PRIVATE quickshell-widgetsplugin)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue