layout: revert "replace string comparison with ID-based matching in WorkspaceAlgoMatcher (#13943)"

This reverts commit 529f72249c.

It's not better, see https://github.com/hyprwm/Hyprland/pull/13943#issuecomment-4180474615

God damnit.
This commit is contained in:
Vaxry
2026-04-02 22:34:04 +01:00
parent a84e98d2a8
commit ad906a473f
@@ -1,6 +1,5 @@
#include "WorkspaceAlgoMatcher.hpp"
#include <unordered_map>
#include <string>
#include "../../config/ConfigValue.hpp"
#include "../../config/shared/workspace/WorkspaceRuleManager.hpp"
@@ -15,8 +14,6 @@
#include "../../Compositor.hpp"
static const std::unordered_map<std::string, int> layoutIDs = {{"dwindle", 1}, {"master", 2}, {"scrolling", 3}, {"monocle", 4}, {"default", 5}, {"floating", 6}};
using namespace Layout;
using namespace Layout::Supplementary;
@@ -115,7 +112,7 @@ SP<CAlgorithm> CWorkspaceAlgoMatcher::createAlgorithmForWorkspace(PHLWORKSPACE w
}
void CWorkspaceAlgoMatcher::updateWorkspaceLayouts() {
// TODO: fully migrate layout selection to ID-based system (comparison optimized)
// TODO: make this ID-based, string comparison is slow
for (const auto& ws : g_pCompositor->getWorkspaces()) {
if (!ws)
continue;
@@ -126,18 +123,9 @@ void CWorkspaceAlgoMatcher::updateWorkspaceLayouts() {
continue;
const auto LAYOUT_TO_USE = tiledAlgoForWorkspace(ws.lock());
auto itLayout = layoutIDs.find(LAYOUT_TO_USE);
const int layoutID = (itLayout != layoutIDs.end()) ? itLayout->second : -1;
if (m_algoNames.contains(&typeid(*TILED_ALGO.get()))) {
const auto& currentName = m_algoNames.at(&typeid(*TILED_ALGO.get()));
auto itCurrent = layoutIDs.find(currentName);
const int currentID = (itCurrent != layoutIDs.end()) ? itCurrent->second : -1;
if (currentID == layoutID)
continue;
}
if (m_algoNames.contains(&typeid(*TILED_ALGO.get())) && m_algoNames.at(&typeid(*TILED_ALGO.get())) == LAYOUT_TO_USE)
continue;
// needs a switchup
ws->m_space->algorithm()->updateTiledAlgo(algoForNameTiled(LAYOUT_TO_USE));