diff --git a/src/config/ConfigManager.cpp b/src/config/ConfigManager.cpp index ad263c4..b3a0264 100644 --- a/src/config/ConfigManager.cpp +++ b/src/config/ConfigManager.cpp @@ -384,6 +384,11 @@ void ConfigManager::loadConfigLoadVars() { configValues["bar:height"].intValue = 15; } + if (configValues["bar:monitor"].intValue > g_pWindowManager->monitors.size()) { + configValues["bar:monitor"].intValue = 0; + Debug::log(ERR, "Incorrect value in MonitorID for the bar. Setting to 0."); + } + g_pWindowManager->statusBar->setup(configValues["bar:monitor"].intValue); } else if (g_pWindowManager->statusBar) { g_pWindowManager->statusBar->destroy(); diff --git a/src/windowManager.cpp b/src/windowManager.cpp index fe8a332..6384f54 100644 --- a/src/windowManager.cpp +++ b/src/windowManager.cpp @@ -680,7 +680,7 @@ void CWindowManager::setEffectiveSizePosUsingConfig(CWindow* pWindow) { return; const auto MONITOR = getMonitorFromWindow(pWindow); - const auto BARHEIGHT = (MONITOR->ID == pWindow->getMonitor() ? (ConfigManager::getInt("bar:enabled") == 1 ? ConfigManager::getInt("bar:height") : ConfigManager::parseError == "" ? 0 : ConfigManager::getInt("bar:height")) : 0); + const auto BARHEIGHT = (MONITOR->ID == ConfigManager::getInt("bar:monitor") ? (ConfigManager::getInt("bar:enabled") == 1 ? ConfigManager::getInt("bar:height") : ConfigManager::parseError == "" ? 0 : ConfigManager::getInt("bar:height")) : 0); // set some flags.