blob: cfbeafd37023942b66ea05c15b847c049246917d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
#pragma once
#include "../../helpers/math/Math.hpp"
#include "../../helpers/math/Direction.hpp"
#include "../../helpers/memory/Memory.hpp"
#include "../LayoutManager.hpp"
#include "../space/Space.hpp"
#include <expected>
namespace Layout {
class ITarget;
class CAlgorithm;
struct SFullscreenRequest {
SP<ITarget> target;
eFullscreenMode currentEffectiveMode = static_cast<eFullscreenMode>(0);
eFullscreenMode effectiveMode = static_cast<eFullscreenMode>(0);
};
class IModeAlgorithm {
public:
virtual ~IModeAlgorithm() = default;
// a completely new target
virtual void newTarget(SP<ITarget> target) = 0;
// a target moved into the algorithm (from another)
virtual void movedTarget(SP<ITarget> target, std::optional<Vector2D> focalPoint = std::nullopt) = 0;
// a target removed
virtual void removeTarget(SP<ITarget> target) = 0;
// a target is being resized by a delta. Corner none likely means not interactive
virtual void resizeTarget(const Vector2D& Δ, SP<ITarget> target, eRectCorner corner = CORNER_NONE) = 0;
// recalculate layout
virtual void recalculate(eRecalculateReason reason = RECALCULATE_REASON_UNKNOWN) = 0;
// swap targets
virtual void swapTargets(SP<ITarget> a, SP<ITarget> b) = 0;
// move a target in a given direction
virtual void moveTargetInDirection(SP<ITarget> t, Math::eDirection dir, bool silent) = 0;
// optional: handle layout messages
virtual Config::ErrorResult layoutMsg(const std::string_view& sv);
// optional: predict new window's size
virtual std::optional<Vector2D> predictSizeForNewTarget();
// optional: allow algorithms to own fullscreen semantics for a target.
virtual eFullscreenRequestResult requestFullscreen(const SFullscreenRequest& request);
// optional: expose an algorithm-owned fullscreen target and whether it is monitor-exclusive.
virtual SP<ITarget> layoutFullscreenTarget() const;
virtual bool layoutFullscreenCoversMonitor() const;
// Impl'd here: focal point for dir
virtual std::optional<Vector2D> focalPointForDir(SP<ITarget> t, Math::eDirection dir);
protected:
IModeAlgorithm() = default;
WP<CAlgorithm> m_parent;
friend class Layout::CAlgorithm;
};
}
|