diff options
| author | Vaxry <43317083+vaxerski@users.noreply.github.com> | 2026-02-21 21:30:39 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-02-21 21:30:39 +0000 |
| commit | 723870337f299d4c80aa0048144f3a1ca1c885bd (patch) | |
| tree | ca3279ae5dbc841f676c64d2f58f895de13cd3bf /src/plugins | |
| parent | 51f8849e541f0a8150ac3a43fa928c1e299daf18 (diff) | |
layout: rethonk layouts from the ground up (#12890)
Rewrites layouts to be much smaller, and deal with much less annoying
BS. Improves the overall architecture, unifies handling of pseudotiling,
and various other improvements.
Diffstat (limited to 'src/plugins')
| -rw-r--r-- | src/plugins/PluginAPI.cpp | 34 | ||||
| -rw-r--r-- | src/plugins/PluginAPI.hpp | 20 | ||||
| -rw-r--r-- | src/plugins/PluginSystem.cpp | 8 | ||||
| -rw-r--r-- | src/plugins/PluginSystem.hpp | 2 |
4 files changed, 50 insertions, 14 deletions
diff --git a/src/plugins/PluginAPI.cpp b/src/plugins/PluginAPI.cpp index 2abddc90..57081183 100644 --- a/src/plugins/PluginAPI.cpp +++ b/src/plugins/PluginAPI.cpp @@ -3,10 +3,11 @@ #include "../debug/HyprCtl.hpp" #include "../plugins/PluginSystem.hpp" #include "../managers/HookSystemManager.hpp" -#include "../managers/LayoutManager.hpp" #include "../managers/eventLoop/EventLoopManager.hpp" #include "../config/ConfigManager.hpp" #include "../debug/HyprNotificationOverlay.hpp" +#include "../layout/target/Target.hpp" +#include "../layout/supplementary/WorkspaceAlgoMatcher.hpp" #include <dlfcn.h> #include <filesystem> @@ -62,25 +63,44 @@ APICALL std::string HyprlandAPI::invokeHyprctlCommand(const std::string& call, c } APICALL bool HyprlandAPI::addLayout(HANDLE handle, const std::string& name, IHyprLayout* layout) { + return false; +} + +APICALL bool HyprlandAPI::removeLayout(HANDLE handle, IHyprLayout* layout) { + return false; +} + +APICALL bool HyprlandAPI::addTiledAlgo(HANDLE handle, const std::string& name, const std::type_info* typeInfo, std::function<UP<Layout::ITiledAlgorithm>()>&& factory) { auto* const PLUGIN = g_pPluginSystem->getPluginByHandle(handle); if (!PLUGIN) return false; - PLUGIN->m_registeredLayouts.push_back(layout); + PLUGIN->m_registeredAlgos.emplace_back(name); - return g_pLayoutManager->addLayout(name, layout); + return Layout::Supplementary::algoMatcher()->registerTiledAlgo(name, typeInfo, std::move(factory)); } -APICALL bool HyprlandAPI::removeLayout(HANDLE handle, IHyprLayout* layout) { +APICALL bool HyprlandAPI::addFloatingAlgo(HANDLE handle, const std::string& name, const std::type_info* typeInfo, std::function<UP<Layout::IFloatingAlgorithm>()>&& factory) { + auto* const PLUGIN = g_pPluginSystem->getPluginByHandle(handle); + + if (!PLUGIN) + return false; + + PLUGIN->m_registeredAlgos.emplace_back(name); + + return Layout::Supplementary::algoMatcher()->registerFloatingAlgo(name, typeInfo, std::move(factory)); +} + +APICALL bool HyprlandAPI::removeAlgo(HANDLE handle, const std::string& name) { auto* const PLUGIN = g_pPluginSystem->getPluginByHandle(handle); if (!PLUGIN) return false; - std::erase(PLUGIN->m_registeredLayouts, layout); + std::erase(PLUGIN->m_registeredAlgos, name); - return g_pLayoutManager->removeLayout(layout); + return Layout::Supplementary::algoMatcher()->unregisterAlgo(name); } APICALL bool HyprlandAPI::reloadConfig() { @@ -130,7 +150,7 @@ APICALL bool HyprlandAPI::addWindowDecoration(HANDLE handle, PHLWINDOW pWindow, pWindow->addWindowDeco(std::move(pDecoration)); - g_pLayoutManager->getCurrentLayout()->recalculateWindow(pWindow); + pWindow->layoutTarget()->recalc(); return true; } diff --git a/src/plugins/PluginAPI.hpp b/src/plugins/PluginAPI.hpp index 47a695db..568b2e0f 100644 --- a/src/plugins/PluginAPI.hpp +++ b/src/plugins/PluginAPI.hpp @@ -71,6 +71,11 @@ class IHyprLayout; class IHyprWindowDecoration; struct SConfigValue; +namespace Layout { + class ITiledAlgorithm; + class IFloatingAlgorithm; +}; + /* These methods are for the plugin to implement Methods marked with REQUIRED are required. @@ -172,15 +177,26 @@ namespace HyprlandAPI { Adds a layout to Hyprland. returns: true on success. False otherwise. + + deprecated: addTiledAlgo, addFloatingAlgo */ - APICALL bool addLayout(HANDLE handle, const std::string& name, IHyprLayout* layout); + APICALL [[deprecated]] bool addLayout(HANDLE handle, const std::string& name, IHyprLayout* layout); /* Removes an added layout from Hyprland. returns: true on success. False otherwise. + + deprecated: V2 removeAlgo + */ + APICALL [[deprecated]] bool removeLayout(HANDLE handle, IHyprLayout* layout); + + /* + Algorithm fns. Used for registering and removing. Return success. */ - APICALL bool removeLayout(HANDLE handle, IHyprLayout* layout); + APICALL bool addTiledAlgo(HANDLE handle, const std::string& name, const std::type_info* typeInfo, std::function<UP<Layout::ITiledAlgorithm>()>&& factory); + APICALL bool addFloatingAlgo(HANDLE handle, const std::string& name, const std::type_info* typeInfo, std::function<UP<Layout::IFloatingAlgorithm>()>&& factory); + APICALL bool removeAlgo(HANDLE handle, const std::string& name); /* Queues a config reload. Does not take effect immediately. diff --git a/src/plugins/PluginSystem.cpp b/src/plugins/PluginSystem.cpp index 0549c81b..7a798ac4 100644 --- a/src/plugins/PluginSystem.cpp +++ b/src/plugins/PluginSystem.cpp @@ -4,11 +4,11 @@ #include <ranges> #include "../config/ConfigManager.hpp" #include "../debug/HyprCtl.hpp" -#include "../managers/LayoutManager.hpp" #include "../managers/HookSystemManager.hpp" #include "../managers/eventLoop/EventLoopManager.hpp" #include "../managers/permissions/DynamicPermissionManager.hpp" #include "../debug/HyprNotificationOverlay.hpp" +#include "../layout/supplementary/WorkspaceAlgoMatcher.hpp" #include "../i18n/Engine.hpp" CPluginSystem::CPluginSystem() { @@ -156,9 +156,9 @@ void CPluginSystem::unloadPlugin(const CPlugin* plugin, bool eject) { g_pHookSystem->unhook(SHP); } - const auto ls = plugin->m_registeredLayouts; - for (auto const& l : ls) - g_pLayoutManager->removeLayout(l); + for (const auto& l : plugin->m_registeredAlgos) { + Layout::Supplementary::algoMatcher()->unregisterAlgo(l); + } g_pFunctionHookSystem->removeAllHooksFrom(plugin->m_handle); diff --git a/src/plugins/PluginSystem.hpp b/src/plugins/PluginSystem.hpp index 286f10d5..ca980d12 100644 --- a/src/plugins/PluginSystem.hpp +++ b/src/plugins/PluginSystem.hpp @@ -23,11 +23,11 @@ class CPlugin { HANDLE m_handle = nullptr; - std::vector<IHyprLayout*> m_registeredLayouts; std::vector<IHyprWindowDecoration*> m_registeredDecorations; std::vector<std::pair<std::string, WP<HOOK_CALLBACK_FN>>> m_registeredCallbacks; std::vector<std::string> m_registeredDispatchers; std::vector<WP<SHyprCtlCommand>> m_registeredHyprctlCommands; + std::vector<std::string> m_registeredAlgos; }; class CPluginSystem { |
