Hyprland/src/layout/DwindleLayout.hpp

74 lines
2.6 KiB
C++
Raw Normal View History

#pragma once
#include "IHyprLayout.hpp"
#include <list>
#include <deque>
#include "../render/decorations/CHyprGroupBarDecoration.hpp"
2022-03-19 20:30:21 +01:00
class CHyprDwindleLayout;
enum eFullscreenMode : uint8_t;
2022-03-19 20:30:21 +01:00
struct SDwindleNodeData {
SDwindleNodeData* pParent = nullptr;
bool isNode = false;
CWindow* pWindow = nullptr;
std::array<SDwindleNodeData*, 2> children = { nullptr, nullptr };
2022-05-16 17:27:55 +02:00
bool splitTop = false; // for preserve_split
bool isGroup = false;
int groupMemberActive = 0;
std::deque<SDwindleNodeData*> groupMembers;
SDwindleNodeData* pGroupParent = nullptr;
Vector2D position;
Vector2D size;
2022-03-20 16:06:17 +01:00
int workspaceID = -1;
float splitRatio = 1.f;
// For list lookup
bool operator==(const SDwindleNodeData& rhs) {
2022-03-20 16:06:17 +01:00
return pWindow == rhs.pWindow && workspaceID == rhs.workspaceID && position == rhs.position && size == rhs.size && pParent == rhs.pParent && children[0] == rhs.children[0] && children[1] == rhs.children[1];
}
2022-03-19 20:30:21 +01:00
void recalcSizePosRecursive();
void getAllChildrenRecursive(std::deque<SDwindleNodeData*>*);
2022-03-19 20:30:21 +01:00
CHyprDwindleLayout* layout = nullptr;
};
class CHyprDwindleLayout : public IHyprLayout {
public:
2022-06-30 12:09:05 +02:00
virtual void onWindowCreatedTiling(CWindow*);
virtual void onWindowRemovedTiling(CWindow*);
virtual bool isWindowTiled(CWindow*);
2022-03-19 20:56:19 +01:00
virtual void recalculateMonitor(const int&);
2022-04-02 20:04:32 +02:00
virtual void recalculateWindow(CWindow*);
2022-06-06 19:32:14 +02:00
virtual void resizeActiveWindow(const Vector2D&, CWindow* pWindow = nullptr);
2022-06-26 12:12:29 +02:00
virtual void fullscreenRequestForWindow(CWindow*, eFullscreenMode, bool);
virtual std::any layoutMessage(SLayoutMessageHeader, std::string);
virtual SWindowRenderLayoutHints requestRenderHints(CWindow*);
2022-04-20 16:53:41 +02:00
virtual void switchWindows(CWindow*, CWindow*);
virtual void alterSplitRatioBy(CWindow*, float);
virtual std::string getLayoutName();
2022-06-30 12:09:05 +02:00
private:
std::list<SDwindleNodeData> m_lDwindleNodesData;
2022-03-20 16:06:17 +01:00
int getNodesOnWorkspace(const int&);
void applyNodeDataToWindow(SDwindleNodeData*);
SDwindleNodeData* getNodeFromWindow(CWindow*);
2022-03-20 16:06:17 +01:00
SDwindleNodeData* getFirstNodeOnWorkspace(const int&);
SDwindleNodeData* getMasterNodeOnWorkspace(const int&);
2022-03-19 20:30:21 +01:00
2022-05-16 17:37:46 +02:00
void toggleWindowGroup(CWindow*);
2022-05-28 19:16:20 +02:00
void switchGroupWindow(CWindow*, bool forward);
2022-05-16 17:37:46 +02:00
void toggleSplit(CWindow*);
std::deque<CWindow*> getGroupMembers(CWindow*);
2022-05-16 17:37:46 +02:00
2022-03-19 20:30:21 +01:00
friend struct SDwindleNodeData;
};