error: Add option to change position of HyprError bar (#3241) (#6111)

This commit is contained in:
Tuur Vanhoutte 2024-05-17 20:06:51 +02:00 committed by GitHub
parent f21b6fe576
commit 0cb8fbe18e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 10 additions and 6 deletions

View File

@ -374,6 +374,7 @@ CConfigManager::CConfigManager() {
m_pConfig->addConfigValue("debug:manual_crash", Hyprlang::INT{0});
m_pConfig->addConfigValue("debug:suppress_errors", Hyprlang::INT{0});
m_pConfig->addConfigValue("debug:error_limit", Hyprlang::INT{5});
m_pConfig->addConfigValue("debug:error_position", Hyprlang::INT{0});
m_pConfig->addConfigValue("debug:watchdog_timeout", Hyprlang::INT{5});
m_pConfig->addConfigValue("debug:disable_scale_checks", Hyprlang::INT{0});
m_pConfig->addConfigValue("debug:colored_stdout_logs", Hyprlang::INT{1});

View File

@ -58,8 +58,11 @@ void CHyprError::createQueued() {
cairo_paint(CAIRO);
cairo_restore(CAIRO);
const auto LINECOUNT = Hyprlang::INT{1} + std::count(m_szQueued.begin(), m_szQueued.end(), '\n');
static auto LINELIMIT = CConfigValue<Hyprlang::INT>("debug:error_limit");
const auto LINECOUNT = Hyprlang::INT{1} + std::count(m_szQueued.begin(), m_szQueued.end(), '\n');
static auto LINELIMIT = CConfigValue<Hyprlang::INT>("debug:error_limit");
static auto BAR_POSITION = CConfigValue<Hyprlang::INT>("debug:error_position");
const bool TOPBAR = *BAR_POSITION == 0;
const auto VISLINECOUNT = std::min(LINECOUNT, *LINELIMIT);
const auto EXTRALINES = (VISLINECOUNT < LINECOUNT) ? 1 : 0;
@ -68,11 +71,11 @@ void CHyprError::createQueued() {
const double PAD = 10 * SCALE;
const double X = PAD;
const double Y = PAD;
const double WIDTH = PMONITOR->vecPixelSize.x - PAD * 2;
const double HEIGHT = (FONTSIZE + 2 * (FONTSIZE / 10.0)) * (VISLINECOUNT + EXTRALINES) + 3;
const double RADIUS = PAD > HEIGHT / 2 ? HEIGHT / 2 - 1 : PAD;
const double X = PAD;
const double Y = TOPBAR ? PAD : PMONITOR->vecPixelSize.y - HEIGHT - PAD;
m_bDamageBox = {0, 0, (int)PMONITOR->vecPixelSize.x, (int)HEIGHT + (int)PAD * 2};
@ -96,9 +99,9 @@ void CHyprError::createQueued() {
cairo_set_font_size(CAIRO, FONTSIZE);
cairo_set_source_rgba(CAIRO, textColor.r, textColor.g, textColor.b, textColor.a);
float yoffset = FONTSIZE;
float yoffset = TOPBAR ? FONTSIZE : Y - PAD + FONTSIZE;
int renderedcnt = 0;
while (m_szQueued != "" && renderedcnt < VISLINECOUNT) {
while (!m_szQueued.empty() && renderedcnt < VISLINECOUNT) {
std::string current = m_szQueued.substr(0, m_szQueued.find('\n'));
if (const auto NEWLPOS = m_szQueued.find('\n'); NEWLPOS != std::string::npos)
m_szQueued = m_szQueued.substr(NEWLPOS + 1);