forked from quickshell/quickshell
all: fix new lints
This commit is contained in:
parent
26d443aa50
commit
2c411fce5a
.clang-tidyJustfile
src
core
desktopentry.cppiconimageprovider.cppimageprovider.cppmodule.mdpaths.cppplugin.cpppopupanchor.cpp
test
variants.cppvariants.hppcrash
dbus
debug
io
launch
services
greetd
mpris
notifications
pipewire
status_notifier
upower
wayland
x11/i3/ipc
|
@ -7,6 +7,7 @@ Checks: >
|
|||
-bugprone-easily-swappable-parameters,
|
||||
-bugprone-forward-declararion-namespace,
|
||||
-bugprone-forward-declararion-namespace,
|
||||
-bugprone-return-const-ref-from-parameter,
|
||||
concurrency-*,
|
||||
cppcoreguidelines-*,
|
||||
-cppcoreguidelines-owning-memory,
|
||||
|
@ -44,6 +45,7 @@ Checks: >
|
|||
-readability-container-data-pointer,
|
||||
-readability-implicit-bool-conversion,
|
||||
-readability-avoid-nested-conditional-operator,
|
||||
-readability-math-missing-parentheses,
|
||||
tidyfox-*,
|
||||
CheckOptions:
|
||||
performance-for-range-copy.WarnOnAllAutoCopies: true
|
||||
|
|
6
Justfile
6
Justfile
|
@ -4,13 +4,13 @@ fmt:
|
|||
find src -type f \( -name "*.cpp" -o -name "*.hpp" \) -print0 | xargs -0 clang-format -i
|
||||
|
||||
lint:
|
||||
find src -type f -name "*.cpp" -print0 | parallel -q0 --no-notice --will-cite --tty --bar clang-tidy --load={{ env_var("TIDYFOX") }}
|
||||
find src -type f -name "*.cpp" -print0 | parallel -j$(nproc) -q0 --no-notice --will-cite --tty --bar clang-tidy --load={{ env_var("TIDYFOX") }}
|
||||
|
||||
lint-ci:
|
||||
find src -type f -name "*.cpp" -print0 | parallel -q0 --no-notice --will-cite --tty clang-tidy --load={{ env_var("TIDYFOX") }}
|
||||
find src -type f -name "*.cpp" -print0 | parallel -j$(nproc) -q0 --no-notice --will-cite --tty clang-tidy --load={{ env_var("TIDYFOX") }}
|
||||
|
||||
lint-changed:
|
||||
git diff --name-only HEAD | grep "^.*\.cpp\$" | parallel --no-notice --will-cite --tty --bar clang-tidy --load={{ env_var("TIDYFOX") }}
|
||||
git diff --name-only HEAD | grep "^.*\.cpp\$" | parallel -j$(nproc) --no-notice --will-cite --tty --bar clang-tidy --load={{ env_var("TIDYFOX") }}
|
||||
|
||||
configure target='debug' *FLAGS='':
|
||||
cmake -GNinja -B {{builddir}} \
|
||||
|
|
|
@ -18,7 +18,9 @@
|
|||
|
||||
#include "model.hpp"
|
||||
|
||||
namespace {
|
||||
Q_LOGGING_CATEGORY(logDesktopEntry, "quickshell.desktopentry", QtWarningMsg);
|
||||
}
|
||||
|
||||
struct Locale {
|
||||
explicit Locale() = default;
|
||||
|
@ -78,6 +80,7 @@ struct Locale {
|
|||
QString modifier;
|
||||
};
|
||||
|
||||
// NOLINTNEXTLINE(misc-use-internal-linkage)
|
||||
QDebug operator<<(QDebug debug, const Locale& locale) {
|
||||
auto saver = QDebugStateSaver(debug);
|
||||
debug.nospace() << "Locale(language=" << locale.language << ", territory=" << locale.territory
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#include "iconimageprovider.hpp"
|
||||
#include <algorithm>
|
||||
|
||||
#include <qcolor.h>
|
||||
#include <qicon.h>
|
||||
|
@ -49,8 +50,8 @@ IconImageProvider::requestPixmap(const QString& id, QSize* size, const QSize& re
|
|||
QPixmap IconImageProvider::missingPixmap(const QSize& size) {
|
||||
auto width = size.width() % 2 == 0 ? size.width() : size.width() + 1;
|
||||
auto height = size.height() % 2 == 0 ? size.height() : size.height() + 1;
|
||||
if (width < 2) width = 2;
|
||||
if (height < 2) height = 2;
|
||||
width = std::max(width, 2);
|
||||
height = std::max(height, 2);
|
||||
|
||||
auto pixmap = QPixmap(width, height);
|
||||
pixmap.fill(QColorConstants::Black);
|
||||
|
|
|
@ -8,7 +8,21 @@
|
|||
#include <qpixmap.h>
|
||||
#include <qqmlengine.h>
|
||||
|
||||
static QMap<QString, QsImageHandle*> liveImages; // NOLINT
|
||||
namespace {
|
||||
|
||||
QMap<QString, QsImageHandle*> liveImages; // NOLINT
|
||||
|
||||
void parseReq(const QString& req, QString& target, QString& param) {
|
||||
auto splitIdx = req.indexOf('/');
|
||||
if (splitIdx != -1) {
|
||||
target = req.sliced(0, splitIdx);
|
||||
param = req.sliced(splitIdx + 1);
|
||||
} else {
|
||||
target = req;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
QsImageHandle::QsImageHandle(QQmlImageProviderBase::ImageType type, QObject* parent)
|
||||
: QObject(parent)
|
||||
|
@ -43,16 +57,6 @@ QPixmap QsImageHandle::
|
|||
return QPixmap();
|
||||
}
|
||||
|
||||
void parseReq(const QString& req, QString& target, QString& param) {
|
||||
auto splitIdx = req.indexOf('/');
|
||||
if (splitIdx != -1) {
|
||||
target = req.sliced(0, splitIdx);
|
||||
param = req.sliced(splitIdx + 1);
|
||||
} else {
|
||||
target = req;
|
||||
}
|
||||
}
|
||||
|
||||
QImage QsImageProvider::requestImage(const QString& id, QSize* size, const QSize& requestedSize) {
|
||||
QString target;
|
||||
QString param;
|
||||
|
|
|
@ -28,5 +28,6 @@ headers = [
|
|||
"types.hpp",
|
||||
"qsmenuanchor.hpp",
|
||||
"clock.hpp",
|
||||
"scriptmodel.hpp",
|
||||
]
|
||||
-----
|
||||
|
|
|
@ -15,7 +15,9 @@
|
|||
|
||||
#include "instanceinfo.hpp"
|
||||
|
||||
namespace {
|
||||
Q_LOGGING_CATEGORY(logPaths, "quickshell.paths", QtWarningMsg);
|
||||
}
|
||||
|
||||
QsPaths* QsPaths::instance() {
|
||||
static auto* instance = new QsPaths(); // NOLINT
|
||||
|
|
|
@ -10,16 +10,9 @@ static QVector<QsEnginePlugin*> plugins; // NOLINT
|
|||
void QsEnginePlugin::registerPlugin(QsEnginePlugin& plugin) { plugins.push_back(&plugin); }
|
||||
|
||||
void QsEnginePlugin::initPlugins() {
|
||||
plugins.erase(
|
||||
std::remove_if(
|
||||
plugins.begin(),
|
||||
plugins.end(),
|
||||
[](QsEnginePlugin* plugin) { return !plugin->applies(); }
|
||||
),
|
||||
plugins.end()
|
||||
);
|
||||
plugins.removeIf([](QsEnginePlugin* plugin) { return !plugin->applies(); });
|
||||
|
||||
std::sort(plugins.begin(), plugins.end(), [](QsEnginePlugin* a, QsEnginePlugin* b) {
|
||||
std::ranges::sort(plugins, [](QsEnginePlugin* a, QsEnginePlugin* b) {
|
||||
return b->dependencies().contains(a->name());
|
||||
});
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#include "popupanchor.hpp"
|
||||
#include <algorithm>
|
||||
|
||||
#include <qcontainerfwd.h>
|
||||
#include <qlogging.h>
|
||||
|
@ -276,9 +277,7 @@ void PopupPositioner::reposition(PopupAnchor* anchor, QWindow* window, bool only
|
|||
effectiveX = screenGeometry.right() - windowGeometry.width() + 1;
|
||||
}
|
||||
|
||||
if (effectiveX < screenGeometry.left()) {
|
||||
effectiveX = screenGeometry.left();
|
||||
}
|
||||
effectiveX = std::max(effectiveX, screenGeometry.left());
|
||||
}
|
||||
|
||||
if (adjustment.testFlag(PopupAdjustment::SlideY)) {
|
||||
|
@ -286,9 +285,7 @@ void PopupPositioner::reposition(PopupAnchor* anchor, QWindow* window, bool only
|
|||
effectiveY = screenGeometry.bottom() - windowGeometry.height() + 1;
|
||||
}
|
||||
|
||||
if (effectiveY < screenGeometry.top()) {
|
||||
effectiveY = screenGeometry.top();
|
||||
}
|
||||
effectiveY = std::max(effectiveY, screenGeometry.top());
|
||||
}
|
||||
|
||||
if (adjustment.testFlag(PopupAdjustment::ResizeX)) {
|
||||
|
|
|
@ -22,6 +22,7 @@ bool ModelOperation::operator==(const ModelOperation& other) const {
|
|||
&& other.length == this->length && other.destIndex == this->destIndex;
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(misc-use-internal-linkage)
|
||||
QDebug& operator<<(QDebug& debug, const ModelOperation& op) {
|
||||
auto saver = QDebugStateSaver(debug);
|
||||
debug.nospace();
|
||||
|
@ -43,6 +44,7 @@ QDebug& operator<<(QDebug& debug, const ModelOperation& op) {
|
|||
return debug;
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(misc-use-internal-linkage)
|
||||
QDebug& operator<<(QDebug& debug, const QVariantList& list) {
|
||||
auto str = QString();
|
||||
|
||||
|
|
|
@ -196,7 +196,7 @@ V* AwfulMap<K, V>::get(const K& key) {
|
|||
}
|
||||
|
||||
template <typename K, typename V>
|
||||
void AwfulMap<K, V>::insert(K key, V value) {
|
||||
void AwfulMap<K, V>::insert(const K& key, V value) {
|
||||
this->values.push_back(QPair<K, V>(key, value));
|
||||
}
|
||||
|
||||
|
|
|
@ -20,8 +20,8 @@ class AwfulMap {
|
|||
public:
|
||||
[[nodiscard]] bool contains(const K& key) const;
|
||||
[[nodiscard]] V* get(const K& key);
|
||||
void insert(K key, V value); // assumes no duplicates
|
||||
bool remove(const K& key); // returns true if anything was removed
|
||||
void insert(const K& key, V value); // assumes no duplicates
|
||||
bool remove(const K& key); // returns true if anything was removed
|
||||
QList<QPair<K, V>> values;
|
||||
};
|
||||
|
||||
|
|
|
@ -22,7 +22,9 @@ using namespace google_breakpad;
|
|||
|
||||
namespace qs::crash {
|
||||
|
||||
namespace {
|
||||
Q_LOGGING_CATEGORY(logCrashHandler, "quickshell.crashhandler", QtWarningMsg);
|
||||
}
|
||||
|
||||
struct CrashHandlerPrivate {
|
||||
ExceptionHandler* exceptionHandler = nullptr;
|
||||
|
|
|
@ -22,49 +22,10 @@
|
|||
#include "build.hpp"
|
||||
#include "interface.hpp"
|
||||
|
||||
namespace {
|
||||
|
||||
Q_LOGGING_CATEGORY(logCrashReporter, "quickshell.crashreporter", QtWarningMsg);
|
||||
|
||||
void recordCrashInfo(const QDir& crashDir, const InstanceInfo& instance);
|
||||
|
||||
void qsCheckCrash(int argc, char** argv) {
|
||||
auto fd = qEnvironmentVariable("__QUICKSHELL_CRASH_DUMP_FD");
|
||||
if (fd.isEmpty()) return;
|
||||
auto app = QApplication(argc, argv);
|
||||
|
||||
RelaunchInfo info;
|
||||
|
||||
auto crashProc = qEnvironmentVariable("__QUICKSHELL_CRASH_DUMP_PID").toInt();
|
||||
|
||||
{
|
||||
auto infoFd = qEnvironmentVariable("__QUICKSHELL_CRASH_INFO_FD").toInt();
|
||||
|
||||
QFile file;
|
||||
file.open(infoFd, QFile::ReadOnly, QFile::AutoCloseHandle);
|
||||
file.seek(0);
|
||||
|
||||
auto ds = QDataStream(&file);
|
||||
ds >> info;
|
||||
}
|
||||
|
||||
LogManager::init(
|
||||
!info.noColor,
|
||||
info.timestamp,
|
||||
info.sparseLogsOnly,
|
||||
info.defaultLogLevel,
|
||||
info.logRules
|
||||
);
|
||||
|
||||
auto crashDir = QsPaths::crashDir(info.instance.instanceId);
|
||||
|
||||
qCInfo(logCrashReporter) << "Starting crash reporter...";
|
||||
|
||||
recordCrashInfo(crashDir, info.instance);
|
||||
|
||||
auto gui = CrashReporterGui(crashDir.path(), crashProc);
|
||||
gui.show();
|
||||
exit(QApplication::exec()); // NOLINT
|
||||
}
|
||||
|
||||
int tryDup(int fd, const QString& path) {
|
||||
QFile sourceFile;
|
||||
if (!sourceFile.open(fd, QFile::ReadOnly, QFile::AutoCloseHandle)) {
|
||||
|
@ -184,3 +145,44 @@ void recordCrashInfo(const QDir& crashDir, const InstanceInfo& instance) {
|
|||
|
||||
qCDebug(logCrashReporter) << "Recorded crash information.";
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
void qsCheckCrash(int argc, char** argv) {
|
||||
auto fd = qEnvironmentVariable("__QUICKSHELL_CRASH_DUMP_FD");
|
||||
if (fd.isEmpty()) return;
|
||||
auto app = QApplication(argc, argv);
|
||||
|
||||
RelaunchInfo info;
|
||||
|
||||
auto crashProc = qEnvironmentVariable("__QUICKSHELL_CRASH_DUMP_PID").toInt();
|
||||
|
||||
{
|
||||
auto infoFd = qEnvironmentVariable("__QUICKSHELL_CRASH_INFO_FD").toInt();
|
||||
|
||||
QFile file;
|
||||
file.open(infoFd, QFile::ReadOnly, QFile::AutoCloseHandle);
|
||||
file.seek(0);
|
||||
|
||||
auto ds = QDataStream(&file);
|
||||
ds >> info;
|
||||
}
|
||||
|
||||
LogManager::init(
|
||||
!info.noColor,
|
||||
info.timestamp,
|
||||
info.sparseLogsOnly,
|
||||
info.defaultLogLevel,
|
||||
info.logRules
|
||||
);
|
||||
|
||||
auto crashDir = QsPaths::crashDir(info.instance.instanceId);
|
||||
|
||||
qCInfo(logCrashReporter) << "Starting crash reporter...";
|
||||
|
||||
recordCrashInfo(crashDir, info.instance);
|
||||
|
||||
auto gui = CrashReporterGui(crashDir.path(), crashProc);
|
||||
gui.show();
|
||||
exit(QApplication::exec()); // NOLINT
|
||||
}
|
||||
|
|
|
@ -14,7 +14,9 @@
|
|||
|
||||
namespace qs::dbus {
|
||||
|
||||
namespace {
|
||||
Q_LOGGING_CATEGORY(logDbus, "quickshell.dbus", QtWarningMsg);
|
||||
}
|
||||
|
||||
void tryLaunchService(
|
||||
QObject* parent,
|
||||
|
|
|
@ -368,11 +368,9 @@ void DBusMenu::updateLayoutRecursive(
|
|||
auto childrenChanged = false;
|
||||
auto iter = item->mChildren.begin();
|
||||
while (iter != item->mChildren.end()) {
|
||||
auto existing = std::find_if(
|
||||
layout.children.begin(),
|
||||
layout.children.end(),
|
||||
[&](const DBusMenuLayout& layout) { return layout.id == *iter; }
|
||||
);
|
||||
auto existing = std::ranges::find_if(layout.children, [&](const DBusMenuLayout& layout) {
|
||||
return layout.id == *iter;
|
||||
});
|
||||
|
||||
if (!item->mShowChildren || existing == layout.children.end()) {
|
||||
qCDebug(logDbusMenu) << "Removing missing layout item" << this->items.value(*iter) << "from"
|
||||
|
|
|
@ -190,11 +190,9 @@ void DBusPropertyGroup::updateAllViaGetAll() {
|
|||
|
||||
void DBusPropertyGroup::updatePropertySet(const QVariantMap& properties, bool complainMissing) {
|
||||
for (const auto [name, value]: properties.asKeyValueRange()) {
|
||||
auto prop = std::find_if(
|
||||
this->properties.begin(),
|
||||
this->properties.end(),
|
||||
[&name](DBusPropertyCore* prop) { return prop->nameRef() == name; }
|
||||
);
|
||||
auto prop = std::ranges::find_if(this->properties, [&name](DBusPropertyCore* prop) {
|
||||
return prop->nameRef() == name;
|
||||
});
|
||||
|
||||
if (prop == this->properties.end()) {
|
||||
qCDebug(logDbusProperties) << "Ignoring untracked property update" << name << "for"
|
||||
|
@ -312,11 +310,9 @@ void DBusPropertyGroup::onPropertiesChanged(
|
|||
<< "Received property change set and invalidations for" << this->toString();
|
||||
|
||||
for (const auto& name: invalidatedProperties) {
|
||||
auto prop = std::find_if(
|
||||
this->properties.begin(),
|
||||
this->properties.end(),
|
||||
[&name](DBusPropertyCore* prop) { return prop->nameRef() == name; }
|
||||
);
|
||||
auto prop = std::ranges::find_if(this->properties, [&name](DBusPropertyCore* prop) {
|
||||
return prop->nameRef() == name;
|
||||
});
|
||||
|
||||
if (prop == this->properties.end()) {
|
||||
qCDebug(logDbusProperties) << "Ignoring untracked property invalidation" << name << "for"
|
||||
|
|
|
@ -66,7 +66,7 @@ template <typename T>
|
|||
void asyncReadProperty(
|
||||
QDBusAbstractInterface& interface,
|
||||
const QString& property,
|
||||
std::function<void(T, QDBusError)> callback
|
||||
const std::function<void(T, QDBusError)>& callback
|
||||
) {
|
||||
asyncReadPropertyInternal(
|
||||
QMetaType::fromType<T>(),
|
||||
|
|
|
@ -13,10 +13,12 @@
|
|||
|
||||
namespace qs::debug {
|
||||
|
||||
namespace {
|
||||
Q_LOGGING_CATEGORY(logLint, "quickshell.linter", QtWarningMsg);
|
||||
|
||||
void lintZeroSized(QQuickItem* item);
|
||||
bool isRenderable(QQuickItem* item);
|
||||
} // namespace
|
||||
|
||||
void lintObjectTree(QObject* object) {
|
||||
if (!logLint().isWarningEnabled()) return;
|
||||
|
@ -41,6 +43,8 @@ void lintItemTree(QQuickItem* item) {
|
|||
}
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
void lintZeroSized(QQuickItem* item) {
|
||||
if (!item->isEnabled() || !item->isVisible()) return;
|
||||
if (item->childItems().isEmpty()) return;
|
||||
|
@ -71,4 +75,6 @@ bool isRenderable(QQuickItem* item) {
|
|||
return std::ranges::any_of(item->childItems(), [](auto* item) { return isRenderable(item); });
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
} // namespace qs::debug
|
||||
|
|
|
@ -24,7 +24,9 @@
|
|||
|
||||
namespace qs::io {
|
||||
|
||||
namespace {
|
||||
Q_LOGGING_CATEGORY(logFileView, "quickshell.io.fileview", QtWarningMsg);
|
||||
}
|
||||
|
||||
QString FileViewError::toString(FileViewError::Enum value) {
|
||||
switch (value) {
|
||||
|
|
|
@ -34,113 +34,7 @@ namespace qs::launch {
|
|||
|
||||
using qs::ipc::IpcClient;
|
||||
|
||||
int readLogFile(CommandState& cmd);
|
||||
int listInstances(CommandState& cmd);
|
||||
int killInstances(CommandState& cmd);
|
||||
int msgInstance(CommandState& cmd);
|
||||
int launchFromCommand(CommandState& cmd, QCoreApplication* coreApplication);
|
||||
int locateConfigFile(CommandState& cmd, QString& path);
|
||||
|
||||
int runCommand(int argc, char** argv, QCoreApplication* coreApplication) {
|
||||
auto state = CommandState();
|
||||
if (auto ret = parseCommand(argc, argv, state); ret != 65535) return ret;
|
||||
|
||||
if (state.misc.checkCompat) {
|
||||
if (strcmp(qVersion(), QT_VERSION_STR) != 0) {
|
||||
QTextStream(stdout) << "\033[31mCOMPATIBILITY WARNING: Quickshell was built against Qt "
|
||||
<< QT_VERSION_STR << " but the system has updated to Qt " << qVersion()
|
||||
<< " without rebuilding the package. This is likely to cause crashes, so "
|
||||
"you must rebuild the quickshell package.\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Has to happen before extra threads are spawned.
|
||||
if (state.misc.daemonize) {
|
||||
auto closepipes = std::array<int, 2>();
|
||||
if (pipe(closepipes.data()) == -1) {
|
||||
qFatal().nospace() << "Failed to create messaging pipes for daemon with error " << errno
|
||||
<< ": " << qt_error_string();
|
||||
}
|
||||
|
||||
pid_t pid = fork(); // NOLINT (include)
|
||||
|
||||
if (pid == -1) {
|
||||
qFatal().nospace() << "Failed to fork daemon with error " << errno << ": "
|
||||
<< qt_error_string();
|
||||
} else if (pid == 0) {
|
||||
DAEMON_PIPE = closepipes[1];
|
||||
close(closepipes[0]);
|
||||
|
||||
if (setsid() == -1) {
|
||||
qFatal().nospace() << "Failed to setsid with error " << errno << ": " << qt_error_string();
|
||||
}
|
||||
} else {
|
||||
close(closepipes[1]);
|
||||
|
||||
int ret = 0;
|
||||
if (read(closepipes[0], &ret, sizeof(int)) == -1) {
|
||||
qFatal() << "Failed to wait for daemon launch (it may have crashed)";
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
auto level = state.log.verbosity == 0 ? QtWarningMsg
|
||||
: state.log.verbosity == 1 ? QtInfoMsg
|
||||
: QtDebugMsg;
|
||||
|
||||
LogManager::init(
|
||||
!state.log.noColor,
|
||||
state.log.timestamp,
|
||||
state.log.sparse,
|
||||
level,
|
||||
*state.log.rules,
|
||||
*state.subcommand.log ? "READER" : ""
|
||||
);
|
||||
}
|
||||
|
||||
if (state.misc.printVersion) {
|
||||
qCInfo(logBare).noquote().nospace() << "quickshell pre-release, revision " << GIT_REVISION
|
||||
<< ", distributed by: " << DISTRIBUTOR;
|
||||
|
||||
if (state.log.verbosity > 1) {
|
||||
qCInfo(logBare).noquote() << "\nBuildtime Qt Version:" << QT_VERSION_STR;
|
||||
qCInfo(logBare).noquote() << "Runtime Qt Version:" << qVersion();
|
||||
qCInfo(logBare).noquote() << "Compiler:" << COMPILER;
|
||||
qCInfo(logBare).noquote() << "Compile Flags:" << COMPILE_FLAGS;
|
||||
}
|
||||
|
||||
if (state.log.verbosity > 0) {
|
||||
qCInfo(logBare).noquote() << "\nBuild Type:" << BUILD_TYPE;
|
||||
qCInfo(logBare).noquote() << "Build configuration:";
|
||||
qCInfo(logBare).noquote().nospace() << BUILD_CONFIGURATION;
|
||||
}
|
||||
} else if (*state.subcommand.log) {
|
||||
return readLogFile(state);
|
||||
} else if (*state.subcommand.list) {
|
||||
return listInstances(state);
|
||||
} else if (*state.subcommand.kill) {
|
||||
return killInstances(state);
|
||||
} else if (*state.subcommand.msg) {
|
||||
return msgInstance(state);
|
||||
} else {
|
||||
if (strcmp(qVersion(), QT_VERSION_STR) != 0) {
|
||||
qWarning() << "\033[31mQuickshell was built against Qt" << QT_VERSION_STR
|
||||
<< "but the system has updated to Qt" << qVersion()
|
||||
<< "without rebuilding the package. This is likely to cause crashes, so "
|
||||
"the quickshell package must be rebuilt.\n";
|
||||
}
|
||||
|
||||
return launchFromCommand(state, coreApplication);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
namespace {
|
||||
|
||||
int locateConfigFile(CommandState& cmd, QString& path) {
|
||||
if (!cmd.config.path->isEmpty()) {
|
||||
|
@ -209,7 +103,7 @@ int locateConfigFile(CommandState& cmd, QString& path) {
|
|||
}
|
||||
|
||||
void sortInstances(QVector<InstanceLockInfo>& list) {
|
||||
std::sort(list.begin(), list.end(), [](const InstanceLockInfo& a, const InstanceLockInfo& b) {
|
||||
std::ranges::sort(list, [](const InstanceLockInfo& a, const InstanceLockInfo& b) {
|
||||
return a.instance.launchTime < b.instance.launchTime;
|
||||
});
|
||||
};
|
||||
|
@ -230,12 +124,9 @@ int selectInstance(CommandState& cmd, InstanceLockInfo* instance) {
|
|||
path = basePath->filePath("by-pid");
|
||||
auto instances = QsPaths::collectInstances(path);
|
||||
|
||||
auto itr =
|
||||
std::remove_if(instances.begin(), instances.end(), [&](const InstanceLockInfo& info) {
|
||||
return !info.instance.instanceId.startsWith(*cmd.instance.id);
|
||||
});
|
||||
|
||||
instances.erase(itr, instances.end());
|
||||
instances.removeIf([&](const InstanceLockInfo& info) {
|
||||
return !info.instance.instanceId.startsWith(*cmd.instance.id);
|
||||
});
|
||||
|
||||
if (instances.isEmpty()) {
|
||||
qCInfo(logBare) << "No running instances start with" << *cmd.instance.id;
|
||||
|
@ -444,4 +335,107 @@ int launchFromCommand(CommandState& cmd, QCoreApplication* coreApplication) {
|
|||
);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
int runCommand(int argc, char** argv, QCoreApplication* coreApplication) {
|
||||
auto state = CommandState();
|
||||
if (auto ret = parseCommand(argc, argv, state); ret != 65535) return ret;
|
||||
|
||||
if (state.misc.checkCompat) {
|
||||
if (strcmp(qVersion(), QT_VERSION_STR) != 0) {
|
||||
QTextStream(stdout) << "\033[31mCOMPATIBILITY WARNING: Quickshell was built against Qt "
|
||||
<< QT_VERSION_STR << " but the system has updated to Qt " << qVersion()
|
||||
<< " without rebuilding the package. This is likely to cause crashes, so "
|
||||
"you must rebuild the quickshell package.\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Has to happen before extra threads are spawned.
|
||||
if (state.misc.daemonize) {
|
||||
auto closepipes = std::array<int, 2>();
|
||||
if (pipe(closepipes.data()) == -1) {
|
||||
qFatal().nospace() << "Failed to create messaging pipes for daemon with error " << errno
|
||||
<< ": " << qt_error_string();
|
||||
}
|
||||
|
||||
pid_t pid = fork(); // NOLINT (include)
|
||||
|
||||
if (pid == -1) {
|
||||
qFatal().nospace() << "Failed to fork daemon with error " << errno << ": "
|
||||
<< qt_error_string();
|
||||
} else if (pid == 0) {
|
||||
DAEMON_PIPE = closepipes[1];
|
||||
close(closepipes[0]);
|
||||
|
||||
if (setsid() == -1) {
|
||||
qFatal().nospace() << "Failed to setsid with error " << errno << ": " << qt_error_string();
|
||||
}
|
||||
} else {
|
||||
close(closepipes[1]);
|
||||
|
||||
int ret = 0;
|
||||
if (read(closepipes[0], &ret, sizeof(int)) == -1) {
|
||||
qFatal() << "Failed to wait for daemon launch (it may have crashed)";
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
auto level = state.log.verbosity == 0 ? QtWarningMsg
|
||||
: state.log.verbosity == 1 ? QtInfoMsg
|
||||
: QtDebugMsg;
|
||||
|
||||
LogManager::init(
|
||||
!state.log.noColor,
|
||||
state.log.timestamp,
|
||||
state.log.sparse,
|
||||
level,
|
||||
*state.log.rules,
|
||||
*state.subcommand.log ? "READER" : ""
|
||||
);
|
||||
}
|
||||
|
||||
if (state.misc.printVersion) {
|
||||
qCInfo(logBare).noquote().nospace() << "quickshell pre-release, revision " << GIT_REVISION
|
||||
<< ", distributed by: " << DISTRIBUTOR;
|
||||
|
||||
if (state.log.verbosity > 1) {
|
||||
qCInfo(logBare).noquote() << "\nBuildtime Qt Version:" << QT_VERSION_STR;
|
||||
qCInfo(logBare).noquote() << "Runtime Qt Version:" << qVersion();
|
||||
qCInfo(logBare).noquote() << "Compiler:" << COMPILER;
|
||||
qCInfo(logBare).noquote() << "Compile Flags:" << COMPILE_FLAGS;
|
||||
}
|
||||
|
||||
if (state.log.verbosity > 0) {
|
||||
qCInfo(logBare).noquote() << "\nBuild Type:" << BUILD_TYPE;
|
||||
qCInfo(logBare).noquote() << "Build configuration:";
|
||||
qCInfo(logBare).noquote().nospace() << BUILD_CONFIGURATION;
|
||||
}
|
||||
} else if (*state.subcommand.log) {
|
||||
return readLogFile(state);
|
||||
} else if (*state.subcommand.list) {
|
||||
return listInstances(state);
|
||||
} else if (*state.subcommand.kill) {
|
||||
return killInstances(state);
|
||||
} else if (*state.subcommand.msg) {
|
||||
return msgInstance(state);
|
||||
} else {
|
||||
if (strcmp(qVersion(), QT_VERSION_STR) != 0) {
|
||||
qWarning() << "\033[31mQuickshell was built against Qt" << QT_VERSION_STR
|
||||
<< "but the system has updated to Qt" << qVersion()
|
||||
<< "without rebuilding the package. This is likely to cause crashes, so "
|
||||
"the quickshell package must be rebuilt.\n";
|
||||
}
|
||||
|
||||
return launchFromCommand(state, coreApplication);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
} // namespace qs::launch
|
||||
|
|
|
@ -32,6 +32,8 @@
|
|||
|
||||
namespace qs::launch {
|
||||
|
||||
namespace {
|
||||
|
||||
template <typename T>
|
||||
QString base36Encode(T number) {
|
||||
const QString digits = "0123456789abcdefghijklmnopqrstuvwxyz";
|
||||
|
@ -52,6 +54,8 @@ QString base36Encode(T number) {
|
|||
return result;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
int launch(const LaunchArgs& args, char** argv, QCoreApplication* coreApplication) {
|
||||
auto pathId = QCryptographicHash::hash(args.configPath.toUtf8(), QCryptographicHash::Md5).toHex();
|
||||
auto shellId = QString(pathId);
|
||||
|
|
|
@ -22,36 +22,7 @@
|
|||
|
||||
namespace qs::launch {
|
||||
|
||||
void checkCrashRelaunch(char** argv, QCoreApplication* coreApplication);
|
||||
|
||||
int DAEMON_PIPE = -1; // NOLINT
|
||||
|
||||
void exitDaemon(int code) {
|
||||
if (DAEMON_PIPE == -1) return;
|
||||
|
||||
if (write(DAEMON_PIPE, &code, sizeof(int)) == -1) {
|
||||
qCritical().nospace() << "Failed to write daemon exit command with error code " << errno << ": "
|
||||
<< qt_error_string();
|
||||
}
|
||||
|
||||
close(DAEMON_PIPE);
|
||||
|
||||
close(STDIN_FILENO);
|
||||
close(STDOUT_FILENO);
|
||||
close(STDERR_FILENO);
|
||||
|
||||
if (open("/dev/null", O_RDONLY) != STDIN_FILENO) { // NOLINT
|
||||
qFatal() << "Failed to open /dev/null on stdin";
|
||||
}
|
||||
|
||||
if (open("/dev/null", O_WRONLY) != STDOUT_FILENO) { // NOLINT
|
||||
qFatal() << "Failed to open /dev/null on stdout";
|
||||
}
|
||||
|
||||
if (open("/dev/null", O_WRONLY) != STDERR_FILENO) { // NOLINT
|
||||
qFatal() << "Failed to open /dev/null on stderr";
|
||||
}
|
||||
}
|
||||
namespace {
|
||||
|
||||
void checkCrashRelaunch(char** argv, QCoreApplication* coreApplication) {
|
||||
#if CRASH_REPORTER
|
||||
|
@ -96,6 +67,37 @@ void checkCrashRelaunch(char** argv, QCoreApplication* coreApplication) {
|
|||
#endif
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
int DAEMON_PIPE = -1; // NOLINT
|
||||
|
||||
void exitDaemon(int code) {
|
||||
if (DAEMON_PIPE == -1) return;
|
||||
|
||||
if (write(DAEMON_PIPE, &code, sizeof(int)) == -1) {
|
||||
qCritical().nospace() << "Failed to write daemon exit command with error code " << errno << ": "
|
||||
<< qt_error_string();
|
||||
}
|
||||
|
||||
close(DAEMON_PIPE);
|
||||
|
||||
close(STDIN_FILENO);
|
||||
close(STDOUT_FILENO);
|
||||
close(STDERR_FILENO);
|
||||
|
||||
if (open("/dev/null", O_RDONLY) != STDIN_FILENO) { // NOLINT
|
||||
qFatal() << "Failed to open /dev/null on stdin";
|
||||
}
|
||||
|
||||
if (open("/dev/null", O_WRONLY) != STDOUT_FILENO) { // NOLINT
|
||||
qFatal() << "Failed to open /dev/null on stdout";
|
||||
}
|
||||
|
||||
if (open("/dev/null", O_WRONLY) != STDERR_FILENO) { // NOLINT
|
||||
qFatal() << "Failed to open /dev/null on stderr";
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
QCoreApplication::setApplicationName("quickshell");
|
||||
|
||||
|
|
|
@ -15,7 +15,9 @@
|
|||
|
||||
#include "../../core/generation.hpp"
|
||||
|
||||
namespace {
|
||||
Q_LOGGING_CATEGORY(logGreetd, "quickshell.service.greetd");
|
||||
}
|
||||
|
||||
QString GreetdState::toString(GreetdState::Enum value) {
|
||||
switch (value) {
|
||||
|
|
|
@ -21,7 +21,9 @@ using namespace qs::dbus;
|
|||
|
||||
namespace qs::service::mpris {
|
||||
|
||||
namespace {
|
||||
Q_LOGGING_CATEGORY(logMprisPlayer, "quickshell.service.mp.player", QtWarningMsg);
|
||||
}
|
||||
|
||||
QString MprisPlaybackState::toString(MprisPlaybackState::Enum status) {
|
||||
switch (status) {
|
||||
|
|
|
@ -14,7 +14,9 @@
|
|||
|
||||
namespace qs::service::mpris {
|
||||
|
||||
namespace {
|
||||
Q_LOGGING_CATEGORY(logMprisWatcher, "quickshell.service.mpris.watcher", QtWarningMsg);
|
||||
}
|
||||
|
||||
MprisWatcher::MprisWatcher() {
|
||||
qCDebug(logMprisWatcher) << "Starting MprisWatcher";
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
|
||||
namespace qs::service::notifications {
|
||||
|
||||
// NOLINTNEXTLINE(misc-use-internal-linkage)
|
||||
Q_DECLARE_LOGGING_CATEGORY(logNotifications); // server.cpp
|
||||
|
||||
QImage DBusNotificationImage::createImage() const {
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
|
||||
namespace qs::service::notifications {
|
||||
|
||||
// NOLINTNEXTLINE(misc-use-internal-linkage)
|
||||
Q_DECLARE_LOGGING_CATEGORY(logNotifications); // server.cpp
|
||||
|
||||
QString NotificationUrgency::toString(NotificationUrgency::Enum value) {
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
|
||||
namespace qs::service::notifications {
|
||||
|
||||
// NOLINTNEXTLINE(misc-use-internal-linkage)
|
||||
Q_LOGGING_CATEGORY(logNotifications, "quickshell.service.notifications");
|
||||
|
||||
NotificationServer::NotificationServer() {
|
||||
|
|
|
@ -15,7 +15,9 @@
|
|||
|
||||
namespace qs::service::pipewire {
|
||||
|
||||
namespace {
|
||||
Q_LOGGING_CATEGORY(logLoop, "quickshell.service.pipewire.loop", QtWarningMsg);
|
||||
}
|
||||
|
||||
PwCore::PwCore(QObject* parent): QObject(parent), notifier(QSocketNotifier::Read) {
|
||||
qCInfo(logLoop) << "Creating pipewire event loop.";
|
||||
|
|
|
@ -18,7 +18,9 @@
|
|||
|
||||
namespace qs::service::pipewire {
|
||||
|
||||
namespace {
|
||||
Q_LOGGING_CATEGORY(logDefaults, "quickshell.service.pipewire.defaults", QtWarningMsg);
|
||||
}
|
||||
|
||||
PwDefaultTracker::PwDefaultTracker(PwRegistry* registry): registry(registry) {
|
||||
QObject::connect(registry, &PwRegistry::metadataAdded, this, &PwDefaultTracker::onMetadataAdded);
|
||||
|
|
|
@ -23,7 +23,9 @@
|
|||
|
||||
namespace qs::service::pipewire {
|
||||
|
||||
namespace {
|
||||
Q_LOGGING_CATEGORY(logDevice, "quickshell.service.pipewire.device", QtWarningMsg);
|
||||
}
|
||||
|
||||
// https://github.com/PipeWire/wireplumber/blob/895c1c7286e8809fad869059179e53ab39c807e9/modules/module-mixer-api.c#L397
|
||||
// https://github.com/PipeWire/pipewire/blob/48c2e9516585ccc791335bc7baf4af6952ec54a0/src/modules/module-protocol-pulse/pulse-server.c#L2743-L2743
|
||||
|
|
|
@ -14,7 +14,9 @@
|
|||
|
||||
namespace qs::service::pipewire {
|
||||
|
||||
namespace {
|
||||
Q_LOGGING_CATEGORY(logLink, "quickshell.service.pipewire.link", QtWarningMsg);
|
||||
}
|
||||
|
||||
QString PwLinkState::toString(Enum value) {
|
||||
return QString(pw_link_state_as_string(static_cast<pw_link_state>(value)));
|
||||
|
|
|
@ -15,7 +15,9 @@
|
|||
|
||||
namespace qs::service::pipewire {
|
||||
|
||||
namespace {
|
||||
Q_LOGGING_CATEGORY(logMeta, "quickshell.service.pipewire.metadata", QtWarningMsg);
|
||||
}
|
||||
|
||||
void PwMetadata::bindHooks() {
|
||||
pw_metadata_add_listener(this->proxy(), &this->listener.hook, &PwMetadata::EVENTS, this);
|
||||
|
|
|
@ -28,7 +28,9 @@
|
|||
|
||||
namespace qs::service::pipewire {
|
||||
|
||||
namespace {
|
||||
Q_LOGGING_CATEGORY(logNode, "quickshell.service.pipewire.node", QtWarningMsg);
|
||||
}
|
||||
|
||||
QString PwAudioChannel::toString(Enum value) {
|
||||
switch (value) {
|
||||
|
|
|
@ -35,7 +35,6 @@ using namespace qs::dbus::dbusmenu;
|
|||
using namespace qs::menu::platform;
|
||||
|
||||
Q_LOGGING_CATEGORY(logStatusNotifierItem, "quickshell.service.sni.item", QtWarningMsg);
|
||||
Q_LOGGING_CATEGORY(logSniMenu, "quickshell.service.sni.item.menu", QtWarningMsg);
|
||||
|
||||
namespace qs::service::sni {
|
||||
|
||||
|
|
|
@ -20,7 +20,9 @@
|
|||
|
||||
namespace qs::service::upower {
|
||||
|
||||
namespace {
|
||||
Q_LOGGING_CATEGORY(logUPower, "quickshell.service.upower", QtWarningMsg);
|
||||
}
|
||||
|
||||
UPower::UPower() {
|
||||
qCDebug(logUPower) << "Starting UPower Service";
|
||||
|
|
|
@ -15,7 +15,9 @@ using namespace qs::dbus;
|
|||
|
||||
namespace qs::service::upower {
|
||||
|
||||
namespace {
|
||||
Q_LOGGING_CATEGORY(logUPowerDevice, "quickshell.service.upower.device", QtWarningMsg);
|
||||
}
|
||||
|
||||
QString UPowerDeviceState::toString(UPowerDeviceState::Enum status) {
|
||||
switch (status) {
|
||||
|
|
|
@ -26,8 +26,10 @@
|
|||
|
||||
namespace qs::hyprland::ipc {
|
||||
|
||||
namespace {
|
||||
Q_LOGGING_CATEGORY(logHyprlandIpc, "quickshell.hyprland.ipc", QtWarningMsg);
|
||||
Q_LOGGING_CATEGORY(logHyprlandIpcEvents, "quickshell.hyprland.ipc.events", QtWarningMsg);
|
||||
} // namespace
|
||||
|
||||
HyprlandIpc::HyprlandIpc() {
|
||||
auto his = qEnvironmentVariable("HYPRLAND_INSTANCE_SIGNATURE");
|
||||
|
@ -241,9 +243,8 @@ void HyprlandIpc::onEvent(HyprlandIpcEvent* event) {
|
|||
const auto& mList = this->mMonitors.valueList();
|
||||
auto name = QString::fromUtf8(event->data);
|
||||
|
||||
auto monitorIter = std::find_if(mList.begin(), mList.end(), [name](const HyprlandMonitor* m) {
|
||||
return m->name() == name;
|
||||
});
|
||||
auto monitorIter =
|
||||
std::ranges::find_if(mList, [name](const HyprlandMonitor* m) { return m->name() == name; });
|
||||
|
||||
if (monitorIter == mList.end()) {
|
||||
qCWarning(logHyprlandIpc) << "Got removal for monitor" << name
|
||||
|
@ -292,9 +293,8 @@ void HyprlandIpc::onEvent(HyprlandIpcEvent* event) {
|
|||
|
||||
const auto& mList = this->mWorkspaces.valueList();
|
||||
|
||||
auto workspaceIter = std::find_if(mList.begin(), mList.end(), [id](const HyprlandWorkspace* m) {
|
||||
return m->id() == id;
|
||||
});
|
||||
auto workspaceIter =
|
||||
std::ranges::find_if(mList, [id](const HyprlandWorkspace* m) { return m->id() == id; });
|
||||
|
||||
if (workspaceIter == mList.end()) {
|
||||
qCWarning(logHyprlandIpc) << "Got removal for workspace id" << id << "name" << name
|
||||
|
@ -359,9 +359,8 @@ HyprlandWorkspace*
|
|||
HyprlandIpc::findWorkspaceByName(const QString& name, bool createIfMissing, qint32 id) {
|
||||
const auto& mList = this->mWorkspaces.valueList();
|
||||
|
||||
auto workspaceIter = std::find_if(mList.begin(), mList.end(), [name](const HyprlandWorkspace* m) {
|
||||
return m->name() == name;
|
||||
});
|
||||
auto workspaceIter =
|
||||
std::ranges::find_if(mList, [name](const HyprlandWorkspace* m) { return m->name() == name; });
|
||||
|
||||
if (workspaceIter != mList.end()) {
|
||||
return *workspaceIter;
|
||||
|
@ -395,10 +394,9 @@ void HyprlandIpc::refreshWorkspaces(bool canCreate) {
|
|||
auto object = entry.toObject().toVariantMap();
|
||||
auto name = object.value("name").toString();
|
||||
|
||||
auto workspaceIter =
|
||||
std::find_if(mList.begin(), mList.end(), [name](const HyprlandWorkspace* m) {
|
||||
return m->name() == name;
|
||||
});
|
||||
auto workspaceIter = std::ranges::find_if(mList, [name](const HyprlandWorkspace* m) {
|
||||
return m->name() == name;
|
||||
});
|
||||
|
||||
auto* workspace = workspaceIter == mList.end() ? nullptr : *workspaceIter;
|
||||
auto existed = workspace != nullptr;
|
||||
|
@ -436,9 +434,8 @@ HyprlandMonitor*
|
|||
HyprlandIpc::findMonitorByName(const QString& name, bool createIfMissing, qint32 id) {
|
||||
const auto& mList = this->mMonitors.valueList();
|
||||
|
||||
auto monitorIter = std::find_if(mList.begin(), mList.end(), [name](const HyprlandMonitor* m) {
|
||||
return m->name() == name;
|
||||
});
|
||||
auto monitorIter =
|
||||
std::ranges::find_if(mList, [name](const HyprlandMonitor* m) { return m->name() == name; });
|
||||
|
||||
if (monitorIter != mList.end()) {
|
||||
return *monitorIter;
|
||||
|
@ -506,7 +503,7 @@ void HyprlandIpc::refreshMonitors(bool canCreate) {
|
|||
auto object = entry.toObject().toVariantMap();
|
||||
auto name = object.value("name").toString();
|
||||
|
||||
auto monitorIter = std::find_if(mList.begin(), mList.end(), [name](const HyprlandMonitor* m) {
|
||||
auto monitorIter = std::ranges::find_if(mList, [name](const HyprlandMonitor* m) {
|
||||
return m->name() == name;
|
||||
});
|
||||
|
||||
|
|
|
@ -10,8 +10,8 @@
|
|||
#include "wlr_layershell.hpp"
|
||||
#endif
|
||||
|
||||
void installPlatformMenuHook();
|
||||
void installPopupPositioner();
|
||||
void installPlatformMenuHook(); // NOLINT(misc-use-internal-linkage)
|
||||
void installPopupPositioner(); // NOLINT(misc-use-internal-linkage)
|
||||
|
||||
namespace {
|
||||
|
||||
|
|
|
@ -12,6 +12,8 @@
|
|||
|
||||
using namespace qs::menu::platform;
|
||||
|
||||
namespace {
|
||||
|
||||
// fixes positioning of submenus when hitting screen edges
|
||||
void platformMenuHook(PlatformMenuQMenu* menu) {
|
||||
auto* window = menu->windowHandle();
|
||||
|
@ -62,4 +64,6 @@ void platformMenuHook(PlatformMenuQMenu* menu) {
|
|||
window->setProperty("_q_waylandPopupConstraintAdjustment", constraintAdjustment);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
void installPlatformMenuHook() { PlatformMenuEntry::registerCreationHook(&platformMenuHook); }
|
||||
|
|
|
@ -22,12 +22,51 @@
|
|||
#include <qpoint.h>
|
||||
#endif
|
||||
|
||||
// clang-format off
|
||||
[[nodiscard]] QtWayland::zwlr_layer_shell_v1::layer toWaylandLayer(const WlrLayer::Enum& layer) noexcept;
|
||||
[[nodiscard]] QtWayland::zwlr_layer_surface_v1::anchor toWaylandAnchors(const Anchors& anchors) noexcept;
|
||||
[[nodiscard]] QtWayland::zwlr_layer_surface_v1::keyboard_interactivity toWaylandKeyboardFocus(const WlrKeyboardFocus::Enum& focus) noexcept;
|
||||
[[nodiscard]] QSize constrainedSize(const Anchors& anchors, const QSize& size) noexcept;
|
||||
// clang-format on
|
||||
namespace {
|
||||
|
||||
[[nodiscard]] QtWayland::zwlr_layer_shell_v1::layer toWaylandLayer(const WlrLayer::Enum& layer
|
||||
) noexcept {
|
||||
switch (layer) {
|
||||
case WlrLayer::Background: return QtWayland::zwlr_layer_shell_v1::layer_background;
|
||||
case WlrLayer::Bottom: return QtWayland::zwlr_layer_shell_v1::layer_bottom;
|
||||
case WlrLayer::Top: return QtWayland::zwlr_layer_shell_v1::layer_top;
|
||||
case WlrLayer::Overlay: return QtWayland::zwlr_layer_shell_v1::layer_overlay;
|
||||
}
|
||||
|
||||
return QtWayland::zwlr_layer_shell_v1::layer_top;
|
||||
}
|
||||
|
||||
[[nodiscard]] QtWayland::zwlr_layer_surface_v1::anchor toWaylandAnchors(const Anchors& anchors
|
||||
) noexcept {
|
||||
quint32 wl = 0;
|
||||
if (anchors.mLeft) wl |= QtWayland::zwlr_layer_surface_v1::anchor_left;
|
||||
if (anchors.mRight) wl |= QtWayland::zwlr_layer_surface_v1::anchor_right;
|
||||
if (anchors.mTop) wl |= QtWayland::zwlr_layer_surface_v1::anchor_top;
|
||||
if (anchors.mBottom) wl |= QtWayland::zwlr_layer_surface_v1::anchor_bottom;
|
||||
return static_cast<QtWayland::zwlr_layer_surface_v1::anchor>(wl);
|
||||
}
|
||||
|
||||
[[nodiscard]] QtWayland::zwlr_layer_surface_v1::keyboard_interactivity
|
||||
toWaylandKeyboardFocus(const WlrKeyboardFocus::Enum& focus) noexcept {
|
||||
switch (focus) {
|
||||
case WlrKeyboardFocus::None: return QtWayland::zwlr_layer_surface_v1::keyboard_interactivity_none;
|
||||
case WlrKeyboardFocus::Exclusive:
|
||||
return QtWayland::zwlr_layer_surface_v1::keyboard_interactivity_exclusive;
|
||||
case WlrKeyboardFocus::OnDemand:
|
||||
return QtWayland::zwlr_layer_surface_v1::keyboard_interactivity_on_demand;
|
||||
}
|
||||
|
||||
return QtWayland::zwlr_layer_surface_v1::keyboard_interactivity_none;
|
||||
}
|
||||
|
||||
[[nodiscard]] QSize constrainedSize(const Anchors& anchors, const QSize& size) noexcept {
|
||||
return QSize(
|
||||
anchors.horizontalConstraint() ? 0 : size.width(),
|
||||
anchors.verticalConstraint() ? 0 : size.height()
|
||||
);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
QSWaylandLayerSurface::QSWaylandLayerSurface(
|
||||
QSWaylandLayerShellIntegration* shell,
|
||||
|
@ -148,46 +187,6 @@ void QSWaylandLayerSurface::updateKeyboardFocus() {
|
|||
this->window()->waylandSurface()->commit();
|
||||
}
|
||||
|
||||
QtWayland::zwlr_layer_shell_v1::layer toWaylandLayer(const WlrLayer::Enum& layer) noexcept {
|
||||
switch (layer) {
|
||||
case WlrLayer::Background: return QtWayland::zwlr_layer_shell_v1::layer_background;
|
||||
case WlrLayer::Bottom: return QtWayland::zwlr_layer_shell_v1::layer_bottom;
|
||||
case WlrLayer::Top: return QtWayland::zwlr_layer_shell_v1::layer_top;
|
||||
case WlrLayer::Overlay: return QtWayland::zwlr_layer_shell_v1::layer_overlay;
|
||||
}
|
||||
|
||||
return QtWayland::zwlr_layer_shell_v1::layer_top;
|
||||
}
|
||||
|
||||
QtWayland::zwlr_layer_surface_v1::anchor toWaylandAnchors(const Anchors& anchors) noexcept {
|
||||
quint32 wl = 0;
|
||||
if (anchors.mLeft) wl |= QtWayland::zwlr_layer_surface_v1::anchor_left;
|
||||
if (anchors.mRight) wl |= QtWayland::zwlr_layer_surface_v1::anchor_right;
|
||||
if (anchors.mTop) wl |= QtWayland::zwlr_layer_surface_v1::anchor_top;
|
||||
if (anchors.mBottom) wl |= QtWayland::zwlr_layer_surface_v1::anchor_bottom;
|
||||
return static_cast<QtWayland::zwlr_layer_surface_v1::anchor>(wl);
|
||||
}
|
||||
|
||||
QtWayland::zwlr_layer_surface_v1::keyboard_interactivity
|
||||
toWaylandKeyboardFocus(const WlrKeyboardFocus::Enum& focus) noexcept {
|
||||
switch (focus) {
|
||||
case WlrKeyboardFocus::None: return QtWayland::zwlr_layer_surface_v1::keyboard_interactivity_none;
|
||||
case WlrKeyboardFocus::Exclusive:
|
||||
return QtWayland::zwlr_layer_surface_v1::keyboard_interactivity_exclusive;
|
||||
case WlrKeyboardFocus::OnDemand:
|
||||
return QtWayland::zwlr_layer_surface_v1::keyboard_interactivity_on_demand;
|
||||
}
|
||||
|
||||
return QtWayland::zwlr_layer_surface_v1::keyboard_interactivity_none;
|
||||
}
|
||||
|
||||
QSize constrainedSize(const Anchors& anchors, const QSize& size) noexcept {
|
||||
return QSize(
|
||||
anchors.horizontalConstraint() ? 0 : size.width(),
|
||||
anchors.verticalConstraint() ? 0 : size.height()
|
||||
);
|
||||
}
|
||||
|
||||
void QSWaylandLayerSurface::attachPopup(QtWaylandClient::QWaylandShellSurface* popup) {
|
||||
std::any role = popup->surfaceRole();
|
||||
|
||||
|
|
|
@ -28,10 +28,12 @@
|
|||
#include "monitor.hpp"
|
||||
#include "workspace.hpp"
|
||||
|
||||
namespace qs::i3::ipc {
|
||||
|
||||
namespace {
|
||||
Q_LOGGING_CATEGORY(logI3Ipc, "quickshell.I3.ipc", QtWarningMsg);
|
||||
Q_LOGGING_CATEGORY(logI3IpcEvents, "quickshell.I3.ipc.events", QtWarningMsg);
|
||||
|
||||
namespace qs::i3::ipc {
|
||||
} // namespace
|
||||
|
||||
void I3Ipc::makeRequest(const QByteArray& request) {
|
||||
if (!this->valid) {
|
||||
|
@ -262,9 +264,8 @@ void I3Ipc::handleGetWorkspacesEvent(I3IpcEvent* event) {
|
|||
auto object = entry.toObject().toVariantMap();
|
||||
auto name = object["name"].toString();
|
||||
|
||||
auto workspaceIter = std::find_if(mList.begin(), mList.end(), [name](const I3Workspace* m) {
|
||||
return m->name() == name;
|
||||
});
|
||||
auto workspaceIter =
|
||||
std::ranges::find_if(mList, [name](const I3Workspace* m) { return m->name() == name; });
|
||||
|
||||
auto* workspace = workspaceIter == mList.end() ? nullptr : *workspaceIter;
|
||||
auto existed = workspace != nullptr;
|
||||
|
@ -319,9 +320,8 @@ void I3Ipc::handleGetOutputsEvent(I3IpcEvent* event) {
|
|||
auto object = elem.toObject().toVariantMap();
|
||||
auto name = object["name"].toString();
|
||||
|
||||
auto monitorIter = std::find_if(mList.begin(), mList.end(), [name](const I3Monitor* m) {
|
||||
return m->name() == name;
|
||||
});
|
||||
auto monitorIter =
|
||||
std::ranges::find_if(mList, [name](const I3Monitor* m) { return m->name() == name; });
|
||||
|
||||
auto* monitor = monitorIter == mList.end() ? nullptr : *monitorIter;
|
||||
auto existed = monitor != nullptr;
|
||||
|
@ -477,25 +477,23 @@ I3Monitor* I3Ipc::monitorFor(QuickshellScreenInfo* screen) {
|
|||
I3Workspace* I3Ipc::findWorkspaceByID(qint32 id) {
|
||||
auto list = this->mWorkspaces.valueList();
|
||||
auto workspaceIter =
|
||||
std::find_if(list.begin(), list.end(), [id](const I3Workspace* m) { return m->id() == id; });
|
||||
std::ranges::find_if(list, [id](const I3Workspace* m) { return m->id() == id; });
|
||||
|
||||
return workspaceIter == list.end() ? nullptr : *workspaceIter;
|
||||
}
|
||||
|
||||
I3Workspace* I3Ipc::findWorkspaceByName(const QString& name) {
|
||||
auto list = this->mWorkspaces.valueList();
|
||||
auto workspaceIter = std::find_if(list.begin(), list.end(), [name](const I3Workspace* m) {
|
||||
return m->name() == name;
|
||||
});
|
||||
auto workspaceIter =
|
||||
std::ranges::find_if(list, [name](const I3Workspace* m) { return m->name() == name; });
|
||||
|
||||
return workspaceIter == list.end() ? nullptr : *workspaceIter;
|
||||
}
|
||||
|
||||
I3Monitor* I3Ipc::findMonitorByName(const QString& name) {
|
||||
auto list = this->mMonitors.valueList();
|
||||
auto monitorIter = std::find_if(list.begin(), list.end(), [name](const I3Monitor* m) {
|
||||
return m->name() == name;
|
||||
});
|
||||
auto monitorIter =
|
||||
std::ranges::find_if(list, [name](const I3Monitor* m) { return m->name() == name; });
|
||||
|
||||
return monitorIter == list.end() ? nullptr : *monitorIter;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue