-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathriverLayout.hpp
115 lines (90 loc) · 4.4 KB
/
riverLayout.hpp
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
#pragma once
#define WLR_USE_UNSTABLE
#include "globals.hpp"
#include "RiverLayoutProtocolManager.hpp"
#include <hyprland/src/desktop/DesktopTypes.hpp>
#include <hyprland/src/layout/IHyprLayout.hpp>
#include <vector>
#include <list>
#include <deque>
#include <any>
enum eFullscreenMode : int8_t;
struct SRiverNodeData {
uint32_t riverSerial;
bool riverDone;
PHLWINDOWREF pWindow;
Vector2D position;
Vector2D size;
float percSize = 1.f; // size multiplier for resizing children
int workspaceID = -1;
bool ignoreFullscreenChecks = false;
bool operator==(const SRiverNodeData& rhs) const {
return pWindow.lock() == rhs.pWindow.lock();
}
};
struct SRiverWorkspaceData {
int workspaceID = -1;
bool operator==(const SRiverWorkspaceData& rhs) const {
return workspaceID == rhs.workspaceID;
}
};
struct SRiverResource {
wl_resource *resource;
MONITORID monitorID;
};
class CRiverLayout : public IHyprLayout {
public:
CRiverLayout(const char *r_namespace);
std::string m_sRiverNamespace = "";
virtual void onWindowCreatedTiling(PHLWINDOW, eDirection direction = DIRECTION_DEFAULT);
virtual void onWindowRemovedTiling(PHLWINDOW);
virtual bool isWindowTiled(PHLWINDOW);
virtual void recalculateMonitor(const MONITORID&);
virtual void recalculateWindow(PHLWINDOW);
virtual void resizeActiveWindow(const Vector2D&, eRectCorner corner, PHLWINDOW pWindow = nullptr);
virtual void fullscreenRequestForWindow(PHLWINDOW, const eFullscreenMode, const eFullscreenMode);
virtual std::any layoutMessage(SLayoutMessageHeader, std::string);
virtual SWindowRenderLayoutHints requestRenderHints(PHLWINDOW);
virtual void switchWindows(PHLWINDOW, PHLWINDOW);
virtual void moveWindowTo(PHLWINDOW, const std::string& dir, bool silent);
virtual void alterSplitRatio(PHLWINDOW, float, bool);
virtual std::string getLayoutName();
virtual void replaceWindowDataWith(PHLWINDOW from, PHLWINDOW to);
virtual void onEnable();
virtual void onDisable();
void riverViewDimensions(int32_t x, int32_t y, uint32_t width, uint32_t height, uint32_t serial);
void riverCommit(const char *layout_name, uint32_t serial);
bool addRiverLayoutResource(wl_resource *resource, MONITORID monitorID);
int removeRiverLayoutResource(wl_resource *resource);
int getRiverLayoutResourceCount();
virtual Vector2D predictSizeForNewWindowTiled();
private:
std::list<SRiverNodeData> m_lMasterNodesData;
std::vector<SRiverWorkspaceData> m_lMasterWorkspacesData;
std::list<SRiverResource> m_lRiverLayoutResources;
Vector2D m_vRemovedWindowVector;
bool m_bForceWarps = false;
int getNodesOnWorkspace(const int&);
void applyNodeDataToWindow(SRiverNodeData*);
void resetNodeSplits(const int&);
SRiverNodeData* getNodeFromWindow(PHLWINDOW);
SRiverWorkspaceData* getMasterWorkspaceData(const int&);
void calculateWorkspace(PHLWORKSPACE);
PHLWINDOW getNextWindow(PHLWINDOW, bool);
int getMastersOnWorkspace(const int&);
friend struct SRiverNodeData;
friend struct SRiverWorkspaceData;
};
template <typename CharT>
struct std::formatter<SRiverNodeData*, CharT> : std::formatter<CharT> {
template <typename FormatContext>
auto format(const SRiverNodeData* const& node, FormatContext& ctx) const {
auto out = ctx.out();
if (!node)
return std::format_to(out, "[Node nullptr]");
std::format_to(out, "[Node {:x}: workspace: {}, pos: {:j2}, size: {:j2}", (uintptr_t)node, node->workspaceID, node->position, node->size);
if (!node->pWindow.expired())
std::format_to(out, ", window: {:x}", node->pWindow.lock());
return std::format_to(out, "]");
}
};