summaryrefslogtreecommitdiff
path: root/src/layout/algorithm/tiled/master/MasterAlgorithm.hpp
diff options
context:
space:
mode:
authorVaxry <43317083+vaxerski@users.noreply.github.com>2026-02-21 21:30:39 +0000
committerGitHub <noreply@github.com>2026-02-21 21:30:39 +0000
commit723870337f299d4c80aa0048144f3a1ca1c885bd (patch)
treeca3279ae5dbc841f676c64d2f58f895de13cd3bf /src/layout/algorithm/tiled/master/MasterAlgorithm.hpp
parent51f8849e541f0a8150ac3a43fa928c1e299daf18 (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/layout/algorithm/tiled/master/MasterAlgorithm.hpp')
-rw-r--r--src/layout/algorithm/tiled/master/MasterAlgorithm.hpp75
1 files changed, 75 insertions, 0 deletions
diff --git a/src/layout/algorithm/tiled/master/MasterAlgorithm.hpp b/src/layout/algorithm/tiled/master/MasterAlgorithm.hpp
new file mode 100644
index 00000000..4524587f
--- /dev/null
+++ b/src/layout/algorithm/tiled/master/MasterAlgorithm.hpp
@@ -0,0 +1,75 @@
+#include "../../TiledAlgorithm.hpp"
+
+#include <hyprutils/string/VarList2.hpp>
+
+namespace Layout {
+ class CAlgorithm;
+}
+
+namespace Layout::Tiled {
+ struct SMasterNodeData;
+
+ //orientation determines which side of the screen the master area resides
+ enum eOrientation : uint8_t {
+ ORIENTATION_LEFT = 0,
+ ORIENTATION_TOP,
+ ORIENTATION_RIGHT,
+ ORIENTATION_BOTTOM,
+ ORIENTATION_CENTER
+ };
+
+ struct SMasterWorkspaceData {
+ WORKSPACEID workspaceID = WORKSPACE_INVALID;
+ eOrientation orientation = ORIENTATION_LEFT;
+ // Previously focused non-master window when `focusmaster previous` command was issued
+ WP<ITarget> focusMasterPrev;
+
+ //
+ bool operator==(const SMasterWorkspaceData& rhs) const {
+ return workspaceID == rhs.workspaceID;
+ }
+ };
+
+ class CMasterAlgorithm : public ITiledAlgorithm {
+ public:
+ CMasterAlgorithm() = default;
+ virtual ~CMasterAlgorithm() = default;
+
+ virtual void newTarget(SP<ITarget> target);
+ virtual void movedTarget(SP<ITarget> target, std::optional<Vector2D> focalPoint = std::nullopt);
+ virtual void removeTarget(SP<ITarget> target);
+
+ virtual void resizeTarget(const Vector2D& Δ, SP<ITarget> target, eRectCorner corner = CORNER_NONE);
+ virtual void recalculate();
+
+ virtual SP<ITarget> getNextCandidate(SP<ITarget> old);
+
+ virtual std::expected<void, std::string> layoutMsg(const std::string_view& sv);
+ virtual std::optional<Vector2D> predictSizeForNewTarget();
+
+ virtual void swapTargets(SP<ITarget> a, SP<ITarget> b);
+ virtual void moveTargetInDirection(SP<ITarget> t, Math::eDirection dir, bool silent);
+
+ private:
+ std::vector<SP<SMasterNodeData>> m_masterNodesData;
+ SMasterWorkspaceData m_workspaceData;
+
+ void addTarget(SP<ITarget> target, bool firstMap);
+
+ bool m_forceWarps = false;
+
+ void buildOrientationCycleVectorFromVars(std::vector<eOrientation>& cycle, Hyprutils::String::CVarList2* vars);
+ void buildOrientationCycleVectorFromEOperation(std::vector<eOrientation>& cycle);
+ void runOrientationCycle(Hyprutils::String::CVarList2* vars, int next);
+ eOrientation getDynamicOrientation();
+ int getNodesNo();
+ SP<SMasterNodeData> getNodeFromWindow(PHLWINDOW);
+ SP<SMasterNodeData> getNodeFromTarget(SP<ITarget>);
+ SP<SMasterNodeData> getMasterNode();
+ SP<SMasterNodeData> getClosestNode(const Vector2D&);
+ void calculateWorkspace();
+ SP<ITarget> getNextTarget(SP<ITarget>, bool, bool);
+ int getMastersNo();
+ bool isWindowTiled(PHLWINDOW);
+ };
+}; \ No newline at end of file