summaryrefslogtreecommitdiff
path: root/src/hyprerror/HyprError.cpp
diff options
context:
space:
mode:
authorTuur Vanhoutte <4633209+zjeffer@users.noreply.github.com>2024-05-17 20:06:51 +0200
committerGitHub <noreply@github.com>2024-05-17 19:06:51 +0100
commit0cb8fbe18e45936ef3e3c6f82fcd200affc9fb13 (patch)
treedfdd9c0108632dda1a2ff3e49ccae5b398500688 /src/hyprerror/HyprError.cpp
parentf21b6fe576b1068598d6c19fbbfd3f0659d5498d (diff)
error: Add option to change position of HyprError bar (#3241) (#6111)
Diffstat (limited to 'src/hyprerror/HyprError.cpp')
-rw-r--r--src/hyprerror/HyprError.cpp15
1 files changed, 9 insertions, 6 deletions
diff --git a/src/hyprerror/HyprError.cpp b/src/hyprerror/HyprError.cpp
index 4c7b6731..e7e2ff0d 100644
--- a/src/hyprerror/HyprError.cpp
+++ b/src/hyprerror/HyprError.cpp
@@ -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);