mirror of
https://github.com/hyprwm/hyprcursor.git
synced 2025-05-12 21:30:36 +01:00
core: clang-tidy and comp fixes (#79)
* clang-tidy and comp fixes * oops
This commit is contained in:
parent
43e5139076
commit
0a8e83d35b
8 changed files with 142 additions and 35 deletions
101
.clang-tidy
Normal file
101
.clang-tidy
Normal file
|
@ -0,0 +1,101 @@
|
|||
WarningsAsErrors: '*'
|
||||
HeaderFilterRegex: '.*\.hpp'
|
||||
FormatStyle: file
|
||||
Checks: >
|
||||
-*,
|
||||
bugprone-*,
|
||||
-bugprone-easily-swappable-parameters,
|
||||
-bugprone-forward-declararion-namespace,
|
||||
-bugprone-forward-declararion-namespace,
|
||||
-bugprone-macro-parentheses,
|
||||
-bugprone-narrowing-conversions,
|
||||
-bugprone-branch-clone,
|
||||
-bugprone-assignment-in-if-condition,
|
||||
concurrency-*,
|
||||
-concurrency-mt-unsafe,
|
||||
cppcoreguidelines-*,
|
||||
-cppcoreguidelines-owning-memory,
|
||||
-cppcoreguidelines-avoid-magic-numbers,
|
||||
-cppcoreguidelines-pro-bounds-constant-array-index,
|
||||
-cppcoreguidelines-avoid-const-or-ref-data-members,
|
||||
-cppcoreguidelines-non-private-member-variables-in-classes,
|
||||
-cppcoreguidelines-avoid-goto,
|
||||
-cppcoreguidelines-pro-bounds-array-to-pointer-decay,
|
||||
-cppcoreguidelines-avoid-do-while,
|
||||
-cppcoreguidelines-avoid-non-const-global-variables,
|
||||
-cppcoreguidelines-special-member-functions,
|
||||
-cppcoreguidelines-explicit-virtual-functions,
|
||||
-cppcoreguidelines-avoid-c-arrays,
|
||||
-cppcoreguidelines-pro-bounds-pointer-arithmetic,
|
||||
-cppcoreguidelines-narrowing-conversions,
|
||||
-cppcoreguidelines-pro-type-union-access,
|
||||
-cppcoreguidelines-pro-type-member-init,
|
||||
-cppcoreguidelines-macro-usage,
|
||||
-cppcoreguidelines-macro-to-enum,
|
||||
-cppcoreguidelines-init-variables,
|
||||
-cppcoreguidelines-pro-type-cstyle-cast,
|
||||
-cppcoreguidelines-pro-type-vararg,
|
||||
-cppcoreguidelines-pro-type-reinterpret-cast,
|
||||
google-global-names-in-headers,
|
||||
-google-readability-casting,
|
||||
google-runtime-operator,
|
||||
misc-*,
|
||||
-misc-unused-parameters,
|
||||
-misc-no-recursion,
|
||||
-misc-non-private-member-variables-in-classes,
|
||||
-misc-include-cleaner,
|
||||
-misc-use-anonymous-namespace,
|
||||
-misc-const-correctness,
|
||||
modernize-*,
|
||||
-modernize-return-braced-init-list,
|
||||
-modernize-use-trailing-return-type,
|
||||
-modernize-use-using,
|
||||
-modernize-use-override,
|
||||
-modernize-avoid-c-arrays,
|
||||
-modernize-macro-to-enum,
|
||||
-modernize-loop-convert,
|
||||
-modernize-use-nodiscard,
|
||||
-modernize-pass-by-value,
|
||||
-modernize-use-auto,
|
||||
performance-*,
|
||||
-performance-avoid-endl,
|
||||
-performance-unnecessary-value-param,
|
||||
portability-std-allocator-const,
|
||||
readability-*,
|
||||
-readability-function-cognitive-complexity,
|
||||
-readability-function-size,
|
||||
-readability-identifier-length,
|
||||
-readability-magic-numbers,
|
||||
-readability-uppercase-literal-suffix,
|
||||
-readability-braces-around-statements,
|
||||
-readability-redundant-access-specifiers,
|
||||
-readability-else-after-return,
|
||||
-readability-container-data-pointer,
|
||||
-readability-implicit-bool-conversion,
|
||||
-readability-avoid-nested-conditional-operator,
|
||||
-readability-redundant-member-init,
|
||||
-readability-redundant-string-init,
|
||||
-readability-avoid-const-params-in-decls,
|
||||
-readability-named-parameter,
|
||||
-readability-convert-member-functions-to-static,
|
||||
-readability-qualified-auto,
|
||||
-readability-make-member-function-const,
|
||||
-readability-isolate-declaration,
|
||||
-readability-inconsistent-declaration-parameter-name,
|
||||
-clang-diagnostic-error,
|
||||
|
||||
CheckOptions:
|
||||
performance-for-range-copy.WarnOnAllAutoCopies: true
|
||||
performance-inefficient-string-concatenation.StrictMode: true
|
||||
readability-braces-around-statements.ShortStatementLines: 0
|
||||
readability-identifier-naming.ClassCase: CamelCase
|
||||
readability-identifier-naming.ClassIgnoredRegexp: I.*
|
||||
readability-identifier-naming.ClassPrefix: C # We can't use regex here?!?!?!?
|
||||
readability-identifier-naming.EnumCase: CamelCase
|
||||
readability-identifier-naming.EnumPrefix: e
|
||||
readability-identifier-naming.EnumConstantCase: UPPER_CASE
|
||||
readability-identifier-naming.FunctionCase: camelBack
|
||||
readability-identifier-naming.NamespaceCase: CamelCase
|
||||
readability-identifier-naming.NamespacePrefix: N
|
||||
readability-identifier-naming.StructPrefix: S
|
||||
readability-identifier-naming.StructCase: CamelCase
|
|
@ -20,6 +20,16 @@ set(LIBDIR ${CMAKE_INSTALL_FULL_LIBDIR})
|
|||
configure_file(hyprcursor.pc.in hyprcursor.pc @ONLY)
|
||||
|
||||
set(CMAKE_CXX_STANDARD 23)
|
||||
add_compile_options(
|
||||
-Wall
|
||||
-Wextra
|
||||
-Wpedantic
|
||||
-Wno-unused-parameter
|
||||
-Wno-unused-value
|
||||
-Wno-missing-field-initializers
|
||||
-Wno-narrowing
|
||||
-Wno-pointer-arith)
|
||||
set(CMAKE_EXPORT_COMPILE_COMMANDS TRUE)
|
||||
|
||||
find_package(PkgConfig REQUIRED)
|
||||
pkg_check_modules(
|
||||
|
|
|
@ -16,12 +16,12 @@
|
|||
#define ZIP_LENGTH_TO_END -1
|
||||
#endif
|
||||
|
||||
enum eOperation {
|
||||
enum eOperation : uint8_t {
|
||||
OPERATION_CREATE = 0,
|
||||
OPERATION_EXTRACT = 1,
|
||||
};
|
||||
|
||||
eHyprcursorResizeAlgo explicitResizeAlgo = HC_RESIZE_INVALID;
|
||||
static eHyprcursorResizeAlgo explicitResizeAlgo = HC_RESIZE_INVALID;
|
||||
|
||||
struct XCursorConfigEntry {
|
||||
int size = 0, hotspotX = 0, hotspotY = 0, delay = 0;
|
||||
|
@ -119,7 +119,7 @@ static std::optional<std::string> createCursorThemeFromPath(const std::string& p
|
|||
return "couldn't parse meta: " + *PARSERESULT2;
|
||||
|
||||
for (auto& i : meta.parsedData.definedSizes) {
|
||||
SHAPE->images.push_back(SCursorImage{i.file, i.size, i.delayMs});
|
||||
SHAPE->images.push_back(SCursorImage{.filename = i.file, .size = i.size, .delay = i.delayMs});
|
||||
}
|
||||
|
||||
SHAPE->overrides = meta.parsedData.overrides;
|
||||
|
@ -388,7 +388,7 @@ int main(int argc, char** argv, char** envp) {
|
|||
eOperation op = OPERATION_CREATE;
|
||||
std::string path = "", out = "";
|
||||
|
||||
for (size_t i = 1; i < argc; ++i) {
|
||||
for (int i = 1; i < argc; ++i) {
|
||||
std::string arg = argv[i];
|
||||
|
||||
if (arg == "-v" || arg == "--version") {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
#include <vector>
|
||||
#include <stdlib.h>
|
||||
#include <cstdlib>
|
||||
#include <string>
|
||||
|
||||
#include "shared.h"
|
||||
|
@ -114,7 +114,7 @@ namespace Hyprcursor {
|
|||
|
||||
SCursorShapeData data;
|
||||
|
||||
for (size_t i = 0; i < size; ++i) {
|
||||
for (int i = 0; i < size; ++i) {
|
||||
SCursorImageData image;
|
||||
image.delay = images[i]->delay;
|
||||
image.size = images[i]->size;
|
||||
|
|
|
@ -38,7 +38,7 @@ CVarList::CVarList(const std::string& in, const size_t lastArgNo, const char del
|
|||
break;
|
||||
}
|
||||
pos += s.size() + 1;
|
||||
m_vArgs.emplace_back(removeBeginEndSpacesTabs(std::string_view{s}.data()));
|
||||
m_vArgs.emplace_back(removeBeginEndSpacesTabs(s.data()));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
#include "internalSharedTypes.hpp"
|
||||
#include "internalDefines.hpp"
|
||||
#include <array>
|
||||
#include <cstddef>
|
||||
#include <sstream>
|
||||
#include <cstdio>
|
||||
#include <filesystem>
|
||||
|
@ -96,7 +97,7 @@ static std::string getFirstTheme(PHYPRCURSORLOGFUNC logfn) {
|
|||
}
|
||||
|
||||
for (auto& dir : systemThemeDirs) {
|
||||
const auto FULLPATH = dir;
|
||||
const auto& FULLPATH = dir;
|
||||
if (!pathAccessible(FULLPATH)) {
|
||||
Debug::log(HC_LOG_TRACE, logfn, "Skipping path {} because it's inaccessible.", FULLPATH);
|
||||
continue;
|
||||
|
@ -175,7 +176,7 @@ static std::string getFullPathForThemeName(const std::string& name, PHYPRCURSORL
|
|||
}
|
||||
|
||||
for (auto& dir : systemThemeDirs) {
|
||||
const auto FULLPATH = dir;
|
||||
const auto& FULLPATH = dir;
|
||||
if (!pathAccessible(FULLPATH)) {
|
||||
Debug::log(HC_LOG_TRACE, logfn, "Skipping path {} because it's inaccessible.", FULLPATH);
|
||||
continue;
|
||||
|
@ -217,23 +218,19 @@ static std::string getFullPathForThemeName(const std::string& name, PHYPRCURSORL
|
|||
return "";
|
||||
}
|
||||
|
||||
SManagerOptions::SManagerOptions() {
|
||||
logFn = nullptr;
|
||||
allowDefaultFallback = true;
|
||||
SManagerOptions::SManagerOptions() : logFn(nullptr), allowDefaultFallback(true) {
|
||||
;
|
||||
}
|
||||
|
||||
CHyprcursorManager::CHyprcursorManager(const char* themeName_) {
|
||||
init(themeName_);
|
||||
}
|
||||
|
||||
CHyprcursorManager::CHyprcursorManager(const char* themeName_, PHYPRCURSORLOGFUNC fn) {
|
||||
logFn = fn;
|
||||
CHyprcursorManager::CHyprcursorManager(const char* themeName_, PHYPRCURSORLOGFUNC fn) : logFn(fn) {
|
||||
init(themeName_);
|
||||
}
|
||||
|
||||
CHyprcursorManager::CHyprcursorManager(const char* themeName_, SManagerOptions options) {
|
||||
logFn = options.logFn;
|
||||
allowDefaultFallback = options.allowDefaultFallback;
|
||||
CHyprcursorManager::CHyprcursorManager(const char* themeName_, SManagerOptions options) : allowDefaultFallback(options.allowDefaultFallback), logFn(options.logFn) {
|
||||
init(themeName_);
|
||||
}
|
||||
|
||||
|
@ -284,8 +281,7 @@ void CHyprcursorManager::init(const char* themeName_) {
|
|||
}
|
||||
|
||||
CHyprcursorManager::~CHyprcursorManager() {
|
||||
if (impl)
|
||||
delete impl;
|
||||
delete impl;
|
||||
}
|
||||
|
||||
bool CHyprcursorManager::valid() {
|
||||
|
@ -508,7 +504,7 @@ bool CHyprcursorManager::loadThemeStyle(const SCursorStyleInfo& info) {
|
|||
auto& newImage = impl->loadedShapes[shape.get()].images.emplace_back(std::make_unique<SLoadedCursorImage>());
|
||||
newImage->artificial = true;
|
||||
newImage->side = PIXELSIDE;
|
||||
newImage->artificialData = new char[PIXELSIDE * PIXELSIDE * 4];
|
||||
newImage->artificialData = new char[static_cast<unsigned long>(PIXELSIDE * PIXELSIDE * 4)];
|
||||
newImage->cairoSurface = cairo_image_surface_create_for_data((unsigned char*)newImage->artificialData, CAIRO_FORMAT_ARGB32, PIXELSIDE, PIXELSIDE, PIXELSIDE * 4);
|
||||
newImage->delay = f->delay;
|
||||
|
||||
|
@ -549,7 +545,7 @@ bool CHyprcursorManager::loadThemeStyle(const SCursorStyleInfo& info) {
|
|||
auto& newImage = impl->loadedShapes[shape.get()].images.emplace_back(std::make_unique<SLoadedCursorImage>());
|
||||
newImage->artificial = true;
|
||||
newImage->side = PIXELSIDE;
|
||||
newImage->artificialData = new char[PIXELSIDE * PIXELSIDE * 4];
|
||||
newImage->artificialData = new char[static_cast<unsigned long>(PIXELSIDE * PIXELSIDE * 4)];
|
||||
newImage->cairoSurface = cairo_image_surface_create_for_data((unsigned char*)newImage->artificialData, CAIRO_FORMAT_ARGB32, PIXELSIDE, PIXELSIDE, PIXELSIDE * 4);
|
||||
newImage->delay = f->delay;
|
||||
|
||||
|
@ -689,9 +685,9 @@ std::optional<std::string> CHyprcursorImplementation::loadTheme() {
|
|||
|
||||
zip_file_t* meta_file = zip_fopen_index(zip, index, ZIP_FL_UNCHANGED);
|
||||
|
||||
char* buffer = new char[1024 * 1024]; /* 1MB should be more than enough */
|
||||
char* buffer = new char[static_cast<unsigned long>(1024 * 1024)]; /* 1MB should be more than enough */
|
||||
|
||||
int readBytes = zip_fread(meta_file, buffer, 1024 * 1024 - 1);
|
||||
int readBytes = zip_fread(meta_file, buffer, (1024 * 1024) - 1);
|
||||
|
||||
zip_fclose(meta_file);
|
||||
|
||||
|
@ -711,7 +707,7 @@ std::optional<std::string> CHyprcursorImplementation::loadTheme() {
|
|||
return "cursor" + cursor.path().string() + "failed to parse meta: " + *METAPARSERESULT;
|
||||
|
||||
for (auto& i : meta.parsedData.definedSizes) {
|
||||
SHAPE->images.push_back(SCursorImage{i.file, i.size, i.delayMs});
|
||||
SHAPE->images.push_back(SCursorImage{.filename = i.file, .size = i.size, .delay = i.delayMs});
|
||||
}
|
||||
|
||||
SHAPE->overrides = meta.parsedData.overrides;
|
||||
|
@ -755,8 +751,8 @@ std::optional<std::string> CHyprcursorImplementation::loadTheme() {
|
|||
IMAGE->data = new char[sb.size + 1];
|
||||
IMAGE->dataLen = sb.size + 1;
|
||||
} else {
|
||||
IMAGE->data = new char[1024 * 1024]; /* 1MB should be more than enough, again. This probably should be in the spec. */
|
||||
IMAGE->dataLen = 1024 * 1024;
|
||||
IMAGE->data = new char[static_cast<unsigned long>(1024 * 1024)]; /* 1MB should be more than enough, again. This probably should be in the spec. */
|
||||
IMAGE->dataLen = static_cast<size_t>(1024 * 1024);
|
||||
}
|
||||
|
||||
IMAGE->dataLen = zip_fread(image_file, IMAGE->data, IMAGE->dataLen - 1);
|
||||
|
|
|
@ -38,7 +38,7 @@ struct SCursorImageData** hyprcursor_get_cursor_image_data(struct hyprcursor_man
|
|||
}
|
||||
|
||||
void hyprcursor_cursor_image_data_free(hyprcursor_cursor_image_data** data, int size) {
|
||||
for (size_t i = 0; i < size; ++i) {
|
||||
for (int i = 0; i < size; ++i) {
|
||||
free(data[i]);
|
||||
}
|
||||
|
||||
|
@ -49,7 +49,7 @@ void hyprcursor_style_done(hyprcursor_manager_t* manager, hyprcursor_cursor_styl
|
|||
const auto MGR = (CHyprcursorManager*)manager;
|
||||
SCursorStyleInfo info;
|
||||
info.size = info_.size;
|
||||
return MGR->cursorSurfaceStyleDone(info);
|
||||
MGR->cursorSurfaceStyleDone(info);
|
||||
}
|
||||
|
||||
void hyprcursor_register_logging_function(struct hyprcursor_manager_t* manager, PHYPRCURSORLOGFUNC fn) {
|
||||
|
|
|
@ -8,9 +8,9 @@
|
|||
|
||||
#include "VarList.hpp"
|
||||
|
||||
CMeta* currentMeta = nullptr;
|
||||
static CMeta* currentMeta = nullptr;
|
||||
|
||||
CMeta::CMeta(const std::string& rawdata_, bool hyprlang_ /* false for toml */, bool dataIsPath) : rawdata(rawdata_), hyprlang(hyprlang_), dataPath(dataIsPath) {
|
||||
CMeta::CMeta(const std::string& rawdata_, bool hyprlang_ /* false for toml */, bool dataIsPath) : dataPath(dataIsPath), hyprlang(hyprlang_), rawdata(rawdata_) {
|
||||
if (!dataIsPath)
|
||||
return;
|
||||
|
||||
|
@ -87,8 +87,8 @@ static Hyprlang::CParseResult parseDefineSize(const char* C, const char* V) {
|
|||
CMeta::SDefinedSize size;
|
||||
|
||||
if (RHS.contains(",")) {
|
||||
const auto LL = removeBeginEndSpacesTabs(RHS.substr(0, RHS.find(",")));
|
||||
const auto RR = removeBeginEndSpacesTabs(RHS.substr(RHS.find(",") + 1));
|
||||
const auto LL = removeBeginEndSpacesTabs(RHS.substr(0, RHS.find(',')));
|
||||
const auto RR = removeBeginEndSpacesTabs(RHS.substr(RHS.find(',') + 1));
|
||||
|
||||
try {
|
||||
size.delayMs = std::stoull(RR);
|
||||
|
|
Loading…
Reference in a new issue