core: Add clang-tidy (#8664)
This adds a .clang-tidy file for us. It's not a strict requirement to be compliant, but I tuned it to be alright.
This commit is contained in:
parent
b1e5cc66bd
commit
8bbeee1173
118 changed files with 720 additions and 679 deletions
|
|
@ -2,11 +2,11 @@
|
|||
#include "../managers/AnimationManager.hpp"
|
||||
#include "../config/ConfigManager.hpp"
|
||||
|
||||
CBaseAnimatedVariable::CBaseAnimatedVariable(ANIMATEDVARTYPE type) : m_Type(type) {
|
||||
CBaseAnimatedVariable::CBaseAnimatedVariable(eAnimatedVarType type) : m_Type(type) {
|
||||
; // dummy var
|
||||
}
|
||||
|
||||
void CBaseAnimatedVariable::create(SAnimationPropertyConfig* pAnimConfig, PHLWINDOW pWindow, AVARDAMAGEPOLICY policy) {
|
||||
void CBaseAnimatedVariable::create(SAnimationPropertyConfig* pAnimConfig, PHLWINDOW pWindow, eAVarDamagePolicy policy) {
|
||||
m_eDamagePolicy = policy;
|
||||
m_pConfig = pAnimConfig;
|
||||
m_pWindow = pWindow;
|
||||
|
|
@ -14,7 +14,7 @@ void CBaseAnimatedVariable::create(SAnimationPropertyConfig* pAnimConfig, PHLWIN
|
|||
m_bDummy = false;
|
||||
}
|
||||
|
||||
void CBaseAnimatedVariable::create(SAnimationPropertyConfig* pAnimConfig, PHLLS pLayer, AVARDAMAGEPOLICY policy) {
|
||||
void CBaseAnimatedVariable::create(SAnimationPropertyConfig* pAnimConfig, PHLLS pLayer, eAVarDamagePolicy policy) {
|
||||
m_eDamagePolicy = policy;
|
||||
m_pConfig = pAnimConfig;
|
||||
m_pLayer = pLayer;
|
||||
|
|
@ -22,7 +22,7 @@ void CBaseAnimatedVariable::create(SAnimationPropertyConfig* pAnimConfig, PHLLS
|
|||
m_bDummy = false;
|
||||
}
|
||||
|
||||
void CBaseAnimatedVariable::create(SAnimationPropertyConfig* pAnimConfig, PHLWORKSPACE pWorkspace, AVARDAMAGEPOLICY policy) {
|
||||
void CBaseAnimatedVariable::create(SAnimationPropertyConfig* pAnimConfig, PHLWORKSPACE pWorkspace, eAVarDamagePolicy policy) {
|
||||
m_eDamagePolicy = policy;
|
||||
m_pConfig = pAnimConfig;
|
||||
m_pWorkspace = pWorkspace;
|
||||
|
|
@ -30,7 +30,7 @@ void CBaseAnimatedVariable::create(SAnimationPropertyConfig* pAnimConfig, PHLWOR
|
|||
m_bDummy = false;
|
||||
}
|
||||
|
||||
void CBaseAnimatedVariable::create(SAnimationPropertyConfig* pAnimConfig, AVARDAMAGEPOLICY policy) {
|
||||
void CBaseAnimatedVariable::create(SAnimationPropertyConfig* pAnimConfig, eAVarDamagePolicy policy) {
|
||||
m_eDamagePolicy = policy;
|
||||
m_pConfig = pAnimConfig;
|
||||
|
||||
|
|
|
|||
|
|
@ -10,38 +10,39 @@
|
|||
#include "../debug/Log.hpp"
|
||||
#include "../desktop/DesktopTypes.hpp"
|
||||
|
||||
enum ANIMATEDVARTYPE {
|
||||
enum eAnimatedVarType : int8_t {
|
||||
AVARTYPE_INVALID = -1,
|
||||
AVARTYPE_FLOAT,
|
||||
AVARTYPE_VECTOR,
|
||||
AVARTYPE_COLOR
|
||||
};
|
||||
|
||||
// Utility to bind a type with its corresponding ANIMATEDVARTYPE
|
||||
// Utility to bind a type with its corresponding eAnimatedVarType
|
||||
template <class T>
|
||||
struct typeToANIMATEDVARTYPE_t {
|
||||
static constexpr ANIMATEDVARTYPE value = AVARTYPE_INVALID;
|
||||
// NOLINTNEXTLINE(readability-identifier-naming)
|
||||
struct STypeToAnimatedVarType_t {
|
||||
static constexpr eAnimatedVarType value = AVARTYPE_INVALID;
|
||||
};
|
||||
|
||||
template <>
|
||||
struct typeToANIMATEDVARTYPE_t<float> {
|
||||
static constexpr ANIMATEDVARTYPE value = AVARTYPE_FLOAT;
|
||||
struct STypeToAnimatedVarType_t<float> {
|
||||
static constexpr eAnimatedVarType value = AVARTYPE_FLOAT;
|
||||
};
|
||||
|
||||
template <>
|
||||
struct typeToANIMATEDVARTYPE_t<Vector2D> {
|
||||
static constexpr ANIMATEDVARTYPE value = AVARTYPE_VECTOR;
|
||||
struct STypeToAnimatedVarType_t<Vector2D> {
|
||||
static constexpr eAnimatedVarType value = AVARTYPE_VECTOR;
|
||||
};
|
||||
|
||||
template <>
|
||||
struct typeToANIMATEDVARTYPE_t<CHyprColor> {
|
||||
static constexpr ANIMATEDVARTYPE value = AVARTYPE_COLOR;
|
||||
struct STypeToAnimatedVarType_t<CHyprColor> {
|
||||
static constexpr eAnimatedVarType value = AVARTYPE_COLOR;
|
||||
};
|
||||
|
||||
template <class T>
|
||||
inline constexpr ANIMATEDVARTYPE typeToANIMATEDVARTYPE = typeToANIMATEDVARTYPE_t<T>::value;
|
||||
inline constexpr eAnimatedVarType typeToeAnimatedVarType = STypeToAnimatedVarType_t<T>::value;
|
||||
|
||||
enum AVARDAMAGEPOLICY {
|
||||
enum eAVarDamagePolicy : int8_t {
|
||||
AVARDAMAGE_NONE = -1,
|
||||
AVARDAMAGE_ENTIRE = 0,
|
||||
AVARDAMAGE_BORDER,
|
||||
|
|
@ -67,11 +68,11 @@ concept Animable = OneOf<T, Vector2D, float, CHyprColor>;
|
|||
|
||||
class CBaseAnimatedVariable {
|
||||
public:
|
||||
CBaseAnimatedVariable(ANIMATEDVARTYPE type);
|
||||
void create(SAnimationPropertyConfig* pAnimConfig, PHLWINDOW pWindow, AVARDAMAGEPOLICY policy);
|
||||
void create(SAnimationPropertyConfig* pAnimConfig, PHLLS pLayer, AVARDAMAGEPOLICY policy);
|
||||
void create(SAnimationPropertyConfig* pAnimConfig, PHLWORKSPACE pWorkspace, AVARDAMAGEPOLICY policy);
|
||||
void create(SAnimationPropertyConfig* pAnimConfig, AVARDAMAGEPOLICY policy);
|
||||
CBaseAnimatedVariable(eAnimatedVarType type);
|
||||
void create(SAnimationPropertyConfig* pAnimConfig, PHLWINDOW pWindow, eAVarDamagePolicy policy);
|
||||
void create(SAnimationPropertyConfig* pAnimConfig, PHLLS pLayer, eAVarDamagePolicy policy);
|
||||
void create(SAnimationPropertyConfig* pAnimConfig, PHLWORKSPACE pWorkspace, eAVarDamagePolicy policy);
|
||||
void create(SAnimationPropertyConfig* pAnimConfig, eAVarDamagePolicy policy);
|
||||
|
||||
CBaseAnimatedVariable(const CBaseAnimatedVariable&) = delete;
|
||||
CBaseAnimatedVariable(CBaseAnimatedVariable&&) = delete;
|
||||
|
|
@ -103,7 +104,7 @@ class CBaseAnimatedVariable {
|
|||
float getCurveValue();
|
||||
|
||||
// checks if an animation is in progress
|
||||
inline bool isBeingAnimated() {
|
||||
bool isBeingAnimated() const {
|
||||
return m_bIsBeingAnimated;
|
||||
}
|
||||
|
||||
|
|
@ -111,7 +112,7 @@ class CBaseAnimatedVariable {
|
|||
if an animation is not running, runs instantly.
|
||||
if "remove" is set to true, will remove the callback when ran. */
|
||||
void setCallbackOnEnd(std::function<void(void* thisptr)> func, bool remove = true) {
|
||||
m_fEndCallback = func;
|
||||
m_fEndCallback = std::move(func);
|
||||
m_bRemoveEndAfterRan = remove;
|
||||
|
||||
if (!isBeingAnimated())
|
||||
|
|
@ -121,14 +122,14 @@ class CBaseAnimatedVariable {
|
|||
/* sets a function to be ran when an animation is started.
|
||||
if "remove" is set to true, will remove the callback when ran. */
|
||||
void setCallbackOnBegin(std::function<void(void* thisptr)> func, bool remove = true) {
|
||||
m_fBeginCallback = func;
|
||||
m_fBeginCallback = std::move(func);
|
||||
m_bRemoveBeginAfterRan = remove;
|
||||
}
|
||||
|
||||
/* Sets the update callback, called every time the value is animated and a step is done
|
||||
Warning: calling unregisterVar/registerVar in this handler will cause UB */
|
||||
void setUpdateCallback(std::function<void(void* thisptr)> func) {
|
||||
m_fUpdateCallback = func;
|
||||
m_fUpdateCallback = std::move(func);
|
||||
}
|
||||
|
||||
/* resets all callbacks. Does not call any. */
|
||||
|
|
@ -157,8 +158,8 @@ class CBaseAnimatedVariable {
|
|||
|
||||
std::chrono::steady_clock::time_point animationBegin;
|
||||
|
||||
AVARDAMAGEPOLICY m_eDamagePolicy = AVARDAMAGE_NONE;
|
||||
ANIMATEDVARTYPE m_Type;
|
||||
eAVarDamagePolicy m_eDamagePolicy = AVARDAMAGE_NONE;
|
||||
eAnimatedVarType m_Type;
|
||||
|
||||
bool m_bRemoveEndAfterRan = true;
|
||||
bool m_bRemoveBeginAfterRan = true;
|
||||
|
|
@ -206,24 +207,26 @@ class CBaseAnimatedVariable {
|
|||
template <Animable VarType>
|
||||
class CAnimatedVariable : public CBaseAnimatedVariable {
|
||||
public:
|
||||
CAnimatedVariable() : CBaseAnimatedVariable(typeToANIMATEDVARTYPE<VarType>) {} // dummy var
|
||||
CAnimatedVariable() : CBaseAnimatedVariable(typeToeAnimatedVarType<VarType>) {
|
||||
;
|
||||
} // dummy var
|
||||
|
||||
void create(const VarType& value, SAnimationPropertyConfig* pAnimConfig, PHLWINDOW pWindow, AVARDAMAGEPOLICY policy) {
|
||||
void create(const VarType& value, SAnimationPropertyConfig* pAnimConfig, PHLWINDOW pWindow, eAVarDamagePolicy policy) {
|
||||
create(pAnimConfig, pWindow, policy);
|
||||
m_Value = value;
|
||||
m_Goal = value;
|
||||
}
|
||||
void create(const VarType& value, SAnimationPropertyConfig* pAnimConfig, PHLLS pLayer, AVARDAMAGEPOLICY policy) {
|
||||
void create(const VarType& value, SAnimationPropertyConfig* pAnimConfig, PHLLS pLayer, eAVarDamagePolicy policy) {
|
||||
create(pAnimConfig, pLayer, policy);
|
||||
m_Value = value;
|
||||
m_Goal = value;
|
||||
}
|
||||
void create(const VarType& value, SAnimationPropertyConfig* pAnimConfig, PHLWORKSPACE pWorkspace, AVARDAMAGEPOLICY policy) {
|
||||
void create(const VarType& value, SAnimationPropertyConfig* pAnimConfig, PHLWORKSPACE pWorkspace, eAVarDamagePolicy policy) {
|
||||
create(pAnimConfig, pWorkspace, policy);
|
||||
m_Value = value;
|
||||
m_Goal = value;
|
||||
}
|
||||
void create(const VarType& value, SAnimationPropertyConfig* pAnimConfig, AVARDAMAGEPOLICY policy) {
|
||||
void create(const VarType& value, SAnimationPropertyConfig* pAnimConfig, eAVarDamagePolicy policy) {
|
||||
create(pAnimConfig, policy);
|
||||
m_Value = value;
|
||||
m_Goal = value;
|
||||
|
|
|
|||
|
|
@ -30,25 +30,27 @@ constexpr LD operator""_TB(const LD BYTES) {
|
|||
return BYTES * 1024 * 1024 * 1024 * 1024;
|
||||
}
|
||||
|
||||
//NOLINTBEGIN
|
||||
template <typename T>
|
||||
using __acceptable_byte_operation_type = typename std::enable_if<std::is_trivially_constructible<T, ULL>::value || std::is_trivially_constructible<T, LD>::value>::type;
|
||||
using internal_hl_acceptable_byte_operation_type = typename std::enable_if<std::is_trivially_constructible<T, ULL>::value || std::is_trivially_constructible<T, LD>::value>::type;
|
||||
|
||||
template <typename X, typename = __acceptable_byte_operation_type<X>>
|
||||
template <typename X, typename = internal_hl_acceptable_byte_operation_type<X>>
|
||||
constexpr X kBtoBytes(const X kB) {
|
||||
return kB * 1024;
|
||||
}
|
||||
template <typename X, typename = __acceptable_byte_operation_type<X>>
|
||||
template <typename X, typename = internal_hl_acceptable_byte_operation_type<X>>
|
||||
constexpr X MBtoBytes(const X MB) {
|
||||
return MB * 1024 * 1024;
|
||||
}
|
||||
template <typename X, typename = __acceptable_byte_operation_type<X>>
|
||||
template <typename X, typename = internal_hl_acceptable_byte_operation_type<X>>
|
||||
constexpr X GBtoBytes(const X GB) {
|
||||
return GB * 1024 * 1024 * 1024;
|
||||
}
|
||||
template <typename X, typename = __acceptable_byte_operation_type<X>>
|
||||
template <typename X, typename = internal_hl_acceptable_byte_operation_type<X>>
|
||||
constexpr X TBtoBytes(const X TB) {
|
||||
return TB * 1024 * 1024 * 1024 * 1024;
|
||||
}
|
||||
//NOLINTEND
|
||||
|
||||
#undef ULL
|
||||
#undef LD
|
||||
|
|
@ -5,32 +5,21 @@
|
|||
#define GREEN(c) ((double)(((c) >> 8) & 0xff) / 255.0)
|
||||
#define BLUE(c) ((double)(((c)) & 0xff) / 255.0)
|
||||
|
||||
CHyprColor::CHyprColor() {}
|
||||
|
||||
CHyprColor::CHyprColor(float r_, float g_, float b_, float a_) {
|
||||
r = r_;
|
||||
g = g_;
|
||||
b = b_;
|
||||
a = a_;
|
||||
CHyprColor::CHyprColor() = default;
|
||||
|
||||
CHyprColor::CHyprColor(float r_, float g_, float b_, float a_) : r(r_), g(g_), b(b_), a(a_) {
|
||||
okLab = Hyprgraphics::CColor(Hyprgraphics::CColor::SSRGB{r, g, b}).asOkLab();
|
||||
}
|
||||
|
||||
CHyprColor::CHyprColor(uint64_t hex) {
|
||||
r = RED(hex);
|
||||
g = GREEN(hex);
|
||||
b = BLUE(hex);
|
||||
a = ALPHA(hex);
|
||||
|
||||
CHyprColor::CHyprColor(uint64_t hex) : r(RED(hex)), g(GREEN(hex)), b(BLUE(hex)), a(ALPHA(hex)) {
|
||||
okLab = Hyprgraphics::CColor(Hyprgraphics::CColor::SSRGB{r, g, b}).asOkLab();
|
||||
}
|
||||
|
||||
CHyprColor::CHyprColor(const Hyprgraphics::CColor& color, float a_) {
|
||||
CHyprColor::CHyprColor(const Hyprgraphics::CColor& color, float a_) : a(a_) {
|
||||
const auto SRGB = color.asRgb();
|
||||
r = SRGB.r;
|
||||
g = SRGB.g;
|
||||
b = SRGB.b;
|
||||
a = a_;
|
||||
|
||||
okLab = color.asOkLab();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -231,7 +231,7 @@ inline const std::vector<SPixelFormat> GLES3_FORMATS = {
|
|||
},
|
||||
};
|
||||
|
||||
SHMFormat FormatUtils::drmToShm(DRMFormat drm) {
|
||||
SHMFormat NFormatUtils::drmToShm(DRMFormat drm) {
|
||||
switch (drm) {
|
||||
case DRM_FORMAT_XRGB8888: return WL_SHM_FORMAT_XRGB8888;
|
||||
case DRM_FORMAT_ARGB8888: return WL_SHM_FORMAT_ARGB8888;
|
||||
|
|
@ -241,7 +241,7 @@ SHMFormat FormatUtils::drmToShm(DRMFormat drm) {
|
|||
return drm;
|
||||
}
|
||||
|
||||
DRMFormat FormatUtils::shmToDRM(SHMFormat shm) {
|
||||
DRMFormat NFormatUtils::shmToDRM(SHMFormat shm) {
|
||||
switch (shm) {
|
||||
case WL_SHM_FORMAT_XRGB8888: return DRM_FORMAT_XRGB8888;
|
||||
case WL_SHM_FORMAT_ARGB8888: return DRM_FORMAT_ARGB8888;
|
||||
|
|
@ -251,7 +251,7 @@ DRMFormat FormatUtils::shmToDRM(SHMFormat shm) {
|
|||
return shm;
|
||||
}
|
||||
|
||||
const SPixelFormat* FormatUtils::getPixelFormatFromDRM(DRMFormat drm) {
|
||||
const SPixelFormat* NFormatUtils::getPixelFormatFromDRM(DRMFormat drm) {
|
||||
for (auto const& fmt : GLES3_FORMATS) {
|
||||
if (fmt.drmFormat == drm)
|
||||
return &fmt;
|
||||
|
|
@ -260,7 +260,7 @@ const SPixelFormat* FormatUtils::getPixelFormatFromDRM(DRMFormat drm) {
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
const SPixelFormat* FormatUtils::getPixelFormatFromGL(uint32_t glFormat, uint32_t glType, bool alpha) {
|
||||
const SPixelFormat* NFormatUtils::getPixelFormatFromGL(uint32_t glFormat, uint32_t glType, bool alpha) {
|
||||
for (auto const& fmt : GLES3_FORMATS) {
|
||||
if (fmt.glFormat == (int)glFormat && fmt.glType == (int)glType && fmt.withAlpha == alpha)
|
||||
return &fmt;
|
||||
|
|
@ -269,23 +269,23 @@ const SPixelFormat* FormatUtils::getPixelFormatFromGL(uint32_t glFormat, uint32_
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
bool FormatUtils::isFormatOpaque(DRMFormat drm) {
|
||||
const auto FMT = FormatUtils::getPixelFormatFromDRM(drm);
|
||||
bool NFormatUtils::isFormatOpaque(DRMFormat drm) {
|
||||
const auto FMT = NFormatUtils::getPixelFormatFromDRM(drm);
|
||||
if (!FMT)
|
||||
return false;
|
||||
|
||||
return !FMT->withAlpha;
|
||||
}
|
||||
|
||||
int FormatUtils::pixelsPerBlock(const SPixelFormat* const fmt) {
|
||||
int NFormatUtils::pixelsPerBlock(const SPixelFormat* const fmt) {
|
||||
return fmt->blockSize.x * fmt->blockSize.y > 0 ? fmt->blockSize.x * fmt->blockSize.y : 1;
|
||||
}
|
||||
|
||||
int FormatUtils::minStride(const SPixelFormat* const fmt, int32_t width) {
|
||||
int NFormatUtils::minStride(const SPixelFormat* const fmt, int32_t width) {
|
||||
return std::ceil((width * fmt->bytesPerBlock) / pixelsPerBlock(fmt));
|
||||
}
|
||||
|
||||
uint32_t FormatUtils::drmFormatToGL(DRMFormat drm) {
|
||||
uint32_t NFormatUtils::drmFormatToGL(DRMFormat drm) {
|
||||
switch (drm) {
|
||||
case DRM_FORMAT_XRGB8888:
|
||||
case DRM_FORMAT_XBGR8888: return GL_RGBA; // doesn't matter, opengl is gucci in this case.
|
||||
|
|
@ -302,7 +302,7 @@ uint32_t FormatUtils::drmFormatToGL(DRMFormat drm) {
|
|||
return GL_RGBA;
|
||||
}
|
||||
|
||||
uint32_t FormatUtils::glFormatToType(uint32_t gl) {
|
||||
uint32_t NFormatUtils::glFormatToType(uint32_t gl) {
|
||||
return gl != GL_RGBA ?
|
||||
#ifdef GLES2
|
||||
GL_UNSIGNED_INT_2_10_10_10_REV_EXT :
|
||||
|
|
@ -312,14 +312,14 @@ uint32_t FormatUtils::glFormatToType(uint32_t gl) {
|
|||
GL_UNSIGNED_BYTE;
|
||||
}
|
||||
|
||||
std::string FormatUtils::drmFormatName(DRMFormat drm) {
|
||||
std::string NFormatUtils::drmFormatName(DRMFormat drm) {
|
||||
auto n = drmGetFormatName(drm);
|
||||
std::string name = n;
|
||||
free(n);
|
||||
return name;
|
||||
}
|
||||
|
||||
std::string FormatUtils::drmModifierName(uint64_t mod) {
|
||||
std::string NFormatUtils::drmModifierName(uint64_t mod) {
|
||||
auto n = drmGetFormatModifierName(mod);
|
||||
std::string name = n;
|
||||
free(n);
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ struct SPixelFormat {
|
|||
|
||||
typedef Aquamarine::SDRMFormat SDRMFormat;
|
||||
|
||||
namespace FormatUtils {
|
||||
namespace NFormatUtils {
|
||||
SHMFormat drmToShm(DRMFormat drm);
|
||||
DRMFormat shmToDRM(SHMFormat shm);
|
||||
|
||||
|
|
|
|||
|
|
@ -953,10 +953,7 @@ bool executableExistsInPath(const std::string& exe) {
|
|||
|
||||
auto perms = stat.permissions();
|
||||
|
||||
if (std::filesystem::perms::none == (perms & std::filesystem::perms::others_exec))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
return std::filesystem::perms::none != (perms & std::filesystem::perms::others_exec);
|
||||
}
|
||||
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -1010,8 +1010,8 @@ void CMonitor::onMonitorFrame() {
|
|||
g_pHyprRenderer->renderMonitor(self.lock());
|
||||
}
|
||||
|
||||
CMonitorState::CMonitorState(CMonitor* owner) {
|
||||
m_pOwner = owner;
|
||||
CMonitorState::CMonitorState(CMonitor* owner) : m_pOwner(owner) {
|
||||
;
|
||||
}
|
||||
|
||||
CMonitorState::~CMonitorState() {
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@
|
|||
#include <aquamarine/allocator/Swapchain.hpp>
|
||||
|
||||
// Enum for the different types of auto directions, e.g. auto-left, auto-up.
|
||||
enum eAutoDirs {
|
||||
enum eAutoDirs : uint8_t {
|
||||
DIR_AUTO_NONE = 0, /* None will be treated as right. */
|
||||
DIR_AUTO_UP,
|
||||
DIR_AUTO_DOWN,
|
||||
|
|
|
|||
|
|
@ -4,59 +4,56 @@
|
|||
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
#include <cerrno>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/un.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
|
||||
namespace Systemd {
|
||||
int SdBooted(void) {
|
||||
if (!faccessat(AT_FDCWD, "/run/systemd/system/", F_OK, AT_SYMLINK_NOFOLLOW))
|
||||
return true;
|
||||
int NSystemd::sdBooted() {
|
||||
if (!faccessat(AT_FDCWD, "/run/systemd/system/", F_OK, AT_SYMLINK_NOFOLLOW))
|
||||
return true;
|
||||
|
||||
if (errno == ENOENT)
|
||||
return false;
|
||||
if (errno == ENOENT)
|
||||
return false;
|
||||
|
||||
return -errno;
|
||||
}
|
||||
|
||||
int SdNotify(int unsetEnvironment, const char* state) {
|
||||
int fd = socket(AF_UNIX, SOCK_DGRAM | SOCK_CLOEXEC, 0);
|
||||
if (fd < 0)
|
||||
return -errno;
|
||||
|
||||
constexpr char envVar[] = "NOTIFY_SOCKET";
|
||||
|
||||
auto cleanup = [unsetEnvironment, envVar](int* fd) {
|
||||
if (unsetEnvironment)
|
||||
unsetenv(envVar);
|
||||
close(*fd);
|
||||
};
|
||||
std::unique_ptr<int, decltype(cleanup)> fdCleaup(&fd, cleanup);
|
||||
|
||||
const char* addr = getenv(envVar);
|
||||
if (!addr)
|
||||
return 0;
|
||||
|
||||
// address length must be at most this; see man 7 unix
|
||||
size_t addrLen = strnlen(addr, 107);
|
||||
|
||||
struct sockaddr_un unixAddr;
|
||||
unixAddr.sun_family = AF_UNIX;
|
||||
strncpy(unixAddr.sun_path, addr, addrLen);
|
||||
if (unixAddr.sun_path[0] == '@')
|
||||
unixAddr.sun_path[0] = '\0';
|
||||
|
||||
if (connect(fd, (const sockaddr*)&unixAddr, sizeof(struct sockaddr_un)) < 0)
|
||||
return -errno;
|
||||
|
||||
// arbitrary value which seems to be enough for s-d messages
|
||||
ssize_t stateLen = strnlen(state, 128);
|
||||
if (write(fd, state, stateLen) == stateLen)
|
||||
return 1;
|
||||
|
||||
return -errno;
|
||||
}
|
||||
return -errno;
|
||||
}
|
||||
|
||||
int NSystemd::sdNotify(int unsetEnvironment, const char* state) {
|
||||
int fd = socket(AF_UNIX, SOCK_DGRAM | SOCK_CLOEXEC, 0);
|
||||
if (fd < 0)
|
||||
return -errno;
|
||||
|
||||
constexpr char envVar[] = "NOTIFY_SOCKET";
|
||||
|
||||
auto cleanup = [unsetEnvironment, envVar](const int* fd) {
|
||||
if (unsetEnvironment)
|
||||
unsetenv(envVar);
|
||||
close(*fd);
|
||||
};
|
||||
std::unique_ptr<int, decltype(cleanup)> fdCleaup(&fd, cleanup);
|
||||
|
||||
const char* addr = getenv(envVar);
|
||||
if (!addr)
|
||||
return 0;
|
||||
|
||||
// address length must be at most this; see man 7 unix
|
||||
size_t addrLen = strnlen(addr, 107);
|
||||
|
||||
struct sockaddr_un unixAddr;
|
||||
unixAddr.sun_family = AF_UNIX;
|
||||
strncpy(unixAddr.sun_path, addr, addrLen);
|
||||
if (unixAddr.sun_path[0] == '@')
|
||||
unixAddr.sun_path[0] = '\0';
|
||||
|
||||
if (connect(fd, (const sockaddr*)&unixAddr, sizeof(struct sockaddr_un)) < 0)
|
||||
return -errno;
|
||||
|
||||
// arbitrary value which seems to be enough for s-d messages
|
||||
ssize_t stateLen = strnlen(state, 128);
|
||||
if (write(fd, state, stateLen) == stateLen)
|
||||
return 1;
|
||||
|
||||
return -errno;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
#pragma once
|
||||
|
||||
namespace Systemd {
|
||||
int SdBooted(void);
|
||||
int SdNotify(int unset_environment, const char* state);
|
||||
namespace NSystemd {
|
||||
int sdBooted(void);
|
||||
int sdNotify(int unset_environment, const char* state);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,11 +5,11 @@
|
|||
|
||||
class CTagKeeper {
|
||||
public:
|
||||
bool isTagged(const std::string& tag, bool strict = false);
|
||||
bool applyTag(const std::string& tag, bool dynamic = false);
|
||||
bool removeDynamicTags();
|
||||
bool isTagged(const std::string& tag, bool strict = false);
|
||||
bool applyTag(const std::string& tag, bool dynamic = false);
|
||||
bool removeDynamicTags();
|
||||
|
||||
inline const auto& getTags() {
|
||||
const auto& getTags() const {
|
||||
return m_tags;
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
#include "Watchdog.hpp"
|
||||
#include <signal.h>
|
||||
#include <csignal>
|
||||
#include "config/ConfigManager.hpp"
|
||||
#include "../config/ConfigValue.hpp"
|
||||
|
||||
|
|
@ -12,8 +12,7 @@ CWatchdog::~CWatchdog() {
|
|||
m_pWatchdog->join();
|
||||
}
|
||||
|
||||
CWatchdog::CWatchdog() {
|
||||
m_iMainThreadPID = pthread_self();
|
||||
CWatchdog::CWatchdog() : m_iMainThreadPID(pthread_self()) {
|
||||
|
||||
m_pWatchdog = std::make_unique<std::thread>([this] {
|
||||
static auto PTIMEOUT = CConfigValue<Hyprlang::INT>("debug:watchdog_timeout");
|
||||
|
|
@ -24,7 +23,7 @@ CWatchdog::CWatchdog() {
|
|||
|
||||
if (!m_bWillWatch)
|
||||
m_cvWatchdogCondition.wait(lk, [this] { return m_bNotified || m_bExitThread; });
|
||||
else if (m_cvWatchdogCondition.wait_for(lk, std::chrono::milliseconds((int)(*PTIMEOUT * 1000.0)), [this] { return m_bNotified || m_bExitThread; }) == false)
|
||||
else if (!m_cvWatchdogCondition.wait_for(lk, std::chrono::milliseconds((int)(*PTIMEOUT * 1000.0)), [this] { return m_bNotified || m_bExitThread; }))
|
||||
pthread_kill(m_iMainThreadPID, SIGUSR1);
|
||||
|
||||
if (m_bExitThread)
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@
|
|||
#include <hyprutils/math/Region.hpp>
|
||||
#include <hyprutils/math/Mat3x3.hpp>
|
||||
|
||||
// NOLINTNEXTLINE
|
||||
using namespace Hyprutils::Math;
|
||||
|
||||
eTransform wlTransformToHyprutils(wl_output_transform t);
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
#include <hyprutils/memory/WeakPtr.hpp>
|
||||
|
||||
//NOLINTNEXTLINE
|
||||
using namespace Hyprutils::Memory;
|
||||
|
||||
#define SP Hyprutils::Memory::CSharedPointer
|
||||
|
|
|
|||
|
|
@ -2,4 +2,5 @@
|
|||
|
||||
#include <hyprutils/signal/Signal.hpp>
|
||||
|
||||
//NOLINTNEXTLINE
|
||||
using namespace Hyprutils::Signal;
|
||||
|
|
|
|||
|
|
@ -2,4 +2,5 @@
|
|||
|
||||
#include <hyprutils/string/VarList.hpp>
|
||||
|
||||
//NOLINTNEXTLINE
|
||||
using namespace Hyprutils::String;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue