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)
 | 
			
		||||
 | 
			
		||||
# pipewire defines this, breaking PCH
 | 
			
		||||
add_compile_definitions(_REENTRANT)
 | 
			
		||||
 | 
			
		||||
if (FRAME_POINTERS)
 | 
			
		||||
	add_compile_options(-fno-omit-frame-pointer)
 | 
			
		||||
endif()
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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<qint64>(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
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,5 +1,6 @@
 | 
			
		|||
#pragma once
 | 
			
		||||
 | 
			
		||||
#include <bit>
 | 
			
		||||
#include <qabstractitemmodel.h>
 | 
			
		||||
#include <qcontainerfwd.h>
 | 
			
		||||
#include <qobject.h>
 | 
			
		||||
| 
						 | 
				
			
			@ -85,11 +86,11 @@ public:
 | 
			
		|||
	explicit ObjectModel(QObject* parent): UntypedObjectModel(parent) {}
 | 
			
		||||
 | 
			
		||||
	[[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 {
 | 
			
		||||
		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) {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,10 +1,24 @@
 | 
			
		|||
#pragma once
 | 
			
		||||
#include <algorithm>
 | 
			
		||||
#include <type_traits>
 | 
			
		||||
 | 
			
		||||
#include <qlatin1stringview.h>
 | 
			
		||||
#include <qobject.h>
 | 
			
		||||
#include <qtclasshelpermacros.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
 | 
			
		||||
#define DROP_EMIT(object, func)                                                                    \
 | 
			
		||||
	DropEmitter(object, static_cast<void (*)(typeof(object))>([](typeof(object) o) { o->func(); }))
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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);
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,5 +1,7 @@
 | 
			
		|||
#pragma once
 | 
			
		||||
 | 
			
		||||
#include <utility>
 | 
			
		||||
 | 
			
		||||
#include <qlogging.h>
 | 
			
		||||
#include <qmutex.h>
 | 
			
		||||
#include <qobject.h>
 | 
			
		||||
| 
						 | 
				
			
			@ -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;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -247,7 +247,7 @@ void IpcHandlerRegistry::deregisterHandler(IpcHandler* handler) {
 | 
			
		|||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	handler->registeredState = {.enabled = false, .target = ""};
 | 
			
		||||
	handler->registeredState = IpcHandler::RegistrationState(false);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
QString IpcHandler::listMembers(qsizetype indent) {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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<QString, IpcFunction> functionMap;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -85,7 +85,7 @@ void Notification::updateProperties(
 | 
			
		|||
    qint32 expireTimeout
 | 
			
		||||
) {
 | 
			
		||||
	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 resident = hints.value("resident").value<bool>();
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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<pw_device, TYPE_INTERFACE_Device, PW_VERSION_DEVICE> {
 | 
			
		||||
class PwDevice: public PwBindable<pw_device, PW_TYPE_INTERFACE_Device, PW_VERSION_DEVICE> {
 | 
			
		||||
	Q_OBJECT;
 | 
			
		||||
 | 
			
		||||
public:
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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<pw_link, TYPE_INTERFACE_Link, PW_VERSION_LINK> { // NOLINT
 | 
			
		||||
class PwLink: public PwBindable<pw_link, PW_TYPE_INTERFACE_Link, PW_VERSION_LINK> {
 | 
			
		||||
	Q_OBJECT;
 | 
			
		||||
 | 
			
		||||
public:
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -11,9 +11,7 @@
 | 
			
		|||
 | 
			
		||||
namespace qs::service::pipewire {
 | 
			
		||||
 | 
			
		||||
constexpr const char TYPE_INTERFACE_Metadata[] = PW_TYPE_INTERFACE_Metadata; // NOLINT
 | 
			
		||||
class PwMetadata
 | 
			
		||||
    : public PwBindable<pw_metadata, TYPE_INTERFACE_Metadata, PW_VERSION_METADATA> { // NOLINT
 | 
			
		||||
class PwMetadata: public PwBindable<pw_metadata, PW_TYPE_INTERFACE_Metadata, PW_VERSION_METADATA> {
 | 
			
		||||
	Q_OBJECT;
 | 
			
		||||
 | 
			
		||||
public:
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -156,8 +156,7 @@ private:
 | 
			
		|||
	PwNode* node;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
constexpr const char TYPE_INTERFACE_Node[] = PW_TYPE_INTERFACE_Node;             // NOLINT
 | 
			
		||||
class PwNode: public PwBindable<pw_node, TYPE_INTERFACE_Node, PW_VERSION_NODE> { // NOLINT
 | 
			
		||||
class PwNode: public PwBindable<pw_node, PW_TYPE_INTERFACE_Node, PW_VERSION_NODE> {
 | 
			
		||||
	Q_OBJECT;
 | 
			
		||||
 | 
			
		||||
public:
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -429,7 +429,7 @@ void PwObjectTracker::setObjects(const QList<QObject*>& objects) {
 | 
			
		|||
 | 
			
		||||
	// connect destroy
 | 
			
		||||
	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);
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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<pw_proxy*>(object);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void PwBindableObject::bind() {
 | 
			
		||||
	qCDebug(logRegistry) << "Bound object" << this;
 | 
			
		||||
	this->bindHooks();
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -12,6 +12,7 @@
 | 
			
		|||
#include <qtmetamacros.h>
 | 
			
		||||
#include <qtypes.h>
 | 
			
		||||
 | 
			
		||||
#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 <typename T, const char* INTERFACE, quint32 VERSION>
 | 
			
		||||
template <typename T, StringLiteral INTERFACE, quint32 VERSION>
 | 
			
		||||
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<pw_proxy*>(object);
 | 
			
		||||
		this->registryBind(INTERFACE, VERSION);
 | 
			
		||||
		this->PwBindableObject::bind();
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -39,7 +39,7 @@ void FocusGrab::addWindow(QWindow* window) {
 | 
			
		|||
	if (auto* waylandWindow = dynamic_cast<QWaylandWindow*>(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();
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue