2022-03-19 15:59:53 +01:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "IHyprLayout.hpp"
|
2023-09-20 17:25:03 +02:00
|
|
|
|
2022-03-19 15:59:53 +01:00
|
|
|
#include <list>
|
2022-04-12 16:44:18 +02:00
|
|
|
#include <deque>
|
2022-12-16 18:17:31 +01:00
|
|
|
#include <array>
|
2023-09-04 15:34:07 +02:00
|
|
|
#include <optional>
|
2023-09-20 17:25:03 +02:00
|
|
|
#include <format>
|
2022-03-19 15:59:53 +01:00
|
|
|
|
2022-03-19 20:30:21 +01:00
|
|
|
class CHyprDwindleLayout;
|
2023-09-28 18:49:33 +02:00
|
|
|
enum eFullscreenMode : int8_t;
|
2022-03-19 20:30:21 +01:00
|
|
|
|
2022-03-19 15:59:53 +01:00
|
|
|
struct SDwindleNodeData {
|
2022-12-16 18:17:31 +01:00
|
|
|
SDwindleNodeData* pParent = nullptr;
|
|
|
|
bool isNode = false;
|
2022-03-19 15:59:53 +01:00
|
|
|
|
2022-12-16 18:17:31 +01:00
|
|
|
CWindow* pWindow = nullptr;
|
2022-03-19 15:59:53 +01:00
|
|
|
|
2022-12-16 18:17:31 +01:00
|
|
|
std::array<SDwindleNodeData*, 2> children = {nullptr, nullptr};
|
2022-03-19 15:59:53 +01:00
|
|
|
|
2022-12-16 18:17:31 +01:00
|
|
|
bool splitTop = false; // for preserve_split
|
2022-05-16 17:27:55 +02:00
|
|
|
|
2023-11-04 22:45:34 +01:00
|
|
|
CBox box = {0};
|
2022-03-19 15:59:53 +01:00
|
|
|
|
2022-12-16 18:17:31 +01:00
|
|
|
int workspaceID = -1;
|
2022-03-19 15:59:53 +01:00
|
|
|
|
2022-12-16 18:17:31 +01:00
|
|
|
float splitRatio = 1.f;
|
2022-04-10 19:31:36 +02:00
|
|
|
|
2022-12-16 18:17:31 +01:00
|
|
|
bool valid = true;
|
2022-08-01 12:51:52 +02:00
|
|
|
|
2023-11-03 13:19:23 +01:00
|
|
|
bool ignoreFullscreenChecks = false;
|
|
|
|
|
2022-03-19 15:59:53 +01:00
|
|
|
// For list lookup
|
2023-01-31 01:03:23 +01:00
|
|
|
bool operator==(const SDwindleNodeData& rhs) const {
|
2023-11-04 22:45:34 +01:00
|
|
|
return pWindow == rhs.pWindow && workspaceID == rhs.workspaceID && box == rhs.box && pParent == rhs.pParent && children[0] == rhs.children[0] &&
|
|
|
|
children[1] == rhs.children[1];
|
2022-03-19 15:59:53 +01:00
|
|
|
}
|
|
|
|
|
2023-05-06 02:02:18 +02:00
|
|
|
void recalcSizePosRecursive(bool force = false, bool horizontalOverride = false, bool verticalOverride = false);
|
2022-12-16 18:17:31 +01:00
|
|
|
void getAllChildrenRecursive(std::deque<SDwindleNodeData*>*);
|
2022-03-19 20:30:21 +01:00
|
|
|
CHyprDwindleLayout* layout = nullptr;
|
2022-03-19 15:59:53 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
class CHyprDwindleLayout : public IHyprLayout {
|
2022-12-16 18:17:31 +01:00
|
|
|
public:
|
2023-09-13 12:13:29 +02:00
|
|
|
virtual void onWindowCreatedTiling(CWindow*, eDirection direction = DIRECTION_DEFAULT);
|
2022-12-16 18:17:31 +01:00
|
|
|
virtual void onWindowRemovedTiling(CWindow*);
|
|
|
|
virtual bool isWindowTiled(CWindow*);
|
|
|
|
virtual void recalculateMonitor(const int&);
|
|
|
|
virtual void recalculateWindow(CWindow*);
|
2023-04-25 17:53:18 +02:00
|
|
|
virtual void onBeginDragWindow();
|
2023-07-13 16:52:11 +02:00
|
|
|
virtual void resizeActiveWindow(const Vector2D&, eRectCorner corner = CORNER_NONE, CWindow* pWindow = nullptr);
|
2022-12-16 18:17:31 +01:00
|
|
|
virtual void fullscreenRequestForWindow(CWindow*, eFullscreenMode, bool);
|
|
|
|
virtual std::any layoutMessage(SLayoutMessageHeader, std::string);
|
2022-04-12 16:44:18 +02:00
|
|
|
virtual SWindowRenderLayoutHints requestRenderHints(CWindow*);
|
2022-12-16 18:17:31 +01:00
|
|
|
virtual void switchWindows(CWindow*, CWindow*);
|
2023-09-04 15:34:07 +02:00
|
|
|
virtual void moveWindowTo(CWindow*, const std::string& dir);
|
2022-12-17 23:37:44 +01:00
|
|
|
virtual void alterSplitRatio(CWindow*, float, bool);
|
2022-12-16 18:17:31 +01:00
|
|
|
virtual std::string getLayoutName();
|
2023-02-19 22:07:32 +01:00
|
|
|
virtual void replaceWindowDataWith(CWindow* from, CWindow* to);
|
2024-02-28 12:45:43 +01:00
|
|
|
virtual Vector2D predictSizeForNewWindow();
|
2022-12-16 18:17:31 +01:00
|
|
|
|
|
|
|
virtual void onEnable();
|
|
|
|
virtual void onDisable();
|
|
|
|
|
|
|
|
private:
|
|
|
|
std::list<SDwindleNodeData> m_lDwindleNodesData;
|
|
|
|
|
2023-04-25 17:53:18 +02:00
|
|
|
struct {
|
|
|
|
bool started = false;
|
|
|
|
bool pseudo = false;
|
|
|
|
bool xExtent = false;
|
|
|
|
bool yExtent = false;
|
|
|
|
} m_PseudoDragFlags;
|
2022-12-16 18:17:31 +01:00
|
|
|
|
2023-09-04 15:34:07 +02:00
|
|
|
std::optional<Vector2D> m_vOverrideFocalPoint; // for onWindowCreatedTiling.
|
2023-04-25 17:53:18 +02:00
|
|
|
|
2023-09-04 15:34:07 +02:00
|
|
|
int getNodesOnWorkspace(const int&);
|
|
|
|
void applyNodeDataToWindow(SDwindleNodeData*, bool force = false);
|
|
|
|
SDwindleNodeData* getNodeFromWindow(CWindow*);
|
|
|
|
SDwindleNodeData* getFirstNodeOnWorkspace(const int&);
|
2024-01-26 23:30:36 +01:00
|
|
|
SDwindleNodeData* getClosestNodeOnWorkspace(const int&, const Vector2D&);
|
2023-09-04 15:34:07 +02:00
|
|
|
SDwindleNodeData* getMasterNodeOnWorkspace(const int&);
|
2022-05-16 17:37:46 +02:00
|
|
|
|
2023-09-04 15:34:07 +02:00
|
|
|
void toggleSplit(CWindow*);
|
2024-02-14 18:58:28 +01:00
|
|
|
void swapSplit(CWindow*);
|
2023-09-04 15:34:07 +02:00
|
|
|
|
2023-09-13 12:13:29 +02:00
|
|
|
eDirection overrideDirection = DIRECTION_DEFAULT;
|
2023-05-06 02:02:18 +02:00
|
|
|
|
2022-03-19 20:30:21 +01:00
|
|
|
friend struct SDwindleNodeData;
|
2022-12-17 23:37:44 +01:00
|
|
|
};
|
2023-09-20 17:25:03 +02:00
|
|
|
|
|
|
|
template <typename CharT>
|
|
|
|
struct std::formatter<SDwindleNodeData*, CharT> : std::formatter<CharT> {
|
|
|
|
template <typename FormatContext>
|
|
|
|
auto format(const SDwindleNodeData* const& node, FormatContext& ctx) const {
|
|
|
|
auto out = ctx.out();
|
|
|
|
if (!node)
|
|
|
|
return std::format_to(out, "[Node nullptr]");
|
2023-11-04 22:45:34 +01:00
|
|
|
std::format_to(out, "[Node {:x}: workspace: {}, pos: {:j2}, size: {:j2}", (uintptr_t)node, node->workspaceID, node->box.pos(), node->box.size());
|
2023-09-20 17:25:03 +02:00
|
|
|
if (!node->isNode && node->pWindow)
|
|
|
|
std::format_to(out, ", window: {:x}", node->pWindow);
|
|
|
|
return std::format_to(out, "]");
|
|
|
|
}
|
|
|
|
};
|