From 7d6a8e8ee7c0e8665f3bcf074060f6fbec0d3942 Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Sun, 21 Nov 2021 20:40:22 +0100 Subject: [PATCH] bar config monitor added --- src/bar/Bar.cpp | 16 ++++++++++------ src/bar/Bar.hpp | 2 +- src/config/ConfigManager.cpp | 7 +++++-- src/windowManager.cpp | 4 +--- 4 files changed, 17 insertions(+), 12 deletions(-) diff --git a/src/bar/Bar.cpp b/src/bar/Bar.cpp index d267842..3849908 100644 --- a/src/bar/Bar.cpp +++ b/src/bar/Bar.cpp @@ -5,14 +5,18 @@ #include "../windowManager.hpp" -void CStatusBar::setup(Vector2D origin, Vector2D size) { - if (origin.x != -1 && origin.y != -1) { - m_vecPosition = origin; - } +void CStatusBar::setup(int MonitorID) { - if (size.x != -1 && size.y != -1) { - m_vecSize = size; + if (MonitorID > g_pWindowManager->monitors.size()) { + MonitorID = 0; + Debug::log(ERR, "Incorrect value in MonitorID for the bar. Setting to 0."); } + + const auto MONITOR = g_pWindowManager->monitors[MonitorID]; + + m_iMonitorID = MonitorID; + m_vecPosition = MONITOR.vecPosition; + m_vecSize = Vector2D(MONITOR.vecSize.x, ConfigManager::getInt("bar_height")); uint32_t values[4]; diff --git a/src/bar/Bar.hpp b/src/bar/Bar.hpp index 975b741..b7482bb 100644 --- a/src/bar/Bar.hpp +++ b/src/bar/Bar.hpp @@ -16,7 +16,7 @@ public: EXPOSED_MEMBER(MonitorID, int, i); void draw(); - void setup(Vector2D, Vector2D); + void setup(int MonitorID); void destroy(); private: diff --git a/src/config/ConfigManager.cpp b/src/config/ConfigManager.cpp index aefa3f2..346e8cc 100644 --- a/src/config/ConfigManager.cpp +++ b/src/config/ConfigManager.cpp @@ -13,9 +13,12 @@ void ConfigManager::init() { configValues["border_size"].intValue = 1; configValues["gaps_in"].intValue = 5; configValues["gaps_out"].intValue = 20; - configValues["bar_height"].intValue = 15; + configValues["max_fps"].intValue = 60; + configValues["bar_monitor"].intValue = 0; + configValues["bar_height"].intValue = 15; + loadConfigLoadVars(); } @@ -142,7 +145,7 @@ void ConfigManager::loadConfigLoadVars() { // Reload the bar as well, don't load it before the default is loaded. if (loadBar) { g_pWindowManager->statusBar.destroy(); - g_pWindowManager->statusBar.setup(Vector2D(-1, -1), Vector2D(g_pWindowManager->monitors[g_pWindowManager->statusBar.getMonitorID()].vecSize.x, configValues["bar_height"].intValue)); + g_pWindowManager->statusBar.setup(configValues["bar_monitor"].intValue); } loadBar = true; diff --git a/src/windowManager.cpp b/src/windowManager.cpp index 89282b6..74203a2 100644 --- a/src/windowManager.cpp +++ b/src/windowManager.cpp @@ -143,9 +143,7 @@ void CWindowManager::setupManager() { for (auto& monitor : monitors) { if (monitor.primary) { - const Vector2D BARSIZE = Vector2D(monitor.vecSize.x, ConfigManager::getInt("bar_height")); - statusBar.setup(monitor.vecPosition, BARSIZE); - statusBar.setMonitorID(monitor.ID); + statusBar.setup(ConfigManager::configValues["bar_monitor"].intValue); } }