From ce4766772d2723f8562a2b991c8ff378fd27d3a2 Mon Sep 17 00:00:00 2001 From: davc0n Date: Thu, 1 May 2025 13:26:43 +0200 Subject: [PATCH] hyprerror: refactor class member vars (#10227) --- src/hyprerror/HyprError.cpp | 104 ++++++++++++++++++------------------ src/hyprerror/HyprError.hpp | 18 +++---- 2 files changed, 61 insertions(+), 61 deletions(-) diff --git a/src/hyprerror/HyprError.cpp b/src/hyprerror/HyprError.cpp index c8000649..9dd26e2c 100644 --- a/src/hyprerror/HyprError.cpp +++ b/src/hyprerror/HyprError.cpp @@ -12,40 +12,40 @@ using namespace Hyprutils::Animation; CHyprError::CHyprError() { - g_pAnimationManager->createAnimation(0.f, m_fFadeOpacity, g_pConfigManager->getAnimationPropertyConfig("fadeIn"), AVARDAMAGE_NONE); + g_pAnimationManager->createAnimation(0.f, m_fadeOpacity, g_pConfigManager->getAnimationPropertyConfig("fadeIn"), AVARDAMAGE_NONE); static auto P = g_pHookSystem->hookDynamic("focusedMon", [&](void* self, SCallbackInfo& info, std::any param) { - if (!m_bIsCreated) + if (!m_isCreated) return; g_pHyprRenderer->damageMonitor(g_pCompositor->m_lastMonitor.lock()); - m_bMonitorChanged = true; + m_monitorChanged = true; }); static auto P2 = g_pHookSystem->hookDynamic("preRender", [&](void* self, SCallbackInfo& info, std::any param) { - if (!m_bIsCreated) + if (!m_isCreated) return; - if (m_fFadeOpacity->isBeingAnimated() || m_bMonitorChanged) - g_pHyprRenderer->damageBox(m_bDamageBox); + if (m_fadeOpacity->isBeingAnimated() || m_monitorChanged) + g_pHyprRenderer->damageBox(m_damageBox); }); - m_pTexture = makeShared(); + m_texture = makeShared(); } void CHyprError::queueCreate(std::string message, const CHyprColor& color) { - m_szQueued = message; - m_cQueued = color; + m_queued = message; + m_queuedColor = color; } void CHyprError::createQueued() { - if (m_bIsCreated) - m_pTexture->destroyTexture(); + if (m_isCreated) + m_texture->destroyTexture(); - m_fFadeOpacity->setConfig(g_pConfigManager->getAnimationPropertyConfig("fadeIn")); + m_fadeOpacity->setConfig(g_pConfigManager->getAnimationPropertyConfig("fadeIn")); - m_fFadeOpacity->setValueAndWarp(0.f); - *m_fFadeOpacity = 1.f; + m_fadeOpacity->setValueAndWarp(0.f); + *m_fadeOpacity = 1.f; const auto PMONITOR = g_pCompositor->m_monitors.front(); @@ -63,7 +63,7 @@ void CHyprError::createQueued() { cairo_paint(CAIRO); cairo_restore(CAIRO); - const auto LINECOUNT = Hyprlang::INT{1} + std::count(m_szQueued.begin(), m_szQueued.end(), '\n'); + const auto LINECOUNT = Hyprlang::INT{1} + std::count(m_queued.begin(), m_queued.end(), '\n'); static auto LINELIMIT = CConfigValue("debug:error_limit"); static auto BAR_POSITION = CConfigValue("debug:error_position"); @@ -82,7 +82,7 @@ void CHyprError::createQueued() { const double X = PAD; const double Y = TOPBAR ? PAD : PMONITOR->m_pixelSize.y - HEIGHT - PAD; - m_bDamageBox = {0, 0, (int)PMONITOR->m_pixelSize.x, (int)HEIGHT + (int)PAD * 2}; + m_damageBox = {0, 0, (int)PMONITOR->m_pixelSize.x, (int)HEIGHT + (int)PAD * 2}; cairo_new_sub_path(CAIRO); cairo_arc(CAIRO, X + WIDTH - RADIUS, Y + RADIUS, RADIUS, -90 * DEGREES, 0 * DEGREES); @@ -93,7 +93,7 @@ void CHyprError::createQueued() { cairo_set_source_rgba(CAIRO, 0.06, 0.06, 0.06, 1.0); cairo_fill_preserve(CAIRO); - cairo_set_source_rgba(CAIRO, m_cQueued.r, m_cQueued.g, m_cQueued.b, m_cQueued.a); + cairo_set_source_rgba(CAIRO, m_queuedColor.r, m_queuedColor.g, m_queuedColor.b, m_queuedColor.a); cairo_set_line_width(CAIRO, 2); cairo_stroke(CAIRO); @@ -113,12 +113,12 @@ void CHyprError::createQueued() { float yoffset = TOPBAR ? 0 : Y - PAD; int renderedcnt = 0; - 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); + while (!m_queued.empty() && renderedcnt < VISLINECOUNT) { + std::string current = m_queued.substr(0, m_queued.find('\n')); + if (const auto NEWLPOS = m_queued.find('\n'); NEWLPOS != std::string::npos) + m_queued = m_queued.substr(NEWLPOS + 1); else - m_szQueued = ""; + m_queued = ""; cairo_move_to(CAIRO, PAD + 1 + RADIUS, yoffset + PAD + 1); pango_layout_set_text(layoutText, current.c_str(), -1); pango_cairo_show_layout(CAIRO, layoutText); @@ -131,9 +131,9 @@ void CHyprError::createQueued() { pango_layout_set_text(layoutText, moreString.c_str(), -1); pango_cairo_show_layout(CAIRO, layoutText); } - m_szQueued = ""; + m_queued = ""; - m_fLastHeight = yoffset + PAD + 1 - (TOPBAR ? 0 : Y - PAD); + m_lastHeight = yoffset + PAD + 1 - (TOPBAR ? 0 : Y - PAD); pango_font_description_free(pangoFD); g_object_unref(layoutText); @@ -142,8 +142,8 @@ void CHyprError::createQueued() { // copy the data to an OpenGL texture we have const auto DATA = cairo_image_surface_get_data(CAIROSURFACE); - m_pTexture->allocate(); - glBindTexture(GL_TEXTURE_2D, m_pTexture->m_iTexID); + m_texture->allocate(); + glBindTexture(GL_TEXTURE_2D, m_texture->m_iTexID); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); @@ -158,9 +158,9 @@ void CHyprError::createQueued() { cairo_destroy(CAIRO); cairo_surface_destroy(CAIROSURFACE); - m_bIsCreated = true; - m_szQueued = ""; - m_cQueued = CHyprColor(); + m_isCreated = true; + m_queued = ""; + m_queuedColor = CHyprColor(); g_pHyprRenderer->damageMonitor(PMONITOR); @@ -168,19 +168,19 @@ void CHyprError::createQueued() { } void CHyprError::draw() { - if (!m_bIsCreated || m_szQueued != "") { - if (m_szQueued != "") + if (!m_isCreated || m_queued != "") { + if (m_queued != "") createQueued(); return; } - if (m_bQueuedDestroy) { - if (!m_fFadeOpacity->isBeingAnimated()) { - if (m_fFadeOpacity->value() == 0.f) { - m_bQueuedDestroy = false; - m_pTexture->destroyTexture(); - m_bIsCreated = false; - m_szQueued = ""; + if (m_queuedDestroy) { + if (!m_fadeOpacity->isBeingAnimated()) { + if (m_fadeOpacity->value() == 0.f) { + m_queuedDestroy = false; + m_texture->destroyTexture(); + m_isCreated = false; + m_queued = ""; for (auto& m : g_pCompositor->m_monitors) { g_pHyprRenderer->arrangeLayersForMonitor(m->m_id); @@ -188,8 +188,8 @@ void CHyprError::draw() { return; } else { - m_fFadeOpacity->setConfig(g_pConfigManager->getAnimationPropertyConfig("fadeOut")); - *m_fFadeOpacity = 0.f; + m_fadeOpacity->setConfig(g_pConfigManager->getAnimationPropertyConfig("fadeOut")); + *m_fadeOpacity = 0.f; } } } @@ -198,33 +198,33 @@ void CHyprError::draw() { CBox monbox = {0, 0, PMONITOR->m_pixelSize.x, PMONITOR->m_pixelSize.y}; - m_bDamageBox.x = (int)PMONITOR->m_position.x; - m_bDamageBox.y = (int)PMONITOR->m_position.y; + m_damageBox.x = (int)PMONITOR->m_position.x; + m_damageBox.y = (int)PMONITOR->m_position.y; - if (m_fFadeOpacity->isBeingAnimated() || m_bMonitorChanged) - g_pHyprRenderer->damageBox(m_bDamageBox); + if (m_fadeOpacity->isBeingAnimated() || m_monitorChanged) + g_pHyprRenderer->damageBox(m_damageBox); - m_bMonitorChanged = false; + m_monitorChanged = false; CTexPassElement::SRenderData data; - data.tex = m_pTexture; + data.tex = m_texture; data.box = monbox; - data.a = m_fFadeOpacity->value(); + data.a = m_fadeOpacity->value(); g_pHyprRenderer->m_sRenderPass.add(makeShared(data)); } void CHyprError::destroy() { - if (m_bIsCreated) - m_bQueuedDestroy = true; + if (m_isCreated) + m_queuedDestroy = true; else - m_szQueued = ""; + m_queued = ""; } bool CHyprError::active() { - return m_bIsCreated; + return m_isCreated; } float CHyprError::height() { - return m_fLastHeight; + return m_lastHeight; } diff --git a/src/hyprerror/HyprError.hpp b/src/hyprerror/HyprError.hpp index 12de0c81..f4bc43d8 100644 --- a/src/hyprerror/HyprError.hpp +++ b/src/hyprerror/HyprError.hpp @@ -20,16 +20,16 @@ class CHyprError { private: void createQueued(); - std::string m_szQueued = ""; - CHyprColor m_cQueued; - bool m_bQueuedDestroy = false; - bool m_bIsCreated = false; - SP m_pTexture; - PHLANIMVAR m_fFadeOpacity; - CBox m_bDamageBox = {0, 0, 0, 0}; - float m_fLastHeight = 0.F; + std::string m_queued = ""; + CHyprColor m_queuedColor; + bool m_queuedDestroy = false; + bool m_isCreated = false; + SP m_texture; + PHLANIMVAR m_fadeOpacity; + CBox m_damageBox = {0, 0, 0, 0}; + float m_lastHeight = 0.F; - bool m_bMonitorChanged = false; + bool m_monitorChanged = false; }; inline UP g_pHyprError; // This is a full-screen error. Treat it with respect, and there can only be one at a time.