mirror of
https://github.com/hyprwm/hyprlock.git
synced 2025-05-12 21:30:37 +01:00
core: clang-tidy and comp fixes (#679)
* clang-tidy and comp fixes * nit changes
This commit is contained in:
parent
ce750456f9
commit
dc6d72158c
18 changed files with 220 additions and 115 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
|
|
@ -49,7 +49,7 @@ int conv(int num_msg, const struct pam_message** msg, struct pam_response** resp
|
||||||
Debug::log(LOG, "PAM: {}", msg[i]->msg);
|
Debug::log(LOG, "PAM: {}", msg[i]->msg);
|
||||||
// Targets this log from pam_faillock: https://github.com/linux-pam/linux-pam/blob/fa3295e079dbbc241906f29bde5fb71bc4172771/modules/pam_faillock/pam_faillock.c#L417
|
// Targets this log from pam_faillock: https://github.com/linux-pam/linux-pam/blob/fa3295e079dbbc241906f29bde5fb71bc4172771/modules/pam_faillock/pam_faillock.c#L417
|
||||||
if (const auto MSG = std::string(msg[i]->msg); MSG.contains("left to unlock")) {
|
if (const auto MSG = std::string(msg[i]->msg); MSG.contains("left to unlock")) {
|
||||||
CONVERSATIONSTATE->failText = std::move(MSG);
|
CONVERSATIONSTATE->failText = MSG;
|
||||||
CONVERSATIONSTATE->failTextFromPam = true;
|
CONVERSATIONSTATE->failTextFromPam = true;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -65,7 +65,7 @@ CPam::CPam() {
|
||||||
m_sPamModule = *PAMMODULE;
|
m_sPamModule = *PAMMODULE;
|
||||||
|
|
||||||
if (!std::filesystem::exists(std::filesystem::path("/etc/pam.d/") / m_sPamModule)) {
|
if (!std::filesystem::exists(std::filesystem::path("/etc/pam.d/") / m_sPamModule)) {
|
||||||
Debug::log(ERR, "Pam module \"/etc/pam.d/{}\" does not exist! Falling back to \"/etc/pam.d/su\"", m_sPamModule);
|
Debug::log(ERR, R"(Pam module "/etc/pam.d/{}" does not exist! Falling back to "/etc/pam.d/su")", m_sPamModule);
|
||||||
m_sPamModule = "su";
|
m_sPamModule = "su";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -106,8 +106,8 @@ void CPam::init() {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CPam::auth() {
|
bool CPam::auth() {
|
||||||
const pam_conv localConv = {conv, (void*)&m_sConversationState};
|
const pam_conv localConv = {.conv = conv, .appdata_ptr = (void*)&m_sConversationState};
|
||||||
pam_handle_t* handle = NULL;
|
pam_handle_t* handle = nullptr;
|
||||||
auto uidPassword = getpwuid(getuid());
|
auto uidPassword = getpwuid(getuid());
|
||||||
RASSERT(uidPassword && uidPassword->pw_name, "Failed to get username (getpwuid)");
|
RASSERT(uidPassword && uidPassword->pw_name, "Failed to get username (getpwuid)");
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,6 @@
|
||||||
#include <hyprlang.hpp>
|
#include <hyprlang.hpp>
|
||||||
#include <hyprutils/string/String.hpp>
|
#include <hyprutils/string/String.hpp>
|
||||||
#include <hyprutils/path/Path.hpp>
|
#include <hyprutils/path/Path.hpp>
|
||||||
#include <hyprutils/string/String.hpp>
|
|
||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
#include <glob.h>
|
#include <glob.h>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
@ -149,7 +148,7 @@ static Hyprlang::CParseResult configHandleGradientSet(const char* VALUE, void**
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
DATA->m_vColors.push_back(CHyprColor(configStringToInt(var)));
|
DATA->m_vColors.emplace_back(configStringToInt(var));
|
||||||
} catch (std::exception& e) {
|
} catch (std::exception& e) {
|
||||||
Debug::log(WARN, "Error parsing gradient {}", V);
|
Debug::log(WARN, "Error parsing gradient {}", V);
|
||||||
parseError = "Error parsing gradient " + V + ": " + e.what();
|
parseError = "Error parsing gradient " + V + ": " + e.what();
|
||||||
|
@ -158,14 +157,14 @@ static Hyprlang::CParseResult configHandleGradientSet(const char* VALUE, void**
|
||||||
|
|
||||||
if (V.empty()) {
|
if (V.empty()) {
|
||||||
DATA->m_bIsFallback = true;
|
DATA->m_bIsFallback = true;
|
||||||
DATA->m_vColors.push_back(0); // transparent
|
DATA->m_vColors.emplace_back(0); // transparent
|
||||||
}
|
}
|
||||||
|
|
||||||
if (DATA->m_vColors.size() == 0) {
|
if (DATA->m_vColors.size() == 0) {
|
||||||
Debug::log(WARN, "Error parsing gradient {}", V);
|
Debug::log(WARN, "Error parsing gradient {}", V);
|
||||||
parseError = "Error parsing gradient " + V + ": No colors?";
|
parseError = "Error parsing gradient " + V + ": No colors?";
|
||||||
|
|
||||||
DATA->m_vColors.push_back(0); // transparent
|
DATA->m_vColors.emplace_back(0); // transparent
|
||||||
}
|
}
|
||||||
|
|
||||||
DATA->updateColorsOk();
|
DATA->updateColorsOk();
|
||||||
|
@ -322,9 +321,9 @@ void CConfigManager::init() {
|
||||||
m_config.addSpecialConfigValue("label", "zindex", Hyprlang::INT{0});
|
m_config.addSpecialConfigValue("label", "zindex", Hyprlang::INT{0});
|
||||||
SHADOWABLE("label");
|
SHADOWABLE("label");
|
||||||
|
|
||||||
m_config.registerHandler(&::handleSource, "source", {false});
|
m_config.registerHandler(&::handleSource, "source", {.allowFlags = false});
|
||||||
m_config.registerHandler(&::handleBezier, "bezier", {false});
|
m_config.registerHandler(&::handleBezier, "bezier", {.allowFlags = false});
|
||||||
m_config.registerHandler(&::handleAnimation, "animation", {false});
|
m_config.registerHandler(&::handleAnimation, "animation", {.allowFlags = false});
|
||||||
|
|
||||||
//
|
//
|
||||||
// Init Animations
|
// Init Animations
|
||||||
|
@ -369,12 +368,13 @@ std::vector<CConfigManager::SWidgetConfig> CConfigManager::getWidgetConfigs() {
|
||||||
|
|
||||||
//
|
//
|
||||||
auto keys = m_config.listKeysForSpecialCategory("background");
|
auto keys = m_config.listKeysForSpecialCategory("background");
|
||||||
|
result.reserve(keys.size());
|
||||||
for (auto& k : keys) {
|
for (auto& k : keys) {
|
||||||
// clang-format off
|
// clang-format off
|
||||||
result.push_back(CConfigManager::SWidgetConfig{
|
result.push_back(CConfigManager::SWidgetConfig{
|
||||||
"background",
|
.type = "background",
|
||||||
std::any_cast<Hyprlang::STRING>(m_config.getSpecialConfigValue("background", "monitor", k.c_str())),
|
.monitor = std::any_cast<Hyprlang::STRING>(m_config.getSpecialConfigValue("background", "monitor", k.c_str())),
|
||||||
{
|
.values = {
|
||||||
{"path", m_config.getSpecialConfigValue("background", "path", k.c_str())},
|
{"path", m_config.getSpecialConfigValue("background", "path", k.c_str())},
|
||||||
{"color", m_config.getSpecialConfigValue("background", "color", k.c_str())},
|
{"color", m_config.getSpecialConfigValue("background", "color", k.c_str())},
|
||||||
{"blur_size", m_config.getSpecialConfigValue("background", "blur_size", k.c_str())},
|
{"blur_size", m_config.getSpecialConfigValue("background", "blur_size", k.c_str())},
|
||||||
|
@ -398,9 +398,9 @@ std::vector<CConfigManager::SWidgetConfig> CConfigManager::getWidgetConfigs() {
|
||||||
for (auto& k : keys) {
|
for (auto& k : keys) {
|
||||||
// clang-format off
|
// clang-format off
|
||||||
result.push_back(CConfigManager::SWidgetConfig{
|
result.push_back(CConfigManager::SWidgetConfig{
|
||||||
"shape",
|
.type = "shape",
|
||||||
std::any_cast<Hyprlang::STRING>(m_config.getSpecialConfigValue("shape", "monitor", k.c_str())),
|
.monitor = std::any_cast<Hyprlang::STRING>(m_config.getSpecialConfigValue("shape", "monitor", k.c_str())),
|
||||||
{
|
.values = {
|
||||||
{"size", m_config.getSpecialConfigValue("shape", "size", k.c_str())},
|
{"size", m_config.getSpecialConfigValue("shape", "size", k.c_str())},
|
||||||
{"rounding", m_config.getSpecialConfigValue("shape", "rounding", k.c_str())},
|
{"rounding", m_config.getSpecialConfigValue("shape", "rounding", k.c_str())},
|
||||||
{"border_size", m_config.getSpecialConfigValue("shape", "border_size", k.c_str())},
|
{"border_size", m_config.getSpecialConfigValue("shape", "border_size", k.c_str())},
|
||||||
|
@ -423,9 +423,9 @@ std::vector<CConfigManager::SWidgetConfig> CConfigManager::getWidgetConfigs() {
|
||||||
for (auto& k : keys) {
|
for (auto& k : keys) {
|
||||||
// clang-format off
|
// clang-format off
|
||||||
result.push_back(CConfigManager::SWidgetConfig{
|
result.push_back(CConfigManager::SWidgetConfig{
|
||||||
"image",
|
.type = "image",
|
||||||
std::any_cast<Hyprlang::STRING>(m_config.getSpecialConfigValue("image", "monitor", k.c_str())),
|
.monitor = std::any_cast<Hyprlang::STRING>(m_config.getSpecialConfigValue("image", "monitor", k.c_str())),
|
||||||
{
|
.values = {
|
||||||
{"path", m_config.getSpecialConfigValue("image", "path", k.c_str())},
|
{"path", m_config.getSpecialConfigValue("image", "path", k.c_str())},
|
||||||
{"size", m_config.getSpecialConfigValue("image", "size", k.c_str())},
|
{"size", m_config.getSpecialConfigValue("image", "size", k.c_str())},
|
||||||
{"rounding", m_config.getSpecialConfigValue("image", "rounding", k.c_str())},
|
{"rounding", m_config.getSpecialConfigValue("image", "rounding", k.c_str())},
|
||||||
|
@ -448,9 +448,9 @@ std::vector<CConfigManager::SWidgetConfig> CConfigManager::getWidgetConfigs() {
|
||||||
for (auto& k : keys) {
|
for (auto& k : keys) {
|
||||||
// clang-format off
|
// clang-format off
|
||||||
result.push_back(CConfigManager::SWidgetConfig{
|
result.push_back(CConfigManager::SWidgetConfig{
|
||||||
"input-field",
|
.type = "input-field",
|
||||||
std::any_cast<Hyprlang::STRING>(m_config.getSpecialConfigValue("input-field", "monitor", k.c_str())),
|
.monitor = std::any_cast<Hyprlang::STRING>(m_config.getSpecialConfigValue("input-field", "monitor", k.c_str())),
|
||||||
{
|
.values = {
|
||||||
{"size", m_config.getSpecialConfigValue("input-field", "size", k.c_str())},
|
{"size", m_config.getSpecialConfigValue("input-field", "size", k.c_str())},
|
||||||
{"inner_color", m_config.getSpecialConfigValue("input-field", "inner_color", k.c_str())},
|
{"inner_color", m_config.getSpecialConfigValue("input-field", "inner_color", k.c_str())},
|
||||||
{"outer_color", m_config.getSpecialConfigValue("input-field", "outer_color", k.c_str())},
|
{"outer_color", m_config.getSpecialConfigValue("input-field", "outer_color", k.c_str())},
|
||||||
|
@ -490,9 +490,9 @@ std::vector<CConfigManager::SWidgetConfig> CConfigManager::getWidgetConfigs() {
|
||||||
for (auto& k : keys) {
|
for (auto& k : keys) {
|
||||||
// clang-format off
|
// clang-format off
|
||||||
result.push_back(CConfigManager::SWidgetConfig{
|
result.push_back(CConfigManager::SWidgetConfig{
|
||||||
"label",
|
.type = "label",
|
||||||
std::any_cast<Hyprlang::STRING>(m_config.getSpecialConfigValue("label", "monitor", k.c_str())),
|
.monitor = std::any_cast<Hyprlang::STRING>(m_config.getSpecialConfigValue("label", "monitor", k.c_str())),
|
||||||
{
|
.values = {
|
||||||
{"position", m_config.getSpecialConfigValue("label", "position", k.c_str())},
|
{"position", m_config.getSpecialConfigValue("label", "position", k.c_str())},
|
||||||
{"color", m_config.getSpecialConfigValue("label", "color", k.c_str())},
|
{"color", m_config.getSpecialConfigValue("label", "color", k.c_str())},
|
||||||
{"font_size", m_config.getSpecialConfigValue("label", "font_size", k.c_str())},
|
{"font_size", m_config.getSpecialConfigValue("label", "font_size", k.c_str())},
|
||||||
|
|
|
@ -31,7 +31,7 @@ void updateColorVariable(CAnimatedVariable<CHyprColor>& av, const float POINTY,
|
||||||
const auto& L1 = av.begun().asOkLab();
|
const auto& L1 = av.begun().asOkLab();
|
||||||
const auto& L2 = av.goal().asOkLab();
|
const auto& L2 = av.goal().asOkLab();
|
||||||
|
|
||||||
static const auto lerp = [](const float one, const float two, const float progress) -> float { return one + (two - one) * progress; };
|
static const auto lerp = [](const float one, const float two, const float progress) -> float { return one + ((two - one) * progress); };
|
||||||
|
|
||||||
const Hyprgraphics::CColor lerped = Hyprgraphics::CColor::SOkLab{
|
const Hyprgraphics::CColor lerped = Hyprgraphics::CColor::SOkLab{
|
||||||
.l = lerp(L1.l, L2.l, POINTY),
|
.l = lerp(L1.l, L2.l, POINTY),
|
||||||
|
@ -57,7 +57,7 @@ void updateGradientVariable(CAnimatedVariable<CGradientValueData>& av, const flo
|
||||||
const auto& L1 = sourceCol.asOkLab();
|
const auto& L1 = sourceCol.asOkLab();
|
||||||
const auto& L2 = targetCol.asOkLab();
|
const auto& L2 = targetCol.asOkLab();
|
||||||
|
|
||||||
static const auto lerp = [](const float one, const float two, const float progress) -> float { return one + (two - one) * progress; };
|
static const auto lerp = [](const float one, const float two, const float progress) -> float { return one + ((two - one) * progress); };
|
||||||
|
|
||||||
const Hyprgraphics::CColor lerped = Hyprgraphics::CColor::SOkLab{
|
const Hyprgraphics::CColor lerped = Hyprgraphics::CColor::SOkLab{
|
||||||
.l = lerp(L1.l, L2.l, POINTY),
|
.l = lerp(L1.l, L2.l, POINTY),
|
||||||
|
|
|
@ -31,21 +31,21 @@ CEGL::CEGL(wl_display* display) {
|
||||||
throw std::runtime_error("EGL_EXT_platform_wayland not supported");
|
throw std::runtime_error("EGL_EXT_platform_wayland not supported");
|
||||||
|
|
||||||
eglGetPlatformDisplayEXT = (PFNEGLGETPLATFORMDISPLAYEXTPROC)eglGetProcAddress("eglGetPlatformDisplayEXT");
|
eglGetPlatformDisplayEXT = (PFNEGLGETPLATFORMDISPLAYEXTPROC)eglGetProcAddress("eglGetPlatformDisplayEXT");
|
||||||
if (eglGetPlatformDisplayEXT == NULL)
|
if (eglGetPlatformDisplayEXT == nullptr)
|
||||||
throw std::runtime_error("Failed to get eglGetPlatformDisplayEXT");
|
throw std::runtime_error("Failed to get eglGetPlatformDisplayEXT");
|
||||||
|
|
||||||
eglCreatePlatformWindowSurfaceEXT = (PFNEGLCREATEPLATFORMWINDOWSURFACEEXTPROC)eglGetProcAddress("eglCreatePlatformWindowSurfaceEXT");
|
eglCreatePlatformWindowSurfaceEXT = (PFNEGLCREATEPLATFORMWINDOWSURFACEEXTPROC)eglGetProcAddress("eglCreatePlatformWindowSurfaceEXT");
|
||||||
if (eglCreatePlatformWindowSurfaceEXT == NULL)
|
if (eglCreatePlatformWindowSurfaceEXT == nullptr)
|
||||||
throw std::runtime_error("Failed to get eglCreatePlatformWindowSurfaceEXT");
|
throw std::runtime_error("Failed to get eglCreatePlatformWindowSurfaceEXT");
|
||||||
|
|
||||||
eglDisplay = eglGetPlatformDisplayEXT(EGL_PLATFORM_WAYLAND_EXT, display, NULL);
|
eglDisplay = eglGetPlatformDisplayEXT(EGL_PLATFORM_WAYLAND_EXT, display, nullptr);
|
||||||
EGLint matched = 0;
|
EGLint matched = 0;
|
||||||
if (eglDisplay == EGL_NO_DISPLAY) {
|
if (eglDisplay == EGL_NO_DISPLAY) {
|
||||||
Debug::log(CRIT, "Failed to create EGL display");
|
Debug::log(CRIT, "Failed to create EGL display");
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (eglInitialize(eglDisplay, NULL, NULL) == EGL_FALSE) {
|
if (eglInitialize(eglDisplay, nullptr, nullptr) == EGL_FALSE) {
|
||||||
Debug::log(CRIT, "Failed to initialize EGL");
|
Debug::log(CRIT, "Failed to initialize EGL");
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
@ -83,4 +83,4 @@ CEGL::~CEGL() {
|
||||||
|
|
||||||
void CEGL::makeCurrent(EGLSurface surf) {
|
void CEGL::makeCurrent(EGLSurface surf) {
|
||||||
eglMakeCurrent(eglDisplay, surf, surf, eglContext);
|
eglMakeCurrent(eglDisplay, surf, surf, eglContext);
|
||||||
}
|
}
|
||||||
|
|
|
@ -94,7 +94,7 @@ void CSessionLockSurface::configure(const Vector2D& size_, uint32_t serial_) {
|
||||||
if (!eglSurface) {
|
if (!eglSurface) {
|
||||||
eglSurface = g_pEGL->eglCreatePlatformWindowSurfaceEXT(g_pEGL->eglDisplay, g_pEGL->eglConfig, eglWindow, nullptr);
|
eglSurface = g_pEGL->eglCreatePlatformWindowSurfaceEXT(g_pEGL->eglDisplay, g_pEGL->eglConfig, eglWindow, nullptr);
|
||||||
if (!eglSurface) {
|
if (!eglSurface) {
|
||||||
Debug::log(CRIT, "Couldn't create eglSurface: {}", (int)eglGetError());
|
Debug::log(CRIT, "Couldn't create eglSurface: {}", eglGetError());
|
||||||
// Clean up resources to prevent leaks
|
// Clean up resources to prevent leaks
|
||||||
wl_egl_window_destroy(eglWindow);
|
wl_egl_window_destroy(eglWindow);
|
||||||
eglWindow = nullptr;
|
eglWindow = nullptr;
|
||||||
|
@ -150,4 +150,4 @@ void CSessionLockSurface::onCallback() {
|
||||||
needsFrame = false;
|
needsFrame = false;
|
||||||
render();
|
render();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
#include "Timer.hpp"
|
#include "Timer.hpp"
|
||||||
|
|
||||||
CTimer::CTimer(std::chrono::system_clock::duration timeout, std::function<void(std::shared_ptr<CTimer> self, void* data)> cb_, void* data_, bool force) : cb(cb_), data(data_) {
|
CTimer::CTimer(std::chrono::system_clock::duration timeout, std::function<void(std::shared_ptr<CTimer> self, void* data)> cb_, void* data_, bool force) :
|
||||||
expires = std::chrono::system_clock::now() + timeout;
|
cb(cb_), data(data_), allowForceUpdate(force) {
|
||||||
allowForceUpdate = force;
|
expires = std::chrono::system_clock::now() + timeout;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CTimer::passed() {
|
bool CTimer::passed() {
|
||||||
|
|
|
@ -10,10 +10,10 @@
|
||||||
#include <sys/poll.h>
|
#include <sys/poll.h>
|
||||||
#include <sys/mman.h>
|
#include <sys/mman.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <signal.h>
|
#include <csignal>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <assert.h>
|
#include <cassert>
|
||||||
#include <string.h>
|
#include <cstring>
|
||||||
#include <xf86drm.h>
|
#include <xf86drm.h>
|
||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
@ -156,7 +156,7 @@ void CHyprlock::addDmabufListener() {
|
||||||
uint64_t modifier;
|
uint64_t modifier;
|
||||||
};
|
};
|
||||||
// An entry in the table has to be 16 bytes long
|
// An entry in the table has to be 16 bytes long
|
||||||
assert(sizeof(fm_entry) == 16);
|
static_assert(sizeof(fm_entry) == 16);
|
||||||
|
|
||||||
uint32_t n_modifiers = dma.formatTableSize / sizeof(fm_entry);
|
uint32_t n_modifiers = dma.formatTableSize / sizeof(fm_entry);
|
||||||
fm_entry* fm_entry = (struct fm_entry*)dma.formatTable;
|
fm_entry* fm_entry = (struct fm_entry*)dma.formatTable;
|
||||||
|
@ -295,7 +295,7 @@ void CHyprlock::run() {
|
||||||
});
|
});
|
||||||
m_sWaylandState.registry->setGlobalRemove([this](CCWlRegistry* r, uint32_t name) {
|
m_sWaylandState.registry->setGlobalRemove([this](CCWlRegistry* r, uint32_t name) {
|
||||||
Debug::log(LOG, " | removed iface {}", name);
|
Debug::log(LOG, " | removed iface {}", name);
|
||||||
auto outputIt = std::find_if(m_vOutputs.begin(), m_vOutputs.end(), [name](const auto& other) { return other->name == name; });
|
auto outputIt = std::ranges::find_if(m_vOutputs, [name](const auto& other) { return other->name == name; });
|
||||||
if (outputIt != m_vOutputs.end()) {
|
if (outputIt != m_vOutputs.end()) {
|
||||||
g_pRenderer->removeWidgetsFor(outputIt->get()->sessionLockSurface.get());
|
g_pRenderer->removeWidgetsFor(outputIt->get()->sessionLockSurface.get());
|
||||||
m_vOutputs.erase(outputIt);
|
m_vOutputs.erase(outputIt);
|
||||||
|
@ -377,8 +377,7 @@ void CHyprlock::run() {
|
||||||
events = poll(pollfds, fdcount, 5000);
|
events = poll(pollfds, fdcount, 5000);
|
||||||
|
|
||||||
if (events < 0) {
|
if (events < 0) {
|
||||||
if (preparedToRead)
|
wl_display_cancel_read(m_sWaylandState.display);
|
||||||
wl_display_cancel_read(m_sWaylandState.display);
|
|
||||||
|
|
||||||
if (errno == EINTR)
|
if (errno == EINTR)
|
||||||
continue;
|
continue;
|
||||||
|
@ -421,8 +420,7 @@ void CHyprlock::run() {
|
||||||
float least = 10000;
|
float least = 10000;
|
||||||
for (auto& t : m_vTimers) {
|
for (auto& t : m_vTimers) {
|
||||||
const auto TIME = std::clamp(t->leftMs(), 1.f, INFINITY);
|
const auto TIME = std::clamp(t->leftMs(), 1.f, INFINITY);
|
||||||
if (TIME < least)
|
least = std::min(TIME, least);
|
||||||
least = TIME;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
m_sLoopState.timersMutex.unlock();
|
m_sLoopState.timersMutex.unlock();
|
||||||
|
@ -444,7 +442,7 @@ void CHyprlock::run() {
|
||||||
|
|
||||||
while (!m_bTerminate) {
|
while (!m_bTerminate) {
|
||||||
std::unique_lock lk(m_sLoopState.eventRequestMutex);
|
std::unique_lock lk(m_sLoopState.eventRequestMutex);
|
||||||
if (m_sLoopState.event == false)
|
if (!m_sLoopState.event)
|
||||||
m_sLoopState.loopCV.wait_for(lk, std::chrono::milliseconds(5000), [this] { return m_sLoopState.event; });
|
m_sLoopState.loopCV.wait_for(lk, std::chrono::milliseconds(5000), [this] { return m_sLoopState.event; });
|
||||||
|
|
||||||
if (m_bTerminate)
|
if (m_bTerminate)
|
||||||
|
@ -545,7 +543,7 @@ void CHyprlock::clearPasswordBuffer() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void CHyprlock::renderOutput(const std::string& stringPort) {
|
void CHyprlock::renderOutput(const std::string& stringPort) {
|
||||||
const auto MON = std::find_if(m_vOutputs.begin(), m_vOutputs.end(), [stringPort](const auto& other) { return other->stringPort == stringPort; });
|
const auto MON = std::ranges::find_if(m_vOutputs, [stringPort](const auto& other) { return other->stringPort == stringPort; });
|
||||||
|
|
||||||
if (MON == m_vOutputs.end() || !MON->get())
|
if (MON == m_vOutputs.end() || !MON->get())
|
||||||
return;
|
return;
|
||||||
|
@ -604,10 +602,10 @@ void CHyprlock::onKey(uint32_t key, bool down) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (down && std::find(m_vPressedKeys.begin(), m_vPressedKeys.end(), key) != m_vPressedKeys.end()) {
|
if (down && std::ranges::find(m_vPressedKeys, key) != m_vPressedKeys.end()) {
|
||||||
Debug::log(ERR, "Invalid key down event (key already pressed?)");
|
Debug::log(ERR, "Invalid key down event (key already pressed?)");
|
||||||
return;
|
return;
|
||||||
} else if (!down && std::find(m_vPressedKeys.begin(), m_vPressedKeys.end(), key) == m_vPressedKeys.end()) {
|
} else if (!down && std::ranges::find(m_vPressedKeys, key) == m_vPressedKeys.end()) {
|
||||||
Debug::log(ERR, "Invalid key down event (stray release event?)");
|
Debug::log(ERR, "Invalid key down event (stray release event?)");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,42 +5,33 @@
|
||||||
#define GREEN(c) ((double)(((c) >> 8) & 0xff) / 255.0)
|
#define GREEN(c) ((double)(((c) >> 8) & 0xff) / 255.0)
|
||||||
#define BLUE(c) ((double)(((c)) & 0xff) / 255.0)
|
#define BLUE(c) ((double)(((c)) & 0xff) / 255.0)
|
||||||
|
|
||||||
CHyprColor::CHyprColor() {}
|
CHyprColor::CHyprColor() {
|
||||||
|
;
|
||||||
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) {
|
CHyprColor::CHyprColor(float r_, float g_, float b_, float a_) : r(r_), g(g_), b(b_), a(a_) {
|
||||||
r = RED(hex);
|
okLab = Hyprgraphics::CColor(Hyprgraphics::CColor::SSRGB{.r = r, .g = g, .b = b}).asOkLab();
|
||||||
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(uint64_t hex) : r(RED(hex)), g(GREEN(hex)), b(BLUE(hex)), a(ALPHA(hex)) {
|
||||||
|
okLab = Hyprgraphics::CColor(Hyprgraphics::CColor::SSRGB{.r = r, .g = g, .b = b}).asOkLab();
|
||||||
|
}
|
||||||
|
|
||||||
|
CHyprColor::CHyprColor(const Hyprgraphics::CColor& color, float a_) : a(a_) {
|
||||||
const auto SRGB = color.asRgb();
|
const auto SRGB = color.asRgb();
|
||||||
r = SRGB.r;
|
r = SRGB.r;
|
||||||
g = SRGB.g;
|
g = SRGB.g;
|
||||||
b = SRGB.b;
|
b = SRGB.b;
|
||||||
a = a_;
|
|
||||||
|
|
||||||
okLab = color.asOkLab();
|
okLab = color.asOkLab();
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t CHyprColor::getAsHex() const {
|
uint32_t CHyprColor::getAsHex() const {
|
||||||
return (uint32_t)(a * 255.f) * 0x1000000 + (uint32_t)(r * 255.f) * 0x10000 + (uint32_t)(g * 255.f) * 0x100 + (uint32_t)(b * 255.f) * 0x1;
|
return ((uint32_t)(a * 255.f) * 0x1000000) + ((uint32_t)(r * 255.f) * 0x10000) + ((uint32_t)(g * 255.f) * 0x100) + ((uint32_t)(b * 255.f) * 0x1);
|
||||||
}
|
}
|
||||||
|
|
||||||
Hyprgraphics::CColor::SSRGB CHyprColor::asRGB() const {
|
Hyprgraphics::CColor::SSRGB CHyprColor::asRGB() const {
|
||||||
return {r, g, b};
|
return {.r = r, .g = g, .b = b};
|
||||||
}
|
}
|
||||||
|
|
||||||
Hyprgraphics::CColor::SOkLab CHyprColor::asOkLab() const {
|
Hyprgraphics::CColor::SOkLab CHyprColor::asOkLab() const {
|
||||||
|
@ -53,4 +44,4 @@ Hyprgraphics::CColor::SHSL CHyprColor::asHSL() const {
|
||||||
|
|
||||||
CHyprColor CHyprColor::stripA() const {
|
CHyprColor CHyprColor::stripA() const {
|
||||||
return {r, g, b, 1.F};
|
return {r, g, b, 1.F};
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,11 +57,11 @@ int64_t configStringToInt(const std::string& VALUE) {
|
||||||
a = std::round(std::stof(trim(rolling.substr(0, rolling.find(',')))) * 255.f);
|
a = std::round(std::stof(trim(rolling.substr(0, rolling.find(',')))) * 255.f);
|
||||||
} catch (std::exception& e) { throw std::invalid_argument("failed parsing " + VALUEWITHOUTFUNC); }
|
} catch (std::exception& e) { throw std::invalid_argument("failed parsing " + VALUEWITHOUTFUNC); }
|
||||||
|
|
||||||
return a * (Hyprlang::INT)0x1000000 + r * (Hyprlang::INT)0x10000 + g * (Hyprlang::INT)0x100 + b;
|
return (a * (Hyprlang::INT)0x1000000) + (r * (Hyprlang::INT)0x10000) + (g * (Hyprlang::INT)0x100) + b;
|
||||||
} else if (VALUEWITHOUTFUNC.length() == 8) {
|
} else if (VALUEWITHOUTFUNC.length() == 8) {
|
||||||
const auto RGBA = parseHex(VALUEWITHOUTFUNC);
|
const auto RGBA = parseHex(VALUEWITHOUTFUNC);
|
||||||
// now we need to RGBA -> ARGB. The config holds ARGB only.
|
// now we need to RGBA -> ARGB. The config holds ARGB only.
|
||||||
return (RGBA >> 8) + 0x1000000 * (RGBA & 0xFF);
|
return (RGBA >> 8) + (0x1000000 * (RGBA & 0xFF));
|
||||||
}
|
}
|
||||||
|
|
||||||
throw std::invalid_argument("rgba() expects length of 8 characters (4 bytes) or 4 comma separated values");
|
throw std::invalid_argument("rgba() expects length of 8 characters (4 bytes) or 4 comma separated values");
|
||||||
|
@ -79,7 +79,7 @@ int64_t configStringToInt(const std::string& VALUE) {
|
||||||
rolling = rolling.substr(rolling.find(',') + 1);
|
rolling = rolling.substr(rolling.find(',') + 1);
|
||||||
auto b = configStringToInt(trim(rolling.substr(0, rolling.find(','))));
|
auto b = configStringToInt(trim(rolling.substr(0, rolling.find(','))));
|
||||||
|
|
||||||
return (Hyprlang::INT)0xFF000000 + r * (Hyprlang::INT)0x10000 + g * (Hyprlang::INT)0x100 + b;
|
return (Hyprlang::INT)0xFF000000 + (r * (Hyprlang::INT)0x10000) + (g * (Hyprlang::INT)0x100) + b;
|
||||||
} else if (VALUEWITHOUTFUNC.length() == 6) {
|
} else if (VALUEWITHOUTFUNC.length() == 6) {
|
||||||
return parseHex(VALUEWITHOUTFUNC) + 0xFF000000;
|
return parseHex(VALUEWITHOUTFUNC) + 0xFF000000;
|
||||||
}
|
}
|
||||||
|
@ -136,4 +136,4 @@ int createPoolFile(size_t size, std::string& name) {
|
||||||
}
|
}
|
||||||
|
|
||||||
return FD;
|
return FD;
|
||||||
}
|
}
|
||||||
|
|
|
@ -130,7 +130,7 @@ void CAsyncResourceGatherer::gather() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
while (!g_pHyprlock->m_bTerminate && std::any_of(scframes.begin(), scframes.end(), [](const auto& d) { return !d->m_asset.ready; })) {
|
while (!g_pHyprlock->m_bTerminate && std::ranges::any_of(scframes, [](const auto& d) { return !d->m_asset.ready; })) {
|
||||||
std::this_thread::sleep_for(std::chrono::milliseconds(1));
|
std::this_thread::sleep_for(std::chrono::milliseconds(1));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -319,7 +319,7 @@ void CAsyncResourceGatherer::asyncAssetSpinLock() {
|
||||||
while (!g_pHyprlock->m_bTerminate) {
|
while (!g_pHyprlock->m_bTerminate) {
|
||||||
|
|
||||||
std::unique_lock lk(asyncLoopState.requestsMutex);
|
std::unique_lock lk(asyncLoopState.requestsMutex);
|
||||||
if (asyncLoopState.pending == false) // avoid a lock if a thread managed to request something already since we .unlock()ed
|
if (!asyncLoopState.pending) // avoid a lock if a thread managed to request something already since we .unlock()ed
|
||||||
asyncLoopState.requestsCV.wait_for(lk, std::chrono::seconds(5), [this] { return asyncLoopState.pending; }); // wait for events
|
asyncLoopState.requestsCV.wait_for(lk, std::chrono::seconds(5), [this] { return asyncLoopState.pending; }); // wait for events
|
||||||
|
|
||||||
asyncLoopState.pending = false;
|
asyncLoopState.pending = false;
|
||||||
|
@ -349,7 +349,7 @@ void CAsyncResourceGatherer::asyncAssetSpinLock() {
|
||||||
|
|
||||||
// plant timer for callback
|
// plant timer for callback
|
||||||
if (r.callback)
|
if (r.callback)
|
||||||
g_pHyprlock->addTimer(std::chrono::milliseconds(0), timerCallback, new STimerCallbackData{r.callback, r.callbackData});
|
g_pHyprlock->addTimer(std::chrono::milliseconds(0), timerCallback, new STimerCallbackData{.cb = r.callback, .data = r.callbackData});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,7 +30,7 @@ GLuint compileShader(const GLuint& type, std::string src) {
|
||||||
|
|
||||||
auto shaderSource = src.c_str();
|
auto shaderSource = src.c_str();
|
||||||
|
|
||||||
glShaderSource(shader, 1, (const GLchar**)&shaderSource, nullptr);
|
glShaderSource(shader, 1, &shaderSource, nullptr);
|
||||||
glCompileShader(shader);
|
glCompileShader(shader);
|
||||||
|
|
||||||
GLint ok;
|
GLint ok;
|
||||||
|
@ -44,11 +44,11 @@ GLuint compileShader(const GLuint& type, std::string src) {
|
||||||
GLuint createProgram(const std::string& vert, const std::string& frag) {
|
GLuint createProgram(const std::string& vert, const std::string& frag) {
|
||||||
auto vertCompiled = compileShader(GL_VERTEX_SHADER, vert);
|
auto vertCompiled = compileShader(GL_VERTEX_SHADER, vert);
|
||||||
|
|
||||||
RASSERT(vertCompiled, "Compiling shader failed. VERTEX NULL! Shader source:\n\n{}", vert.c_str());
|
RASSERT(vertCompiled, "Compiling shader failed. VERTEX NULL! Shader source:\n\n{}", vert);
|
||||||
|
|
||||||
auto fragCompiled = compileShader(GL_FRAGMENT_SHADER, frag);
|
auto fragCompiled = compileShader(GL_FRAGMENT_SHADER, frag);
|
||||||
|
|
||||||
RASSERT(fragCompiled, "Compiling shader failed. FRAGMENT NULL! Shader source:\n\n{}", frag.c_str());
|
RASSERT(fragCompiled, "Compiling shader failed. FRAGMENT NULL! Shader source:\n\n{}", frag);
|
||||||
|
|
||||||
auto prog = glCreateProgram();
|
auto prog = glCreateProgram();
|
||||||
glAttachShader(prog, vertCompiled);
|
glAttachShader(prog, vertCompiled);
|
||||||
|
@ -78,7 +78,7 @@ CRenderer::CRenderer() {
|
||||||
g_pEGL->makeCurrent(nullptr);
|
g_pEGL->makeCurrent(nullptr);
|
||||||
|
|
||||||
glEnable(GL_DEBUG_OUTPUT);
|
glEnable(GL_DEBUG_OUTPUT);
|
||||||
glDebugMessageCallback(glMessageCallbackA, 0);
|
glDebugMessageCallback(glMessageCallbackA, nullptr);
|
||||||
|
|
||||||
GLuint prog = createProgram(QUADVERTSRC, QUADFRAGSRC);
|
GLuint prog = createProgram(QUADVERTSRC, QUADFRAGSRC);
|
||||||
rectShader.program = prog;
|
rectShader.program = prog;
|
||||||
|
@ -402,7 +402,7 @@ std::vector<std::unique_ptr<IWidget>>* CRenderer::getOrCreateWidgetsFor(const CS
|
||||||
|
|
||||||
auto CWIDGETS = g_pConfigManager->getWidgetConfigs();
|
auto CWIDGETS = g_pConfigManager->getWidgetConfigs();
|
||||||
|
|
||||||
std::sort(CWIDGETS.begin(), CWIDGETS.end(), [](CConfigManager::SWidgetConfig& a, CConfigManager::SWidgetConfig& b) {
|
std::ranges::sort(CWIDGETS, [](CConfigManager::SWidgetConfig& a, CConfigManager::SWidgetConfig& b) {
|
||||||
return std::any_cast<Hyprlang::INT>(a.values.at("zindex")) < std::any_cast<Hyprlang::INT>(b.values.at("zindex"));
|
return std::any_cast<Hyprlang::INT>(a.values.at("zindex")) < std::any_cast<Hyprlang::INT>(b.values.at("zindex"));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -194,11 +194,26 @@ bool CSCDMAFrame::onBufferReady(SPreloadedAsset& asset) {
|
||||||
EGLAttrib pitch;
|
EGLAttrib pitch;
|
||||||
EGLAttrib modlo;
|
EGLAttrib modlo;
|
||||||
EGLAttrib modhi;
|
EGLAttrib modhi;
|
||||||
} attrNames[4] = {
|
} attrNames[4] = {{.fd = EGL_DMA_BUF_PLANE0_FD_EXT,
|
||||||
{EGL_DMA_BUF_PLANE0_FD_EXT, EGL_DMA_BUF_PLANE0_OFFSET_EXT, EGL_DMA_BUF_PLANE0_PITCH_EXT, EGL_DMA_BUF_PLANE0_MODIFIER_LO_EXT, EGL_DMA_BUF_PLANE0_MODIFIER_HI_EXT},
|
.offset = EGL_DMA_BUF_PLANE0_OFFSET_EXT,
|
||||||
{EGL_DMA_BUF_PLANE1_FD_EXT, EGL_DMA_BUF_PLANE1_OFFSET_EXT, EGL_DMA_BUF_PLANE1_PITCH_EXT, EGL_DMA_BUF_PLANE1_MODIFIER_LO_EXT, EGL_DMA_BUF_PLANE1_MODIFIER_HI_EXT},
|
.pitch = EGL_DMA_BUF_PLANE0_PITCH_EXT,
|
||||||
{EGL_DMA_BUF_PLANE2_FD_EXT, EGL_DMA_BUF_PLANE2_OFFSET_EXT, EGL_DMA_BUF_PLANE2_PITCH_EXT, EGL_DMA_BUF_PLANE2_MODIFIER_LO_EXT, EGL_DMA_BUF_PLANE2_MODIFIER_HI_EXT},
|
.modlo = EGL_DMA_BUF_PLANE0_MODIFIER_LO_EXT,
|
||||||
{EGL_DMA_BUF_PLANE3_FD_EXT, EGL_DMA_BUF_PLANE3_OFFSET_EXT, EGL_DMA_BUF_PLANE3_PITCH_EXT, EGL_DMA_BUF_PLANE3_MODIFIER_LO_EXT, EGL_DMA_BUF_PLANE3_MODIFIER_HI_EXT}};
|
.modhi = EGL_DMA_BUF_PLANE0_MODIFIER_HI_EXT},
|
||||||
|
{.fd = EGL_DMA_BUF_PLANE1_FD_EXT,
|
||||||
|
.offset = EGL_DMA_BUF_PLANE1_OFFSET_EXT,
|
||||||
|
.pitch = EGL_DMA_BUF_PLANE1_PITCH_EXT,
|
||||||
|
.modlo = EGL_DMA_BUF_PLANE1_MODIFIER_LO_EXT,
|
||||||
|
.modhi = EGL_DMA_BUF_PLANE1_MODIFIER_HI_EXT},
|
||||||
|
{.fd = EGL_DMA_BUF_PLANE2_FD_EXT,
|
||||||
|
.offset = EGL_DMA_BUF_PLANE2_OFFSET_EXT,
|
||||||
|
.pitch = EGL_DMA_BUF_PLANE2_PITCH_EXT,
|
||||||
|
.modlo = EGL_DMA_BUF_PLANE2_MODIFIER_LO_EXT,
|
||||||
|
.modhi = EGL_DMA_BUF_PLANE2_MODIFIER_HI_EXT},
|
||||||
|
{.fd = EGL_DMA_BUF_PLANE3_FD_EXT,
|
||||||
|
.offset = EGL_DMA_BUF_PLANE3_OFFSET_EXT,
|
||||||
|
.pitch = EGL_DMA_BUF_PLANE3_PITCH_EXT,
|
||||||
|
.modlo = EGL_DMA_BUF_PLANE3_MODIFIER_LO_EXT,
|
||||||
|
.modhi = EGL_DMA_BUF_PLANE3_MODIFIER_HI_EXT}};
|
||||||
|
|
||||||
std::vector<EGLAttrib> attribs = {
|
std::vector<EGLAttrib> attribs = {
|
||||||
EGL_WIDTH, m_w, EGL_HEIGHT, m_h, EGL_LINUX_DRM_FOURCC_EXT, m_fmt,
|
EGL_WIDTH, m_w, EGL_HEIGHT, m_h, EGL_LINUX_DRM_FOURCC_EXT, m_fmt,
|
||||||
|
@ -316,10 +331,10 @@ void CSCSHMFrame::convertBuffer() {
|
||||||
unsigned char green;
|
unsigned char green;
|
||||||
unsigned char red;
|
unsigned char red;
|
||||||
unsigned char alpha;
|
unsigned char alpha;
|
||||||
}* px = (struct pixel*)(data + y * m_w * 4 + x * 4);
|
}* px = (struct pixel*)(data + (y * m_w * 4) + (x * 4));
|
||||||
|
|
||||||
// RGBA
|
// RGBA
|
||||||
*px = {px->red, px->green, px->blue, px->alpha};
|
*px = {.blue = px->red, .green = px->green, .red = px->blue, .alpha = px->alpha};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
|
@ -336,10 +351,10 @@ void CSCSHMFrame::convertBuffer() {
|
||||||
unsigned char green;
|
unsigned char green;
|
||||||
unsigned char red;
|
unsigned char red;
|
||||||
unsigned char alpha;
|
unsigned char alpha;
|
||||||
}* px = (struct pixel*)(data + y * m_w * 4 + x * 4);
|
}* px = (struct pixel*)(data + (y * m_w * 4) + (x * 4));
|
||||||
|
|
||||||
// RGBA
|
// BGRA
|
||||||
*px = {px->blue, px->green, px->red, px->alpha};
|
*px = {.blue = px->blue, .green = px->green, .red = px->red, .alpha = px->alpha};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
|
@ -354,7 +369,7 @@ void CSCSHMFrame::convertBuffer() {
|
||||||
|
|
||||||
for (uint32_t y = 0; y < m_h; ++y) {
|
for (uint32_t y = 0; y < m_h; ++y) {
|
||||||
for (uint32_t x = 0; x < m_w; ++x) {
|
for (uint32_t x = 0; x < m_w; ++x) {
|
||||||
uint32_t* px = (uint32_t*)(data + y * m_w * 4 + x * 4);
|
uint32_t* px = (uint32_t*)(data + (y * m_w * 4) + (x * 4));
|
||||||
|
|
||||||
// conv to 8 bit
|
// conv to 8 bit
|
||||||
uint8_t R = (uint8_t)std::round((255.0 * (((*px) & 0b00000000000000000000001111111111) >> 0) / 1023.0));
|
uint8_t R = (uint8_t)std::round((255.0 * (((*px) & 0b00000000000000000000001111111111) >> 0) / 1023.0));
|
||||||
|
@ -387,15 +402,15 @@ void CSCSHMFrame::convertBuffer() {
|
||||||
unsigned char blue;
|
unsigned char blue;
|
||||||
unsigned char green;
|
unsigned char green;
|
||||||
unsigned char red;
|
unsigned char red;
|
||||||
}* srcPx = (struct pixel3*)((char*)m_shmData + y * m_stride + x * 3);
|
}* srcPx = (struct pixel3*)((char*)m_shmData + (y * m_stride) + (x * 3));
|
||||||
struct pixel4 {
|
struct pixel4 {
|
||||||
// little-endian ARGB
|
// little-endian ARGB
|
||||||
unsigned char blue;
|
unsigned char blue;
|
||||||
unsigned char green;
|
unsigned char green;
|
||||||
unsigned char red;
|
unsigned char red;
|
||||||
unsigned char alpha;
|
unsigned char alpha;
|
||||||
}* dstPx = (struct pixel4*)((char*)m_convBuffer + y * NEWSTRIDE + x * 4);
|
}* dstPx = (struct pixel4*)((char*)m_convBuffer + (y * NEWSTRIDE) + (x * 4));
|
||||||
*dstPx = {srcPx->blue, srcPx->green, srcPx->red, 0xFF};
|
*dstPx = {.blue = srcPx->blue, .green = srcPx->green, .red = srcPx->red, .alpha = 0xFF};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
|
@ -408,15 +423,15 @@ void CSCSHMFrame::convertBuffer() {
|
||||||
unsigned char red;
|
unsigned char red;
|
||||||
unsigned char green;
|
unsigned char green;
|
||||||
unsigned char blue;
|
unsigned char blue;
|
||||||
}* srcPx = (struct pixel3*)((char*)m_shmData + y * m_stride + x * 3);
|
}* srcPx = (struct pixel3*)((char*)m_shmData + (y * m_stride) + (x * 3));
|
||||||
struct pixel4 {
|
struct pixel4 {
|
||||||
// big-endian ARGB
|
// big-endian ARGB
|
||||||
unsigned char alpha;
|
unsigned char alpha;
|
||||||
unsigned char red;
|
unsigned char red;
|
||||||
unsigned char green;
|
unsigned char green;
|
||||||
unsigned char blue;
|
unsigned char blue;
|
||||||
}* dstPx = (struct pixel4*)((char*)m_convBuffer + y * NEWSTRIDE + x * 4);
|
}* dstPx = (struct pixel4*)((char*)m_convBuffer + (y * NEWSTRIDE) + (x * 4));
|
||||||
*dstPx = {srcPx->red, srcPx->green, srcPx->blue, 0xFF};
|
*dstPx = {.alpha = srcPx->red, .red = srcPx->green, .green = srcPx->blue, .blue = 0xFF};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#include "Texture.hpp"
|
#include "Texture.hpp"
|
||||||
|
|
||||||
CTexture::CTexture() {
|
CTexture::CTexture() {
|
||||||
// naffin'
|
; // naffin'
|
||||||
}
|
}
|
||||||
|
|
||||||
CTexture::~CTexture() {
|
CTexture::~CTexture() {
|
||||||
|
@ -20,4 +20,4 @@ void CTexture::allocate() {
|
||||||
if (!m_bAllocated)
|
if (!m_bAllocated)
|
||||||
glGenTextures(1, &m_iTexID);
|
glGenTextures(1, &m_iTexID);
|
||||||
m_bAllocated = true;
|
m_bAllocated = true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -150,7 +150,8 @@ bool CBackground::draw(const SRenderData& data) {
|
||||||
HYPRUTILS_TRANSFORM_NORMAL); // this could be omitted but whatever it's only once and makes code cleaner plus less blurring on large texs
|
HYPRUTILS_TRANSFORM_NORMAL); // this could be omitted but whatever it's only once and makes code cleaner plus less blurring on large texs
|
||||||
|
|
||||||
if (blurPasses > 0)
|
if (blurPasses > 0)
|
||||||
g_pRenderer->blurFB(blurredFB, CRenderer::SBlurParams{blurSize, blurPasses, noise, contrast, brightness, vibrancy, vibrancy_darkness});
|
g_pRenderer->blurFB(blurredFB, CRenderer::SBlurParams{
|
||||||
|
.size = blurSize, .passes = blurPasses, .noise = noise, .contrast = contrast, .brightness = brightness, .vibrancy = vibrancy, .vibrancy_darkness = vibrancy_darkness});
|
||||||
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
|
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -192,7 +193,7 @@ void CBackground::onCrossFadeTimerUpdate() {
|
||||||
fade.reset(nullptr);
|
fade.reset(nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(blurPasses > 0 || isScreenshot))
|
if (blurPasses <= 0 && !isScreenshot)
|
||||||
blurredFB.release();
|
blurredFB.release();
|
||||||
|
|
||||||
asset = pendingAsset;
|
asset = pendingAsset;
|
||||||
|
@ -282,4 +283,4 @@ void CBackground::startCrossFadeOrUpdateRender() {
|
||||||
}
|
}
|
||||||
|
|
||||||
g_pHyprlock->renderOutput(output->stringPort);
|
g_pHyprlock->renderOutput(output->stringPort);
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,7 @@ namespace std {
|
||||||
Vector2D rotateVector(const Vector2D& vec, const double& ang) {
|
Vector2D rotateVector(const Vector2D& vec, const double& ang) {
|
||||||
const double COS = std::abs(std::cos(ang));
|
const double COS = std::abs(std::cos(ang));
|
||||||
const double SIN = std::abs(std::sin(ang));
|
const double SIN = std::abs(std::sin(ang));
|
||||||
return Vector2D(vec.x * COS + vec.y * SIN, vec.x * SIN + vec.y * COS);
|
return Vector2D((vec.x * COS) + (vec.y * SIN), (vec.x * SIN) + (vec.y * COS));
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector2D IWidget::posFromHVAlign(const Vector2D& viewport, const Vector2D& size, const Vector2D& offset, const std::string& halign, const std::string& valign, const double& ang) {
|
Vector2D IWidget::posFromHVAlign(const Vector2D& viewport, const Vector2D& size, const Vector2D& offset, const std::string& halign, const std::string& valign, const double& ang) {
|
||||||
|
|
|
@ -219,16 +219,16 @@ bool CPasswordInputField::draw(const SRenderData& data) {
|
||||||
|
|
||||||
const auto CURRDOTS = dots.currentAmount->value();
|
const auto CURRDOTS = dots.currentAmount->value();
|
||||||
const double DOTPAD = (inputFieldBox.h - passSize.y) / 2.0;
|
const double DOTPAD = (inputFieldBox.h - passSize.y) / 2.0;
|
||||||
const double DOTAREAWIDTH = inputFieldBox.w - DOTPAD * 2;
|
const double DOTAREAWIDTH = inputFieldBox.w - (DOTPAD * 2);
|
||||||
const int MAXDOTS = std::round(DOTAREAWIDTH * 1.0 / (passSize.x + passSpacing));
|
const int MAXDOTS = std::round(DOTAREAWIDTH * 1.0 / (passSize.x + passSpacing));
|
||||||
const int DOTFLOORED = std::floor(CURRDOTS);
|
const int DOTFLOORED = std::floor(CURRDOTS);
|
||||||
const auto DOTALPHA = fontCol.a;
|
const auto DOTALPHA = fontCol.a;
|
||||||
|
|
||||||
// Calculate the total width required for all dots including spaces between them
|
// Calculate the total width required for all dots including spaces between them
|
||||||
const double CURRWIDTH = (passSize.x + passSpacing) * CURRDOTS - passSpacing;
|
const double CURRWIDTH = ((passSize.x + passSpacing) * CURRDOTS) - passSpacing;
|
||||||
|
|
||||||
// Calculate starting x-position to ensure dots stay centered within the input field
|
// Calculate starting x-position to ensure dots stay centered within the input field
|
||||||
double xstart = dots.center ? (DOTAREAWIDTH - CURRWIDTH) / 2.0 + DOTPAD : DOTPAD;
|
double xstart = dots.center ? ((DOTAREAWIDTH - CURRWIDTH) / 2.0) + DOTPAD : DOTPAD;
|
||||||
|
|
||||||
if (CURRDOTS > MAXDOTS)
|
if (CURRDOTS > MAXDOTS)
|
||||||
xstart = (inputFieldBox.w + MAXDOTS * (passSize.x + passSpacing) - passSpacing - 2 * CURRWIDTH) / 2.0;
|
xstart = (inputFieldBox.w + MAXDOTS * (passSize.x + passSpacing) - passSpacing - 2 * CURRWIDTH) / 2.0;
|
||||||
|
@ -249,7 +249,7 @@ bool CPasswordInputField::draw(const SRenderData& data) {
|
||||||
fontCol.a *= (1 - CURRDOTS + DOTFLOORED) * data.opacity;
|
fontCol.a *= (1 - CURRDOTS + DOTFLOORED) * data.opacity;
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector2D dotPosition = inputFieldBox.pos() + Vector2D{xstart + i * (passSize.x + passSpacing), inputFieldBox.h / 2.0 - passSize.y / 2.0};
|
Vector2D dotPosition = inputFieldBox.pos() + Vector2D{xstart + (i * (passSize.x + passSpacing)), (inputFieldBox.h / 2.0) - (passSize.y / 2.0)};
|
||||||
CBox box{dotPosition, passSize};
|
CBox box{dotPosition, passSize};
|
||||||
if (!dots.textFormat.empty()) {
|
if (!dots.textFormat.empty()) {
|
||||||
if (!dots.textAsset) {
|
if (!dots.textAsset) {
|
||||||
|
@ -339,7 +339,7 @@ void CPasswordInputField::updatePlaceholder() {
|
||||||
placeholder.asset = nullptr;
|
placeholder.asset = nullptr;
|
||||||
placeholder.resourceID = NEWRESOURCEID;
|
placeholder.resourceID = NEWRESOURCEID;
|
||||||
|
|
||||||
if (std::find(placeholder.registeredResourceIDs.begin(), placeholder.registeredResourceIDs.end(), placeholder.resourceID) != placeholder.registeredResourceIDs.end())
|
if (std::ranges::find(placeholder.registeredResourceIDs, placeholder.resourceID) != placeholder.registeredResourceIDs.end())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Debug::log(TRACE, "Requesting new placeholder asset: {}", placeholder.resourceID);
|
Debug::log(TRACE, "Requesting new placeholder asset: {}", placeholder.resourceID);
|
||||||
|
@ -362,8 +362,7 @@ void CPasswordInputField::updateWidth() {
|
||||||
if (passwordLength == 0 && placeholder.asset)
|
if (passwordLength == 0 && placeholder.asset)
|
||||||
targetSizeX = placeholder.asset->texture.m_vSize.x + size->goal().y;
|
targetSizeX = placeholder.asset->texture.m_vSize.x + size->goal().y;
|
||||||
|
|
||||||
if (targetSizeX < configSize.x)
|
targetSizeX = std::max(targetSizeX, configSize.x);
|
||||||
targetSizeX = configSize.x;
|
|
||||||
|
|
||||||
if (size->goal().x != targetSizeX) {
|
if (size->goal().x != targetSizeX) {
|
||||||
*size = Vector2D{targetSizeX, configSize.y};
|
*size = Vector2D{targetSizeX, configSize.y};
|
||||||
|
|
|
@ -72,7 +72,7 @@ bool CShape::draw(const SRenderData& data) {
|
||||||
const int BORDERROUND = roundingForBorderBox(borderBox, rounding, border);
|
const int BORDERROUND = roundingForBorderBox(borderBox, rounding, border);
|
||||||
Debug::log(LOG, "round: {}, borderround: {}", ROUND, BORDERROUND);
|
Debug::log(LOG, "round: {}, borderround: {}", ROUND, BORDERROUND);
|
||||||
|
|
||||||
shapeFB.alloc(borderBox.width + borderBox.x * 2.0, borderBox.height + borderBox.y * 2.0, true);
|
shapeFB.alloc(borderBox.width + (borderBox.x * 2.0), borderBox.height + (borderBox.y * 2.0), true);
|
||||||
g_pRenderer->pushFb(shapeFB.m_iFb);
|
g_pRenderer->pushFb(shapeFB.m_iFb);
|
||||||
glClearColor(0.0, 0.0, 0.0, 0.0);
|
glClearColor(0.0, 0.0, 0.0, 0.0);
|
||||||
glClear(GL_COLOR_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT);
|
||||||
|
|
Loading…
Reference in a new issue