summaryrefslogtreecommitdiff
path: root/src/debug
diff options
context:
space:
mode:
authorVaxry <vaxry@vaxry.net>2024-12-16 15:58:19 +0000
committerVaxry <vaxry@vaxry.net>2024-12-16 15:58:19 +0000
commita5234f26e4b7146ae7c2df25950f0177534cd643 (patch)
treebe319115cca2eb369791fad1822bdda0e0f358e9 /src/debug
parentde3ad245dcbcd42c88e9afc48264bdb8f2356c15 (diff)
core: drop using deques in favor of vectors
No point in most of these.
Diffstat (limited to 'src/debug')
-rw-r--r--src/debug/HyprDebugOverlay.cpp36
-rw-r--r--src/debug/HyprDebugOverlay.hpp2
-rw-r--r--src/debug/HyprNotificationOverlay.cpp18
-rw-r--r--src/debug/HyprNotificationOverlay.hpp18
4 files changed, 52 insertions, 22 deletions
diff --git a/src/debug/HyprDebugOverlay.cpp b/src/debug/HyprDebugOverlay.cpp
index 9326cfe0..0df46086 100644
--- a/src/debug/HyprDebugOverlay.cpp
+++ b/src/debug/HyprDebugOverlay.cpp
@@ -8,7 +8,12 @@ CHyprDebugOverlay::CHyprDebugOverlay() {
}
void CHyprMonitorDebugOverlay::renderData(PHLMONITOR pMonitor, float durationUs) {
- m_dLastRenderTimes.push_back(durationUs / 1000.f);
+ static auto PDEBUGOVERLAY = CConfigValue<Hyprlang::INT>("debug:overlay");
+
+ if (!*PDEBUGOVERLAY)
+ return;
+
+ m_dLastRenderTimes.emplace_back(durationUs / 1000.f);
if (m_dLastRenderTimes.size() > (long unsigned int)pMonitor->refreshRate)
m_dLastRenderTimes.pop_front();
@@ -18,7 +23,12 @@ void CHyprMonitorDebugOverlay::renderData(PHLMONITOR pMonitor, float durationUs)
}
void CHyprMonitorDebugOverlay::renderDataNoOverlay(PHLMONITOR pMonitor, float durationUs) {
- m_dLastRenderTimesNoOverlay.push_back(durationUs / 1000.f);
+ static auto PDEBUGOVERLAY = CConfigValue<Hyprlang::INT>("debug:overlay");
+
+ if (!*PDEBUGOVERLAY)
+ return;
+
+ m_dLastRenderTimesNoOverlay.emplace_back(durationUs / 1000.f);
if (m_dLastRenderTimesNoOverlay.size() > (long unsigned int)pMonitor->refreshRate)
m_dLastRenderTimesNoOverlay.pop_front();
@@ -28,7 +38,12 @@ void CHyprMonitorDebugOverlay::renderDataNoOverlay(PHLMONITOR pMonitor, float du
}
void CHyprMonitorDebugOverlay::frameData(PHLMONITOR pMonitor) {
- m_dLastFrametimes.push_back(std::chrono::duration_cast<std::chrono::microseconds>(std::chrono::high_resolution_clock::now() - m_tpLastFrame).count() / 1000.f);
+ static auto PDEBUGOVERLAY = CConfigValue<Hyprlang::INT>("debug:overlay");
+
+ if (!*PDEBUGOVERLAY)
+ return;
+
+ m_dLastFrametimes.emplace_back(std::chrono::duration_cast<std::chrono::microseconds>(std::chrono::high_resolution_clock::now() - m_tpLastFrame).count() / 1000.f);
if (m_dLastFrametimes.size() > (long unsigned int)pMonitor->refreshRate)
m_dLastFrametimes.pop_front();
@@ -189,14 +204,29 @@ int CHyprMonitorDebugOverlay::draw(int offset) {
}
void CHyprDebugOverlay::renderData(PHLMONITOR pMonitor, float durationUs) {
+ static auto PDEBUGOVERLAY = CConfigValue<Hyprlang::INT>("debug:overlay");
+
+ if (!*PDEBUGOVERLAY)
+ return;
+
m_mMonitorOverlays[pMonitor].renderData(pMonitor, durationUs);
}
void CHyprDebugOverlay::renderDataNoOverlay(PHLMONITOR pMonitor, float durationUs) {
+ static auto PDEBUGOVERLAY = CConfigValue<Hyprlang::INT>("debug:overlay");
+
+ if (!*PDEBUGOVERLAY)
+ return;
+
m_mMonitorOverlays[pMonitor].renderDataNoOverlay(pMonitor, durationUs);
}
void CHyprDebugOverlay::frameData(PHLMONITOR pMonitor) {
+ static auto PDEBUGOVERLAY = CConfigValue<Hyprlang::INT>("debug:overlay");
+
+ if (!*PDEBUGOVERLAY)
+ return;
+
m_mMonitorOverlays[pMonitor].frameData(pMonitor);
}
diff --git a/src/debug/HyprDebugOverlay.hpp b/src/debug/HyprDebugOverlay.hpp
index 89d1d606..42cdac55 100644
--- a/src/debug/HyprDebugOverlay.hpp
+++ b/src/debug/HyprDebugOverlay.hpp
@@ -3,9 +3,9 @@
#include "../defines.hpp"
#include "../helpers/Monitor.hpp"
#include "../render/Texture.hpp"
-#include <deque>
#include <cairo/cairo.h>
#include <map>
+#include <deque>
class CHyprRenderer;
diff --git a/src/debug/HyprNotificationOverlay.cpp b/src/debug/HyprNotificationOverlay.cpp
index 482db541..153d2395 100644
--- a/src/debug/HyprNotificationOverlay.cpp
+++ b/src/debug/HyprNotificationOverlay.cpp
@@ -18,7 +18,7 @@ inline auto iconBackendFromLayout(PangoLayout* layout) {
CHyprNotificationOverlay::CHyprNotificationOverlay() {
static auto P = g_pHookSystem->hookDynamic("focusedMon", [&](void* self, SCallbackInfo& info, std::any param) {
- if (m_dNotifications.size() == 0)
+ if (m_vNotifications.size() == 0)
return;
g_pHyprRenderer->damageBox(&m_bLastDamage);
@@ -35,7 +35,7 @@ CHyprNotificationOverlay::~CHyprNotificationOverlay() {
}
void CHyprNotificationOverlay::addNotification(const std::string& text, const CHyprColor& color, const float timeMs, const eIcons icon, const float fontSize) {
- const auto PNOTIF = m_dNotifications.emplace_back(std::make_unique<SNotification>()).get();
+ const auto PNOTIF = m_vNotifications.emplace_back(std::make_unique<SNotification>()).get();
PNOTIF->text = icon != eIcons::ICON_NONE ? " " + text /* tiny bit of padding otherwise icon touches text */ : text;
PNOTIF->color = color == CHyprColor(0) ? ICONS_COLORS[icon] : color;
@@ -51,12 +51,12 @@ void CHyprNotificationOverlay::addNotification(const std::string& text, const CH
void CHyprNotificationOverlay::dismissNotifications(const int amount) {
if (amount == -1)
- m_dNotifications.clear();
+ m_vNotifications.clear();
else {
- const int AMT = std::min(amount, static_cast<int>(m_dNotifications.size()));
+ const int AMT = std::min(amount, static_cast<int>(m_vNotifications.size()));
for (int i = 0; i < AMT; ++i) {
- m_dNotifications.pop_front();
+ m_vNotifications.erase(m_vNotifications.begin());
}
}
}
@@ -87,7 +87,7 @@ CBox CHyprNotificationOverlay::drawNotifications(PHLMONITOR pMonitor) {
const auto iconBackendID = iconBackendFromLayout(layout);
const auto PBEZIER = g_pAnimationManager->getBezier("default");
- for (auto const& notif : m_dNotifications) {
+ for (auto const& notif : m_vNotifications) {
const auto ICONPADFORNOTIF = notif->icon == ICON_NONE ? 0 : ICON_PAD;
const auto FONTSIZE = std::clamp((int)(notif->fontSize * ((pMonitor->vecPixelSize.x * SCALE) / 1920.f)), 8, 40);
@@ -182,7 +182,7 @@ CBox CHyprNotificationOverlay::drawNotifications(PHLMONITOR pMonitor) {
g_object_unref(layout);
// cleanup notifs
- std::erase_if(m_dNotifications, [](const auto& notif) { return notif->started.getMillis() > notif->timeMs; });
+ std::erase_if(m_vNotifications, [](const auto& notif) { return notif->started.getMillis() > notif->timeMs; });
return CBox{(int)(pMonitor->vecPosition.x + pMonitor->vecSize.x - maxWidth - 20), (int)pMonitor->vecPosition.y, (int)maxWidth + 20, (int)offsetY + 10};
}
@@ -205,7 +205,7 @@ void CHyprNotificationOverlay::draw(PHLMONITOR pMonitor) {
}
// Draw the notifications
- if (m_dNotifications.size() == 0)
+ if (m_vNotifications.size() == 0)
return;
// Render to the monitor
@@ -246,5 +246,5 @@ void CHyprNotificationOverlay::draw(PHLMONITOR pMonitor) {
}
bool CHyprNotificationOverlay::hasAny() {
- return !m_dNotifications.empty();
+ return !m_vNotifications.empty();
}
diff --git a/src/debug/HyprNotificationOverlay.hpp b/src/debug/HyprNotificationOverlay.hpp
index 5e88ebc0..3ff0b35c 100644
--- a/src/debug/HyprNotificationOverlay.hpp
+++ b/src/debug/HyprNotificationOverlay.hpp
@@ -6,7 +6,7 @@
#include "../render/Texture.hpp"
#include "../SharedDefs.hpp"
-#include <deque>
+#include <vector>
#include <cairo/cairo.h>
@@ -47,18 +47,18 @@ class CHyprNotificationOverlay {
bool hasAny();
private:
- CBox drawNotifications(PHLMONITOR pMonitor);
- CBox m_bLastDamage;
+ CBox drawNotifications(PHLMONITOR pMonitor);
+ CBox m_bLastDamage;
- std::deque<std::unique_ptr<SNotification>> m_dNotifications;
+ std::vector<std::unique_ptr<SNotification>> m_vNotifications;
- cairo_surface_t* m_pCairoSurface = nullptr;
- cairo_t* m_pCairo = nullptr;
+ cairo_surface_t* m_pCairoSurface = nullptr;
+ cairo_t* m_pCairo = nullptr;
- PHLMONITORREF m_pLastMonitor;
- Vector2D m_vecLastSize = Vector2D(-1, -1);
+ PHLMONITORREF m_pLastMonitor;
+ Vector2D m_vecLastSize = Vector2D(-1, -1);
- SP<CTexture> m_pTexture;
+ SP<CTexture> m_pTexture;
};
inline std::unique_ptr<CHyprNotificationOverlay> g_pHyprNotificationOverlay;