summaryrefslogtreecommitdiff
path: root/src/layout/LayoutManager.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/LayoutManager.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/LayoutManager.hpp')
-rw-r--r--src/layout/LayoutManager.hpp86
1 files changed, 86 insertions, 0 deletions
diff --git a/src/layout/LayoutManager.hpp b/src/layout/LayoutManager.hpp
new file mode 100644
index 00000000..638c9f4c
--- /dev/null
+++ b/src/layout/LayoutManager.hpp
@@ -0,0 +1,86 @@
+#pragma once
+
+#include "../helpers/memory/Memory.hpp"
+#include "../helpers/math/Math.hpp"
+#include "../managers/input/InputManager.hpp"
+
+#include "supplementary/DragController.hpp"
+
+#include <optional>
+#include <expected>
+
+enum eFullscreenMode : int8_t;
+
+namespace Layout {
+ class ITarget;
+ class CSpace;
+
+ enum eRectCorner : uint8_t {
+ CORNER_NONE = 0,
+ CORNER_TOPLEFT = (1 << 0),
+ CORNER_TOPRIGHT = (1 << 1),
+ CORNER_BOTTOMRIGHT = (1 << 2),
+ CORNER_BOTTOMLEFT = (1 << 3),
+ };
+
+ inline eRectCorner cornerFromBox(const CBox& box, const Vector2D& pos) {
+ const auto CENTER = box.middle();
+
+ if (pos.x < CENTER.x)
+ return pos.y < CENTER.y ? CORNER_TOPLEFT : CORNER_BOTTOMLEFT;
+ return pos.y < CENTER.y ? CORNER_TOPRIGHT : CORNER_BOTTOMRIGHT;
+ }
+
+ enum eSnapEdge : uint8_t {
+ SNAP_INVALID = 0,
+ SNAP_UP = (1 << 0),
+ SNAP_DOWN = (1 << 1),
+ SNAP_LEFT = (1 << 2),
+ SNAP_RIGHT = (1 << 3),
+ };
+
+ class CLayoutManager {
+ public:
+ CLayoutManager();
+ ~CLayoutManager() = default;
+
+ void newTarget(SP<ITarget> target, SP<CSpace> space);
+ void removeTarget(SP<ITarget> target);
+
+ void changeFloatingMode(SP<ITarget> target);
+
+ void beginDragTarget(SP<ITarget> target, eMouseBindMode mode);
+ void moveMouse(const Vector2D& mousePos);
+ void resizeTarget(const Vector2D& Δ, SP<ITarget> target, eRectCorner corner = CORNER_NONE);
+ void moveTarget(const Vector2D& Δ, SP<ITarget> target);
+ void endDragTarget();
+
+ std::expected<void, std::string> layoutMsg(const std::string_view& sv);
+
+ void fullscreenRequestForTarget(SP<ITarget> target, eFullscreenMode currentEffectiveMode, eFullscreenMode effectiveMode);
+
+ void switchTargets(SP<ITarget> a, SP<ITarget> b, bool preserveFocus = true);
+
+ void moveInDirection(SP<ITarget> target, const std::string& direction, bool silent = false);
+
+ SP<ITarget> getNextCandidate(SP<CSpace> space, SP<ITarget> from);
+
+ bool isReachable(SP<ITarget> target);
+
+ void bringTargetToTop(SP<ITarget> target);
+
+ std::optional<Vector2D> predictSizeForNewTiledTarget();
+
+ void performSnap(Vector2D& sourcePos, Vector2D& sourceSize, SP<ITarget> target, eMouseBindMode mode, int corner, const Vector2D& beginSize);
+
+ void invalidateMonitorGeometries(PHLMONITOR);
+ void recalculateMonitor(PHLMONITOR);
+
+ const UP<Supplementary::CDragStateController>& dragController();
+
+ private:
+ UP<Supplementary::CDragStateController> m_dragStateController = makeUnique<Supplementary::CDragStateController>();
+ };
+}
+
+inline UP<Layout::CLayoutManager> g_layoutManager; \ No newline at end of file